syncpack 8.4.11 → 9.0.0

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 (182) hide show
  1. package/README.md +195 -109
  2. package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +3 -0
  3. package/dist/bin-fix-mismatches/fix-mismatches-cli.js +10 -0
  4. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -3
  5. package/dist/bin-fix-mismatches/fix-mismatches.js +46 -58
  6. package/dist/bin-fix-mismatches/index.js +12 -22
  7. package/dist/bin-format/format-cli.d.ts +3 -0
  8. package/dist/bin-format/format-cli.js +10 -0
  9. package/dist/bin-format/format.d.ts +2 -3
  10. package/dist/bin-format/format.js +10 -11
  11. package/dist/bin-format/index.js +5 -4
  12. package/dist/bin-lint-semver-ranges/index.js +13 -23
  13. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.d.ts +3 -0
  14. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +10 -0
  15. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -3
  16. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +72 -27
  17. package/dist/bin-list/index.js +12 -22
  18. package/dist/bin-list/list-cli.d.ts +3 -0
  19. package/dist/bin-list/list-cli.js +10 -0
  20. package/dist/bin-list/list.d.ts +2 -3
  21. package/dist/bin-list/list.js +60 -35
  22. package/dist/bin-list-mismatches/index.js +12 -22
  23. package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +3 -0
  24. package/dist/bin-list-mismatches/list-mismatches-cli.js +10 -0
  25. package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -3
  26. package/dist/bin-list-mismatches/list-mismatches.js +75 -73
  27. package/dist/bin-set-semver-ranges/index.js +13 -23
  28. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +3 -0
  29. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +10 -0
  30. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -3
  31. package/dist/bin-set-semver-ranges/set-semver-ranges.js +5 -29
  32. package/dist/constants.d.ts +31 -21
  33. package/dist/constants.js +27 -42
  34. package/dist/get-context/$R.d.ts +13 -0
  35. package/dist/get-context/$R.js +56 -0
  36. package/dist/get-context/get-all-instances.d.ts +3 -0
  37. package/dist/get-context/get-all-instances.js +8 -0
  38. package/dist/get-context/get-config/get-core-types.d.ts +36 -0
  39. package/dist/get-context/get-config/get-core-types.js +68 -0
  40. package/dist/get-context/get-config/get-custom-types.d.ts +4 -0
  41. package/dist/get-context/get-config/get-custom-types.js +28 -0
  42. package/dist/get-context/get-config/get-enabled-types.d.ts +4 -0
  43. package/dist/get-context/get-config/get-enabled-types.js +19 -0
  44. package/dist/get-context/get-config/index.d.ts +7 -0
  45. package/dist/get-context/get-config/index.js +115 -0
  46. package/dist/get-context/get-config/path-strategy/index.d.ts +8 -0
  47. package/dist/get-context/get-config/path-strategy/index.js +18 -0
  48. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.d.ts +4 -0
  49. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.js +11 -0
  50. package/dist/get-context/get-config/path-strategy/name-and-version-props.d.ts +2 -0
  51. package/dist/get-context/get-config/path-strategy/name-and-version-props.js +66 -0
  52. package/dist/get-context/get-config/path-strategy/name-and-version-string.d.ts +2 -0
  53. package/dist/get-context/get-config/path-strategy/name-and-version-string.js +60 -0
  54. package/dist/get-context/get-config/path-strategy/types.d.ts +15 -0
  55. package/dist/{types/index.js → get-context/get-config/path-strategy/types.js} +0 -0
  56. package/dist/get-context/get-config/path-strategy/version-string.d.ts +2 -0
  57. package/dist/get-context/get-config/path-strategy/version-string.js +60 -0
  58. package/dist/get-context/get-config/path-strategy/versions-by-name.d.ts +2 -0
  59. package/dist/get-context/get-config/path-strategy/versions-by-name.js +39 -0
  60. package/dist/get-context/get-config/schema/base-group.d.ts +6 -0
  61. package/dist/get-context/get-config/schema/base-group.js +9 -0
  62. package/dist/get-context/get-config/schema/index.d.ts +1276 -0
  63. package/dist/get-context/get-config/schema/index.js +104 -0
  64. package/dist/get-context/get-config/schema/paths.d.ts +89 -0
  65. package/dist/get-context/get-config/schema/paths.js +33 -0
  66. package/dist/get-context/get-config/schema/semver-group.d.ts +101 -0
  67. package/dist/get-context/get-config/schema/semver-group.js +50 -0
  68. package/dist/get-context/get-config/schema/semver-range.d.ts +2 -0
  69. package/dist/get-context/get-config/schema/semver-range.js +16 -0
  70. package/dist/get-context/get-config/schema/version-group.d.ts +151 -0
  71. package/dist/get-context/get-config/schema/version-group.js +31 -0
  72. package/dist/get-context/get-groups/get-semver-groups.d.ts +4 -0
  73. package/dist/get-context/get-groups/get-semver-groups.js +46 -0
  74. package/dist/get-context/get-groups/get-version-groups.d.ts +4 -0
  75. package/dist/get-context/get-groups/get-version-groups.js +72 -0
  76. package/dist/get-context/get-groups/semver-group/index.d.ts +29 -0
  77. package/dist/get-context/get-groups/semver-group/index.js +56 -0
  78. package/dist/get-context/get-groups/version-group/index.d.ts +29 -0
  79. package/dist/get-context/get-groups/version-group/index.js +23 -0
  80. package/dist/{bin-fix-mismatches/get-expected-version → get-context/get-groups/version-group/instance-group}/get-highest-version.d.ts +0 -0
  81. package/dist/{bin-fix-mismatches/get-expected-version → get-context/get-groups/version-group/instance-group}/get-highest-version.js +10 -10
  82. package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +34 -0
  83. package/dist/get-context/get-groups/version-group/instance-group/index.js +80 -0
  84. package/dist/{lib/get-input/get-wrappers → get-context/get-package-json-files}/get-file-paths.d.ts +7 -5
  85. package/dist/get-context/get-package-json-files/get-file-paths.js +40 -0
  86. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +4 -0
  87. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +19 -0
  88. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +4 -0
  89. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +23 -0
  90. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +4 -0
  91. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +20 -0
  92. package/dist/get-context/get-package-json-files/get-patterns/index.d.ts +11 -0
  93. package/dist/get-context/get-package-json-files/get-patterns/index.js +70 -0
  94. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.d.ts +1 -0
  95. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.js +10 -0
  96. package/dist/get-context/get-package-json-files/get-patterns/props.d.ts +6 -0
  97. package/dist/get-context/get-package-json-files/get-patterns/props.js +48 -0
  98. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.d.ts +12 -0
  99. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.js +20 -0
  100. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.d.ts +4 -0
  101. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +11 -0
  102. package/dist/get-context/get-package-json-files/index.d.ts +5 -0
  103. package/dist/get-context/get-package-json-files/index.js +16 -0
  104. package/dist/get-context/get-package-json-files/package-json-file/index.d.ts +51 -0
  105. package/dist/get-context/get-package-json-files/package-json-file/index.js +85 -0
  106. package/dist/get-context/get-package-json-files/package-json-file/instance.d.ts +25 -0
  107. package/dist/get-context/get-package-json-files/package-json-file/instance.js +62 -0
  108. package/dist/get-context/index.d.ts +21 -0
  109. package/dist/get-context/index.js +38 -0
  110. package/dist/lib/disk.d.ts +11 -11
  111. package/dist/lib/disk.js +0 -1
  112. package/dist/lib/error.d.ts +12 -0
  113. package/dist/lib/error.js +43 -0
  114. package/dist/lib/exit-if-invalid.d.ts +2 -0
  115. package/dist/lib/exit-if-invalid.js +10 -0
  116. package/dist/lib/is-semver.d.ts +2 -2
  117. package/dist/lib/is-semver.js +9 -9
  118. package/dist/lib/log.d.ts +6 -0
  119. package/dist/lib/log.js +40 -1
  120. package/dist/lib/newlines.d.ts +6 -0
  121. package/dist/lib/newlines.js +24 -0
  122. package/dist/lib/set-semver-range.d.ts +2 -2
  123. package/dist/lib/set-semver-range.js +1 -1
  124. package/dist/lib/show-help-on-error.d.ts +2 -0
  125. package/dist/lib/show-help-on-error.js +16 -0
  126. package/dist/lib/write-if-changed.d.ts +2 -0
  127. package/dist/lib/{get-input/get-wrappers/get-patterns/read-yaml-safe.js → write-if-changed.js} +14 -8
  128. package/dist/option.d.ts +6 -11
  129. package/dist/option.js +10 -18
  130. package/dist/types.d.ts +88 -0
  131. package/dist/{types/semver-group.js → types.js} +0 -0
  132. package/package.json +24 -23
  133. package/dist/bin-fix-mismatches/get-expected-version/get-pinned-version.d.ts +0 -2
  134. package/dist/bin-fix-mismatches/get-expected-version/get-pinned-version.js +0 -7
  135. package/dist/bin-fix-mismatches/get-expected-version/get-workspace-version.d.ts +0 -6
  136. package/dist/bin-fix-mismatches/get-expected-version/get-workspace-version.js +0 -17
  137. package/dist/bin-fix-mismatches/get-expected-version/index.d.ts +0 -3
  138. package/dist/bin-fix-mismatches/get-expected-version/index.js +0 -27
  139. package/dist/bin-lint-semver-ranges/list-semver-group-mismatches.d.ts +0 -2
  140. package/dist/bin-lint-semver-ranges/list-semver-group-mismatches.js +0 -12
  141. package/dist/bin-list/list-version-groups.d.ts +0 -10
  142. package/dist/bin-list/list-version-groups.js +0 -52
  143. package/dist/lib/collect.d.ts +0 -1
  144. package/dist/lib/collect.js +0 -7
  145. package/dist/lib/get-input/get-config.d.ts +0 -12
  146. package/dist/lib/get-input/get-config.js +0 -135
  147. package/dist/lib/get-input/get-instances.d.ts +0 -29
  148. package/dist/lib/get-input/get-instances.js +0 -172
  149. package/dist/lib/get-input/get-wrappers/get-file-paths.js +0 -50
  150. package/dist/lib/get-input/get-wrappers/get-patterns/get-lerna-patterns.d.ts +0 -3
  151. package/dist/lib/get-input/get-wrappers/get-patterns/get-lerna-patterns.js +0 -40
  152. package/dist/lib/get-input/get-wrappers/get-patterns/get-pnpm-patterns.d.ts +0 -3
  153. package/dist/lib/get-input/get-wrappers/get-patterns/get-pnpm-patterns.js +0 -45
  154. package/dist/lib/get-input/get-wrappers/get-patterns/get-yarn-patterns.d.ts +0 -3
  155. package/dist/lib/get-input/get-wrappers/get-patterns/get-yarn-patterns.js +0 -46
  156. package/dist/lib/get-input/get-wrappers/get-patterns/index.d.ts +0 -10
  157. package/dist/lib/get-input/get-wrappers/get-patterns/index.js +0 -79
  158. package/dist/lib/get-input/get-wrappers/get-patterns/props.d.ts +0 -7
  159. package/dist/lib/get-input/get-wrappers/get-patterns/props.js +0 -43
  160. package/dist/lib/get-input/get-wrappers/get-patterns/read-json-safe.d.ts +0 -4
  161. package/dist/lib/get-input/get-wrappers/get-patterns/read-json-safe.js +0 -41
  162. package/dist/lib/get-input/get-wrappers/get-patterns/read-yaml-safe.d.ts +0 -3
  163. package/dist/lib/get-input/get-wrappers/index.d.ts +0 -38
  164. package/dist/lib/get-input/get-wrappers/index.js +0 -40
  165. package/dist/lib/get-input/get-wrappers/readonly.d.ts +0 -4
  166. package/dist/lib/get-input/get-wrappers/readonly.js +0 -10
  167. package/dist/lib/get-input/get-wrappers/tap.d.ts +0 -15
  168. package/dist/lib/get-input/get-wrappers/tap.js +0 -56
  169. package/dist/lib/get-input/get-wrappers/try-catch.d.ts +0 -5
  170. package/dist/lib/get-input/get-wrappers/try-catch.js +0 -13
  171. package/dist/lib/get-input/index.d.ts +0 -20
  172. package/dist/lib/get-input/index.js +0 -32
  173. package/dist/lib/group-by.d.ts +0 -1
  174. package/dist/lib/group-by.js +0 -11
  175. package/dist/lib/write-if-changed/index.d.ts +0 -10
  176. package/dist/lib/write-if-changed/index.js +0 -25
  177. package/dist/lib/write-if-changed/set-newlines.d.ts +0 -4
  178. package/dist/lib/write-if-changed/set-newlines.js +0 -24
  179. package/dist/types/index.d.ts +0 -77
  180. package/dist/types/semver-group.d.ts +0 -30
  181. package/dist/types/version-group.d.ts +0 -35
  182. package/dist/types/version-group.js +0 -2
