Переглянути джерело

Merge pull request #142 from javascript-obfuscator/cli-options-kebab-case-naming

Cli options kebab case naming
Timofey Kachalov 7 роки тому
батько
коміт
80fbd9e0b3

+ 1 - 0
CHANGELOG.md

@@ -2,6 +2,7 @@ Change Log
 ===
 v0.13.0
 ---
+* **Breaking change:** all CLI options were renamed to `kebab-case` format (`--disableConsoleOutout` -> `--disable-console-output`)
 * Implemented custom `mangle` option algorithm without `esmangle`; fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/110
 
 v0.12.5

+ 22 - 22
README.md

@@ -199,10 +199,10 @@ If the destination path is not specified with the `--output` option, obfuscated
 
 Examples:
 ```sh
-javascript-obfuscator samples/sample.js --compact true --selfDefending false
+javascript-obfuscator samples/sample.js --compact true --self-defending false
 // creates a new file samples/sample-obfuscated.js
 
-javascript-obfuscator samples/sample.js --output output/output.js --compact true --selfDefending false
+javascript-obfuscator samples/sample.js --output output/output.js --compact true --self-defending false
 // creates a new file output/output.js
 ```
 
@@ -284,30 +284,30 @@ Following options are available for the JS Obfuscator:
 
     --compact <boolean>
     --config <string>
-    --controlFlowFlattening <boolean>
-    --controlFlowFlatteningThreshold <number>
-    --deadCodeInjection <boolean>
-    --deadCodeInjectionThreshold <number>
-    --debugProtection <boolean>
-    --debugProtectionInterval <boolean>
-    --disableConsoleOutput <boolean>
-    --domainLock '<list>' (comma separated)
+    --control-flow-flattening <boolean>
+    --control-flow-flattening-threshold <number>
+    --dead-code-njection <boolean>
+    --dead-code-injection-threshold <number>
+    --debug-protection <boolean>
+    --debug-protection-interval <boolean>
+    --disable-console-output <boolean>
+    --domain-lock '<list>' (comma separated)
     --log <boolean>
     --mangle <boolean>
-    --renameGlobals <boolean>
-    --reservedNames '<list>' (comma separated)
-    --rotateStringArray <boolean>
+    --rename-globals <boolean>
+    --reserved-names '<list>' (comma separated)
+    --rotate-string-array <boolean>
     --seed <number>
-    --selfDefending <boolean>
-    --sourceMap <boolean>
-    --sourceMapBaseUrl <string>
-    --sourceMapFileName <string>
-    --sourceMapMode <string> [inline, separate]
-    --stringArray <boolean>
-    --stringArrayEncoding <boolean|string> [true, false, base64, rc4]
-    --stringArrayThreshold <number>
+    --self-defending <boolean>
+    --source-map <boolean>
+    --source-map-base-url <string>
+    --source-map-file-name <string>
+    --source-map-mode <string> [inline, separate]
+    --string-array <boolean>
+    --string-array-encoding <boolean|string> [true, false, base64, rc4]
+    --string-array-threshold <number>
     --target <string> [browser, extension, node]
