syncpack 9.3.2 → 9.8.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 +17 -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 +20 -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 +13 -35
- 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 +55 -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-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.d.ts +3 -1
- package/dist/get-context/get-config/index.js +37 -61
- 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 -2
- package/dist/get-context/get-config/schema/base-group.js +5 -5
- package/dist/get-context/get-config/schema/index.d.ts +292 -164
- package/dist/get-context/get-config/schema/index.js +40 -63
- package/dist/get-context/get-config/schema/lib/non-empty-string.d.ts +2 -0
- package/dist/get-context/get-config/schema/lib/non-empty-string.js +5 -0
- package/dist/get-context/get-config/schema/paths.js +12 -12
- package/dist/get-context/get-config/schema/semver-group.d.ts +24 -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 +90 -41
- package/dist/get-context/get-config/schema/version-group.js +28 -23
- 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 +7 -3
- package/dist/get-context/get-groups/index.js +42 -38
- 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 +7 -4
- package/dist/get-context/get-groups/version-group/index.js +31 -70
- 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/get-lowest-version.d.ts +3 -0
- package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.js +44 -0
- package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +16 -5
- package/dist/get-context/get-groups/version-group/instance-group/index.js +66 -54
- 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 +4 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +38 -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.d.ts +3 -1
- package/dist/get-context/get-package-json-files/index.js +8 -8
- 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.d.ts +2 -1
- package/dist/get-context/get-package-json-files/package-json-file/instance.js +15 -15
- package/dist/get-context/index.d.ts +3 -2
- package/dist/get-context/index.js +28 -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.js +38 -58
- 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 +3 -1
- package/dist/types.js +1 -1
- package/package.json +20 -16
- package/dist/get-context/get-all-instances.d.ts +0 -3
- package/dist/get-context/get-all-instances.js +0 -8
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fixMismatchesCli = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const get_context_1 = require("../get-context");
|
|
5
|
+
const write_if_changed_1 = require("../lib/write-if-changed");
|
|
6
|
+
const fix_mismatches_1 = require("./fix-mismatches");
|
|
7
7
|
function fixMismatchesCli(input, disk) {
|
|
8
8
|
(0, write_if_changed_1.writeIfChanged)((0, fix_mismatches_1.fixMismatches)((0, get_context_1.getContext)(input, disk)));
|
|
9
9
|
}
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fixMismatches = void 0;
|
|
4
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const is_object_1 = require("expect-more/dist/is-object");
|
|
6
|
+
const is_undefined_1 = require("expect-more/dist/is-undefined");
|
|
7
|
+
const _R_1 = require("../get-context/$R");
|
|
5
8
|
function fixMismatches(ctx) {
|
|
6
|
-
ctx.versionGroups.forEach(
|
|
7
|
-
|
|
9
|
+
ctx.versionGroups.forEach((versionGroup) => {
|
|
10
|
+
const invalidGroups = versionGroup.getInvalidInstanceGroups();
|
|
8
11
|
// Nothing to do if there are no mismatches
|
|
9
12
|
if (invalidGroups.length === 0)
|
|
10
13
|
return;
|
|
11
14
|
// Set the correct version on each instance.
|
|
12
|
-
invalidGroups.forEach(
|
|
15
|
+
invalidGroups.forEach((instanceGroup) => {
|
|
13
16
|
if (!instanceGroup.hasUnsupportedVersion()) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
17
|
+
(0, ts_belt_1.pipe)(instanceGroup.getExpectedVersion(), ts_belt_1.R.tap((nextVersion) => {
|
|
18
|
+
instanceGroup.instances.forEach((instance) => instance.setVersion(nextVersion));
|
|
19
|
+
}), _R_1.$R.tapErrVerbose);
|
|
18
20
|
}
|
|
19
21
|
});
|
|
20
22
|
});
|
|
21
23
|
/** Remove eg `{"dependencies": {}, "devDependencies": {}}` */
|
|
22
|
-
ctx.packageJsonFiles.forEach(
|
|
23
|
-
|
|
24
|
-
Object.keys(contents).forEach(
|
|
25
|
-
|
|
26
|
-
if ((0,
|
|
27
|
-
Object.values(value).every(
|
|
24
|
+
ctx.packageJsonFiles.forEach((packageJsonFile) => {
|
|
25
|
+
const contents = packageJsonFile.contents;
|
|
26
|
+
Object.keys(contents).forEach((key) => {
|
|
27
|
+
const value = contents[key];
|
|
28
|
+
if ((0, is_object_1.isObject)(value) &&
|
|
29
|
+
Object.values(value).every(is_undefined_1.isUndefined)) {
|
|
28
30
|
delete contents[key];
|
|
29
31
|
}
|
|
30
32
|
});
|
|
@@ -1,61 +1,63 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
4
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
5
|
-
return cooked;
|
|
6
|
-
};
|
|
7
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
8
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
9
|
-
if (!m) return o;
|
|
10
|
-
var i = m.call(o), r, ar = [], e;
|
|
11
|
-
try {
|
|
12
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
13
|
-
}
|
|
14
|
-
catch (error) { e = { error: error }; }
|
|
15
|
-
finally {
|
|
16
|
-
try {
|
|
17
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18
|
-
}
|
|
19
|
-
finally { if (e) throw e.error; }
|
|
20
|
-
}
|
|
21
|
-
return ar;
|
|
22
|
-
};
|
|
23
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
-
if (ar || !(i in from)) {
|
|
26
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
-
ar[i] = from[i];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
-
};
|
|
32
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
5
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const disk_1 = require("../lib/disk");
|
|
10
|
+
const show_help_on_error_1 = require("../lib/show-help-on-error");
|
|
11
|
+
const option_1 = require("../option");
|
|
12
|
+
const fix_mismatches_cli_1 = require("./fix-mismatches-cli");
|
|
13
|
+
commander_1.program.description((0, chalk_1.default) `
|
|
14
|
+
Ensure that multiple packages requiring the same dependency define the same
|
|
15
|
+
version, so that every package requires eg. {yellow react@16.4.2}, instead of a
|
|
16
|
+
combination of {yellow react@16.4.2}, {yellow react@0.15.9}, and {yellow react@16.0.0}.`.replace(/^\n/, ''));
|
|
17
|
+
commander_1.program.on('--help', () => {
|
|
18
|
+
console.log((0, chalk_1.default) `
|
|
19
|
+
Resolving Packages:
|
|
20
|
+
1. If {yellow --source} globs are provided, use those.
|
|
21
|
+
2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
22
|
+
3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
23
|
+
4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
24
|
+
5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
{dim # uses defaults for resolving packages}
|
|
28
|
+
syncpack fix-mismatches
|
|
29
|
+
{dim # uses packages defined by --source when provided}
|
|
30
|
+
syncpack fix-mismatches --source {yellow "apps/*/package.json"}
|
|
31
|
+
{dim # multiple globs can be provided like this}
|
|
32
|
+
syncpack fix-mismatches --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
|
|
33
|
+
{dim # uses dependencies regular expression defined by --filter when provided}
|
|
34
|
+
syncpack fix-mismatches --filter {yellow "typescript|tslint"}
|
|
35
|
+
{dim # only inspect "devDependencies"}
|
|
36
|
+
syncpack fix-mismatches --types dev
|
|
37
|
+
{dim # only inspect "devDependencies" and "peerDependencies"}
|
|
38
|
+
syncpack fix-mismatches --types dev,peer
|
|
39
|
+
{dim # indent package.json with 4 spaces instead of 2}
|
|
40
|
+
syncpack fix-mismatches --indent {yellow " "}
|
|
41
|
+
|
|
42
|
+
Reference:
|
|
43
|
+
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
44
|
+
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
45
|
+
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
46
|
+
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
47
|
+
`);
|
|
46
48
|
});
|
|
47
49
|
(0, show_help_on_error_1.showHelpOnError)(commander_1.program);
|
|
48
|
-
|
|
49
|
-
.option
|
|
50
|
-
.option
|
|
51
|
-
.option
|
|
52
|
-
.option
|
|
53
|
-
.option
|
|
50
|
+
commander_1.program
|
|
51
|
+
.option(...option_1.option.source)
|
|
52
|
+
.option(...option_1.option.filter)
|
|
53
|
+
.option(...option_1.option.types)
|
|
54
|
+
.option(...option_1.option.config)
|
|
55
|
+
.option(...option_1.option.indent)
|
|
56
|
+
.parse(process.argv);
|
|
54
57
|
(0, fix_mismatches_cli_1.fixMismatchesCli)({
|
|
55
58
|
configPath: commander_1.program.opts().config,
|
|
56
59
|
filter: commander_1.program.opts().filter,
|
|
57
60
|
indent: commander_1.program.opts().indent,
|
|
58
61
|
source: commander_1.program.opts().source,
|
|
59
|
-
types: commander_1.program.opts().types
|
|
62
|
+
types: commander_1.program.opts().types,
|
|
60
63
|
}, disk_1.disk);
|
|
61
|
-
var templateObject_1, templateObject_2;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatCli = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const get_context_1 = require("../get-context");
|
|
5
|
+
const write_if_changed_1 = require("../lib/write-if-changed");
|
|
6
|
+
const format_1 = require("./format");
|
|
7
7
|
function formatCli(input, disk) {
|
|
8
8
|
(0, write_if_changed_1.writeIfChanged)((0, format_1.format)((0, get_context_1.getContext)(input, disk)));
|
|
9
9
|
}
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.format = void 0;
|
|
4
|
-
|
|
4
|
+
const is_array_1 = require("expect-more/dist/is-array");
|
|
5
|
+
const is_non_empty_string_1 = require("expect-more/dist/is-non-empty-string");
|
|
6
|
+
const is_object_1 = require("expect-more/dist/is-object");
|
|
5
7
|
function format(ctx) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
const { packageJsonFiles } = ctx;
|
|
9
|
+
const { sortAz, sortFirst } = ctx.config;
|
|
10
|
+
packageJsonFiles.forEach((packageJsonFile) => {
|
|
11
|
+
const { contents } = packageJsonFile;
|
|
12
|
+
const sortedKeys = Object.keys(contents).sort();
|
|
13
|
+
const keys = new Set(sortFirst.concat(sortedKeys));
|
|
14
|
+
const optionalChaining = contents;
|
|
15
|
+
const bugsUrl = optionalChaining?.bugs?.url;
|
|
16
|
+
const repoUrl = optionalChaining?.repository?.url;
|
|
17
|
+
const repoDir = optionalChaining?.repository?.directory;
|
|
16
18
|
if (bugsUrl) {
|
|
17
19
|
contents.bugs = bugsUrl;
|
|
18
20
|
}
|
|
19
|
-
if ((0,
|
|
21
|
+
if ((0, is_non_empty_string_1.isNonEmptyString)(repoUrl) && !(0, is_non_empty_string_1.isNonEmptyString)(repoDir)) {
|
|
20
22
|
contents.repository = repoUrl.includes('github.com')
|
|
21
23
|
? repoUrl.replace(/^.+github\.com\//, '')
|
|
22
24
|
: repoUrl;
|
|
23
25
|
}
|
|
24
|
-
sortAz.forEach(
|
|
26
|
+
sortAz.forEach((key) => sortAlphabetically(contents[key]));
|
|
25
27
|
sortObject(keys, contents);
|
|
26
28
|
});
|
|
27
29
|
return ctx;
|
|
28
30
|
function sortObject(sortedKeys, obj) {
|
|
29
|
-
sortedKeys.forEach(
|
|
30
|
-
|
|
31
|
+
sortedKeys.forEach((key) => {
|
|
32
|
+
const value = obj[key];
|
|
31
33
|
delete obj[key];
|
|
32
34
|
obj[key] = value;
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
function sortAlphabetically(value) {
|
|
36
|
-
if ((0,
|
|
38
|
+
if ((0, is_array_1.isArray)(value)) {
|
|
37
39
|
value.sort();
|
|
38
40
|
}
|
|
39
|
-
else if ((0,
|
|
41
|
+
else if ((0, is_object_1.isObject)(value)) {
|
|
40
42
|
sortObject(Object.keys(value).sort(), value);
|
|
41
43
|
}
|
|
42
44
|
}
|
package/dist/bin-format/index.js
CHANGED
|
@@ -1,57 +1,54 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
4
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
5
|
-
return cooked;
|
|
6
|
-
};
|
|
7
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
8
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
9
|
-
if (!m) return o;
|
|
10
|
-
var i = m.call(o), r, ar = [], e;
|
|
11
|
-
try {
|
|
12
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
13
|
-
}
|
|
14
|
-
catch (error) { e = { error: error }; }
|
|
15
|
-
finally {
|
|
16
|
-
try {
|
|
17
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18
|
-
}
|
|
19
|
-
finally { if (e) throw e.error; }
|
|
20
|
-
}
|
|
21
|
-
return ar;
|
|
22
|
-
};
|
|
23
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
-
if (ar || !(i in from)) {
|
|
26
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
-
ar[i] = from[i];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
-
};
|
|
32
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
5
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const disk_1 = require("../lib/disk");
|
|
10
|
+
const show_help_on_error_1 = require("../lib/show-help-on-error");
|
|
11
|
+
const option_1 = require("../option");
|
|
12
|
+
const format_cli_1 = require("./format-cli");
|
|
13
|
+
commander_1.program.description((0, chalk_1.default) `
|
|
14
|
+
Organise package.json files according to a conventional format, where fields
|
|
15
|
+
appear in a predictable order and nested fields are ordered alphabetically.
|
|
16
|
+
Shorthand properties are used where available, such as the {yellow repository} and
|
|
17
|
+
{yellow bugs} fields.`.replace(/^\n/, ''));
|
|
18
|
+
commander_1.program.on('--help', () => {
|
|
19
|
+
console.log((0, chalk_1.default) `
|
|
20
|
+
Examples:
|
|
21
|
+
{dim # uses defaults for resolving packages}
|
|
22
|
+
syncpack format
|
|
23
|
+
{dim # uses packages defined by --source when provided}
|
|
24
|
+
syncpack format --source {yellow "apps/*/package.json"}
|
|
25
|
+
{dim # multiple globs can be provided like this}
|
|
26
|
+
syncpack format --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
|
|
27
|
+
{dim # indent package.json with 4 spaces instead of 2}
|
|
28
|
+
syncpack format --indent {yellow " "}
|
|
29
|
+
|
|
30
|
+
Resolving Packages:
|
|
31
|
+
1. If {yellow --source} globs are provided, use those.
|
|
32
|
+
2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
33
|
+
3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
34
|
+
4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
35
|
+
5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
36
|
+
|
|
37
|
+
Reference:
|
|
38
|
+
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
39
|
+
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
40
|
+
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
41
|
+
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
42
|
+
`);
|
|
46
43
|
});
|
|
47
44
|
(0, show_help_on_error_1.showHelpOnError)(commander_1.program);
|
|
48
|
-
|
|
49
|
-
.option
|
|
50
|
-
.option
|
|
51
|
-
.option
|
|
45
|
+
commander_1.program
|
|
46
|
+
.option(...option_1.option.source)
|
|
47
|
+
.option(...option_1.option.config)
|
|
48
|
+
.option(...option_1.option.indent)
|
|
49
|
+
.parse(process.argv);
|
|
52
50
|
(0, format_cli_1.formatCli)({
|
|
53
51
|
configPath: commander_1.program.opts().config,
|
|
54
52
|
indent: commander_1.program.opts().indent,
|
|
55
|
-
source: commander_1.program.opts().source
|
|
53
|
+
source: commander_1.program.opts().source,
|
|
56
54
|
}, disk_1.disk);
|
|
57
|
-
var templateObject_1, templateObject_2;
|
|
@@ -1,61 +1,72 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
4
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
5
|
-
return cooked;
|
|
6
|
-
};
|
|
7
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
8
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
9
|
-
if (!m) return o;
|
|
10
|
-
var i = m.call(o), r, ar = [], e;
|
|
11
|
-
try {
|
|
12
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
13
|
-
}
|
|
14
|
-
catch (error) { e = { error: error }; }
|
|
15
|
-
finally {
|
|
16
|
-
try {
|
|
17
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18
|
-
}
|
|
19
|
-
finally { if (e) throw e.error; }
|
|
20
|
-
}
|
|
21
|
-
return ar;
|
|
22
|
-
};
|
|
23
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
-
if (ar || !(i in from)) {
|
|
26
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
-
ar[i] = from[i];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
-
};
|
|
32
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
5
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const disk_1 = require("../lib/disk");
|
|
10
|
+
const show_help_on_error_1 = require("../lib/show-help-on-error");
|
|
11
|
+
const option_1 = require("../option");
|
|
12
|
+
const lint_semver_ranges_cli_1 = require("./lint-semver-ranges-cli");
|
|
13
|
+
commander_1.program.description((0, chalk_1.default) `
|
|
14
|
+
Check dependency versions within {yellow dependencies}, {yellow devDependencies},
|
|
15
|
+
{yellow peerDependencies}, {yellow overrides}, and {yellow resolutions} follow a consistent format.`.replace(/^\n/, ''));
|
|
16
|
+
commander_1.program.on('--help', () => {
|
|
17
|
+
console.log((0, chalk_1.default) `
|
|
18
|
+
Examples:
|
|
19
|
+
{dim # uses defaults for resolving packages}
|
|
20
|
+
syncpack lint-semver-ranges
|
|
21
|
+
{dim # uses packages defined by --source when provided}
|
|
22
|
+
syncpack lint-semver-ranges --source {yellow "apps/*/package.json"}
|
|
23
|
+
{dim # multiple globs can be provided like this}
|
|
24
|
+
syncpack lint-semver-ranges --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
|
|
25
|
+
{dim # uses dependencies regular expression defined by --filter when provided}
|
|
26
|
+
syncpack lint-semver-ranges --filter {yellow "typescript|tslint"}
|
|
27
|
+
{dim # use ~ range instead of default ""}
|
|
28
|
+
syncpack lint-semver-ranges --semver-range ~
|
|
29
|
+
{dim # use ~ range in "devDependencies"}
|
|
30
|
+
syncpack lint-semver-ranges --types dev --semver-range ~
|
|
31
|
+
{dim # use ~ range in "devDependencies" and "peerDependencies"}
|
|
32
|
+
syncpack lint-semver-ranges --types dev,peer semver-range ~
|
|
33
|
+
|
|
34
|
+
Supported Ranges:
|
|
35
|
+
< {dim <1.4.2}
|
|
36
|
+
<= {dim <=1.4.2}
|
|
37
|
+
"" {dim 1.4.2}
|
|
38
|
+
~ {dim ~1.4.2}
|
|
39
|
+
^ {dim ^1.4.2}
|
|
40
|
+
>= {dim >=1.4.2}
|
|
41
|
+
> {dim >1.4.2}
|
|
42
|
+
* {dim *}
|
|
43
|
+
|
|
44
|
+
Resolving Packages:
|
|
45
|
+
1. If {yellow --source} globs are provided, use those.
|
|
46
|
+
2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
47
|
+
3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
48
|
+
4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
49
|
+
5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
50
|
+
|
|
51
|
+
Reference:
|
|
52
|
+
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
53
|
+
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
54
|
+
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
55
|
+
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
56
|
+
`);
|
|
46
57
|
});
|
|
47
58
|
(0, show_help_on_error_1.showHelpOnError)(commander_1.program);
|
|
48
|
-
|
|
49
|
-
.option
|
|
50
|
-
.option
|
|
51
|
-
.option
|
|
52
|
-
.option
|
|
53
|
-
.option
|
|
59
|
+
commander_1.program
|
|
60
|
+
.option(...option_1.option.source)
|
|
61
|
+
.option(...option_1.option.filter)
|
|
62
|
+
.option(...option_1.option.semverRange)
|
|
63
|
+
.option(...option_1.option.config)
|
|
64
|
+
.option(...option_1.option.types)
|
|
65
|
+
.parse(process.argv);
|
|
54
66
|
(0, lint_semver_ranges_cli_1.lintSemverRangesCli)({
|
|
55
67
|
configPath: commander_1.program.opts().config,
|
|
56
68
|
filter: commander_1.program.opts().filter,
|
|
57
69
|
semverRange: commander_1.program.opts().semverRange,
|
|
58
70
|
source: commander_1.program.opts().source,
|
|
59
|
-
types: commander_1.program.opts().types
|
|
71
|
+
types: commander_1.program.opts().types,
|
|
60
72
|
}, disk_1.disk);
|
|
61
|
-
var templateObject_1, templateObject_2;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lintSemverRangesCli = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const get_context_1 = require("../get-context");
|
|
5
|
+
const exit_if_invalid_1 = require("../lib/exit-if-invalid");
|
|
6
|
+
const lint_semver_ranges_1 = require("./lint-semver-ranges");
|
|
7
7
|
function lintSemverRangesCli(input, disk) {
|
|
8
8
|
(0, exit_if_invalid_1.exitIfInvalid)((0, lint_semver_ranges_1.lintSemverRanges)((0, get_context_1.getContext)(input, disk)));
|
|
9
9
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
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
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
3
|
if (k2 === undefined) k2 = k;
|
|
8
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -26,33 +22,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
22
|
__setModuleDefault(result, mod);
|
|
27
23
|
return result;
|
|
28
24
|
};
|
|
29
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
30
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
31
|
-
if (!m) return o;
|
|
32
|
-
var i = m.call(o), r, ar = [], e;
|
|
33
|
-
try {
|
|
34
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
35
|
-
}
|
|
36
|
-
catch (error) { e = { error: error }; }
|
|
37
|
-
finally {
|
|
38
|
-
try {
|
|
39
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
40
|
-
}
|
|
41
|
-
finally { if (e) throw e.error; }
|
|
42
|
-
}
|
|
43
|
-
return ar;
|
|
44
|
-
};
|
|
45
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
27
|
};
|
|
48
|
-
exports
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
29
|
exports.lintSemverRanges = void 0;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
31
|
+
const constants_1 = require("../constants");
|
|
32
|
+
const log = __importStar(require("../lib/log"));
|
|
53
33
|
function lintSemverRanges(ctx) {
|
|
54
|
-
|
|
55
|
-
ctx.semverGroups.forEach(
|
|
34
|
+
const hasUserGroups = ctx.semverGroups.length > 1;
|
|
35
|
+
ctx.semverGroups.forEach((semverGroup, i) => {
|
|
56
36
|
// Nothing to do if there are no mismatches
|
|
57
37
|
if (!semverGroup.hasMismatches())
|
|
58
38
|
return;
|
|
@@ -62,12 +42,11 @@ function lintSemverRanges(ctx) {
|
|
|
62
42
|
// Annotate each group
|
|
63
43
|
hasUserGroups && log.semverGroupHeader(semverGroup, i);
|
|
64
44
|
// Log each group which has mismatches
|
|
65
|
-
semverGroup.getMismatches().forEach(
|
|
66
|
-
var _b = __read(_a, 2), name = _b[0], mismatches = _b[1];
|
|
45
|
+
semverGroup.getMismatches().forEach(([name, mismatches]) => {
|
|
67
46
|
// Log the dependency name
|
|
68
47
|
log.invalid(name);
|
|
69
48
|
// Log each of the dependencies mismatches
|
|
70
|
-
mismatches.forEach(
|
|
49
|
+
mismatches.forEach((instance) => {
|
|
71
50
|
logSemverRangeMismatch(instance, semverGroup);
|
|
72
51
|
});
|
|
73
52
|
});
|
|
@@ -76,10 +55,9 @@ function lintSemverRanges(ctx) {
|
|
|
76
55
|
}
|
|
77
56
|
exports.lintSemverRanges = lintSemverRanges;
|
|
78
57
|
function logSemverRangeMismatch(instance, semverGroup) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
console.log((0, chalk_1
|
|
58
|
+
const path = instance.pathDef.path;
|
|
59
|
+
const shortPath = instance.packageJsonFile.shortPath;
|
|
60
|
+
const actual = instance.version;
|
|
61
|
+
const expected = semverGroup.getExpectedVersion(instance);
|
|
62
|
+
console.log((0, chalk_1.default) ` {red ${actual}} ${constants_1.ICON.rightArrow} {green ${expected}} {dim in ${path} of ${shortPath}}`);
|
|
84
63
|
}
|
|
85
|
-
var templateObject_1;
|