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.
Files changed (100) hide show
  1. package/dist/bin-fix-mismatches/fix-mismatches-cli.js +4 -4
  2. package/dist/bin-fix-mismatches/fix-mismatches.js +17 -15
  3. package/dist/bin-fix-mismatches/index.js +50 -48
  4. package/dist/bin-format/format-cli.js +4 -4
  5. package/dist/bin-format/format.js +20 -18
  6. package/dist/bin-format/index.js +43 -46
  7. package/dist/bin-lint-semver-ranges/index.js +59 -48
  8. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +4 -4
  9. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +13 -35
  10. package/dist/bin-list/index.js +43 -46
  11. package/dist/bin-list/list-cli.js +4 -4
  12. package/dist/bin-list/list.js +26 -29
  13. package/dist/bin-list-mismatches/index.js +46 -47
  14. package/dist/bin-list-mismatches/list-mismatches-cli.js +4 -4
  15. package/dist/bin-list-mismatches/list-mismatches.js +55 -40
  16. package/dist/bin-set-semver-ranges/index.js +62 -49
  17. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +4 -4
  18. package/dist/bin-set-semver-ranges/set-semver-ranges.js +4 -4
  19. package/dist/bin.js +8 -8
  20. package/dist/constants.d.ts +2 -1
  21. package/dist/constants.js +6 -5
  22. package/dist/get-context/$R.js +14 -36
  23. package/dist/get-context/get-config/get-core-types.js +11 -41
  24. package/dist/get-context/get-config/get-custom-types.js +7 -19
  25. package/dist/get-context/get-config/get-enabled-types.js +9 -11
  26. package/dist/get-context/get-config/index.d.ts +3 -1
  27. package/dist/get-context/get-config/index.js +37 -61
  28. package/dist/get-context/get-config/path-strategy/index.js +8 -8
  29. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.js +6 -6
  30. package/dist/get-context/get-config/path-strategy/name-and-version-props.js +23 -49
  31. package/dist/get-context/get-config/path-strategy/name-and-version-string.js +26 -42
  32. package/dist/get-context/get-config/path-strategy/types.js +1 -1
  33. package/dist/get-context/get-config/path-strategy/version-string.js +25 -41
  34. package/dist/get-context/get-config/path-strategy/versions-by-name.js +14 -30
  35. package/dist/get-context/get-config/schema/base-group.d.ts +2 -2
  36. package/dist/get-context/get-config/schema/base-group.js +5 -5
  37. package/dist/get-context/get-config/schema/index.d.ts +292 -164
  38. package/dist/get-context/get-config/schema/index.js +40 -63
  39. package/dist/get-context/get-config/schema/lib/non-empty-string.d.ts +2 -0
  40. package/dist/get-context/get-config/schema/lib/non-empty-string.js +5 -0
  41. package/dist/get-context/get-config/schema/paths.js +12 -12
  42. package/dist/get-context/get-config/schema/semver-group.d.ts +24 -24
  43. package/dist/get-context/get-config/schema/semver-group.js +11 -18
  44. package/dist/get-context/get-config/schema/semver-range.js +4 -4
  45. package/dist/get-context/get-config/schema/version-group.d.ts +90 -41
  46. package/dist/get-context/get-config/schema/version-group.js +28 -23
  47. package/dist/get-context/get-groups/base-group.d.ts +4 -1
  48. package/dist/get-context/get-groups/base-group.js +18 -19
  49. package/dist/get-context/get-groups/index.d.ts +7 -3
  50. package/dist/get-context/get-groups/index.js +42 -38
  51. package/dist/get-context/get-groups/semver-group.d.ts +0 -1
  52. package/dist/get-context/get-groups/semver-group.js +23 -66
  53. package/dist/get-context/get-groups/version-group/index.d.ts +7 -4
  54. package/dist/get-context/get-groups/version-group/index.js +31 -70
  55. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.d.ts +3 -1
  56. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +36 -45
  57. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.d.ts +3 -0
  58. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.js +44 -0
  59. package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +16 -5
  60. package/dist/get-context/get-groups/version-group/instance-group/index.js +66 -54
  61. package/dist/get-context/get-groups/version-group/instance-group/lib/clean.d.ts +2 -0
  62. package/dist/get-context/get-groups/version-group/instance-group/lib/clean.js +13 -0
  63. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +4 -0
  64. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +38 -0
  65. package/dist/get-context/get-groups/version-group/instance-group/lib/get-range-score.d.ts +2 -0
  66. package/dist/get-context/get-groups/version-group/instance-group/lib/get-range-score.js +23 -0
  67. package/dist/get-context/get-package-json-files/get-file-paths.js +18 -19
  68. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +9 -12
  69. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +9 -11
  70. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +10 -13
  71. package/dist/get-context/get-package-json-files/get-patterns/index.js +15 -42
  72. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.js +4 -6
  73. package/dist/get-context/get-package-json-files/get-patterns/props.js +9 -33
  74. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.js +6 -9
  75. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +4 -4
  76. package/dist/get-context/get-package-json-files/index.d.ts +3 -1
  77. package/dist/get-context/get-package-json-files/index.js +8 -8
  78. package/dist/get-context/get-package-json-files/package-json-file/index.js +32 -55
  79. package/dist/get-context/get-package-json-files/package-json-file/instance.d.ts +2 -1
  80. package/dist/get-context/get-package-json-files/package-json-file/instance.js +15 -15
  81. package/dist/get-context/index.d.ts +3 -2
  82. package/dist/get-context/index.js +28 -24
  83. package/dist/lib/disk.js +28 -29
  84. package/dist/lib/error.js +13 -31
  85. package/dist/lib/exit-if-invalid.js +1 -1
  86. package/dist/lib/is-semver.d.ts +1 -1
  87. package/dist/lib/is-semver.js +15 -7
  88. package/dist/lib/log.js +38 -58
  89. package/dist/lib/newlines.js +11 -11
  90. package/dist/lib/print-strings.js +2 -2
  91. package/dist/lib/set-semver-range.js +8 -8
  92. package/dist/lib/show-help-on-error.js +31 -8
  93. package/dist/lib/sort-by-name.js +1 -1
  94. package/dist/lib/write-if-changed.js +3 -3
  95. package/dist/option.js +8 -13
  96. package/dist/types.d.ts +3 -1
  97. package/dist/types.js +1 -1
  98. package/package.json +20 -16
  99. package/dist/get-context/get-all-instances.d.ts +0 -3
  100. package/dist/get-context/get-all-instances.js +0 -8
