jscrambler 8.8.4 → 8.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/bin/jscrambler.js +1 -11
- package/dist/index.js +11 -0
- package/dist/utils.js +14 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# jscrambler
|
|
2
2
|
|
|
3
|
+
## 8.8.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [8818c8e]: Use max/min file size instead ao file size threshold
|
|
8
|
+
|
|
9
|
+
## 8.8.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [c4e79f4]: Add support for file size threshold with string value
|
|
14
|
+
|
|
3
15
|
## 8.8.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/bin/jscrambler.js
CHANGED
|
@@ -6,7 +6,6 @@ require("core-js/modules/web.dom-collections.iterator.js");
|
|
|
6
6
|
var _commander = _interopRequireDefault(require("commander"));
|
|
7
7
|
var _lodash = _interopRequireDefault(require("lodash.defaults"));
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
|
|
10
9
|
var _config2 = _interopRequireDefault(require("../config"));
|
|
11
10
|
var _ = _interopRequireDefault(require("../"));
|
|
12
11
|
var _utils = require("../utils");
|
|
@@ -24,16 +23,7 @@ const validateBool = option => val => {
|
|
|
24
23
|
}
|
|
25
24
|
return val.toLowerCase();
|
|
26
25
|
};
|
|
27
|
-
const validateCodeHardeningThreshold =
|
|
28
|
-
let inBytes;
|
|
29
|
-
try {
|
|
30
|
-
inBytes = (0, _filesizeParser.default)(val);
|
|
31
|
-
} catch (e) {
|
|
32
|
-
console.error('*code-hardening-threshold* requires a valid <threshold> value. Format: {number}{unit="b,kb,mb"}. Example: --code-hardening-threshold 200kb');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
return inBytes;
|
|
36
|
-
};
|
|
26
|
+
const validateCodeHardeningThreshold = (0, _utils.validateThresholdFn)('code-hardening-threshold');
|
|
37
27
|
const validateProfilingDataMode = mode => {
|
|
38
28
|
const availableModes = ['automatic', 'annotations', 'off'];
|
|
39
29
|
const normalizedMode = mode.toLowerCase();
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,15 @@ function printSourcesErrors(errors) {
|
|
|
79
79
|
}
|
|
80
80
|
console.error();
|
|
81
81
|
}
|
|
82
|
+
function normalizeFileSizeFilter(parameters, fileSizeOption) {
|
|
83
|
+
const validateFileSizeThreshold = (0, _utils.validateThresholdFn)(fileSizeOption);
|
|
84
|
+
parameters.filter(parameter => typeof parameter[fileSizeOption] === 'string').forEach(parameter => {
|
|
85
|
+
// change from "1kb" to 1024 bytes
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line no-param-reassign
|
|
88
|
+
parameter[fileSizeOption] = validateFileSizeThreshold(parameter[fileSizeOption]);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
82
91
|
function normalizeParameters(parameters) {
|
|
83
92
|
let result;
|
|
84
93
|
if (!Array.isArray(parameters)) {
|
|
@@ -92,6 +101,8 @@ function normalizeParameters(parameters) {
|
|
|
92
101
|
} else {
|
|
93
102
|
result = parameters;
|
|
94
103
|
}
|
|
104
|
+
normalizeFileSizeFilter(result, 'minFileSize');
|
|
105
|
+
normalizeFileSizeFilter(result, 'maxFileSize');
|
|
95
106
|
return result;
|
|
96
107
|
}
|
|
97
108
|
function buildFinalConfig(configPathOrObject) {
|
package/dist/utils.js
CHANGED
|
@@ -8,9 +8,11 @@ exports.concatenate = concatenate;
|
|
|
8
8
|
exports.getMatchedFiles = getMatchedFiles;
|
|
9
9
|
exports.isJavascriptFile = isJavascriptFile;
|
|
10
10
|
exports.validateNProtections = validateNProtections;
|
|
11
|
+
exports.validateThresholdFn = void 0;
|
|
11
12
|
var _glob = require("glob");
|
|
12
13
|
var _fs = _interopRequireDefault(require("fs"));
|
|
13
14
|
var _path = require("path");
|
|
15
|
+
var _filesizeParser = _interopRequireDefault(require("filesize-parser"));
|
|
14
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
17
|
/**
|
|
16
18
|
* Return the list of matched files for minimatch patterns.
|
|
@@ -86,4 +88,15 @@ function isJavascriptFile(filename) {
|
|
|
86
88
|
const fileExtension = (0, _path.extname)(filename);
|
|
87
89
|
const validJsFileExtensions = ['.js', '.mjs', '.cjs'];
|
|
88
90
|
return validJsFileExtensions.includes(fileExtension);
|
|
89
|
-
}
|
|
91
|
+
}
|
|
92
|
+
const validateThresholdFn = optionName => val => {
|
|
93
|
+
let inBytes;
|
|
94
|
+
try {
|
|
95
|
+
inBytes = (0, _filesizeParser.default)(val);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error("*".concat(optionName, "* requires a valid <threshold> value. Format: {number}{unit=\"b,kb,mb\"}. Example: 200kb"));
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
return inBytes;
|
|
101
|
+
};
|
|
102
|
+
exports.validateThresholdFn = validateThresholdFn;
|
package/package.json
CHANGED