-    --unicodeEscapeSequence <boolean>
+    --unicode-escape-sequence <boolean>
 ```
 
 ### `compact`

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
dist/index.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "javascript-obfuscator",
-  "version": "0.13.0-dev.0",
+  "version": "0.13.0-dev.1",
   "description": "JavaScript obfuscator",
   "keywords": [
     "obfuscator",

+ 25 - 25
src/cli/JavaScriptObfuscatorCLI.ts

@@ -200,42 +200,42 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 'Name of js / json config file'
             )
             .option(
-                '--controlFlowFlattening <boolean>',
+                '--control-flow-flattening <boolean>',
                 'Enables control flow flattening',
                 BooleanSanitizer
             )
             .option(
-                '--controlFlowFlatteningThreshold <number>',
+                '--control-flow-flattening-threshold <number>',
                 'The probability that the control flow flattening transformation will be applied to the node',
                 parseFloat
             )
             .option(
-                '--deadCodeInjection <boolean>',
+                '--dead-code-injection <boolean>',
                 'Enables dead code injection',
                 BooleanSanitizer
             )
             .option(
-                '--deadCodeInjectionThreshold <number>',
+                '--dead-code-injection-threshold <number>',
                 'The probability that the dead code injection transformation will be applied to the node',
                 parseFloat
             )
             .option(
-                '--debugProtection <boolean>',
+                '--debug-protection <boolean>',
                 'Disable browser Debug panel (can cause DevTools enabled browser freeze)',
                 BooleanSanitizer
             )
             .option(
-                '--debugProtectionInterval <boolean>',
+                '--debug-protection-interval <boolean>',
                 'Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)',
                 BooleanSanitizer
             )
             .option(
-                '--disableConsoleOutput <boolean>',
+                '--disable-console-output <boolean>',
                 'Allow console.log, console.info, console.error and console.warn messages output into browser console',
                 BooleanSanitizer
             )
             .option(
-                '--domainLock <list> (comma separated, without whitespaces)',
+                '--domain-lock <list> (comma separated, without whitespaces)',
                 'Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)',
                 ArraySanitizer
             )
@@ -248,16 +248,16 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 BooleanSanitizer
             )
             .option(
-                '--reservedNames <list> (comma separated, without whitespaces)',
+                '--reserved-names <list> (comma separated, without whitespaces)',
                 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)',
                 ArraySanitizer
             )
             .option(
-                '--renameGlobals <boolean>', 'Allows to enable obfuscation of global variable and function names with declaration.',
+                '--rename-globals <boolean>', 'Allows to enable obfuscation of global variable and function names with declaration.',
                 BooleanSanitizer
             )
             .option(
-                '--rotateStringArray <boolean>', 'Disable rotation of unicode array values during obfuscation',
+                '--rotate-string-array <boolean>', 'Disable rotation of unicode array values during obfuscation',
                 BooleanSanitizer
             )
             .option(
@@ -266,40 +266,40 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 parseFloat
             )
             .option(
-                '--selfDefending <boolean>',
+                '--self-defending <boolean>',
                 'Disables self-defending for obfuscated code',
                 BooleanSanitizer
             )
             .option(
-                '--sourceMap <boolean>',
+                '--source-map <boolean>',
                 'Enables source map generation',
                 BooleanSanitizer
             )
             .option(
-                '--sourceMapBaseUrl <string>',
-                'Sets base url to the source map import url when `--sourceMapMode=separate`'
+                '--source-map-base-url <string>',
+                'Sets base url to the source map import url when `--source-map-mode=separate`'
             )
             .option(
-                '--sourceMapFileName <string>',
-                'Sets file name for output source map when `--sourceMapMode=separate`'
+                '--source-map-file-name <string>',
+                'Sets file name for output source map when `--source-map-mode=separate`'
             )
             .option(
-                '--sourceMapMode <string> [inline, separate]',
+                '--source-map-mode <string> [inline, separate]',
                 'Specify source map output mode',
                 SourceMapModeSanitizer
             )
             .option(
-                '--stringArray <boolean>',
+                '--string-array <boolean>',
                 'Disables gathering of all literal strings into an array and replacing every literal string with an array call',
                 BooleanSanitizer
             )
             .option(
-                '--stringArrayEncoding <boolean|string> [true, false, base64, rc4]',
+                '--string-array-encoding <boolean|string> [true, false, base64, rc4]',
                 'Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed',
                 StringArrayEncodingSanitizer
             )
             .option(
-                '--stringArrayThreshold <number>',
+                '--string-array-threshold <number>',
                 'The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)',
                 parseFloat
             )
@@ -309,7 +309,7 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 ObfuscationTargetSanitizer
             )
             .option(
-                '--unicodeEscapeSequence <boolean>',
+                '--unicode-escape-sequence <boolean>',
                 'Allows to enable/disable string conversion to unicode escape sequence',
                 BooleanSanitizer
             )
@@ -319,9 +319,9 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
     private configureHelp (): void {
         this.commands.on('--help', () => {
             console.log('  Examples:\n');
-            console.log('    %> javascript-obfuscator input_file_name.js --compact true --selfDefending false');
-            console.log('    %> javascript-obfuscator input_file_name.js --output output_file_name.js --compact true --selfDefending false');
-            console.log('    %> javascript-obfuscator input_directory_name --compact true --selfDefending false');
+            console.log('    %> javascript-obfuscator input_file_name.js --compact true --self-defending false');
+            console.log('    %> javascript-obfuscator input_file_name.js --output output_file_name.js --compact true --self-defending false');
+            console.log('    %> javascript-obfuscator input_directory_name --compact true --self-defending false');
             console.log('');
         });
     }

+ 13 - 13
test/functional-tests/cli/JavaScriptObfuscatorCLI.spec.ts

@@ -40,7 +40,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
                         outputFilePath,
                         '--compact',
                         'true',
-                        '--selfDefending',
+                        '--self-defending',
                         '0'
                     ]);
 
@@ -192,9 +192,9 @@ describe('JavaScriptObfuscatorCLI', function (): void {
                             outputFilePath,
                             '--compact',
                             'true',
-                            '--selfDefending',
+                            '--self-defending',
                             '0',
-                            '--sourceMap',
+                            '--source-map',
                             'true'
                         ]);
 
@@ -243,11 +243,11 @@ describe('JavaScriptObfuscatorCLI', function (): void {
                             outputFilePath,
                             '--compact',
                             'true',
-                            '--selfDefending',
+                            '--self-defending',
                             '0',
-                            '--sourceMap',
+                            '--source-map',
                             'true',
-                            '--sourceMapBaseUrl',
+                            '--source-map-base-url',
                             'http://localhost:9000/'
                         ]);
 
@@ -300,11 +300,11 @@ describe('JavaScriptObfuscatorCLI', function (): void {
                             outputFilePath,
                             '--compact',
                             'true',
-                            '--selfDefending',
+                            '--self-defending',
                             '0',
-                            '--sourceMap',
+                            '--source-map',
                             'true',
-                            '--sourceMapFileName',
+                            '--source-map-file-name',
                             sourceMapFileName
                         ]);
 
@@ -353,11 +353,11 @@ describe('JavaScriptObfuscatorCLI', function (): void {
                         outputFilePath,
                         '--compact',
                         'true',
-                        '--selfDefending',
+                        '--self-defending',
                         '0',
-                        '--sourceMap',
+                        '--source-map',
                         'true',
-                        '--sourceMapMode',
+                        '--source-map-mode',
                         'inline'
                     ]);
 
@@ -493,7 +493,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
                     outputFilePath,
                     '--config',
                     configFilePath,
-                    '--sourceMap',
+                    '--source-map',
                     'false',
                 ]);
 

Деякі файли не було показано, через те що забагато файлів було змінено