syncpack 9.8.6 → 10.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 (184) hide show
  1. package/README.md +17 -19
  2. package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +2 -2
  3. package/dist/bin-fix-mismatches/fix-mismatches-cli.js +3 -1
  4. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -2
  5. package/dist/bin-fix-mismatches/fix-mismatches.js +42 -24
  6. package/dist/bin-format/format-cli.d.ts +2 -2
  7. package/dist/bin-format/format-cli.js +2 -1
  8. package/dist/bin-format/format.d.ts +2 -2
  9. package/dist/bin-format/format.js +4 -1
  10. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.d.ts +2 -2
  11. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +2 -1
  12. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -2
  13. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +29 -25
  14. package/dist/bin-list/list-cli.d.ts +2 -2
  15. package/dist/bin-list/list-cli.js +2 -1
  16. package/dist/bin-list/list.d.ts +2 -2
  17. package/dist/bin-list/list.js +58 -54
  18. package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +2 -2
  19. package/dist/bin-list-mismatches/list-mismatches-cli.js +2 -1
  20. package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -2
  21. package/dist/bin-list-mismatches/list-mismatches.js +72 -106
  22. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +2 -2
  23. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +2 -1
  24. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -2
  25. package/dist/bin-set-semver-ranges/set-semver-ranges.js +17 -3
  26. package/dist/config/get-custom-types.d.ts +9 -0
  27. package/dist/config/get-custom-types.js +49 -0
  28. package/dist/config/get-enabled-types.d.ts +3 -0
  29. package/dist/config/get-enabled-types.js +48 -0
  30. package/dist/config/get-filter.d.ts +2 -0
  31. package/dist/config/get-filter.js +13 -0
  32. package/dist/config/get-indent.d.ts +2 -0
  33. package/dist/config/get-indent.js +12 -0
  34. package/dist/config/get-semver-range.d.ts +3 -0
  35. package/dist/config/get-semver-range.js +12 -0
  36. package/dist/config/get-sort-az.d.ts +2 -0
  37. package/dist/config/get-sort-az.js +18 -0
  38. package/dist/config/get-sort-first.d.ts +2 -0
  39. package/dist/config/get-sort-first.js +10 -0
  40. package/dist/config/get-source.d.ts +2 -0
  41. package/dist/config/get-source.js +13 -0
  42. package/dist/config/types.d.ts +106 -0
  43. package/dist/constants.d.ts +1 -0
  44. package/dist/constants.js +1 -0
  45. package/dist/get-context/index.d.ts +8 -16
  46. package/dist/get-context/index.js +7 -33
  47. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.d.ts +3 -3
  48. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.js +4 -4
  49. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-lerna-patterns.d.ts +1 -1
  50. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-lerna-patterns.js +1 -1
  51. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-pnpm-patterns.d.ts +1 -1
  52. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-pnpm-patterns.js +1 -1
  53. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-yarn-patterns.d.ts +1 -1
  54. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-yarn-patterns.js +1 -1
  55. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.d.ts +3 -3
  56. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.js +4 -3
  57. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-json-safe.d.ts +1 -1
  58. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-yaml-safe.d.ts +1 -1
  59. package/dist/{get-context/get-package-json-files → get-package-json-files}/index.d.ts +3 -3
  60. package/dist/{get-context/get-package-json-files → get-package-json-files}/index.js +1 -1
  61. package/dist/{get-context/get-package-json-files/package-json-file → get-package-json-files}/instance.d.ts +6 -8
  62. package/dist/get-package-json-files/instance.js +23 -0
  63. package/dist/{get-context/get-package-json-files/package-json-file/index.d.ts → get-package-json-files/package-json-file.d.ts} +7 -9
  64. package/dist/get-package-json-files/package-json-file.js +45 -0
  65. package/dist/get-semver-groups/catch-all.d.ts +4 -0
  66. package/dist/get-semver-groups/catch-all.js +11 -0
  67. package/dist/get-semver-groups/filtered-out.d.ts +13 -0
  68. package/dist/get-semver-groups/filtered-out.js +29 -0
  69. package/dist/get-semver-groups/ignored.d.ts +11 -0
  70. package/dist/get-semver-groups/ignored.js +22 -0
  71. package/dist/get-semver-groups/index.d.ts +32 -0
  72. package/dist/get-semver-groups/index.js +90 -0
  73. package/dist/get-semver-groups/with-range.d.ts +11 -0
  74. package/dist/get-semver-groups/with-range.js +55 -0
  75. package/dist/get-version-groups/banned.d.ts +11 -0
  76. package/dist/get-version-groups/banned.js +24 -0
  77. package/dist/get-version-groups/catch-all.d.ts +4 -0
  78. package/dist/get-version-groups/catch-all.js +11 -0
  79. package/dist/get-version-groups/filtered-out.d.ts +13 -0
  80. package/dist/get-version-groups/filtered-out.js +31 -0
  81. package/dist/get-version-groups/ignored.d.ts +11 -0
  82. package/dist/get-version-groups/ignored.js +24 -0
  83. package/dist/get-version-groups/index.d.ts +57 -0
  84. package/dist/get-version-groups/index.js +119 -0
  85. package/dist/get-version-groups/lib/delete.d.ts +2 -0
  86. package/dist/get-version-groups/lib/delete.js +4 -0
  87. package/dist/get-version-groups/lib/get-highest-version.js +13 -0
  88. package/dist/get-version-groups/lib/get-lowest-version.js +13 -0
  89. package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.js +3 -2
  90. package/dist/get-version-groups/lib/get-unique-versions.d.ts +2 -0
  91. package/dist/get-version-groups/lib/get-unique-versions.js +8 -0
  92. package/dist/get-version-groups/lib/group-by.d.ts +1 -0
  93. package/dist/get-version-groups/lib/group-by.js +11 -0
  94. package/dist/get-version-groups/lib/sort.d.ts +1 -0
  95. package/dist/get-version-groups/lib/sort.js +44 -0
  96. package/dist/get-version-groups/pinned.d.ts +11 -0
  97. package/dist/get-version-groups/pinned.js +43 -0
  98. package/dist/get-version-groups/snapped-to.d.ts +11 -0
  99. package/dist/get-version-groups/snapped-to.js +52 -0
  100. package/dist/get-version-groups/standard.d.ts +11 -0
  101. package/dist/get-version-groups/standard.js +95 -0
  102. package/dist/index.d.ts +2 -0
  103. package/dist/{get-context → lib}/$R.d.ts +2 -2
  104. package/dist/{get-context → lib}/$R.js +3 -4
  105. package/dist/lib/disk.d.ts +3 -2
  106. package/dist/lib/exit-if-invalid.d.ts +2 -2
  107. package/dist/lib/is-semver.d.ts +5 -3
  108. package/dist/lib/is-semver.js +17 -3
  109. package/dist/lib/log.d.ts +4 -8
  110. package/dist/lib/log.js +3 -29
  111. package/dist/lib/set-semver-range.d.ts +2 -2
  112. package/dist/lib/write-if-changed.d.ts +2 -2
  113. package/dist/lib/write-if-changed.js +6 -25
  114. package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.d.ts +1 -1
  115. package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.js +1 -2
  116. package/dist/strategy/name-and-version-props.d.ts +12 -0
  117. package/dist/strategy/name-and-version-props.js +50 -0
  118. package/dist/strategy/named-version-string.d.ts +11 -0
  119. package/dist/{get-context/get-config/path-strategy/name-and-version-string.js → strategy/named-version-string.js} +26 -22
  120. package/dist/strategy/unnamed-version-string.d.ts +11 -0
  121. package/dist/strategy/unnamed-version-string.js +48 -0
  122. package/dist/strategy/versions-by-name.d.ts +11 -0
  123. package/dist/strategy/versions-by-name.js +29 -0
  124. package/package.json +8 -4
  125. package/dist/get-context/get-config/get-core-types.d.ts +0 -36
  126. package/dist/get-context/get-config/get-core-types.js +0 -38
  127. package/dist/get-context/get-config/get-custom-types.d.ts +0 -4
  128. package/dist/get-context/get-config/get-custom-types.js +0 -16
  129. package/dist/get-context/get-config/get-enabled-types.d.ts +0 -4
  130. package/dist/get-context/get-config/get-enabled-types.js +0 -17
  131. package/dist/get-context/get-config/index.d.ts +0 -8
  132. package/dist/get-context/get-config/index.js +0 -98
  133. package/dist/get-context/get-config/path-strategy/index.d.ts +0 -8
  134. package/dist/get-context/get-config/path-strategy/index.js +0 -18
  135. package/dist/get-context/get-config/path-strategy/name-and-version-props.d.ts +0 -2
  136. package/dist/get-context/get-config/path-strategy/name-and-version-props.js +0 -44
  137. package/dist/get-context/get-config/path-strategy/name-and-version-string.d.ts +0 -2
  138. package/dist/get-context/get-config/path-strategy/types.d.ts +0 -14
  139. package/dist/get-context/get-config/path-strategy/version-string.d.ts +0 -2
  140. package/dist/get-context/get-config/path-strategy/version-string.js +0 -49
  141. package/dist/get-context/get-config/path-strategy/versions-by-name.d.ts +0 -2
  142. package/dist/get-context/get-config/path-strategy/versions-by-name.js +0 -21
  143. package/dist/get-context/get-config/schema/base-group.d.ts +0 -7
  144. package/dist/get-context/get-config/schema/base-group.js +0 -10
  145. package/dist/get-context/get-config/schema/index.d.ts +0 -1540
  146. package/dist/get-context/get-config/schema/index.js +0 -81
  147. package/dist/get-context/get-config/schema/lib/non-empty-string.d.ts +0 -2
  148. package/dist/get-context/get-config/schema/lib/non-empty-string.js +0 -5
  149. package/dist/get-context/get-config/schema/paths.d.ts +0 -89
  150. package/dist/get-context/get-config/schema/paths.js +0 -33
  151. package/dist/get-context/get-config/schema/semver-group.d.ts +0 -119
  152. package/dist/get-context/get-config/schema/semver-group.js +0 -43
  153. package/dist/get-context/get-config/schema/semver-range.d.ts +0 -2
  154. package/dist/get-context/get-config/schema/semver-range.js +0 -16
  155. package/dist/get-context/get-config/schema/version-group.d.ts +0 -230
  156. package/dist/get-context/get-config/schema/version-group.js +0 -36
  157. package/dist/get-context/get-groups/base-group.d.ts +0 -22
  158. package/dist/get-context/get-groups/base-group.js +0 -39
  159. package/dist/get-context/get-groups/index.d.ts +0 -11
  160. package/dist/get-context/get-groups/index.js +0 -53
  161. package/dist/get-context/get-groups/semver-group.d.ts +0 -15
  162. package/dist/get-context/get-groups/semver-group.js +0 -46
  163. package/dist/get-context/get-groups/version-group/index.d.ts +0 -15
  164. package/dist/get-context/get-groups/version-group/index.js +0 -40
  165. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +0 -42
  166. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.js +0 -44
  167. package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +0 -34
  168. package/dist/get-context/get-groups/version-group/instance-group/index.js +0 -103
  169. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +0 -4
  170. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +0 -38
  171. package/dist/get-context/get-package-json-files/package-json-file/index.js +0 -65
  172. package/dist/get-context/get-package-json-files/package-json-file/instance.js +0 -46
  173. package/dist/lib/error.d.ts +0 -12
  174. package/dist/lib/error.js +0 -25
  175. package/dist/types.d.ts +0 -90
  176. /package/dist/{get-context/get-config/path-strategy → config}/types.js +0 -0
  177. /package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-json-safe.js +0 -0
  178. /package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-yaml-safe.js +0 -0
  179. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.d.ts +0 -0
  180. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.js +0 -0
  181. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups/lib}/get-highest-version.d.ts +0 -0
  182. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups/lib}/get-lowest-version.d.ts +0 -0
  183. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.d.ts +0 -0
  184. /package/dist/{types.js → index.js} +0 -0