@@ -1,59 +1,56 @@
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
- var _a, _b, _c;
36
- exports.__esModule = true;
37
- var chalk_1 = __importDefault(require("chalk"));
38
- var commander_1 = require("commander");
39
- var disk_1 = require("../lib/disk");
40
- var show_help_on_error_1 = require("../lib/show-help-on-error");
41
- var option_1 = require("../option");
42
- var list_cli_1 = require("./list-cli");
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 list_cli_1 = require("./list-cli");
43
13
  commander_1.program.description(' List all dependencies required by your packages.');
44
- commander_1.program.on('--help', function () {
45
- 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 --types dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list --types 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 --types dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list --types 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"]))));
14
+ commander_1.program.on('--help', () => {
15
+ console.log((0, chalk_1.default) `
16
+ Examples:
17
+ {dim # uses defaults for resolving packages}
18
+ syncpack list
19
+ {dim # uses packages defined by --source when provided}
20
+ syncpack list --source {yellow "apps/*/package.json"}
21
+ {dim # multiple globs can be provided like this}
22
+ syncpack list --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
23
+ {dim # uses dependencies regular expression defined by --filter when provided}
24
+ syncpack list --filter {yellow "typescript|tslint"}
25
+ {dim # only inspect "devDependencies"}
26
+ syncpack list --types dev
27
+ {dim # only inspect "devDependencies" and "peerDependencies"}
28
+ syncpack list --types dev,peer
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
- (_a = (_b = (_c = commander_1.program
49
- .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
50
- .option.apply(_c, __spreadArray([], __read(option_1.option.filter), false)))
51
- .option.apply(_b, __spreadArray([], __read(option_1.option.config), false)))
52
- .option.apply(_a, __spreadArray([], __read(option_1.option.types), false)).parse(process.argv);
45
+ commander_1.program
46
+ .option(...option_1.option.source)
47
+ .option(...option_1.option.filter)
48
+ .option(...option_1.option.config)
49
+ .option(...option_1.option.types)
50
+ .parse(process.argv);
53
51
  (0, list_cli_1.listCli)({
54
52
  configPath: commander_1.program.opts().config,
55
53
  filter: commander_1.program.opts().filter,
56
54
  source: commander_1.program.opts().source,
57
- types: commander_1.program.opts().types
55
+ types: commander_1.program.opts().types,
58
56
  }, disk_1.disk);
59
- var templateObject_1;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listCli = void 0;
4
- var get_context_1 = require("../get-context");
5
- var exit_if_invalid_1 = require("../lib/exit-if-invalid");
6
- var list_1 = require("./list");
4
+ const get_context_1 = require("../get-context");
5
+ const exit_if_invalid_1 = require("../lib/exit-if-invalid");
6
+ const list_1 = require("./list");
7
7
  function listCli(input, disk) {
8
8
  (0, exit_if_invalid_1.exitIfInvalid)((0, list_1.list)((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);
@@ -29,21 +25,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
29
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
30
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
31
27
  };
32
- exports.__esModule = true;
28
+ Object.defineProperty(exports, "__esModule", { value: true });
33
29
  exports.list = void 0;
34
- var chalk_1 = __importDefault(require("chalk"));
35
- var constants_1 = require("../constants");
36
- var log = __importStar(require("../lib/log"));
30
+ const ts_belt_1 = require("@mobily/ts-belt");
31
+ const chalk_1 = __importDefault(require("chalk"));
32
+ const constants_1 = require("../constants");
33
+ const _R_1 = require("../get-context/$R");
34
+ const log = __importStar(require("../lib/log"));
37
35
  function list(ctx) {
38
- var hasUserGroups = ctx.versionGroups.length > 1;
39
- ctx.versionGroups.forEach(function (versionGroup, i) {
40
- var instanceGroups = versionGroup.getAllInstanceGroups();
36
+ const hasUserGroups = ctx.versionGroups.length > 1;
37
+ ctx.versionGroups.forEach((versionGroup, i) => {
38
+ const instanceGroups = versionGroup.getAllInstanceGroups();
41
39
  // Nothing to do if empty
42
40
  if (instanceGroups.length === 0)
43
41
  return;
44
42
  // Annotate each group
45
43
  hasUserGroups && log.versionGroupHeader(versionGroup, i);
46
- instanceGroups.forEach(function (instanceGroup) {
44
+ instanceGroups.forEach((instanceGroup) => {
47
45
  // Record that this project has mismatches, so that eg. the CLI can exit
48
46
  // with the correct status code.
49
47
  if (instanceGroup.isInvalid())
@@ -64,34 +62,33 @@ function list(ctx) {
64
62
  });
65
63
  return ctx;
66
64
  function logVersionMatch(instanceGroup) {
67
- console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim -} {white ", "} {dim ", "}"], ["{dim -} {white ", "} {dim ", "}"])), instanceGroup.name, instanceGroup.getUniqueVersions()));
65
+ console.log((0, chalk_1.default) `{dim -} {white ${instanceGroup.name}} {dim ${instanceGroup.getUniqueVersions()}}`);
68
66
  }
69
67
  function logVersionMismatch(instanceGroup) {
70
- console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{red ", " ", "} ", ""], ["{red ", " ", "} ", ""])), constants_1.ICON.cross, instanceGroup.name, instanceGroup
71
- .getUniqueVersions()
72
- .map(function (version) {
73
- return version === instanceGroup.getExpectedVersion()
74
- ? chalk_1["default"].green(version)
75
- : chalk_1["default"].red(version);
76
- })
77
- .join(chalk_1["default"].dim(', '))));
68
+ (0, ts_belt_1.pipe)(instanceGroup.getExpectedVersion(), ts_belt_1.R.tap((expectedVersion) => {
69
+ const uniqueVersions = instanceGroup.getUniqueVersions();
70
+ console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} ${uniqueVersions
71
+ .map((version) => version === expectedVersion
72
+ ? chalk_1.default.green(version)
73
+ : chalk_1.default.red(version))
74
+ .join(chalk_1.default.dim(', '))}`);
75
+ }), _R_1.$R.tapErrVerbose);
78
76
  }