@@ -1,69 +1,57 @@
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 };
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
8
17
  };
9
18
  exports.__esModule = true;
10
19
  exports.fixMismatches = void 0;
11
- var chalk_1 = __importDefault(require("chalk"));
12
20
  var expect_more_1 = require("expect-more");
13
- var list_version_groups_1 = require("../bin-list/list-version-groups");
14
- var write_if_changed_1 = require("../lib/write-if-changed");
15
- var get_expected_version_1 = require("./get-expected-version");
16
- function fixMismatches(input, disk) {
17
- /**
18
- * Reverse the list so the default/ungrouped version group is rendered first
19
- * (appears at the top). The actual version groups which the user configured
20
- * will then start from index 1.
21
- */
22
- input.instances.versionGroups.reverse().forEach(function (versionGroup, i) {
23
- var isVersionGroup = i > 0;
24
- var groups = (0, list_version_groups_1.listVersionGroups)(versionGroup);
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
- }
21
+ function fixMismatches(ctx) {
22
+ ctx.versionGroups.reverse().forEach(function (versionGroup) {
23
+ var invalidGroups = versionGroup.getInvalidInstanceGroups();
24
+ // Nothing to do if there are no mismatches
25
+ if (invalidGroups.length === 0)
26
+ return;
27
+ // Set the correct version on each instance.
28
+ invalidGroups.forEach(function (instanceGroup) {
29
+ var nextVersion = instanceGroup.getExpectedVersion();
30
+ if (nextVersion === '')
31
+ console.trace(instanceGroup);
32
+ instanceGroup.instances.forEach(function (instance) {
33
+ return instance.setVersion(nextVersion);
34
+ });
45
35
  });
46
36
  });
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
54
- });
37
+ ctx.packageJsonFiles.forEach(function (file) {
38
+ removeEmptyObjects(file.contents);
55
39
  });
56
- /**
57
- * Remove eg `{"dependencies": {}, "devDependencies": {}}`
58
- */
59
- function removeEmptyIndexes(wrapper) {
60
- input.dependencyTypes.forEach(function (dependencyType) {
61
- var deps = wrapper.contents[dependencyType];
62
- if (deps && Object.values(deps).every(expect_more_1.isUndefined)) {
63
- delete wrapper.contents[dependencyType];
64
- }
65
- });
40
+ return ctx;
41
+ /** Remove eg { "dependencies": {}, "devDependencies": {} }` */
42
+ function removeEmptyObjects(parent) {
43
+ if ((0, expect_more_1.isObject)(parent)) {
44
+ Object.entries(parent).forEach(function (_a) {
45
+ var _b = __read(_a, 2), key = _b[0], child = _b[1];
46
+ if ((0, expect_more_1.isObject)(child) &&
47
+ ((0, expect_more_1.isEmptyObject)(child) || Object.values(child).every(expect_more_1.isUndefined))) {
48
+ delete parent[key];
49
+ }
50
+ else {
51
+ removeEmptyObjects(child);
52
+ }
53
+ });
54
+ }
66
55
  }
67
56
  }
68
57
  exports.fixMismatches = fixMismatches;
69
- var templateObject_1;
@@ -32,40 +32,30 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
32
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
35
+ var _a, _b, _c, _d;
36
36
  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");
40
+ var show_help_on_error_1 = require("../lib/show-help-on-error");
41
41
  var option_1 = require("../option");
42
- var fix_mismatches_1 = require("./fix-mismatches");
42
+ var fix_mismatches_cli_1 = require("./fix-mismatches-cli");
43
43
  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
44
  commander_1.program.on('--help', function () {
45
- 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"]))));
45
+ 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 --types dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack fix-mismatches --types 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 --types dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack fix-mismatches --types 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"]))));
46
46
  });
47
- (_a = (_b = (_c = (_d = (_e = (_f = (_g = (_h = (_j = commander_1.program
47
+ (0, show_help_on_error_1.showHelpOnError)(commander_1.program);
48
+ (_a = (_b = (_c = (_d = commander_1.program
48
49
  .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
49
- .option.apply(_j, __spreadArray([], __read(option_1.option.filter), false)))
50
- .option.apply(_h, __spreadArray([], __read(option_1.option.config), false)))
51
- .option.apply(_g, __spreadArray([], __read(option_1.option.prod), false)))
52
- .option.apply(_f, __spreadArray([], __read(option_1.option.dev), false)))
53
- .option.apply(_e, __spreadArray([], __read(option_1.option.peer), false)))
54
- .option.apply(_d, __spreadArray([], __read(option_1.option.resolutions), false)))
55
- .option.apply(_c, __spreadArray([], __read(option_1.option.overrides), false)))
56
- .option.apply(_b, __spreadArray([], __read(option_1.option.workspace), false)))
50
+ .option.apply(_d, __spreadArray([], __read(option_1.option.filter), false)))
51
+ .option.apply(_c, __spreadArray([], __read(option_1.option.types), false)))
52
+ .option.apply(_b, __spreadArray([], __read(option_1.option.config), false)))
57
53
  .option.apply(_a, __spreadArray([], __read(option_1.option.indent), false)).parse(process.argv);
58
- (0, fix_mismatches_1.fixMismatches)((0, get_input_1.getInput)(disk_1.disk, {
54
+ (0, fix_mismatches_cli_1.fixMismatchesCli)({
59
55
  configPath: commander_1.program.opts().config,
60
- dev: commander_1.program.opts().dev,
61
56
  filter: commander_1.program.opts().filter,
62
57
  indent: commander_1.program.opts().indent,
63
- overrides: commander_1.program.opts().overrides,
64
- peer: commander_1.program.opts().peer,
65
- pnpmOverrides: commander_1.program.opts().pnpmOverrides,
66
- prod: commander_1.program.opts().prod,
67
- resolutions: commander_1.program.opts().resolutions,
68
58
  source: commander_1.program.opts().source,
69
- workspace: commander_1.program.opts().workspace
70
- }), disk_1.disk);
59
+ types: commander_1.program.opts().types
60
+ }, disk_1.disk);
71
61
  var templateObject_1, templateObject_2;
@@ -0,0 +1,3 @@
1
+ import type { Disk } from '../lib/disk';
2
+ import type { Syncpack } from '../types';
3
+ export declare function formatCli(input: Partial<Syncpack.Config.Cli>, disk: Disk): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.formatCli = void 0;
4
+ var get_context_1 = require("../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 { Disk } from '../lib/disk';
2
- import type { ProgramInput } from '../lib/get-input';
3
- export declare function format(input: ProgramInput, disk: Disk): void;
1
+ import type { Syncpack } from '../types';
2
+ export declare function format(ctx: Syncpack.Ctx): Syncpack.Ctx;
@@ -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
- var write_if_changed_1 = require("../lib/write-if-changed");
6
- function format(input, disk) {
7
- var indent = input.indent, sortAz = input.sortAz, sortFirst = input.sortFirst, wrappers = input.wrappers;
8
- wrappers.forEach(function (_a) {
9
- var _b, _c, _d;
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 = (_b = optionalChaining === null || optionalChaining === void 0 ? void 0 : optionalChaining.bugs) === null || _b === void 0 ? void 0 : _b.url;
15
- var repoUrl = (_c = optionalChaining === null || optionalChaining === void 0 ? void 0 : optionalChaining.repository) === null || _c === void 0 ? void 0 : _c.url;
16
- var repoDir = (_d = optionalChaining === null || optionalChaining === void 0 ? void 0 : optionalChaining.repository) === null || _d === void 0 ? void 0 : _d.directory;
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 (value && typeof value === 'object') {
39
+ else if ((0, expect_more_1.isObject)(value)) {
41
40
  sortObject(Object.keys(value).sort(), value);
42
41
  }
43
42
  }
@@ -37,20 +37,21 @@ 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");
40
+ var show_help_on_error_1 = require("../lib/show-help-on-error");
41
41
  var option_1 = require("../option");
42
- var format_1 = require("./format");
42
+ var format_cli_1 = require("./format-cli");
43
43
  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
44
  commander_1.program.on('--help', function () {
45
45
  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"]))));
46
46
  });
47
+ (0, show_help_on_error_1.showHelpOnError)(commander_1.program);
47
48
  (_a = (_b = commander_1.program
48
49
  .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
49
50
  .option.apply(_b, __spreadArray([], __read(option_1.option.config), false)))
50
51
  .option.apply(_a, __spreadArray([], __read(option_1.option.indent), false)).parse(process.argv);
51
- (0, format_1.format)((0, get_input_1.getInput)(disk_1.disk, {
52
+ (0, format_cli_1.formatCli)({
52
53
  configPath: commander_1.program.opts().config,
53
54
  indent: commander_1.program.opts().indent,
54
55
  source: commander_1.program.opts().source
55
- }), disk_1.disk);
56
+ }, disk_1.disk);
56
57
  var templateObject_1, templateObject_2;
@@ -32,40 +32,30 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
32
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
35
+ var _a, _b, _c, _d;
36
36
  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");
40
+ var show_help_on_error_1 = require("../lib/show-help-on-error");
41
41
  var option_1 = require("../option");
42
- var lint_semver_ranges_1 = require("./lint-semver-ranges");
42
+ var lint_semver_ranges_cli_1 = require("./lint-semver-ranges-cli");
43
43
  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
44
  commander_1.program.on('--help', function () {
45
- 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"]))));
45
+ 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 --types dev --semver-range ~\n {dim # use ~ range in \"devDependencies\" and \"peerDependencies\"}\n syncpack lint-semver-ranges --types 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 --types dev --semver-range ~\n {dim # use ~ range in \"devDependencies\" and \"peerDependencies\"}\n syncpack lint-semver-ranges --types 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"]))));
46
46
  });
47
- (_a = (_b = (_c = (_d = (_e = (_f = (_g = (_h = (_j = commander_1.program
47
+ (0, show_help_on_error_1.showHelpOnError)(commander_1.program);
48
+ (_a = (_b = (_c = (_d = commander_1.program
48
49
  .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
49
- .option.apply(_j, __spreadArray([], __read(option_1.option.filter), false)))
50
- .option.apply(_h, __spreadArray([], __read(option_1.option.semverRange), false)))
51
- .option.apply(_g, __spreadArray([], __read(option_1.option.config), false)))
52
- .option.apply(_f, __spreadArray([], __read(option_1.option.prod), false)))
53
- .option.apply(_e, __spreadArray([], __read(option_1.option.dev), false)))
54
- .option.apply(_d, __spreadArray([], __read(option_1.option.peer), false)))
55
- .option.apply(_c, __spreadArray([], __read(option_1.option.resolutions), false)))
56
- .option.apply(_b, __spreadArray([], __read(option_1.option.overrides), false)))
57
- .option.apply(_a, __spreadArray([], __read(option_1.option.workspace), false)).parse(process.argv);
58
- (0, lint_semver_ranges_1.lintSemverRanges)((0, get_input_1.getInput)(disk_1.disk, {
50
+ .option.apply(_d, __spreadArray([], __read(option_1.option.filter), false)))
51
+ .option.apply(_c, __spreadArray([], __read(option_1.option.semverRange), false)))
52
+ .option.apply(_b, __spreadArray([], __read(option_1.option.config), false)))
53
+ .option.apply(_a, __spreadArray([], __read(option_1.option.types), false)).parse(process.argv);
54
+ (0, lint_semver_ranges_cli_1.lintSemverRangesCli)({
59
55
  configPath: commander_1.program.opts().config,
60
- dev: commander_1.program.opts().dev,
61
56
  filter: commander_1.program.opts().filter,
62
- overrides: commander_1.program.opts().overrides,
63
- peer: commander_1.program.opts().peer,
64
- pnpmOverrides: commander_1.program.opts().pnpmOverrides,
65
- prod: commander_1.program.opts().prod,
66
- resolutions: commander_1.program.opts().resolutions,
67
57
  semverRange: commander_1.program.opts().semverRange,
68
58
  source: commander_1.program.opts().source,
69
- workspace: commander_1.program.opts().workspace
70
- }), disk_1.disk);
59
+ types: commander_1.program.opts().types
60
+ }, disk_1.disk);
71
61
  var templateObject_1, templateObject_2;
@@ -0,0 +1,3 @@
1
+ import type { Disk } from '../lib/disk';
2
+ import type { Syncpack } from '../types';
3
+ export declare function lintSemverRangesCli(input: Partial<Syncpack.Config.Cli>, disk: Disk): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.lintSemverRangesCli = void 0;
4
+ var get_context_1 = require("../get-context");
5
+ var exit_if_invalid_1 = require("../lib/exit-if-invalid");
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 { Disk } from '../lib/disk';
2
- import type { ProgramInput } from '../lib/get-input';
3
- export declare function lintSemverRanges(input: ProgramInput, disk: Disk): void;
1
+ import type { Syncpack } from '../types';
2
+ export declare function lintSemverRanges(ctx: Syncpack.Ctx): Syncpack.Ctx;
@@ -3,41 +3,86 @@ 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"));
12
- var is_semver_1 = require("../lib/is-semver");
51
+ var constants_1 = require("../constants");
52
+ var log = __importStar(require("../lib/log"));
13
53
  var set_semver_range_1 = require("../lib/set-semver-range");
14
- var list_semver_group_mismatches_1 = require("./list-semver-group-mismatches");
15
- function lintSemverRanges(input, disk) {
16
- var isInvalid = false;
17
- /**
18
- * Reverse the list so the default/ungrouped semver group is rendered first
19
- * (appears at the top). The actual semver groups which the user configured
20
- * will then start from index 1.
21
- */
22
- input.instances.semverGroups.reverse().forEach(function (semverGroup, i) {
23
- if ('range' in semverGroup && (0, is_semver_1.isValidSemverRange)(semverGroup.range)) {
24
- var isSemverGroup = i > 0;
25
- var mismatches = (0, list_semver_group_mismatches_1.listSemverGroupMismatches)(semverGroup);
26
- if (isSemverGroup && mismatches.length > 0) {
27
- console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim = Semver Group ", " ", "}"], ["{dim = Semver Group ", " ", "}"])), i, '='.repeat(63)));
28
- }
29
- mismatches.forEach(function (_a) {
30
- var dependencyType = _a.dependencyType, name = _a.name, version = _a.version, wrapper = _a.wrapper;
31
- console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{red \u2715 ", "} {red.dim ", " in ", " of ", " should be ", "}"], ["{red \u2715 ", "} {red.dim ", " in ", " of ", " should be ", "}"])), name, version, dependencyType, wrapper.contents.name, (0, set_semver_range_1.setSemverRange)(semverGroup.range, version)));
54
+ function lintSemverRanges(ctx) {
55
+ ctx.semverGroups.reverse().forEach(function (semverGroup, i) {
56
+ // Nothing to do if there are no mismatches
57
+ if (!semverGroup.hasMismatches())
58
+ return;
59
+ // Record that this project has mismatches, so that eg. the CLI can exit
60
+ // with the correct status code.
61
+ ctx.isInvalid = true;
62
+ // Log each group which has mismatches
63
+ semverGroup.getMismatches().forEach(function (_a) {
64
+ var _b = __read(_a, 2), name = _b[0], mismatches = _b[1];
65
+ // Annotate user-defined version groups
66
+ if (!semverGroup.isDefault)
67
+ log.semverGroupHeader(i);
68
+ // Log the dependency name
69
+ log.invalid(name);
70
+ // Log each of the dependencies mismatches
71
+ mismatches.forEach(function (instance) {
72
+ if (!instance.hasRange(semverGroup.range)) {
73
+ logSemverRangeMismatch(instance, semverGroup);
74
+ }
32
75
  });
33
- if (mismatches.length > 0) {
34
- isInvalid = true;
35
- }
36
- }
76
+ });
37
77
  });
38
- if (isInvalid) {
39
- disk.process.exit(1);
40
- }
78
+ return ctx;
41
79
  }
42
80
  exports.lintSemverRanges = lintSemverRanges;
43
- var templateObject_1, templateObject_2;
81
+ function logSemverRangeMismatch(instance, semverGroup) {
82
+ var path = instance.pathDef.path;
83
+ var shortPath = instance.packageJsonFile.shortPath;
84
+ var actual = instance.version;
85
+ var expected = (0, set_semver_range_1.setSemverRange)(semverGroup.range, actual);
86
+ 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, path, shortPath));
87
+ }
88
+ var templateObject_1;
@@ -32,38 +32,28 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
32
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
- var _a, _b, _c, _d, _e, _f, _g, _h;
35
+ var _a, _b, _c;
36
36
  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");
40
+ var show_help_on_error_1 = require("../lib/show-help-on-error");
41
41
  var option_1 = require("../option");
42
- var list_1 = require("./list");
42
+ var list_cli_1 = require("./list-cli");
43
43
  commander_1.program.description(' List all dependencies required by your packages.');
44
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 --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"]))));
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"]))));
46
46
  });
47
- (_a = (_b = (_c = (_d = (_e = (_f = (_g = (_h = commander_1.program
47
+ (0, show_help_on_error_1.showHelpOnError)(commander_1.program);
48
+ (_a = (_b = (_c = commander_1.program
48
49
  .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
49
- .option.apply(_h, __spreadArray([], __read(option_1.option.filter), false)))
50
- .option.apply(_g, __spreadArray([], __read(option_1.option.config), false)))
51
- .option.apply(_f, __spreadArray([], __read(option_1.option.prod), false)))
52
- .option.apply(_e, __spreadArray([], __read(option_1.option.dev), false)))
53
- .option.apply(_d, __spreadArray([], __read(option_1.option.peer), false)))
54
- .option.apply(_c, __spreadArray([], __read(option_1.option.resolutions), false)))
55
- .option.apply(_b, __spreadArray([], __read(option_1.option.overrides), false)))
56
- .option.apply(_a, __spreadArray([], __read(option_1.option.workspace), false)).parse(process.argv);
57
- (0, list_1.list)((0, get_input_1.getInput)(disk_1.disk, {
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);
53
+ (0, list_cli_1.listCli)({
58
54
  configPath: commander_1.program.opts().config,
59
- dev: commander_1.program.opts().dev,
60
55
  filter: commander_1.program.opts().filter,
61
- overrides: commander_1.program.opts().overrides,
62
- peer: commander_1.program.opts().peer,
63
- pnpmOverrides: commander_1.program.opts().pnpmOverrides,
64
- prod: commander_1.program.opts().prod,
65
- resolutions: commander_1.program.opts().resolutions,
66
56
  source: commander_1.program.opts().source,
67
- workspace: commander_1.program.opts().workspace
68
- }), disk_1.disk);
57
+ types: commander_1.program.opts().types
58
+ }, disk_1.disk);
69
59
  var templateObject_1;
@@ -0,0 +1,3 @@
1
+ import type { Disk } from '../lib/disk';
2
+ import type { Syncpack } from '../types';
3
+ export declare function listCli(input: Partial<Syncpack.Config.Cli>, disk: Disk): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ exports.__esModule = true;
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");
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;
@@ -1,3 +1,2 @@
1
- import type { Disk } from '../lib/disk';
2
- import type { ProgramInput } from '../lib/get-input';
3
- export declare function list(input: ProgramInput, disk: Disk): void;
1
+ import type { Syncpack } from '../types';
2
+ export declare function list(ctx: Syncpack.Ctx): Syncpack.Ctx;