package/README.md CHANGED
@@ -10,28 +10,26 @@ npm install --save-dev syncpack
10
10
 
11
11
  ## Documentation
12
12
 
13
- Full information can be found in the documentation at
14
- https://jamiemason.github.io/syncpack/.
13
+ Full information can be found in the documentation at https://jamiemason.github.io/syncpack/.
15
14
 
16
15
  ## Commands
17
16
 
18
17
  ### [fix-mismatches](https://jamiemason.github.io/syncpack/fix-mismatches)
19
18
 
20
- Ensure that multiple packages requiring the same dependency define the same
21
- version, so that every package requires eg. `react@16.4.2`, instead of a
22
- combination of `react@16.4.2`, `react@0.15.9`, and `react@16.0.0`.
19
+ Ensure that multiple packages requiring the same dependency define the same version, so that every
20
+ package requires eg. `react@16.4.2`, instead of a combination of `react@16.4.2`, `react@0.15.9`, and
21
+ `react@16.0.0`.
23
22
 
24
23
  ### [format](https://jamiemason.github.io/syncpack/format)
25
24
 
26
- Organise package.json files according to a conventional format, where fields
27
- appear in a predictable order and nested fields are ordered alphabetically.
28
- Shorthand properties are used where available, such as the `"repository"` and
29
- `"bugs"` fields.
25
+ Organise package.json files according to a conventional format, where fields appear in a predictable
26
+ order and nested fields are ordered alphabetically. Shorthand properties are used where available,
27
+ such as the `"repository"` and `"bugs"` fields.
30
28
 