79
77
  function logIgnored(instanceGroup) {
80
- 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));
78
+ console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip} ${instanceGroup.name}} is ignored in this version group`);
81
79
  }
82
80
  function logBanned(instanceGroup) {
83
- 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));
81
+ console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red is banned in this version group}`);
84
82
  }
85
83
  function logUnpinned(instanceGroup) {
86
- var pinVersion = instanceGroup.versionGroup.getPinnedVersion();
87
- console.log((0, chalk_1["default"])(templateObject_5 || (templateObject_5 = __makeTemplateObject(["{red ", " ", "} {dim.red is pinned to ", " in this version group}"], ["{red ", " ", "} {dim.red is pinned to ", " in this version group}"])), constants_1.ICON.cross, instanceGroup.name, pinVersion));
84
+ const pinVersion = ts_belt_1.O.getExn(instanceGroup.versionGroup.getPinnedVersion());
85
+ console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red is pinned to ${pinVersion} in this version group}`);
88
86
  }
89
87
  function logUnsupportedMismatches(instanceGroup) {
90
- console.log((0, chalk_1["default"])(templateObject_6 || (templateObject_6 = __makeTemplateObject(["{red ", " ", "} {dim.red has mismatched versions which syncpack cannot fix: ", "}"], ["{red ", " ", "} {dim.red has mismatched versions which syncpack cannot fix: ", "}"])), constants_1.ICON.cross, instanceGroup.name, instanceGroup
88
+ console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red has mismatched versions which syncpack cannot fix: ${instanceGroup
91
89
  .getUniqueVersions()
92
- .map(function (version) { return chalk_1["default"].yellow(version); })
93
- .join(chalk_1["default"].dim(', '))));
90
+ .map((version) => chalk_1.default.yellow(version))
91
+ .join(chalk_1.default.dim(', '))}}`);
94
92
  }
