syncpack 8.4.10 → 8.5.14
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/README.md +1 -1
- package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +3 -0
- package/dist/bin-fix-mismatches/fix-mismatches-cli.js +10 -0
- package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -3
- package/dist/bin-fix-mismatches/fix-mismatches.js +19 -58
- package/dist/bin-fix-mismatches/index.js +3 -4
- package/dist/bin-format/format-cli.d.ts +3 -0
- package/dist/bin-format/format-cli.js +10 -0
- package/dist/bin-format/format.d.ts +2 -3
- package/dist/bin-format/format.js +10 -11
- package/dist/bin-format/index.js +3 -4
- package/dist/bin-lint-semver-ranges/index.js +3 -4
- package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.d.ts +3 -0
- package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +10 -0
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -3
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +73 -26
- package/dist/bin-list/index.js +3 -4
- package/dist/bin-list/list-cli.d.ts +3 -0
- package/dist/bin-list/list-cli.js +10 -0
- package/dist/bin-list/list.d.ts +2 -3
- package/dist/bin-list/list.js +60 -35
- package/dist/bin-list-mismatches/index.js +3 -4
- package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +3 -0
- package/dist/bin-list-mismatches/list-mismatches-cli.js +10 -0
- package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -3
- package/dist/bin-list-mismatches/list-mismatches.js +75 -73
- package/dist/bin-set-semver-ranges/index.js +3 -4
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +3 -0
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +10 -0
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -3
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +5 -28
- package/dist/constants.d.ts +27 -21
- package/dist/constants.js +28 -32
- package/dist/lib/disk.d.ts +3 -3
- package/dist/lib/disk.js +0 -1
- package/dist/lib/exit-if-invalid.d.ts +2 -0
- package/dist/lib/exit-if-invalid.js +10 -0
- package/dist/lib/get-context/get-all-instances.d.ts +3 -0
- package/dist/lib/get-context/get-all-instances.js +8 -0
- package/dist/lib/get-context/get-config/config.d.ts +151 -0
- package/dist/{types/index.js → lib/get-context/get-config/config.js} +0 -0
- package/dist/lib/get-context/get-config/index.d.ts +8 -0
- package/dist/lib/{get-input/get-config.js → get-context/get-config/index.js} +35 -10
- package/dist/lib/get-context/get-config/internal-config.d.ts +24 -0
- package/dist/{types/semver-group.js → lib/get-context/get-config/internal-config.js} +0 -0
- package/dist/lib/get-context/get-groups/get-semver-groups.d.ts +4 -0
- package/dist/lib/get-context/get-groups/get-semver-groups.js +45 -0
- package/dist/lib/get-context/get-groups/get-version-groups.d.ts +4 -0
- package/dist/lib/get-context/get-groups/get-version-groups.js +71 -0
- package/dist/lib/get-context/get-groups/semver-group/index.d.ts +30 -0
- package/dist/lib/get-context/get-groups/semver-group/index.js +33 -0
- package/dist/lib/get-context/get-groups/version-group/index.d.ts +30 -0
- package/dist/lib/get-context/get-groups/version-group/index.js +23 -0
- package/dist/{bin-fix-mismatches/get-expected-version → lib/get-context/get-groups/version-group/instance-group}/get-highest-version.d.ts +0 -0
- package/dist/{bin-fix-mismatches/get-expected-version → lib/get-context/get-groups/version-group/instance-group}/get-highest-version.js +10 -10
- package/dist/lib/get-context/get-groups/version-group/instance-group/index.d.ts +32 -0
- package/dist/lib/get-context/get-groups/version-group/instance-group/index.js +79 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-file-paths.d.ts +3 -3
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-file-paths.js +7 -2
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-lerna-patterns.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-lerna-patterns.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-pnpm-patterns.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-pnpm-patterns.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-yarn-patterns.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-yarn-patterns.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/index.d.ts +3 -3
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/index.js +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/props.d.ts +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/props.js +0 -0
- package/dist/lib/get-context/get-package-json-files/get-patterns/read-json-safe.d.ts +11 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/read-json-safe.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/read-yaml-safe.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/read-yaml-safe.js +0 -0
- package/dist/lib/get-context/get-package-json-files/index.d.ts +5 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/index.js +8 -8
- package/dist/lib/get-context/get-package-json-files/package-json-file/index.d.ts +50 -0
- package/dist/lib/get-context/get-package-json-files/package-json-file/index.js +95 -0
- package/dist/lib/get-context/get-package-json-files/package-json-file/instance.d.ts +25 -0
- package/dist/lib/get-context/get-package-json-files/package-json-file/instance.js +46 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/tap.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/tap.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/try-catch.d.ts +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/try-catch.js +0 -0
- package/dist/lib/get-context/index.d.ts +22 -0
- package/dist/lib/get-context/index.js +38 -0
- package/dist/lib/is-semver.d.ts +1 -1
- package/dist/lib/is-semver.js +9 -9
- package/dist/lib/log.d.ts +6 -0
- package/dist/lib/log.js +40 -1
- package/dist/lib/newlines.d.ts +6 -0
- package/dist/lib/newlines.js +24 -0
- package/dist/lib/set-semver-range.d.ts +1 -1
- package/dist/lib/set-semver-range.js +1 -1
- package/dist/lib/write-if-changed.d.ts +2 -0
- package/dist/lib/write-if-changed.js +40 -0
- package/dist/option.d.ts +2 -1
- package/dist/option.js +4 -2
- package/package.json +21 -21
- package/dist/bin-fix-mismatches/get-expected-version/get-pinned-version.d.ts +0 -2
- package/dist/bin-fix-mismatches/get-expected-version/get-pinned-version.js +0 -7
- package/dist/bin-fix-mismatches/get-expected-version/get-workspace-version.d.ts +0 -6
- package/dist/bin-fix-mismatches/get-expected-version/get-workspace-version.js +0 -17
- package/dist/bin-fix-mismatches/get-expected-version/index.d.ts +0 -3
- package/dist/bin-fix-mismatches/get-expected-version/index.js +0 -27
- package/dist/bin-lint-semver-ranges/list-semver-group-mismatches.d.ts +0 -2
- package/dist/bin-lint-semver-ranges/list-semver-group-mismatches.js +0 -12
- package/dist/bin-list/list-version-groups.d.ts +0 -10
- package/dist/bin-list/list-version-groups.js +0 -52
- package/dist/lib/collect.d.ts +0 -1
- package/dist/lib/collect.js +0 -7
- package/dist/lib/get-input/get-config.d.ts +0 -12
- package/dist/lib/get-input/get-instances.d.ts +0 -29
- package/dist/lib/get-input/get-instances.js +0 -172
- package/dist/lib/get-input/get-wrappers/get-patterns/read-json-safe.d.ts +0 -4
- package/dist/lib/get-input/get-wrappers/index.d.ts +0 -38
- package/dist/lib/get-input/get-wrappers/readonly.d.ts +0 -4
- package/dist/lib/get-input/get-wrappers/readonly.js +0 -10
- package/dist/lib/get-input/index.d.ts +0 -20
- package/dist/lib/get-input/index.js +0 -32
- package/dist/lib/group-by.d.ts +0 -1
- package/dist/lib/group-by.js +0 -11
- package/dist/lib/write-if-changed/index.d.ts +0 -10
- package/dist/lib/write-if-changed/index.js +0 -25
- package/dist/lib/write-if-changed/set-newlines.d.ts +0 -4
- package/dist/lib/write-if-changed/set-newlines.js +0 -24
- package/dist/types/index.d.ts +0 -77
- package/dist/types/semver-group.d.ts +0 -30
- package/dist/types/version-group.d.ts +0 -35
- package/dist/types/version-group.js +0 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
[](https://www.npmjs.com/package/syncpack)
|
|
7
7
|
[](https://www.npmjs.com/package/syncpack)
|
|
8
|
-
[](https://github.com/JamieMason/syncpack/actions)
|
|
8
|
+
[](https://github.com/JamieMason/syncpack/actions)
|
|
9
9
|
[](https://codeclimate.com/github/JamieMason/syncpack/maintainability)
|
|
10
10
|
|
|
11
11
|
## 🌩 Installation
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.fixMismatchesCli = void 0;
|
|
4
|
+
var get_context_1 = require("../lib/get-context");
|
|
5
|
+
var write_if_changed_1 = require("../lib/write-if-changed");
|
|
6
|
+
var fix_mismatches_1 = require("./fix-mismatches");
|
|
7
|
+
function fixMismatchesCli(input, disk) {
|
|
8
|
+
(0, write_if_changed_1.writeIfChanged)((0, fix_mismatches_1.fixMismatches)((0, get_context_1.getContext)(input, disk)));
|
|
9
|
+
}
|
|
10
|
+
exports.fixMismatchesCli = fixMismatchesCli;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function fixMismatches(input: ProgramInput, disk: Disk): void;
|
|
1
|
+
import type { Context } from '../lib/get-context';
|
|
2
|
+
export declare function fixMismatches(ctx: Context): Context;
|
|
@@ -1,69 +1,30 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
2
|
exports.__esModule = true;
|
|
10
3
|
exports.fixMismatches = void 0;
|
|
11
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
12
4
|
var expect_more_1 = require("expect-more");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (isVersionGroup) {
|
|
26
|
-
console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim = Version Group ", " ", "}"], ["{dim = Version Group ", " ", "}"])), i, '='.repeat(63)));
|
|
27
|
-
}
|
|
28
|
-
groups.forEach(function (_a) {
|
|
29
|
-
var hasMismatches = _a.hasMismatches, instances = _a.instances, isIgnored = _a.isIgnored, name = _a.name;
|
|
30
|
-
if (hasMismatches && !isIgnored) {
|
|
31
|
-
var nextVersion_1 = (0, get_expected_version_1.getExpectedVersion)(name, versionGroup, input);
|
|
32
|
-
instances.forEach(function (_a) {
|
|
33
|
-
var dependencyType = _a.dependencyType, version = _a.version, wrapper = _a.wrapper;
|
|
34
|
-
var root = wrapper.contents;
|
|
35
|
-
if (version !== nextVersion_1) {
|
|
36
|
-
if (dependencyType === 'pnpmOverrides') {
|
|
37
|
-
root.pnpm.overrides[name] = nextVersion_1;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
root[dependencyType][name] = nextVersion_1;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
input.wrappers.forEach(function (wrapper) {
|
|
48
|
-
removeEmptyIndexes(wrapper);
|
|
49
|
-
(0, write_if_changed_1.writeIfChanged)(disk, {
|
|
50
|
-
contents: wrapper.contents,
|
|
51
|
-
filePath: wrapper.filePath,
|
|
52
|
-
indent: input.indent,
|
|
53
|
-
json: wrapper.json
|
|
5
|
+
function fixMismatches(ctx) {
|
|
6
|
+
ctx.versionGroups.reverse().forEach(function (versionGroup) {
|
|
7
|
+
var invalidGroups = versionGroup.getInvalidInstanceGroups();
|
|
8
|
+
// Nothing to do if there are no mismatches
|
|
9
|
+
if (invalidGroups.length === 0)
|
|
10
|
+
return;
|
|
11
|
+
// Set the correct version on each instance.
|
|
12
|
+
invalidGroups.forEach(function (instanceGroup) {
|
|
13
|
+
var nextVersion = instanceGroup.getExpectedVersion();
|
|
14
|
+
instanceGroup.instances.forEach(function (instance) {
|
|
15
|
+
return instance.setVersion(nextVersion);
|
|
16
|
+
});
|
|
54
17
|
});
|
|
55
18
|
});
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
input.dependencyTypes.forEach(function (dependencyType) {
|
|
61
|
-
var deps = wrapper.contents[dependencyType];
|
|
19
|
+
/** Remove eg `{"dependencies": {}, "devDependencies": {}}` */
|
|
20
|
+
ctx.packageJsonFiles.forEach(function (packageJsonFile) {
|
|
21
|
+
ctx.dependencyTypes.forEach(function (dependencyType) {
|
|
22
|
+
var deps = packageJsonFile.contents[dependencyType];
|
|
62
23
|
if (deps && Object.values(deps).every(expect_more_1.isUndefined)) {
|
|
63
|
-
delete
|
|
24
|
+
delete packageJsonFile.contents[dependencyType];
|
|
64
25
|
}
|
|
65
26
|
});
|
|
66
|
-
}
|
|
27
|
+
});
|
|
28
|
+
return ctx;
|
|
67
29
|
}
|
|
68
30
|
exports.fixMismatches = fixMismatches;
|
|
69
|
-
var templateObject_1;
|
|
@@ -37,9 +37,8 @@ exports.__esModule = true;
|
|
|
37
37
|
var chalk_1 = __importDefault(require("chalk"));
|
|
38
38
|
var commander_1 = require("commander");
|
|
39
39
|
var disk_1 = require("../lib/disk");
|
|
40
|
-
var get_input_1 = require("../lib/get-input");
|
|
41
40
|
var option_1 = require("../option");
|
|
42
|
-
var
|
|
41
|
+
var fix_mismatches_cli_1 = require("./fix-mismatches-cli");
|
|
43
42
|
commander_1.program.description((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Ensure that multiple packages requiring the same dependency define the same\n version, so that every package requires eg. {yellow react@16.4.2}, instead of a\n combination of {yellow react@16.4.2}, {yellow react@0.15.9}, and {yellow react@16.0.0}."], ["\n Ensure that multiple packages requiring the same dependency define the same\n version, so that every package requires eg. {yellow react@16.4.2}, instead of a\n combination of {yellow react@16.4.2}, {yellow react@0.15.9}, and {yellow react@16.0.0}."]))).replace(/^\n/, ''));
|
|
44
43
|
commander_1.program.on('--help', function () {
|
|
45
44
|
console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack fix-mismatches\n {dim # uses packages defined by --source when provided}\n syncpack fix-mismatches --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack fix-mismatches --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack fix-mismatches --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack fix-mismatches --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack fix-mismatches --dev --peer\n {dim # indent package.json with 4 spaces instead of 2}\n syncpack fix-mismatches --indent {yellow \" \"}\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"], ["\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack fix-mismatches\n {dim # uses packages defined by --source when provided}\n syncpack fix-mismatches --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack fix-mismatches --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack fix-mismatches --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack fix-mismatches --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack fix-mismatches --dev --peer\n {dim # indent package.json with 4 spaces instead of 2}\n syncpack fix-mismatches --indent {yellow \" \"}\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"]))));
|
|
@@ -55,7 +54,7 @@ commander_1.program.on('--help', function () {
|
|
|
55
54
|
.option.apply(_c, __spreadArray([], __read(option_1.option.overrides), false)))
|
|
56
55
|
.option.apply(_b, __spreadArray([], __read(option_1.option.workspace), false)))
|
|
57
56
|
.option.apply(_a, __spreadArray([], __read(option_1.option.indent), false)).parse(process.argv);
|
|
58
|
-
(0,
|
|
57
|
+
(0, fix_mismatches_cli_1.fixMismatchesCli)({
|
|
59
58
|
configPath: commander_1.program.opts().config,
|
|
60
59
|
dev: commander_1.program.opts().dev,
|
|
61
60
|
filter: commander_1.program.opts().filter,
|
|
@@ -67,5 +66,5 @@ commander_1.program.on('--help', function () {
|
|
|
67
66
|
resolutions: commander_1.program.opts().resolutions,
|
|
68
67
|
source: commander_1.program.opts().source,
|
|
69
68
|
workspace: commander_1.program.opts().workspace
|
|
70
|
-
}
|
|
69
|
+
}, disk_1.disk);
|
|
71
70
|
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.formatCli = void 0;
|
|
4
|
+
var get_context_1 = require("../lib/get-context");
|
|
5
|
+
var write_if_changed_1 = require("../lib/write-if-changed");
|
|
6
|
+
var format_1 = require("./format");
|
|
7
|
+
function formatCli(input, disk) {
|
|
8
|
+
(0, write_if_changed_1.writeIfChanged)((0, format_1.format)((0, get_context_1.getContext)(input, disk)));
|
|
9
|
+
}
|
|
10
|
+
exports.formatCli = formatCli;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function format(input: ProgramInput, disk: Disk): void;
|
|
1
|
+
import type { Context } from '../lib/get-context';
|
|
2
|
+
export declare function format(ctx: Context): Context;
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.format = void 0;
|
|
4
4
|
var expect_more_1 = require("expect-more");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
var contents = _a.contents, filePath = _a.filePath, json = _a.json;
|
|
5
|
+
function format(ctx) {
|
|
6
|
+
var sortAz = ctx.sortAz, sortFirst = ctx.sortFirst, packageJsonFiles = ctx.packageJsonFiles;
|
|
7
|
+
packageJsonFiles.forEach(function (packageJsonFile) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
var contents = packageJsonFile.contents;
|
|
11
10
|
var sortedKeys = Object.keys(contents).sort();
|
|
12
11
|
var keys = new Set(sortFirst.concat(sortedKeys));
|
|
13
12
|
var optionalChaining = contents;
|
|
14
|
-
var bugsUrl = (
|
|
15
|
-
var repoUrl = (
|
|
16
|
-
var repoDir = (
|
|
13
|
+
var bugsUrl = (_a = optionalChaining === null || optionalChaining === void 0 ? void 0 : optionalChaining.bugs) === null || _a === void 0 ? void 0 : _a.url;
|
|
14
|
+
var repoUrl = (_b = optionalChaining === null || optionalChaining === void 0 ? void 0 : optionalChaining.repository) === null || _b === void 0 ? void 0 : _b.url;
|
|
15
|
+
var repoDir = (_c = optionalChaining === null || optionalChaining === void 0 ? void 0 : optionalChaining.repository) === null || _c === void 0 ? void 0 : _c.directory;
|
|
17
16
|
if (bugsUrl) {
|
|
18
17
|
contents.bugs = bugsUrl;
|
|
19
18
|
}
|
|
@@ -24,8 +23,8 @@ function format(input, disk) {
|
|
|
24
23
|
}
|
|
25
24
|
sortAz.forEach(function (key) { return sortAlphabetically(contents[key]); });
|
|
26
25
|
sortObject(keys, contents);
|
|
27
|
-
(0, write_if_changed_1.writeIfChanged)(disk, { contents: contents, filePath: filePath, indent: indent, json: json });
|
|
28
26
|
});
|
|
27
|
+
return ctx;
|
|
29
28
|
function sortObject(sortedKeys, obj) {
|
|
30
29
|
sortedKeys.forEach(function (key) {
|
|
31
30
|
var value = obj[key];
|
|
@@ -37,7 +36,7 @@ function format(input, disk) {
|
|
|
37
36
|
if ((0, expect_more_1.isArray)(value)) {
|
|
38
37
|
value.sort();
|
|
39
38
|
}
|
|
40
|
-
else if (
|
|
39
|
+
else if ((0, expect_more_1.isObject)(value)) {
|
|
41
40
|
sortObject(Object.keys(value).sort(), value);
|
|
42
41
|
}
|
|
43
42
|
}
|
package/dist/bin-format/index.js
CHANGED
|
@@ -37,9 +37,8 @@ exports.__esModule = true;
|
|
|
37
37
|
var chalk_1 = __importDefault(require("chalk"));
|
|
38
38
|
var commander_1 = require("commander");
|
|
39
39
|
var disk_1 = require("../lib/disk");
|
|
40
|
-
var get_input_1 = require("../lib/get-input");
|
|
41
40
|
var option_1 = require("../option");
|
|
42
|
-
var
|
|
41
|
+
var format_cli_1 = require("./format-cli");
|
|
43
42
|
commander_1.program.description((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Organise package.json files according to a conventional format, where fields\n appear in a predictable order and nested fields are ordered alphabetically.\n Shorthand properties are used where available, such as the {yellow repository} and\n {yellow bugs} fields."], ["\n Organise package.json files according to a conventional format, where fields\n appear in a predictable order and nested fields are ordered alphabetically.\n Shorthand properties are used where available, such as the {yellow repository} and\n {yellow bugs} fields."]))).replace(/^\n/, ''));
|
|
44
43
|
commander_1.program.on('--help', function () {
|
|
45
44
|
console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack format\n {dim # uses packages defined by --source when provided}\n syncpack format --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack format --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # indent package.json with 4 spaces instead of 2}\n syncpack format --indent {yellow \" \"}\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"], ["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack format\n {dim # uses packages defined by --source when provided}\n syncpack format --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack format --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # indent package.json with 4 spaces instead of 2}\n syncpack format --indent {yellow \" \"}\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"]))));
|
|
@@ -48,9 +47,9 @@ commander_1.program.on('--help', function () {
|
|
|
48
47
|
.option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
|
|
49
48
|
.option.apply(_b, __spreadArray([], __read(option_1.option.config), false)))
|
|
50
49
|
.option.apply(_a, __spreadArray([], __read(option_1.option.indent), false)).parse(process.argv);
|
|
51
|
-
(0,
|
|
50
|
+
(0, format_cli_1.formatCli)({
|
|
52
51
|
configPath: commander_1.program.opts().config,
|
|
53
52
|
indent: commander_1.program.opts().indent,
|
|
54
53
|
source: commander_1.program.opts().source
|
|
55
|
-
}
|
|
54
|
+
}, disk_1.disk);
|
|
56
55
|
var templateObject_1, templateObject_2;
|
|
@@ -37,9 +37,8 @@ exports.__esModule = true;
|
|
|
37
37
|
var chalk_1 = __importDefault(require("chalk"));
|
|
38
38
|
var commander_1 = require("commander");
|
|
39
39
|
var disk_1 = require("../lib/disk");
|
|
40
|
-
var get_input_1 = require("../lib/get-input");
|
|
41
40
|
var option_1 = require("../option");
|
|
42
|
-
var
|
|
41
|
+
var lint_semver_ranges_cli_1 = require("./lint-semver-ranges-cli");
|
|
43
42
|
commander_1.program.description((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Check dependency versions within {yellow dependencies}, {yellow devDependencies},\n {yellow peerDependencies}, {yellow overrides}, and {yellow resolutions} follow a consistent format."], ["\n Check dependency versions within {yellow dependencies}, {yellow devDependencies},\n {yellow peerDependencies}, {yellow overrides}, and {yellow resolutions} follow a consistent format."]))).replace(/^\n/, ''));
|
|
44
43
|
commander_1.program.on('--help', function () {
|
|
45
44
|
console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack lint-semver-ranges\n {dim # uses packages defined by --source when provided}\n syncpack lint-semver-ranges --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack lint-semver-ranges --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack lint-semver-ranges --filter {yellow \"typescript|tslint\"}\n {dim # use ~ range instead of default \"\"}\n syncpack lint-semver-ranges --semver-range ~\n {dim # use ~ range in \"devDependencies\"}\n syncpack lint-semver-ranges --dev --semver-range ~\n {dim # use ~ range in \"devDependencies\" and \"peerDependencies\"}\n syncpack lint-semver-ranges --dev --peer --semver-range ~\n\nSupported Ranges:\n < {dim <1.4.2}\n <= {dim <=1.4.2}\n \"\" {dim 1.4.2}\n ~ {dim ~1.4.2}\n ^ {dim ^1.4.2}\n >= {dim >=1.4.2}\n > {dim >1.4.2}\n * {dim *}\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"], ["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack lint-semver-ranges\n {dim # uses packages defined by --source when provided}\n syncpack lint-semver-ranges --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack lint-semver-ranges --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack lint-semver-ranges --filter {yellow \"typescript|tslint\"}\n {dim # use ~ range instead of default \"\"}\n syncpack lint-semver-ranges --semver-range ~\n {dim # use ~ range in \"devDependencies\"}\n syncpack lint-semver-ranges --dev --semver-range ~\n {dim # use ~ range in \"devDependencies\" and \"peerDependencies\"}\n syncpack lint-semver-ranges --dev --peer --semver-range ~\n\nSupported Ranges:\n < {dim <1.4.2}\n <= {dim <=1.4.2}\n \"\" {dim 1.4.2}\n ~ {dim ~1.4.2}\n ^ {dim ^1.4.2}\n >= {dim >=1.4.2}\n > {dim >1.4.2}\n * {dim *}\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"]))));
|
|
@@ -55,7 +54,7 @@ commander_1.program.on('--help', function () {
|
|
|
55
54
|
.option.apply(_c, __spreadArray([], __read(option_1.option.resolutions), false)))
|
|
56
55
|
.option.apply(_b, __spreadArray([], __read(option_1.option.overrides), false)))
|
|
57
56
|
.option.apply(_a, __spreadArray([], __read(option_1.option.workspace), false)).parse(process.argv);
|
|
58
|
-
(0,
|
|
57
|
+
(0, lint_semver_ranges_cli_1.lintSemverRangesCli)({
|
|
59
58
|
configPath: commander_1.program.opts().config,
|
|
60
59
|
dev: commander_1.program.opts().dev,
|
|
61
60
|
filter: commander_1.program.opts().filter,
|
|
@@ -67,5 +66,5 @@ commander_1.program.on('--help', function () {
|
|
|
67
66
|
semverRange: commander_1.program.opts().semverRange,
|
|
68
67
|
source: commander_1.program.opts().source,
|
|
69
68
|
workspace: commander_1.program.opts().workspace
|
|
70
|
-
}
|
|
69
|
+
}, disk_1.disk);
|
|
71
70
|
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.lintSemverRangesCli = void 0;
|
|
4
|
+
var exit_if_invalid_1 = require("../lib/exit-if-invalid");
|
|
5
|
+
var get_context_1 = require("../lib/get-context");
|
|
6
|
+
var lint_semver_ranges_1 = require("./lint-semver-ranges");
|
|
7
|
+
function lintSemverRangesCli(input, disk) {
|
|
8
|
+
(0, exit_if_invalid_1.exitIfInvalid)((0, lint_semver_ranges_1.lintSemverRanges)((0, get_context_1.getContext)(input, disk)));
|
|
9
|
+
}
|
|
10
|
+
exports.lintSemverRangesCli = lintSemverRangesCli;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function lintSemverRanges(input: ProgramInput, disk: Disk): void;
|
|
1
|
+
import type { Context } from '../lib/get-context';
|
|
2
|
+
export declare function lintSemverRanges(ctx: Context): Context;
|
|
@@ -3,40 +3,87 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
4
|
return cooked;
|
|
5
5
|
};
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
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
|
+
};
|
|
6
45
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
47
|
};
|
|
9
48
|
exports.__esModule = true;
|
|
10
49
|
exports.lintSemverRanges = void 0;
|
|
11
50
|
var chalk_1 = __importDefault(require("chalk"));
|
|
51
|
+
var constants_1 = require("../constants");
|
|
52
|
+
var log = __importStar(require("../lib/log"));
|
|
12
53
|
var set_semver_range_1 = require("../lib/set-semver-range");
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
54
|
+
function lintSemverRanges(ctx) {
|
|
55
|
+
ctx.semverGroups.reverse().forEach(function (semverGroup, i) {
|
|
56
|
+
Object.entries(semverGroup.instancesByName).forEach(function (_a) {
|
|
57
|
+
var _b = __read(_a, 2), name = _b[0], instances = _b[1];
|
|
58
|
+
var range = semverGroup.range;
|
|
59
|
+
var hasMismatches = instances.some(function (obj) { return !obj.hasRange(range); });
|
|
60
|
+
// Nothing to do if there are no mismatches
|
|
61
|
+
if (!hasMismatches)
|
|
62
|
+
return;
|
|
63
|
+
// Annotate user-defined version groups
|
|
64
|
+
if (!semverGroup.isDefault)
|
|
65
|
+
log.semverGroupHeader(i);
|
|
66
|
+
// Record that this project has mismatches, so that eg. the CLI can exit
|
|
67
|
+
// with the correct status code.
|
|
68
|
+
ctx.isInvalid = true;
|
|
69
|
+
// Log the dependency name
|
|
70
|
+
log.invalid(name);
|
|
71
|
+
// Log each of the dependencies mismatches
|
|
72
|
+
instances.forEach(function (instance) {
|
|
73
|
+
if (!instance.hasRange(range)) {
|
|
74
|
+
logSemverRangeMismatch(instance, semverGroup);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
32
77
|
});
|
|
33
|
-
if (mismatches.length > 0) {
|
|
34
|
-
isInvalid = true;
|
|
35
|
-
}
|
|
36
78
|
});
|
|
37
|
-
|
|
38
|
-
disk.process.exit(1);
|
|
39
|
-
}
|
|
79
|
+
return ctx;
|
|
40
80
|
}
|
|
41
81
|
exports.lintSemverRanges = lintSemverRanges;
|
|
42
|
-
|
|
82
|
+
function logSemverRangeMismatch(instance, semverGroup) {
|
|
83
|
+
var type = instance.dependencyType;
|
|
84
|
+
var shortPath = instance.packageJsonFile.shortPath;
|
|
85
|
+
var actual = instance.version;
|
|
86
|
+
var expected = (0, set_semver_range_1.setSemverRange)(semverGroup.range, actual);
|
|
87
|
+
console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject([" {red ", "} ", " {green ", "} {dim in ", " of ", "}"], [" {red ", "} ", " {green ", "} {dim in ", " of ", "}"])), actual, constants_1.ICON.rightArrow, expected, type, shortPath));
|
|
88
|
+
}
|
|
89
|
+
var templateObject_1;
|
package/dist/bin-list/index.js
CHANGED
|
@@ -37,9 +37,8 @@ exports.__esModule = true;
|
|
|
37
37
|
var chalk_1 = __importDefault(require("chalk"));
|
|
38
38
|
var commander_1 = require("commander");
|
|
39
39
|
var disk_1 = require("../lib/disk");
|
|
40
|
-
var get_input_1 = require("../lib/get-input");
|
|
41
40
|
var option_1 = require("../option");
|
|
42
|
-
var
|
|
41
|
+
var list_cli_1 = require("./list-cli");
|
|
43
42
|
commander_1.program.description(' List all dependencies required by your packages.');
|
|
44
43
|
commander_1.program.on('--help', function () {
|
|
45
44
|
console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack list\n {dim # uses packages defined by --source when provided}\n syncpack list --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack list --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack list --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack list --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list --dev --peer\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"], ["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack list\n {dim # uses packages defined by --source when provided}\n syncpack list --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack list --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack list --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack list --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list --dev --peer\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"]))));
|
|
@@ -54,7 +53,7 @@ commander_1.program.on('--help', function () {
|
|
|
54
53
|
.option.apply(_c, __spreadArray([], __read(option_1.option.resolutions), false)))
|
|
55
54
|
.option.apply(_b, __spreadArray([], __read(option_1.option.overrides), false)))
|
|
56
55
|
.option.apply(_a, __spreadArray([], __read(option_1.option.workspace), false)).parse(process.argv);
|
|
57
|
-
(0,
|
|
56
|
+
(0, list_cli_1.listCli)({
|
|
58
57
|
configPath: commander_1.program.opts().config,
|
|
59
58
|
dev: commander_1.program.opts().dev,
|
|
60
59
|
filter: commander_1.program.opts().filter,
|
|
@@ -65,5 +64,5 @@ commander_1.program.on('--help', function () {
|
|
|
65
64
|
resolutions: commander_1.program.opts().resolutions,
|
|
66
65
|
source: commander_1.program.opts().source,
|
|
67
66
|
workspace: commander_1.program.opts().workspace
|
|
68
|
-
}
|
|
67
|
+
}, disk_1.disk);
|
|
69
68
|
var templateObject_1;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.listCli = void 0;
|
|
4
|
+
var exit_if_invalid_1 = require("../lib/exit-if-invalid");
|
|
5
|
+
var get_context_1 = require("../lib/get-context");
|
|
6
|
+
var list_1 = require("./list");
|
|
7
|
+
function listCli(input, disk) {
|
|
8
|
+
(0, exit_if_invalid_1.exitIfInvalid)((0, list_1.list)((0, get_context_1.getContext)(input, disk)));
|
|
9
|
+
}
|
|
10
|
+
exports.listCli = listCli;
|
package/dist/bin-list/list.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function list(input: ProgramInput, disk: Disk): void;
|
|
1
|
+
import type { Context } from '../lib/get-context';
|
|
2
|
+
export declare function list(ctx: Context): Context;
|
package/dist/bin-list/list.js
CHANGED
|
@@ -3,50 +3,75 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
4
|
return cooked;
|
|
5
5
|
};
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
6
29
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
30
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
31
|
};
|
|
9
32
|
exports.__esModule = true;
|
|
10
33
|
exports.list = void 0;
|
|
11
34
|
var chalk_1 = __importDefault(require("chalk"));
|
|
12
|
-
var get_expected_version_1 = require("../bin-fix-mismatches/get-expected-version");
|
|
13
35
|
var constants_1 = require("../constants");
|
|
14
|
-
var
|
|
15
|
-
function list(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
? (0, chalk_1["default"])(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{dim ", " ", "} is ignored in this version group"], ["{dim ", " ", "} is ignored in this version group"])), constants_1.ICON.skip, name) : hasMismatches
|
|
35
|
-
? (0, chalk_1["default"])(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{red ", " ", "} ", ""], ["{red ", " ", "} ", ""])), constants_1.ICON.cross, name, versionList
|
|
36
|
-
.map(function (version) {
|
|
37
|
-
return version === expected
|
|
38
|
-
? chalk_1["default"].green(version)
|
|
39
|
-
: chalk_1["default"].red(version);
|
|
40
|
-
})
|
|
41
|
-
.join(chalk_1["default"].dim(', '))) : (0, chalk_1["default"])(templateObject_5 || (templateObject_5 = __makeTemplateObject(["{dim -} {white ", "} {dim ", "}"], ["{dim -} {white ", "} {dim ", "}"])), name, versionList));
|
|
36
|
+
var log = __importStar(require("../lib/log"));
|
|
37
|
+
function list(ctx) {
|
|
38
|
+
ctx.versionGroups.reverse().forEach(function (versionGroup, i) {
|
|
39
|
+
// Annotate user-defined version groups
|
|
40
|
+
if (!versionGroup.isDefault)
|
|
41
|
+
log.versionGroupHeader(i);
|
|
42
|
+
versionGroup.instanceGroups.forEach(function (instanceGroup) {
|
|
43
|
+
var expected = instanceGroup.getExpectedVersion();
|
|
44
|
+
var uniques = instanceGroup.uniques;
|
|
45
|
+
// Record that this project has mismatches, so that eg. the CLI can exit
|
|
46
|
+
// with the correct status code.
|
|
47
|
+
if (instanceGroup.isInvalid)
|
|
48
|
+
ctx.isInvalid = true;
|
|
49
|
+
instanceGroup.versionGroup.isBanned
|
|
50
|
+
? logBanned(instanceGroup)
|
|
51
|
+
: instanceGroup.versionGroup.isIgnored
|
|
52
|
+
? logIgnored(instanceGroup)
|
|
53
|
+
: instanceGroup.hasMismatches
|
|
54
|
+
? logVersionMismatch(instanceGroup, uniques, expected)
|
|
55
|
+
: logVersionMatch(instanceGroup, uniques);
|
|
42
56
|
});
|
|
43
|
-
if (groups.some(function (group) { return !group.isIgnored && group.hasMismatches; })) {
|
|
44
|
-
isInvalid = true;
|
|
45
|
-
}
|
|
46
57
|
});
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
return ctx;
|
|
59
|
+
function logVersionMatch(instanceGroup, uniques) {
|
|
60
|
+
console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim -} {white ", "} {dim ", "}"], ["{dim -} {white ", "} {dim ", "}"])), instanceGroup.name, uniques));
|
|
61
|
+
}
|
|
62
|
+
function logVersionMismatch(instanceGroup, uniques, expected) {
|
|
63
|
+
console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{red ", " ", "} ", ""], ["{red ", " ", "} ", ""])), constants_1.ICON.cross, instanceGroup.name, uniques
|
|
64
|
+
.map(function (version) {
|
|
65
|
+
return version === expected ? chalk_1["default"].green(version) : chalk_1["default"].red(version);
|
|
66
|
+
})
|
|
67
|
+
.join(chalk_1["default"].dim(', '))));
|
|
68
|
+
}
|
|
69
|
+
function logIgnored(instanceGroup) {
|
|
70
|
+
console.log((0, chalk_1["default"])(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{dim ", " ", "} is ignored in this version group"], ["{dim ", " ", "} is ignored in this version group"])), constants_1.ICON.skip, instanceGroup.name));
|
|
71
|
+
}
|
|
72
|
+
function logBanned(instanceGroup) {
|
|
73
|
+
console.log((0, chalk_1["default"])(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{red ", " ", "} {dim.red is banned in this version group}"], ["{red ", " ", "} {dim.red is banned in this version group}"])), constants_1.ICON.cross, instanceGroup.name));
|
|
49
74
|
}
|
|
50
75
|
}
|
|
51
76
|
exports.list = list;
|
|
52
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4
|
|
77
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|