syncpack 9.1.2 → 9.7.4
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/dist/bin-fix-mismatches/fix-mismatches-cli.js +4 -4
- package/dist/bin-fix-mismatches/fix-mismatches.js +14 -15
- package/dist/bin-fix-mismatches/index.js +50 -48
- package/dist/bin-format/format-cli.js +4 -4
- package/dist/bin-format/format.js +19 -18
- package/dist/bin-format/index.js +43 -46
- package/dist/bin-lint-semver-ranges/index.js +59 -48
- package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +4 -4
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +15 -37
- package/dist/bin-list/index.js +43 -46
- package/dist/bin-list/list-cli.js +4 -4
- package/dist/bin-list/list.js +26 -29
- package/dist/bin-list-mismatches/index.js +46 -47
- package/dist/bin-list-mismatches/list-mismatches-cli.js +4 -4
- package/dist/bin-list-mismatches/list-mismatches.js +51 -40
- package/dist/bin-set-semver-ranges/index.js +62 -49
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +4 -4
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +4 -4
- package/dist/bin.js +8 -8
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +6 -5
- package/dist/get-context/$R.js +14 -36
- package/dist/get-context/get-all-instances.js +3 -3
- package/dist/get-context/get-config/get-core-types.js +11 -41
- package/dist/get-context/get-config/get-custom-types.js +7 -19
- package/dist/get-context/get-config/get-enabled-types.js +9 -11
- package/dist/get-context/get-config/index.js +29 -59
- package/dist/get-context/get-config/path-strategy/index.js +8 -8
- package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.js +6 -6
- package/dist/get-context/get-config/path-strategy/name-and-version-props.js +23 -49
- package/dist/get-context/get-config/path-strategy/name-and-version-string.js +26 -42
- package/dist/get-context/get-config/path-strategy/types.js +1 -1
- package/dist/get-context/get-config/path-strategy/version-string.js +25 -41
- package/dist/get-context/get-config/path-strategy/versions-by-name.js +14 -30
- package/dist/get-context/get-config/schema/base-group.d.ts +2 -1
- package/dist/get-context/get-config/schema/base-group.js +5 -4
- package/dist/get-context/get-config/schema/index.d.ts +374 -148
- package/dist/get-context/get-config/schema/index.js +40 -63
- package/dist/get-context/get-config/schema/paths.js +12 -12
- package/dist/get-context/get-config/schema/semver-group.d.ts +42 -24
- package/dist/get-context/get-config/schema/semver-group.js +11 -18
- package/dist/get-context/get-config/schema/semver-range.js +4 -4
- package/dist/get-context/get-config/schema/version-group.d.ts +91 -24
- package/dist/get-context/get-config/schema/version-group.js +20 -21
- package/dist/get-context/get-groups/base-group.d.ts +4 -1
- package/dist/get-context/get-groups/base-group.js +18 -19
- package/dist/get-context/get-groups/index.d.ts +2 -1
- package/dist/get-context/get-groups/index.js +31 -37
- package/dist/get-context/get-groups/semver-group.d.ts +0 -1
- package/dist/get-context/get-groups/semver-group.js +23 -66
- package/dist/get-context/get-groups/version-group/index.d.ts +2 -1
- package/dist/get-context/get-groups/version-group/index.js +29 -68
- package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.d.ts +3 -1
- package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +36 -45
- package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +2 -1
- package/dist/get-context/get-groups/version-group/instance-group/index.js +55 -47
- package/dist/get-context/get-groups/version-group/instance-group/lib/clean.d.ts +2 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/clean.js +13 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +2 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +22 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/get-range-score.d.ts +2 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/get-range-score.js +23 -0
- package/dist/get-context/get-package-json-files/get-file-paths.js +18 -19
- package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +9 -12
- package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +9 -11
- package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +10 -13
- package/dist/get-context/get-package-json-files/get-patterns/index.js +15 -42
- package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.js +4 -6
- package/dist/get-context/get-package-json-files/get-patterns/props.js +9 -33
- package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.js +6 -9
- package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +4 -4
- package/dist/get-context/get-package-json-files/index.js +7 -7
- package/dist/get-context/get-package-json-files/package-json-file/index.js +32 -55
- package/dist/get-context/get-package-json-files/package-json-file/instance.js +14 -15
- package/dist/get-context/index.js +19 -24
- package/dist/lib/disk.js +28 -29
- package/dist/lib/error.js +13 -31
- package/dist/lib/exit-if-invalid.js +1 -1
- package/dist/lib/is-semver.d.ts +1 -1
- package/dist/lib/is-semver.js +15 -7
- package/dist/lib/log.d.ts +4 -2
- package/dist/lib/log.js +44 -60
- package/dist/lib/newlines.js +11 -11
- package/dist/lib/print-strings.js +2 -2
- package/dist/lib/set-semver-range.js +8 -8
- package/dist/lib/show-help-on-error.js +31 -8
- package/dist/lib/sort-by-name.js +1 -1
- package/dist/lib/write-if-changed.js +3 -3
- package/dist/option.js +8 -13
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -1
- package/package.json +20 -16
|
@@ -1,31 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
exports.__esModule = true;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
3
|
exports.PackageJsonFile = void 0;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const constants_1 = require("../../../constants");
|
|
7
|
+
const log_1 = require("../../../lib/log");
|
|
8
|
+
const newlines_1 = require("../../../lib/newlines");
|
|
9
|
+
const path_strategy_1 = require("../../get-config/path-strategy");
|
|
10
|
+
const instance_1 = require("./instance");
|
|
11
|
+
class PackageJsonFile {
|
|
12
|
+
constructor(jsonFile, config, disk) {
|
|
29
13
|
this.contents = jsonFile.contents;
|
|
30
14
|
this.disk = disk;
|
|
31
15
|
this.filePath = jsonFile.filePath;
|
|
@@ -33,41 +17,35 @@ var PackageJsonFile = /** @class */ (function () {
|
|
|
33
17
|
this.config = config;
|
|
34
18
|
this.shortPath = (0, path_1.relative)(constants_1.CWD, jsonFile.filePath);
|
|
35
19
|
}
|
|
36
|
-
|
|
20
|
+
hasChanged() {
|
|
37
21
|
return this.json !== this.getSource();
|
|
38
|
-
}
|
|
39
|
-
|
|
22
|
+
}
|
|
23
|
+
write() {
|
|
40
24
|
this.disk.writeFileSync(this.filePath, this.getSource());
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
25
|
+
}
|
|
26
|
+
getSource() {
|
|
27
|
+
const contents = this.contents;
|
|
28
|
+
const indent = this.config.indent;
|
|
29
|
+
const EOL = newlines_1.newlines.detect(this.json);
|
|
30
|
+
const source = `${JSON.stringify(contents, null, indent)}${EOL}`;
|
|
47
31
|
return newlines_1.newlines.fix(source, EOL);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
var _this = this;
|
|
32
|
+
}
|
|
33
|
+
getInstances() {
|
|
51
34
|
return this.config.enabledTypes
|
|
52
|
-
.flatMap(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
})
|
|
58
|
-
.filter(function (instance) {
|
|
59
|
-
var pathDef = instance.pathDef, name = instance.name, version = instance.version;
|
|
60
|
-
var filter = _this.config.filter;
|
|
35
|
+
.flatMap((pathDef) => this.getPathEntries(pathDef, this).map(([name, version]) => new instance_1.Instance(pathDef, name, this, version)))
|
|
36
|
+
.filter((instance) => {
|
|
37
|
+
const { pathDef, name, version } = instance;
|
|
38
|
+
const filter = this.config.filter;
|
|
61
39
|
if (name.search(new RegExp(filter)) === -1) {
|
|
62
|
-
(0, log_1.verbose)(
|
|
40
|
+
(0, log_1.verbose)(`skip, name "${name}" does not match filter "${filter}"`);
|
|
63
41
|
return false;
|
|
64
42
|
}
|
|
65
|
-
(0, log_1.verbose)(
|
|
43
|
+
(0, log_1.verbose)(`add ${name}@${version} to ${pathDef.name}:${pathDef.strategy} ${this.shortPath}`);
|
|
66
44
|
return true;
|
|
67
45
|
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
46
|
+
}
|
|
47
|
+
getPathEntries(pathDef, file) {
|
|
48
|
+
const strategyName = pathDef.strategy;
|
|
71
49
|
switch (strategyName) {
|
|
72
50
|
case 'name@version':
|
|
73
51
|
return (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), ts_belt_1.R.getWithDefault([]));
|
|
@@ -80,7 +58,6 @@ var PackageJsonFile = /** @class */ (function () {
|
|
|
80
58
|
default:
|
|
81
59
|
return (0, path_strategy_1.exhaustiveCheck)(strategyName);
|
|
82
60
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
}());
|
|
61
|
+
}
|
|
62
|
+
}
|
|
86
63
|
exports.PackageJsonFile = PackageJsonFile;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Instance = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const _R_1 = require("../../$R");
|
|
6
|
+
const path_strategy_1 = require("../../get-config/path-strategy");
|
|
7
|
+
class Instance {
|
|
8
|
+
constructor(pathDef, name, packageJsonFile, version) {
|
|
9
9
|
this.pathDef = pathDef;
|
|
10
10
|
this.name = name;
|
|
11
11
|
this.packageJsonFile = packageJsonFile;
|
|
@@ -13,17 +13,17 @@ var Instance = /** @class */ (function () {
|
|
|
13
13
|
this.version = version;
|
|
14
14
|
}
|
|
15
15
|
/** Is this instance the package.json file of this package developed in this repo? */
|
|
16
|
-
|
|
16
|
+
isWorkspace() {
|
|
17
17
|
return this.pathDef.name === 'workspace';
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
/**
|
|
20
20
|
* In the case of banned dependencies, their version is set to `undefined`,
|
|
21
21
|
* which causes them to be removed by `JSON.stringify`.
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
setVersion(version) {
|
|
24
|
+
const strategyName = this.pathDef.strategy;
|
|
25
|
+
const entry = [this.name, version];
|
|
26
|
+
const file = this.packageJsonFile;
|
|
27
27
|
switch (strategyName) {
|
|
28
28
|
case 'name@version':
|
|
29
29
|
(0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
|
|
@@ -40,7 +40,6 @@ var Instance = /** @class */ (function () {
|
|
|
40
40
|
default:
|
|
41
41
|
return (0, path_strategy_1.exhaustiveCheck)(strategyName);
|
|
42
42
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
46
45
|
exports.Instance = Instance;
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
exports.__esModule = true;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.getContext = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
const disk_1 = require("../lib/disk");
|
|
5
|
+
const get_all_instances_1 = require("./get-all-instances");
|
|
6
|
+
const get_config_1 = require("./get-config");
|
|
7
|
+
const get_groups_1 = require("./get-groups");
|
|
8
|
+
const get_package_json_files_1 = require("./get-package-json-files");
|
|
20
9
|
/**
|
|
21
10
|
* Every command in syncpack should accept the return value of this function as
|
|
22
11
|
* its input.
|
|
@@ -25,12 +14,18 @@ var get_package_json_files_1 = require("./get-package-json-files");
|
|
|
25
14
|
* that the majority of syncpack and its tests don't have to deal with the file
|
|
26
15
|
* system and can focus solely on transformation logic.
|
|
27
16
|
*/
|
|
28
|
-
function getContext(program, disk) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
function getContext(program, disk = disk_1.disk) {
|
|
18
|
+
const config = (0, get_config_1.getConfig)(disk, program);
|
|
19
|
+
const packageJsonFiles = (0, get_package_json_files_1.getPackageJsonFiles)(disk, config);
|
|
20
|
+
const instances = (0, get_all_instances_1.getAllInstances)(packageJsonFiles);
|
|
21
|
+
const groups = (0, get_groups_1.getGroups)(config, instances, packageJsonFiles);
|
|
22
|
+
return {
|
|
23
|
+
...config,
|
|
24
|
+
disk,
|
|
25
|
+
isInvalid: false,
|
|
26
|
+
packageJsonFiles,
|
|
27
|
+
semverGroups: groups.semverGroups,
|
|
28
|
+
versionGroups: groups.versionGroups,
|
|
29
|
+
};
|
|
35
30
|
}
|
|
36
31
|
exports.getContext = getContext;
|
package/dist/lib/disk.js
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.disk = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
const cosmiconfig_1 = require("cosmiconfig");
|
|
5
|
+
const is_non_empty_object_1 = require("expect-more/dist/is-non-empty-object");
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
const glob_1 = require("glob");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const read_yaml_file_1 = require("read-yaml-file");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const log_1 = require("./log");
|
|
12
|
+
const client = (0, cosmiconfig_1.cosmiconfigSync)('syncpack');
|
|
13
13
|
exports.disk = {
|
|
14
14
|
process: {
|
|
15
|
-
exit
|
|
15
|
+
exit(code) {
|
|
16
16
|
(0, log_1.verbose)('exit(', code, ')');
|
|
17
17
|
process.exit(code);
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
19
|
},
|
|
20
|
-
globSync
|
|
20
|
+
globSync(pattern) {
|
|
21
21
|
(0, log_1.verbose)('globSync(', pattern, ')');
|
|
22
22
|
return (0, glob_1.sync)(pattern, {
|
|
23
23
|
ignore: '**/node_modules/**',
|
|
24
24
|
absolute: true,
|
|
25
|
-
cwd: constants_1.CWD
|
|
25
|
+
cwd: constants_1.CWD,
|
|
26
26
|
});
|
|
27
27
|
},
|
|
28
|
-
readConfigFileSync
|
|
29
|
-
var _a;
|
|
28
|
+
readConfigFileSync(configPath) {
|
|
30
29
|
(0, log_1.verbose)('readConfigFileSync(', configPath, ')');
|
|
31
30
|
try {
|
|
32
|
-
|
|
31
|
+
const result = configPath ? client.load(configPath) : client.search();
|
|
33
32
|
if (result === null) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if ((0,
|
|
38
|
-
return
|
|
33
|
+
const rcPath = (0, path_1.join)(constants_1.CWD, 'package.json');
|
|
34
|
+
const pjson = (0, fs_extra_1.readJsonSync)(rcPath, { throws: false });
|
|
35
|
+
const rcConfig = pjson?.config?.syncpack;
|
|
36
|
+
if ((0, is_non_empty_object_1.isNonEmptyObject)(rcConfig))
|
|
37
|
+
return rcConfig;
|
|
39
38
|
(0, log_1.verbose)('no config file found');
|
|
40
39
|
return {};
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const rcPath = result.filepath;
|
|
42
|
+
const rcConfig = result.config;
|
|
44
43
|
(0, log_1.verbose)('.syncpackrc path:', rcPath);
|
|
45
44
|
(0, log_1.verbose)('.syncpackrc contents:', rcConfig);
|
|
46
45
|
return rcConfig;
|
|
@@ -50,20 +49,20 @@ exports.disk = {
|
|
|
50
49
|
return {};
|
|
51
50
|
}
|
|
52
51
|
},
|
|
53
|
-
readFileSync
|
|
52
|
+
readFileSync(filePath) {
|
|
54
53
|
(0, log_1.verbose)('readFileSync(', filePath, ')');
|
|
55
54
|
return (0, fs_extra_1.readFileSync)(filePath, { encoding: 'utf8' });
|
|
56
55
|
},
|
|
57
|
-
readYamlFileSync
|
|
56
|
+
readYamlFileSync(filePath) {
|
|
58
57
|
(0, log_1.verbose)('readYamlFileSync(', filePath, ')');
|
|
59
58
|
return (0, read_yaml_file_1.sync)(filePath);
|
|
60
59
|
},
|
|
61
|
-
removeSync
|
|
60
|
+
removeSync(filePath) {
|
|
62
61
|
(0, log_1.verbose)('removeSync(', filePath, ')');
|
|
63
62
|
(0, fs_extra_1.removeSync)(filePath);
|
|
64
63
|
},
|
|
65
|
-
writeFileSync
|
|
64
|
+
writeFileSync(filePath, contents) {
|
|
66
65
|
(0, log_1.verbose)('writeFileSync(', filePath, contents, ')');
|
|
67
66
|
(0, fs_extra_1.writeFileSync)(filePath, contents);
|
|
68
|
-
}
|
|
67
|
+
},
|
|
69
68
|
};
|
package/dist/lib/error.js
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.BaseError = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
_this.cause = BaseError.normalize(options === null || options === void 0 ? void 0 : options.cause);
|
|
25
|
-
return _this;
|
|
4
|
+
class BaseError extends Error {
|
|
5
|
+
constructor(message, options) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'SyncpackError';
|
|
8
|
+
this.cause = BaseError.normalize(options?.cause);
|
|
26
9
|
}
|
|
27
|
-
|
|
10
|
+
static normalize(value) {
|
|
28
11
|
if (value instanceof BaseError)
|
|
29
12
|
return value;
|
|
30
13
|
if (value instanceof Error)
|
|
@@ -32,12 +15,11 @@ var BaseError = /** @class */ (function (_super) {
|
|
|
32
15
|
if (typeof value === 'string')
|
|
33
16
|
return new Error(value);
|
|
34
17
|
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return
|
|
38
|
-
return new BaseError(message, { cause
|
|
18
|
+
}
|
|
19
|
+
static map(message) {
|
|
20
|
+
return (cause) => {
|
|
21
|
+
return new BaseError(message, { cause });
|
|
39
22
|
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}(Error));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
43
25
|
exports.BaseError = BaseError;
|
package/dist/lib/is-semver.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Syncpack } from '../types';
|
|
2
2
|
export declare function isValidSemverRange(value: unknown): value is Syncpack.Config.SemverRange.Value;
|
|
3
|
-
export declare function isSemver(version: unknown):
|
|
3
|
+
export declare function isSemver(version: unknown): version is string;
|
|
4
4
|
export declare function isLooseSemver(version: unknown): boolean;
|
package/dist/lib/is-semver.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isLooseSemver = exports.isSemver = exports.isValidSemverRange = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const is_string_1 = require("expect-more/dist/is-string");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
6
|
function isValidSemverRange(value) {
|
|
7
7
|
return (value === constants_1.RANGE.ANY ||
|
|
8
8
|
value === constants_1.RANGE.EXACT ||
|
|
@@ -16,12 +16,20 @@ function isValidSemverRange(value) {
|
|
|
16
16
|
}
|
|
17
17
|
exports.isValidSemverRange = isValidSemverRange;
|
|
18
18
|
function isSemver(version) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const range = '(~|\\^|>=|>|<=|<)?';
|
|
20
|
+
const ints = '[0-9]+';
|
|
21
|
+
const intsOrX = '([0-9]+|x)';
|
|
22
|
+
const dot = '\\.';
|
|
23
|
+
const major = new RegExp(`^${range}${ints}$`);
|
|
24
|
+
const minor = new RegExp(`^${range}${ints}${dot}${intsOrX}$`);
|
|
25
|
+
const patch = new RegExp(`^${range}${ints}${dot}${intsOrX}${dot}${intsOrX}$`);
|
|
26
|
+
return ((0, is_string_1.isString)(version) &&
|
|
27
|
+
(version.search(major) !== -1 ||
|
|
28
|
+
version.search(minor) !== -1 ||
|
|
29
|
+
version.search(patch) !== -1));
|
|
22
30
|
}
|
|
23
31
|
exports.isSemver = isSemver;
|
|
24
32
|
function isLooseSemver(version) {
|
|
25
|
-
return
|
|
33
|
+
return isSemver(version) && version.search(/\.x(\.|$)/) !== -1;
|
|
26
34
|
}
|
|
27
35
|
exports.isLooseSemver = isLooseSemver;
|
package/dist/lib/log.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { SemverGroup } from '../get-context/get-groups/semver-group';
|
|
2
|
+
import type { VersionGroup } from '../get-context/get-groups/version-group';
|
|
1
3
|
export declare function verbose(...values: unknown[]): void;
|
|
2
4
|
export declare function fixed(message: string): void;
|
|
3
5
|
export declare function skip(message: string): void;
|
|
4
|
-
export declare function semverGroupHeader(order: number): void;
|
|
5
|
-
export declare function versionGroupHeader(order: number): void;
|
|
6
6
|
export declare function valid(message: string, comment?: string): void;
|
|
7
7
|
export declare function invalid(message: string, comment?: string): void;
|
|
8
|
+
export declare function semverGroupHeader(group: SemverGroup, i: number): void;
|
|
9
|
+
export declare function versionGroupHeader(group: VersionGroup, i: number): void;
|
package/dist/lib/log.js
CHANGED
|
@@ -1,88 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
7
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
8
|
-
if (!m) return o;
|
|
9
|
-
var i = m.call(o), r, ar = [], e;
|
|
10
|
-
try {
|
|
11
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
12
|
-
}
|
|
13
|
-
catch (error) { e = { error: error }; }
|
|
14
|
-
finally {
|
|
15
|
-
try {
|
|
16
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
17
|
-
}
|
|
18
|
-
finally { if (e) throw e.error; }
|
|
19
|
-
}
|
|
20
|
-
return ar;
|
|
21
|
-
};
|
|
22
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
23
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
24
|
-
if (ar || !(i in from)) {
|
|
25
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
26
|
-
ar[i] = from[i];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
30
|
-
};
|
|
31
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
4
|
};
|
|
34
|
-
exports
|
|
35
|
-
exports.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
function verbose() {
|
|
41
|
-
|
|
42
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
43
|
-
values[_i] = arguments[_i];
|
|
44
|
-
}
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.versionGroupHeader = exports.semverGroupHeader = exports.invalid = exports.valid = exports.skip = exports.fixed = exports.verbose = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const is_string_1 = require("expect-more/dist/is-string");
|
|
9
|
+
const util_1 = require("util");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
function verbose(...values) {
|
|
12
|
+
/* istanbul ignore if */
|
|
45
13
|
if (process.env.SYNCPACK_VERBOSE) {
|
|
46
|
-
console.info
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: (0, util_1.inspect)(value, false, null, true);
|
|
50
|
-
})), false));
|
|
14
|
+
console.info(chalk_1.default.yellow(constants_1.ICON.debug), ...values.map((value) => (0, is_string_1.isString)(value)
|
|
15
|
+
? chalk_1.default.yellow(value)
|
|
16
|
+
: (0, util_1.inspect)(value, { showHidden: false, colors: true, depth: 20 })));
|
|
51
17
|
}
|
|
52
18
|
}
|
|
53
19
|
exports.verbose = verbose;
|
|
54
20
|
function fixed(message) {
|
|
55
|
-
console.log((0, chalk_1
|
|
21
|
+
console.log((0, chalk_1.default) `{green ${constants_1.ICON.tick}}`, message);
|
|
56
22
|
}
|
|
57
23
|
exports.fixed = fixed;
|
|
58
24
|
function skip(message) {
|
|
59
|
-
console.log(chalk_1
|
|
25
|
+
console.log(chalk_1.default.dim(constants_1.ICON.skip), chalk_1.default.dim(message));
|
|
60
26
|
}
|
|
61
27
|
exports.skip = skip;
|
|
62
|
-
function semverGroupHeader(order) {
|
|
63
|
-
console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{dim = Semver Group ", " ", "}"], ["{dim = Semver Group ", " ", "}"])), order, '='.repeat(63)));
|
|
64
|
-
}
|
|
65
|
-
exports.semverGroupHeader = semverGroupHeader;
|
|
66
|
-
function versionGroupHeader(order) {
|
|
67
|
-
console.log((0, chalk_1["default"])(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{dim = Version Group ", " ", "}"], ["{dim = Version Group ", " ", "}"])), order, '='.repeat(63)));
|
|
68
|
-
}
|
|
69
|
-
exports.versionGroupHeader = versionGroupHeader;
|
|
70
28
|
function valid(message, comment) {
|
|
71
29
|
if (comment) {
|
|
72
|
-
console.log((0, chalk_1
|
|
30
|
+
console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip}} ${message} {dim ${comment}}`);
|
|
73
31
|
}
|
|
74
32
|
else {
|
|
75
|
-
console.log((0, chalk_1
|
|
33
|
+
console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip}} ${message}`);
|
|
76
34
|
}
|
|
77
35
|
}
|
|
78
36
|
exports.valid = valid;
|
|
79
37
|
function invalid(message, comment) {
|
|
80
38
|
if (comment) {
|
|
81
|
-
console.log((0, chalk_1
|
|
39
|
+
console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross}} ${message} {dim ${comment}}`);
|
|
82
40
|
}
|
|
83
41
|
else {
|
|
84
|
-
console.log((0, chalk_1
|
|
42
|
+
console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross}} ${message}`);
|
|
85
43
|
}
|
|
86
44
|
}
|
|
87
45
|
exports.invalid = invalid;
|
|
88
|
-
|
|
46
|
+
function semverGroupHeader(group, i) {
|
|
47
|
+
logHeader(group, 'Semver', i);
|
|
48
|
+
}
|
|
49
|
+
exports.semverGroupHeader = semverGroupHeader;
|
|
50
|
+
function versionGroupHeader(group, i) {
|
|
51
|
+
logHeader(group, 'Version', i);
|
|
52
|
+
}
|
|
53
|
+
exports.versionGroupHeader = versionGroupHeader;
|
|
54
|
+
function logHeader(group, type, i) {
|
|
55
|
+
const customLabel = group.groupConfig.label;
|
|
56
|
+
const labelWhenDefault = group.isDefault ? `Default ${type} Group` : '';
|
|
57
|
+
const anonymousLabel = `${type} Group ${i + 1}`;
|
|
58
|
+
const label = (customLabel || labelWhenDefault || anonymousLabel).trim();
|
|
59
|
+
const hasNewLines = label.search(/[\r\n]/) !== -1;
|
|
60
|
+
const header = hasNewLines ? formatMultiLine(label) : formatSingleLine(label);
|
|
61
|
+
console.log(chalk_1.default.blue(header));
|
|
62
|
+
}
|
|
63
|
+
function formatSingleLine(label) {
|
|
64
|
+
const leftSide = `= ${label} `;
|
|
65
|
+
const dividerWidth = 80 - leftSide.length;
|
|
66
|
+
const rightSide = dividerWidth > 0 ? '='.repeat(dividerWidth) : '';
|
|
67
|
+
return `${leftSide}${rightSide}`;
|
|
68
|
+
}
|
|
69
|
+
function formatMultiLine(label) {
|
|
70
|
+
const reindented = label.replace(/^\s+/gm, ' ');
|
|
71
|
+
return `= ${reindented}`;
|
|
72
|
+
}
|
package/dist/lib/newlines.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.newlines = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const os_1 = require("os");
|
|
5
|
+
const CR = '\r';
|
|
6
|
+
const CRLF = '\r\n';
|
|
7
|
+
const LF = '\n';
|
|
8
8
|
exports.newlines = {
|
|
9
|
-
detect
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
detect(source) {
|
|
10
|
+
const cr = source.split(CR).length;
|
|
11
|
+
const lf = source.split(LF).length;
|
|
12
|
+
const crlf = source.split(CRLF).length;
|
|
13
13
|
if (cr + lf === 0)
|
|
14
14
|
return os_1.EOL;
|
|
15
15
|
if (crlf === cr && crlf === lf)
|
|
@@ -18,7 +18,7 @@ exports.newlines = {
|
|
|
18
18
|
return CR;
|
|
19
19
|
return LF;
|
|
20
20
|
},
|
|
21
|
-
fix
|
|
21
|
+
fix(source, lineEnding) {
|
|
22
22
|
return source.replace(/\r\n|\n|\r/g, lineEnding);
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
24
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printStrings = void 0;
|
|
4
4
|
function printStrings(strings) {
|
|
5
|
-
return strings.map(
|
|
5
|
+
return strings.map((str) => `"${str}"`).join(', ');
|
|
6
6
|
}
|
|
7
7
|
exports.printStrings = printStrings;
|