95
93
  }
96
94
  exports.list = list;
97
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
@@ -1,59 +1,58 @@
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
- var _a, _b, _c;
36
- exports.__esModule = true;
37
- var chalk_1 = __importDefault(require("chalk"));
38
- var commander_1 = require("commander");
39
- var disk_1 = require("../lib/disk");
40
- var show_help_on_error_1 = require("../lib/show-help-on-error");
41
- var option_1 = require("../option");
42
- var list_mismatches_cli_1 = require("./list-mismatches-cli");
43
- commander_1.program.description("\n List dependencies which are required by multiple packages, where the version\n is not the same across every package.".replace(/^\n/, ''));
44
- commander_1.program.on('--help', function () {
45
- console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack list-mismatches\n {dim # uses packages defined by --source when provided}\n syncpack list-mismatches --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack list-mismatches --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack list-mismatches --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack list-mismatches --types dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list-mismatches --types 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-mismatches\n {dim # uses packages defined by --source when provided}\n syncpack list-mismatches --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack list-mismatches --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack list-mismatches --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack list-mismatches --types dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list-mismatches --types 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"]))));
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 list_mismatches_cli_1 = require("./list-mismatches-cli");
13
+ commander_1.program.description(`
14
+ List dependencies which are required by multiple packages, where the version
15
+ is not the same across every package.`.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 list-mismatches
21
+ {dim # uses packages defined by --source when provided}
22
+ syncpack list-mismatches --source {yellow "apps/*/package.json"}
23
+ {dim # multiple globs can be provided like this}
24
+ syncpack list-mismatches --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
25
+ {dim # uses dependencies regular expression defined by --filter when provided}
26
+ syncpack list-mismatches --filter {yellow "typescript|tslint"}
27
+ {dim # only inspect "devDependencies"}
28
+ syncpack list-mismatches --types dev
29
+ {dim # only inspect "devDependencies" and "peerDependencies"}
30
+ syncpack list-mismatches --types dev,peer
31
+
32
+ Resolving Packages:
33
+ 1. If {yellow --source} globs are provided, use those.
34
+ 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
35
+ 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
36
+ 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
37
+ 5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
38
+
39
+ Reference:
40
+ globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
41
+ lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
42
+ Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
43
+ Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
44
+ `);
46
45
  });
47
46
  (0, show_help_on_error_1.showHelpOnError)(commander_1.program);
48
- (_a = (_b = (_c = commander_1.program
49
- .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
50
- .option.apply(_c, __spreadArray([], __read(option_1.option.filter), false)))
51
- .option.apply(_b, __spreadArray([], __read(option_1.option.config), false)))
52
- .option.apply(_a, __spreadArray([], __read(option_1.option.types), false)).parse(process.argv);
47
+ commander_1.program
48
+ .option(...option_1.option.source)
49
+ .option(...option_1.option.filter)
50
+ .option(...option_1.option.config)
51
+ .option(...option_1.option.types)
52
+ .parse(process.argv);
53
53
  (0, list_mismatches_cli_1.listMismatchesCli)({
54
54
  configPath: commander_1.program.opts().config,
55
55
  filter: commander_1.program.opts().filter,
56
56
  source: commander_1.program.opts().source,
57
- types: commander_1.program.opts().types
57
+ types: commander_1.program.opts().types,
58
58
  }, disk_1.disk);
59
- var templateObject_1;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listMismatchesCli = void 0;
4
- var get_context_1 = require("../get-context");
5
- var exit_if_invalid_1 = require("../lib/exit-if-invalid");
6
- var list_mismatches_1 = require("./list-mismatches");
4
+ const get_context_1 = require("../get-context");
5
+ const exit_if_invalid_1 = require("../lib/exit-if-invalid");
6
+ const list_mismatches_1 = require("./list-mismatches");
7
7
  function listMismatchesCli(input, disk) {
8
8
  (0, exit_if_invalid_1.exitIfInvalid)((0, list_mismatches_1.listMismatches)((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);
@@ -29,14 +25,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
29
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
30
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
31
27
  };
32
- exports.__esModule = true;
28
+ Object.defineProperty(exports, "__esModule", { value: true });
33
29
  exports.listMismatches = void 0;
34
- var chalk_1 = __importDefault(require("chalk"));
35
- var log = __importStar(require("../lib/log"));
30
+ const ts_belt_1 = require("@mobily/ts-belt");
31
+ const chalk_1 = __importDefault(require("chalk"));
32
+ const log = __importStar(require("../lib/log"));
36
33
  function listMismatches(ctx) {
37
- var hasUserGroups = ctx.versionGroups.length > 1;
38
- ctx.versionGroups.forEach(function (versionGroup, i) {
39
- var invalidGroups = versionGroup.getInvalidInstanceGroups();
34
+ const hasUserGroups = ctx.versionGroups.length > 1;
35
+ ctx.versionGroups.forEach((versionGroup, i) => {
36
+ const invalidGroups = versionGroup.getInvalidInstanceGroups();
40
37
  // Nothing to do if there are no mismatches
41
38
  if (invalidGroups.length === 0)
42
39
  return;
@@ -46,83 +43,101 @@ function listMismatches(ctx) {
46
43
  // Annotate each group
47
44
  hasUserGroups && log.versionGroupHeader(versionGroup, i);
48
45
  // Log the mismatches
49
- invalidGroups.forEach(function (instanceGroup) {
46
+ invalidGroups.forEach((instanceGroup) => {
50
47
  if (versionGroup.isBanned())
51
48
  return logBanned(instanceGroup);
52
49
  if (versionGroup.isUnpinned())
53
50
  return logUnpinned(instanceGroup);
51
+ if (versionGroup.hasSnappedToPackages())
52
+ return logSnappedTo(instanceGroup);
54
53
  if (instanceGroup.hasUnsupportedVersion())
55
54
  return logUnsupportedMismatches(instanceGroup);
56
55
  if (instanceGroup.hasWorkspaceInstance()) {
57
56
  return logWorkspaceMismatch(instanceGroup);
58
57
  }
59
- logHighestVersionMismatch(instanceGroup);
58
+ logHighLowVersionMismatch(instanceGroup);
60
59
  });
61
60
  });
62
61
  return ctx;
63
62
  function logBanned(instanceGroup) {
64
- var name = instanceGroup.name;
63
+ const name = instanceGroup.name;
65
64
  log.invalid(name, 'is banned in this version group');
66
65
  // Log each of the dependencies mismatches
67
- instanceGroup.instances.forEach(function (instance) {
66
+ instanceGroup.instances.forEach((instance) => {
68
67
  logVersionMismatch(instance);
69
68
  });
70
69
  }
71
70
  function logUnsupportedMismatches(instanceGroup) {
72
- var name = instanceGroup.name;
71
+ const name = instanceGroup.name;
73
72
  log.invalid(name, 'has mismatched versions which syncpack cannot fix');
74
73
  // Log each of the dependencies mismatches
75
- instanceGroup.instances.forEach(function (instance) {
74
+ instanceGroup.instances.forEach((instance) => {
76
75
  logUnsupportedVersionMismatch(instance);
77
76
  });
78
77
  }
79
78
  function logUnpinned(instanceGroup) {
80
- var name = instanceGroup.name;
81
- var pinVersion = instanceGroup.versionGroup.getPinnedVersion();
82
- log.invalid(name, (0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["is pinned in this version group at {reset.green ", "}"], ["is pinned in this version group at {reset.green ", "}"])), pinVersion));
79
+ const name = instanceGroup.name;
80
+ const pinVersion = ts_belt_1.O.getExn(instanceGroup.versionGroup.getPinnedVersion());
81
+ log.invalid(name, (0, chalk_1.default) `is pinned in this version group at {reset.green ${pinVersion}}`);
83
82
  // Log each of the dependencies mismatches
84
- instanceGroup.instances.forEach(function (instance) {
83
+ instanceGroup.instances.forEach((instance) => {
85
84
  if (instance.version !== pinVersion) {
86
85
  logVersionMismatch(instance);
87
86
  }
88
87
  });
89
88
  }
89
+ function logSnappedTo(instanceGroup) {
90
+ const name = instanceGroup.name;
91
+ const versionGroup = instanceGroup.versionGroup;
92
+ const snappedVersion = ts_belt_1.R.getExn(instanceGroup.getSnappedVersion());
93
+ const snappedToPackages = ts_belt_1.O.getExn(versionGroup.getSnappedToPackages()).join(' || ');
94
+ const version = ts_belt_1.R.getExn(instanceGroup.getExpectedVersion());
95
+ log.invalid(name, (0, chalk_1.default) `should snap to {reset.green ${version}}, used by ${snappedToPackages}`);
96
+ // Log each of the dependencies mismatches
97
+ instanceGroup.instances.forEach((instance) => {
98
+ if (instance.version !== snappedVersion) {
99
+ logVersionMismatch(instance);
100
+ }
101
+ });
102
+ }
90
103
  function logWorkspaceMismatch(instanceGroup) {
91
- var name = instanceGroup.name;
92
- var workspaceInstance = instanceGroup.getWorkspaceInstance();
93
- var shortPath = workspaceInstance === null || workspaceInstance === void 0 ? void 0 : workspaceInstance.packageJsonFile.shortPath;
94
- var expected = instanceGroup.getExpectedVersion();
95
- log.invalid(name, (0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{reset.green ", "} {dim is developed in this repo at ", "}"], ["{reset.green ", "} {dim is developed in this repo at ", "}"])), expected, shortPath));
104
+ const name = instanceGroup.name;
105
+ const workspaceInstance = ts_belt_1.O.getExn(instanceGroup.getWorkspaceInstance());
106
+ const shortPath = workspaceInstance?.packageJsonFile.shortPath;
107
+ const expected = ts_belt_1.R.getExn(instanceGroup.getExpectedVersion());
108
+ log.invalid(name, (0, chalk_1.default) `{reset.green ${expected}} {dim is developed in this repo at ${shortPath}}`);
96
109
  // Log each of the dependencies mismatches
97
- instanceGroup.instances.forEach(function (instance) {
110
+ instanceGroup.instances.forEach((instance) => {
98
111
  if (instance.version !== expected) {
99
112
  logVersionMismatch(instance);
100
113
  }
101
114
  });
102
115
  }
103
- function logHighestVersionMismatch(instanceGroup) {
104
- var name = instanceGroup.name;
105
- var expected = instanceGroup.getExpectedVersion();
106
- log.invalid(name, (0, chalk_1["default"])(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{reset.green ", "} {dim is the highest valid semver version in use}"], ["{reset.green ", "} {dim is the highest valid semver version in use}"])), expected));
116
+ function logHighLowVersionMismatch(instanceGroup) {
117
+ const name = instanceGroup.name;
118
+ const preference = instanceGroup.versionGroup
119
+ .groupConfig.preferVersion;
120
+ const direction = preference === 'highestSemver' ? 'highest' : 'lowest';
121
+ const expected = ts_belt_1.R.getExn(instanceGroup.getExpectedVersion());
122
+ log.invalid(name, (0, chalk_1.default) `{reset.green ${expected}} {dim is the ${direction} valid semver version in use}`);
107
123
  // Log each of the dependencies mismatches
108
- instanceGroup.instances.forEach(function (instance) {
124
+ instanceGroup.instances.forEach((instance) => {
109
125
  if (instance.version !== expected) {
110
126
  logVersionMismatch(instance);
111
127
  }
112
128
  });
113
129
  }
114
130
  function logVersionMismatch(instance) {
115
- var type = instance.pathDef.path;
116
- var shortPath = instance.packageJsonFile.shortPath;
117
- var actual = instance.version;
118
- console.log((0, chalk_1["default"])(templateObject_4 || (templateObject_4 = __makeTemplateObject([" {red ", "} {dim in ", " of ", "}"], [" {red ", "} {dim in ", " of ", "}"])), actual, type, shortPath));
131
+ const type = instance.pathDef.path;
132
+ const shortPath = instance.packageJsonFile.shortPath;
133
+ const actual = instance.version;
134
+ console.log((0, chalk_1.default) ` {red ${actual}} {dim in ${type} of ${shortPath}}`);
119
135
  }
120
136
  function logUnsupportedVersionMismatch(instance) {
121
- var type = instance.pathDef.path;
122
- var shortPath = instance.packageJsonFile.shortPath;
123
- var actual = instance.version;
124
- console.log((0, chalk_1["default"])(templateObject_5 || (templateObject_5 = __makeTemplateObject([" {yellow ", "} {dim in ", " of ", "}"], [" {yellow ", "} {dim in ", " of ", "}"])), actual, type, shortPath));
137
+ const type = instance.pathDef.path;
138
+ const shortPath = instance.packageJsonFile.shortPath;
139
+ const actual = instance.version;
140
+ console.log((0, chalk_1.default) ` {yellow ${actual}} {dim in ${type} of ${shortPath}}`);
125
141
  }
126
142
  }
127
143
  exports.listMismatches = listMismatches;
128
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;