31
29
  ### [lint-semver-ranges](https://jamiemason.github.io/syncpack/lint-semver-ranges)
32
30
 
33
- Check whether dependency versions used within "dependencies", "devDependencies",
34
- etc follow a consistent format.
31
+ Check whether dependency versions used within "dependencies", "devDependencies", etc follow a
32
+ consistent format.
35
33
 
36
34
  ### [list](https://jamiemason.github.io/syncpack/list)
37
35
 
@@ -39,20 +37,20 @@ List all dependencies required by your packages.
39
37
 
40
38
  ### [list-mismatches](https://jamiemason.github.io/syncpack/list-mismatches)
41
39
 
42
- List dependencies which are required by multiple packages, where the version is
43
- not the same across every package.
40
+ List dependencies which are required by multiple packages, where the version is not the same across
41
+ every package.
44
42
 
45
43
  ### [set-semver-ranges](https://jamiemason.github.io/syncpack/set-semver-ranges)
46
44
 
47
- Ensure dependency versions used within `"dependencies"`, `"devDependencies"` etc
48
- follow a consistent format.
45
+ Ensure dependency versions used within `"dependencies"`, `"devDependencies"` etc follow a consistent
46
+ format.
49
47
 
50
48
  ## Breaking Changes
51
49
 
52
- Version [9.0.0](https://github.com/JamieMason/syncpack/releases/tag/9.0.0)
53
- required some breaking API changes to add support for a new
54
- [`customTypes`](https://jamiemason.github.io/syncpack/config/custom-types)
55
- feature, but they are very simple to make.
50
+ Version [9.0.0](https://github.com/JamieMason/syncpack/releases/tag/9.0.0) required some breaking
51
+ API changes to add support for a new
52
+ [`customTypes`](https://jamiemason.github.io/syncpack/config/custom-types) feature, but they are
53
+ very simple to make.
56
54
 
57
55
  ## Badges
58
56
 
@@ -1,3 +1,3 @@
1
+ import type { CliConfig } from '../config/types';
1
2
  import type { Disk } from '../lib/disk';
2
- import type { Syncpack } from '../types';
3
- export declare function fixMismatchesCli(input: Partial<Syncpack.Config.Cli>, disk: Disk): void;
3
+ export declare function fixMismatchesCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fixMismatchesCli = void 0;
4
+ const pipe_1 = require("tightrope/fn/pipe");
4
5
  const get_context_1 = require("../get-context");
6
+ const exit_if_invalid_1 = require("../lib/exit-if-invalid");
5
7
  const write_if_changed_1 = require("../lib/write-if-changed");
6
8
  const fix_mismatches_1 = require("./fix-mismatches");
7
9
  function fixMismatchesCli(input, disk) {
8
- (0, write_if_changed_1.writeIfChanged)((0, fix_mismatches_1.fixMismatches)((0, get_context_1.getContext)(input, disk)));
10
+ (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), fix_mismatches_1.fixMismatches, write_if_changed_1.writeIfChanged, exit_if_invalid_1.exitIfInvalid);
9
11
  }
10
12
  exports.fixMismatchesCli = fixMismatchesCli;
@@ -1,2 +1,2 @@
1
- import type { Syncpack } from '../types';
2
- export declare function fixMismatches(ctx: Syncpack.Ctx): Syncpack.Ctx;
1
+ import type { Context } from '../get-context';
2
+ export declare function fixMismatches(ctx: Context): Context;
@@ -1,37 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fixMismatches = void 0;
4
- const pipe_1 = require("tightrope/fn/pipe");
5
4
  const is_object_1 = require("tightrope/guard/is-object");
6
5
  const is_undefined_1 = require("tightrope/guard/is-undefined");
7
- const tap_1 = require("tightrope/result/tap");
8
- const _R_1 = require("../get-context/$R");
6
+ const get_version_groups_1 = require("../get-version-groups");
7
+ const delete_1 = require("../get-version-groups/lib/delete");
9
8
  function fixMismatches(ctx) {
10
- ctx.versionGroups.forEach((versionGroup) => {
11
- const invalidGroups = versionGroup.getInvalidInstanceGroups();
12
- // Nothing to do if there are no mismatches
13
- if (invalidGroups.length === 0)
14
- return;
15
- // Set the correct version on each instance.
16
- invalidGroups.forEach((instanceGroup) => {
17
- if (!instanceGroup.hasUnsupportedVersion()) {
18
- (0, pipe_1.pipe)(instanceGroup.getExpectedVersion(), (0, tap_1.tap)((nextVersion) => {
19
- instanceGroup.instances.forEach((instance) => instance.setVersion(nextVersion));
20
- }), _R_1.$R.tapErrVerbose);
9
+ const versionGroups = (0, get_version_groups_1.getVersionGroups)(ctx);
10
+ let shouldPruneEmpty = false;
11
+ versionGroups.forEach((versionGroup) => {
12
+ versionGroup.inspect().forEach((outcome) => {
13
+ if (!outcome.isValid) {
14
+ outcome.instances.forEach((instance) => {
15
+ switch (outcome.status) {
16
+ case 'HIGHEST_SEMVER_MISMATCH':
17
+ case 'LOWEST_SEMVER_MISMATCH':
18
+ case 'PINNED_MISMATCH':
19
+ case 'SNAPPED_TO_MISMATCH':
20
+ case 'WORKSPACE_MISMATCH': {
21
+ instance.setVersion(outcome.expectedVersion);
22
+ break;
23
+ }
24
+ case 'BANNED': {
25
+ shouldPruneEmpty = true;
26
+ instance.setVersion(delete_1.DELETE);
27
+ break;
28
+ }
29
+ case 'UNSUPPORTED_MISMATCH': {
30
+ // @TODO Output something when fix-mismatches faces an unsupported mismatch
31
+ ctx.isInvalid = true;
32
+ break;
33
+ }
34
+ // @TODO case 'SEMVER_UNSATISFIED': break;
35
+ // @TODO case 'WORKSPACE_UNSATISFIED': break;
36
+ }
37
+ });
21
38
  }
22
39
  });
23
40
  });
24
- /** Remove eg `{"dependencies": {}, "devDependencies": {}}` */
25
- ctx.packageJsonFiles.forEach((packageJsonFile) => {
26
- const contents = packageJsonFile.contents;
27
- Object.keys(contents).forEach((key) => {
28
- const value = contents[key];
29
- if ((0, is_object_1.isObject)(value) &&
30
- Object.values(value).every(is_undefined_1.isUndefined)) {
31
- delete contents[key];
32
- }
41
+ /** Remove empty objects such as `{"dependencies": {}}` left after deleting */
42
+ if (shouldPruneEmpty) {
43
+ ctx.packageJsonFiles.forEach((packageJsonFile) => {
44
+ const contents = packageJsonFile.contents;
45
+ Object.keys(contents).forEach((key) => {
46
+ const value = contents[key];
47
+ if ((0, is_object_1.isObject)(value) && Object.values(value).every(is_undefined_1.isUndefined)) {
48
+ delete contents[key];
49
+ }
50
+ });
33
51
  });
34
- });
52
+ }
35
53
  return ctx;
36
54
  }
37
55
  exports.fixMismatches = fixMismatches;
@@ -1,3 +1,3 @@
1
+ import type { CliConfig } from '../config/types';
1
2
  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;
3
+ export declare function formatCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatCli = void 0;
4
+ const pipe_1 = require("tightrope/fn/pipe");
4
5
  const get_context_1 = require("../get-context");
5
6
  const write_if_changed_1 = require("../lib/write-if-changed");
6
7
  const format_1 = require("./format");
7
8
  function formatCli(input, disk) {
8
- (0, write_if_changed_1.writeIfChanged)((0, format_1.format)((0, get_context_1.getContext)(input, disk)));
9
+ (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), format_1.format, write_if_changed_1.writeIfChanged);
9
10
  }
10
11
  exports.formatCli = formatCli;
@@ -1,2 +1,2 @@
1
- import type { Syncpack } from '../types';
2
- export declare function format(ctx: Syncpack.Ctx): Syncpack.Ctx;
1
+ import type { Context } from '../get-context';
2
+ export declare function format(ctx: Context): Context;
@@ -4,9 +4,12 @@ exports.format = void 0;
4
4
  const is_array_1 = require("tightrope/guard/is-array");
5
5
  const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
6
6
  const is_object_1 = require("tightrope/guard/is-object");
7
+ const get_sort_az_1 = require("../config/get-sort-az");
8
+ const get_sort_first_1 = require("../config/get-sort-first");
7
9
  function format(ctx) {
8
10
  const { packageJsonFiles } = ctx;
9
- const { sortAz, sortFirst } = ctx.config;
11
+ const sortAz = (0, get_sort_az_1.getSortAz)(ctx.config);
12
+ const sortFirst = (0, get_sort_first_1.getSortFirst)(ctx.config);
10
13
  packageJsonFiles.forEach((packageJsonFile) => {
11
14
  const { contents } = packageJsonFile;
12
15
  const sortedKeys = Object.keys(contents).sort();
@@ -1,3 +1,3 @@
1
+ import type { CliConfig } from '../config/types';
1
2
  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;
3
+ export declare function lintSemverRangesCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lintSemverRangesCli = void 0;
4
+ const pipe_1 = require("tightrope/fn/pipe");
4
5
  const get_context_1 = require("../get-context");
5
6
  const exit_if_invalid_1 = require("../lib/exit-if-invalid");
6
7
  const lint_semver_ranges_1 = require("./lint-semver-ranges");
7
8
  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
+ (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), lint_semver_ranges_1.lintSemverRanges, exit_if_invalid_1.exitIfInvalid);
9
10
  }
10
11
  exports.lintSemverRangesCli = lintSemverRangesCli;
@@ -1,2 +1,2 @@
1
- import type { Syncpack } from '../types';
2
- export declare function lintSemverRanges(ctx: Syncpack.Ctx): Syncpack.Ctx;
1
+ import type { Context } from '../get-context';
2
+ export declare function lintSemverRanges(ctx: Context): Context;
@@ -28,36 +28,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.lintSemverRanges = void 0;
30
30
  const chalk_1 = __importDefault(require("chalk"));
31
+ const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
31
32
  const constants_1 = require("../constants");
33
+ const get_semver_groups_1 = require("../get-semver-groups");
32
34
  const log = __importStar(require("../lib/log"));
35
+ const sort_by_name_1 = require("../lib/sort-by-name");
33
36
  function lintSemverRanges(ctx) {
34
- const hasUserGroups = ctx.semverGroups.length > 1;
35
- ctx.semverGroups.forEach((semverGroup, i) => {
36
- // Nothing to do if there are no mismatches
37
- if (!semverGroup.hasMismatches())
38
- return;
39
- // Record that this project has mismatches, so that eg. the CLI can exit
40
- // with the correct status code.
41
- ctx.isInvalid = true;
42
- // Annotate each group
43
- hasUserGroups && log.semverGroupHeader(semverGroup, i);
44
- // Log each group which has mismatches
45
- semverGroup.getMismatches().forEach(([name, mismatches]) => {
46
- // Log the dependency name
47
- log.invalid(name);
48
- // Log each of the dependencies mismatches
49
- mismatches.forEach((instance) => {
50
- logSemverRangeMismatch(instance, semverGroup);
51
- });
37
+ const semverGroups = (0, get_semver_groups_1.getSemverGroups)(ctx);
38
+ const hasUserGroups = (0, is_non_empty_array_1.isNonEmptyArray)(ctx.config.rcFile.semverGroups);
39
+ semverGroups.forEach((semverGroup, i) => {
40
+ semverGroup
41
+ .inspect()
42
+ .sort(sort_by_name_1.sortByName)
43
+ .forEach((report, ii) => {
44
+ // Allow eg. CLI to exit with the correct status code.
45
+ if (!report.isValid)
46
+ ctx.isInvalid = true;
47
+ switch (report.status) {
48
+ case 'WORKSPACE_SEMVER_RANGE_MISMATCH':
49
+ case 'SEMVER_RANGE_MISMATCH': {
50
+ // Annotate each group
51
+ if (ii === 0 && hasUserGroups)
52
+ log.semverGroupHeader(semverGroup, i);
53
+ console.log((0, chalk_1.default) `{red %s} %s {red %s} %s {green %s} {dim in %s of %s}`, constants_1.ICON.cross, report.name, report.instance.version, constants_1.ICON.rightArrow, report.expectedVersion, report.instance.strategy.path, report.instance.packageJsonFile.shortPath);
54
+ break;
55
+ }
56
+ case 'IGNORED':
57
+ case 'UNSUPPORTED_VERSION':
58
+ case 'VALID': {
59
+ // no action needed
60
+ break;
61
+ }
62
+ }
52
63
  });
53
64
  });
54
65
  return ctx;
55
66
  }
56
67
  exports.lintSemverRanges = lintSemverRanges;
57
- function logSemverRangeMismatch(instance, semverGroup) {
58
- const path = instance.pathDef.path;
59
- const shortPath = instance.packageJsonFile.shortPath;
60
- const actual = instance.version;
61
- const expected = semverGroup.getExpectedVersion(instance);
62
- console.log((0, chalk_1.default) ` {red ${actual}} ${constants_1.ICON.rightArrow} {green ${expected}} {dim in ${path} of ${shortPath}}`);
63
- }
@@ -1,3 +1,3 @@
1
+ import type { CliConfig } from '../config/types';
1
2
  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;
3
+ export declare function listCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listCli = void 0;
4
+ const pipe_1 = require("tightrope/fn/pipe");
4
5
  const get_context_1 = require("../get-context");
5
6
  const exit_if_invalid_1 = require("../lib/exit-if-invalid");
6
7
  const list_1 = require("./list");
7
8
  function listCli(input, disk) {
8
- (0, exit_if_invalid_1.exitIfInvalid)((0, list_1.list)((0, get_context_1.getContext)(input, disk)));
9
+ (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), list_1.list, exit_if_invalid_1.exitIfInvalid);
9
10
  }
10
11
  exports.listCli = listCli;
@@ -1,2 +1,2 @@
1
- import type { Syncpack } from '../types';
2
- export declare function list(ctx: Syncpack.Ctx): Syncpack.Ctx;
1
+ import type { Context } from '../get-context';
2
+ export declare function list(ctx: Context): Context;
@@ -28,69 +28,73 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.list = void 0;
30
30
  const chalk_1 = __importDefault(require("chalk"));
31
- const pipe_1 = require("tightrope/fn/pipe");
32
- const unwrap_1 = require("tightrope/option/unwrap");
33
- const tap_1 = require("tightrope/result/tap");
31
+ const uniq_1 = require("tightrope/array/uniq");
32
+ const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
34
33
  const constants_1 = require("../constants");
35
- const _R_1 = require("../get-context/$R");
34
+ const get_version_groups_1 = require("../get-version-groups");
36
35
  const log = __importStar(require("../lib/log"));
36
+ const sort_by_name_1 = require("../lib/sort-by-name");
37
37
  function list(ctx) {
38
- const hasUserGroups = ctx.versionGroups.length > 1;
39
- ctx.versionGroups.forEach((versionGroup, i) => {
40
- const instanceGroups = versionGroup.getAllInstanceGroups();
41
- // Nothing to do if empty
42
- if (instanceGroups.length === 0)
43
- return;
38
+ const versionGroups = (0, get_version_groups_1.getVersionGroups)(ctx);
39
+ const hasUserGroups = (0, is_non_empty_array_1.isNonEmptyArray)(ctx.config.rcFile.versionGroups);
40
+ versionGroups.forEach((versionGroup, i) => {
44
41
  // Annotate each group
45
42
  hasUserGroups && log.versionGroupHeader(versionGroup, i);
46
- instanceGroups.forEach((instanceGroup) => {
47
- // Record that this project has mismatches, so that eg. the CLI can exit
48
- // with the correct status code.
49
- if (instanceGroup.isInvalid())
43
+ versionGroup
44
+ .inspect()
45
+ .sort(sort_by_name_1.sortByName)
46
+ .forEach((report) => {
47
+ // Allow eg. CLI to exit with the correct status code.
48
+ if (!report.isValid)
50
49
  ctx.isInvalid = true;
51
- if (versionGroup.isBanned())
52
- return logBanned(instanceGroup);
53
- if (versionGroup.isIgnored())
54
- return logIgnored(instanceGroup);
55
- if (versionGroup.isUnpinned())
56
- return logUnpinned(instanceGroup);
57
- if (instanceGroup.hasMismatchingVersions()) {
58
- return instanceGroup.hasUnsupportedVersion()
59
- ? logUnsupportedMismatches(instanceGroup)
60
- : logVersionMismatch(instanceGroup);
50
+ switch (report.status) {
51
+ case 'HIGHEST_SEMVER_MISMATCH':
52
+ case 'LOWEST_SEMVER_MISMATCH':
53
+ case 'PINNED_MISMATCH':
54
+ case 'SNAPPED_TO_MISMATCH':
55
+ case 'WORKSPACE_MISMATCH': {
56
+ console.log((0, chalk_1.default) `{red %s %s} %s`, constants_1.ICON.cross, report.name, listColouredVersions(report.expectedVersion, report.instances));
57
+ break;
58
+ }
59
+ case 'BANNED': {
60
+ console.log((0, chalk_1.default) `{red %s %s} {dim.red is banned in this version group}`, constants_1.ICON.cross, report.name);
61
+ break;
62
+ }
63
+ // ignored completely
64
+ case 'FILTERED_OUT':
65
+ break;
66
+ case 'IGNORED': {
67
+ console.log((0, chalk_1.default) `{dim -} {dim %s} {white is ignored in this version group}`, report.name);
68
+ break;
69
+ }
70
+ case 'VALID': {
71
+ console.log((0, chalk_1.default) `{dim -} {white %s} {dim %s}`, report.name, report.instances?.[0]?.version);
72
+ break;
73
+ }
74
+ case 'UNSUPPORTED_MISMATCH': {
75
+ console.log((0, chalk_1.default) `{red %s %s} %s`, constants_1.ICON.cross, report.name, report.instances
76
+ .map((instance) => chalk_1.default.red(instance.version))
77
+ .join(chalk_1.default.dim(', ')));
78
+ break;
79
+ }
80
+ // @TODO case 'SEMVER_UNSATISFIED': break;
81
+ // @TODO case 'WORKSPACE_UNSATISFIED': break;
82
+ }
83
+ function listColouredVersions(pinVersion, instances) {
84
+ return getAllVersions(pinVersion, instances)
85
+ .map((version) => withColour(pinVersion, version))
86
+ .join(chalk_1.default.dim(', '));
87
+ }
88
+ function withColour(pinVersion, version) {
89
+ return version === pinVersion
90
+ ? chalk_1.default.green(version)
91
+ : chalk_1.default.red(version);
92
+ }
93
+ function getAllVersions(pinVersion, instances) {
94
+ return (0, uniq_1.uniq)([pinVersion].concat(instances.map((i) => i.version)));
61
95
  }
62
- logVersionMatch(instanceGroup);
63
96
  });
64
97
  });
65
98
  return ctx;
66
- function logVersionMatch(instanceGroup) {
67
- console.log((0, chalk_1.default) `{dim -} {white ${instanceGroup.name}} {dim ${instanceGroup.getUniqueVersions()}}`);
68
- }
69
- function logVersionMismatch(instanceGroup) {
70
- (0, pipe_1.pipe)(instanceGroup.getExpectedVersion(), (0, tap_1.tap)((expectedVersion) => {
71
- const uniqueVersions = instanceGroup.getUniqueVersions();
72
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} ${uniqueVersions
73
- .map((version) => version === expectedVersion
74
- ? chalk_1.default.green(version)
75
- : chalk_1.default.red(version))
76
- .join(chalk_1.default.dim(', '))}`);
77
- }), _R_1.$R.tapErrVerbose);
78
- }
79
- function logIgnored(instanceGroup) {
80
- console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip} ${instanceGroup.name}} is ignored in this version group`);
81
- }
82
- function logBanned(instanceGroup) {
83
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red is banned in this version group}`);
84
- }
85
- function logUnpinned(instanceGroup) {
86
- const pinVersion = (0, unwrap_1.unwrap)(instanceGroup.versionGroup.getPinnedVersion());
87
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red is pinned to ${pinVersion} in this version group}`);
88
- }
89
- function logUnsupportedMismatches(instanceGroup) {
90
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red has mismatched versions which syncpack cannot fix: ${instanceGroup
91
- .getUniqueVersions()
92
- .map((version) => chalk_1.default.yellow(version))
93
- .join(chalk_1.default.dim(', '))}}`);
94
- }
95
99
  }
96
100
  exports.list = list;
@@ -1,3 +1,3 @@
1
+ import type { CliConfig } from '../config/types';
1
2
  import type { Disk } from '../lib/disk';
2
- import type { Syncpack } from '../types';
3
- export declare function listMismatchesCli(input: Partial<Syncpack.Config.Cli>, disk: Disk): void;
3
+ export declare function listMismatchesCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listMismatchesCli = void 0;
4
+ const pipe_1 = require("tightrope/fn/pipe");
4
5
  const get_context_1 = require("../get-context");
5
6
  const exit_if_invalid_1 = require("../lib/exit-if-invalid");
6
7
  const list_mismatches_1 = require("./list-mismatches");
7
8
  function listMismatchesCli(input, disk) {
8
- (0, exit_if_invalid_1.exitIfInvalid)((0, list_mismatches_1.listMismatches)((0, get_context_1.getContext)(input, disk)));
9
+ (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), list_mismatches_1.listMismatches, exit_if_invalid_1.exitIfInvalid);
9
10
  }
10
11
  exports.listMismatchesCli = listMismatchesCli;
@@ -1,2 +1,2 @@
1
- import type { Syncpack } from '../types';
2
- export declare function listMismatches(ctx: Syncpack.Ctx): Syncpack.Ctx;
1
+ import type { Context } from '../get-context';
2
+ export declare function listMismatches(ctx: Context): Context;