syncpack 9.8.4 → 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 (212) hide show
  1. package/LICENSE +12 -13
  2. package/README.md +17 -19
  3. package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +2 -2
  4. package/dist/bin-fix-mismatches/fix-mismatches-cli.js +3 -1
  5. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -2
  6. package/dist/bin-fix-mismatches/fix-mismatches.js +44 -25
  7. package/dist/bin-format/format-cli.d.ts +2 -2
  8. package/dist/bin-format/format-cli.js +2 -1
  9. package/dist/bin-format/format.d.ts +2 -2
  10. package/dist/bin-format/format.js +7 -4
  11. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.d.ts +2 -2
  12. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +2 -1
  13. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -2
  14. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +29 -25
  15. package/dist/bin-list/list-cli.d.ts +2 -2
  16. package/dist/bin-list/list-cli.js +2 -1
  17. package/dist/bin-list/list.d.ts +2 -2
  18. package/dist/bin-list/list.js +58 -52
  19. package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +2 -2
  20. package/dist/bin-list-mismatches/list-mismatches-cli.js +2 -1
  21. package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -2
  22. package/dist/bin-list-mismatches/list-mismatches.js +72 -105
  23. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +2 -2
  24. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +2 -1
  25. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -2
  26. package/dist/bin-set-semver-ranges/set-semver-ranges.js +17 -3
  27. package/dist/config/get-custom-types.d.ts +9 -0
  28. package/dist/config/get-custom-types.js +49 -0
  29. package/dist/config/get-enabled-types.d.ts +3 -0
  30. package/dist/config/get-enabled-types.js +48 -0
  31. package/dist/config/get-filter.d.ts +2 -0
  32. package/dist/config/get-filter.js +13 -0
  33. package/dist/config/get-indent.d.ts +2 -0
  34. package/dist/config/get-indent.js +12 -0
  35. package/dist/config/get-semver-range.d.ts +3 -0
  36. package/dist/config/get-semver-range.js +12 -0
  37. package/dist/config/get-sort-az.d.ts +2 -0
  38. package/dist/config/get-sort-az.js +18 -0
  39. package/dist/config/get-sort-first.d.ts +2 -0
  40. package/dist/config/get-sort-first.js +10 -0
  41. package/dist/config/get-source.d.ts +2 -0
  42. package/dist/config/get-source.js +13 -0
  43. package/dist/config/types.d.ts +106 -0
  44. package/dist/constants.d.ts +1 -0
  45. package/dist/constants.js +1 -0
  46. package/dist/get-context/index.d.ts +8 -16
  47. package/dist/get-context/index.js +8 -31
  48. package/dist/get-package-json-files/get-file-paths.d.ts +13 -0
  49. package/dist/get-package-json-files/get-file-paths.js +30 -0
  50. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +3 -0
  51. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +17 -0
  52. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +3 -0
  53. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +22 -0
  54. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +3 -0
  55. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +18 -0
  56. package/dist/get-package-json-files/get-patterns/index.d.ts +10 -0
  57. package/dist/get-package-json-files/get-patterns/index.js +35 -0
  58. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-json-safe.d.ts +3 -4
  59. package/dist/get-package-json-files/get-patterns/read-json-safe.js +14 -0
  60. package/dist/get-package-json-files/get-patterns/read-yaml-safe.d.ts +3 -0
  61. package/dist/get-package-json-files/get-patterns/read-yaml-safe.js +12 -0
  62. package/dist/get-package-json-files/index.d.ts +6 -0
  63. package/dist/get-package-json-files/index.js +18 -0
  64. package/dist/{get-context/get-package-json-files/package-json-file → get-package-json-files}/instance.d.ts +6 -8
  65. package/dist/get-package-json-files/instance.js +23 -0
  66. 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
  67. package/dist/get-package-json-files/package-json-file.js +45 -0
  68. package/dist/get-semver-groups/catch-all.d.ts +4 -0
  69. package/dist/get-semver-groups/catch-all.js +11 -0
  70. package/dist/get-semver-groups/filtered-out.d.ts +13 -0
  71. package/dist/get-semver-groups/filtered-out.js +29 -0
  72. package/dist/get-semver-groups/ignored.d.ts +11 -0
  73. package/dist/get-semver-groups/ignored.js +22 -0
  74. package/dist/get-semver-groups/index.d.ts +32 -0
  75. package/dist/get-semver-groups/index.js +90 -0
  76. package/dist/get-semver-groups/with-range.d.ts +11 -0
  77. package/dist/get-semver-groups/with-range.js +55 -0
  78. package/dist/get-version-groups/banned.d.ts +11 -0
  79. package/dist/get-version-groups/banned.js +24 -0
  80. package/dist/get-version-groups/catch-all.d.ts +4 -0
  81. package/dist/get-version-groups/catch-all.js +11 -0
  82. package/dist/get-version-groups/filtered-out.d.ts +13 -0
  83. package/dist/get-version-groups/filtered-out.js +31 -0
  84. package/dist/get-version-groups/ignored.d.ts +11 -0
  85. package/dist/get-version-groups/ignored.js +24 -0
  86. package/dist/get-version-groups/index.d.ts +57 -0
  87. package/dist/get-version-groups/index.js +119 -0
  88. package/dist/get-version-groups/lib/delete.d.ts +2 -0
  89. package/dist/get-version-groups/lib/delete.js +4 -0
  90. package/dist/get-version-groups/lib/get-highest-version.d.ts +2 -0
  91. package/dist/get-version-groups/lib/get-highest-version.js +13 -0
  92. package/dist/get-version-groups/lib/get-lowest-version.d.ts +2 -0
  93. package/dist/get-version-groups/lib/get-lowest-version.js +13 -0
  94. package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.js +3 -2
  95. package/dist/get-version-groups/lib/get-unique-versions.d.ts +2 -0
  96. package/dist/get-version-groups/lib/get-unique-versions.js +8 -0
  97. package/dist/get-version-groups/lib/group-by.d.ts +1 -0
  98. package/dist/get-version-groups/lib/group-by.js +11 -0
  99. package/dist/get-version-groups/lib/sort.d.ts +1 -0
  100. package/dist/get-version-groups/lib/sort.js +44 -0
  101. package/dist/get-version-groups/pinned.d.ts +11 -0
  102. package/dist/get-version-groups/pinned.js +43 -0
  103. package/dist/get-version-groups/snapped-to.d.ts +11 -0
  104. package/dist/get-version-groups/snapped-to.js +52 -0
  105. package/dist/get-version-groups/standard.d.ts +11 -0
  106. package/dist/get-version-groups/standard.js +95 -0
  107. package/dist/index.d.ts +2 -0
  108. package/dist/lib/$R.d.ts +12 -0
  109. package/dist/lib/$R.js +34 -0
  110. package/dist/lib/disk.d.ts +3 -2
  111. package/dist/lib/disk.js +1 -1
  112. package/dist/lib/exit-if-invalid.d.ts +2 -2
  113. package/dist/lib/is-semver.d.ts +5 -3
  114. package/dist/lib/is-semver.js +18 -4
  115. package/dist/lib/log.d.ts +4 -8
  116. package/dist/lib/log.js +4 -30
  117. package/dist/lib/set-semver-range.d.ts +2 -2
  118. package/dist/lib/write-if-changed.d.ts +2 -2
  119. package/dist/lib/write-if-changed.js +6 -25
  120. package/dist/strategy/lib/get-non-empty-string-prop.d.ts +3 -0
  121. package/dist/strategy/lib/get-non-empty-string-prop.js +12 -0
  122. package/dist/strategy/name-and-version-props.d.ts +12 -0
  123. package/dist/strategy/name-and-version-props.js +50 -0
  124. package/dist/strategy/named-version-string.d.ts +11 -0
  125. package/dist/strategy/named-version-string.js +53 -0
  126. package/dist/strategy/unnamed-version-string.d.ts +11 -0
  127. package/dist/strategy/unnamed-version-string.js +48 -0
  128. package/dist/strategy/versions-by-name.d.ts +11 -0
  129. package/dist/strategy/versions-by-name.js +29 -0
  130. package/package.json +23 -20
  131. package/dist/get-context/$R.d.ts +0 -13
  132. package/dist/get-context/$R.js +0 -34
  133. package/dist/get-context/get-config/get-core-types.d.ts +0 -36
  134. package/dist/get-context/get-config/get-core-types.js +0 -38
  135. package/dist/get-context/get-config/get-custom-types.d.ts +0 -4
  136. package/dist/get-context/get-config/get-custom-types.js +0 -16
  137. package/dist/get-context/get-config/get-enabled-types.d.ts +0 -4
  138. package/dist/get-context/get-config/get-enabled-types.js +0 -17
  139. package/dist/get-context/get-config/index.d.ts +0 -9
  140. package/dist/get-context/get-config/index.js +0 -91
  141. package/dist/get-context/get-config/path-strategy/index.d.ts +0 -8
  142. package/dist/get-context/get-config/path-strategy/index.js +0 -18
  143. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.d.ts +0 -4
  144. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.js +0 -11
  145. package/dist/get-context/get-config/path-strategy/name-and-version-props.d.ts +0 -2
  146. package/dist/get-context/get-config/path-strategy/name-and-version-props.js +0 -40
  147. package/dist/get-context/get-config/path-strategy/name-and-version-string.d.ts +0 -2
  148. package/dist/get-context/get-config/path-strategy/name-and-version-string.js +0 -44
  149. package/dist/get-context/get-config/path-strategy/types.d.ts +0 -15
  150. package/dist/get-context/get-config/path-strategy/version-string.d.ts +0 -2
  151. package/dist/get-context/get-config/path-strategy/version-string.js +0 -44
  152. package/dist/get-context/get-config/path-strategy/versions-by-name.d.ts +0 -2
  153. package/dist/get-context/get-config/path-strategy/versions-by-name.js +0 -23
  154. package/dist/get-context/get-config/schema/base-group.d.ts +0 -7
  155. package/dist/get-context/get-config/schema/base-group.js +0 -10
  156. package/dist/get-context/get-config/schema/index.d.ts +0 -1540
  157. package/dist/get-context/get-config/schema/index.js +0 -81
  158. package/dist/get-context/get-config/schema/lib/non-empty-string.d.ts +0 -2
  159. package/dist/get-context/get-config/schema/lib/non-empty-string.js +0 -5
  160. package/dist/get-context/get-config/schema/paths.d.ts +0 -89
  161. package/dist/get-context/get-config/schema/paths.js +0 -33
  162. package/dist/get-context/get-config/schema/semver-group.d.ts +0 -119
  163. package/dist/get-context/get-config/schema/semver-group.js +0 -43
  164. package/dist/get-context/get-config/schema/semver-range.d.ts +0 -2
  165. package/dist/get-context/get-config/schema/semver-range.js +0 -16
  166. package/dist/get-context/get-config/schema/version-group.d.ts +0 -230
  167. package/dist/get-context/get-config/schema/version-group.js +0 -36
  168. package/dist/get-context/get-groups/base-group.d.ts +0 -22
  169. package/dist/get-context/get-groups/base-group.js +0 -39
  170. package/dist/get-context/get-groups/index.d.ts +0 -12
  171. package/dist/get-context/get-groups/index.js +0 -51
  172. package/dist/get-context/get-groups/semver-group.d.ts +0 -15
  173. package/dist/get-context/get-groups/semver-group.js +0 -46
  174. package/dist/get-context/get-groups/version-group/index.d.ts +0 -15
  175. package/dist/get-context/get-groups/version-group/index.js +0 -36
  176. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.d.ts +0 -3
  177. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +0 -42
  178. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.d.ts +0 -3
  179. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.js +0 -44
  180. package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +0 -35
  181. package/dist/get-context/get-groups/version-group/instance-group/index.js +0 -88
  182. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +0 -4
  183. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +0 -38
  184. package/dist/get-context/get-package-json-files/get-file-paths.d.ts +0 -14
  185. package/dist/get-context/get-package-json-files/get-file-paths.js +0 -40
  186. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +0 -4
  187. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +0 -16
  188. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +0 -4
  189. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +0 -21
  190. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +0 -4
  191. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +0 -17
  192. package/dist/get-context/get-package-json-files/get-patterns/index.d.ts +0 -11
  193. package/dist/get-context/get-package-json-files/get-patterns/index.js +0 -43
  194. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.d.ts +0 -1
  195. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.js +0 -8
  196. package/dist/get-context/get-package-json-files/get-patterns/props.d.ts +0 -6
  197. package/dist/get-context/get-package-json-files/get-patterns/props.js +0 -24
  198. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.js +0 -17
  199. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.d.ts +0 -4
  200. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +0 -11
  201. package/dist/get-context/get-package-json-files/index.d.ts +0 -7
  202. package/dist/get-context/get-package-json-files/index.js +0 -16
  203. package/dist/get-context/get-package-json-files/package-json-file/index.js +0 -63
  204. package/dist/get-context/get-package-json-files/package-json-file/instance.js +0 -46
  205. package/dist/lib/error.d.ts +0 -12
  206. package/dist/lib/error.js +0 -25
  207. package/dist/types.d.ts +0 -90
  208. /package/dist/{get-context/get-config/path-strategy → config}/types.js +0 -0
  209. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.d.ts +0 -0
  210. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.js +0 -0
  211. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.d.ts +0 -0
  212. /package/dist/{types.js → index.js} +0 -0
package/LICENSE CHANGED
@@ -1,21 +1,20 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 Jamie Mason
3
+ Copyright (c) 2017-2023 Jamie Mason
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
11
 
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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,36 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fixMismatches = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const is_object_1 = require("expect-more/dist/is-object");
6
- const is_undefined_1 = require("expect-more/dist/is-undefined");
7
- const _R_1 = require("../get-context/$R");
4
+ const is_object_1 = require("tightrope/guard/is-object");
5
+ const is_undefined_1 = require("tightrope/guard/is-undefined");
6
+ const get_version_groups_1 = require("../get-version-groups");
7
+ const delete_1 = require("../get-version-groups/lib/delete");
8
8
  function fixMismatches(ctx) {
9
- ctx.versionGroups.forEach((versionGroup) => {
10
- const invalidGroups = versionGroup.getInvalidInstanceGroups();
11
- // Nothing to do if there are no mismatches
12
- if (invalidGroups.length === 0)
13
- return;
14
- // Set the correct version on each instance.
15
- invalidGroups.forEach((instanceGroup) => {
16
- if (!instanceGroup.hasUnsupportedVersion()) {
17
- (0, ts_belt_1.pipe)(instanceGroup.getExpectedVersion(), ts_belt_1.R.tap((nextVersion) => {
18
- instanceGroup.instances.forEach((instance) => instance.setVersion(nextVersion));
19
- }), _R_1.$R.tapErrVerbose);
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
+ });
20
38
  }
21
39
  });
22
40
  });
23
- /** Remove eg `{"dependencies": {}, "devDependencies": {}}` */
24
- ctx.packageJsonFiles.forEach((packageJsonFile) => {
25
- const contents = packageJsonFile.contents;
26
- Object.keys(contents).forEach((key) => {
27
- const value = contents[key];
28
- if ((0, is_object_1.isObject)(value) &&
29
- Object.values(value).every(is_undefined_1.isUndefined)) {
30
- delete contents[key];
31
- }
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
+ });
32
51
  });
33
- });
52
+ }
34
53
  return ctx;
35
54
  }
36
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;
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.format = void 0;
4
- const is_array_1 = require("expect-more/dist/is-array");
5
- const is_non_empty_string_1 = require("expect-more/dist/is-non-empty-string");
6
- const is_object_1 = require("expect-more/dist/is-object");
4
+ const is_array_1 = require("tightrope/guard/is-array");
5
+ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
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;
@@ -27,68 +27,74 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.list = void 0;
30
- const ts_belt_1 = require("@mobily/ts-belt");
31
30
  const chalk_1 = __importDefault(require("chalk"));
31
+ const uniq_1 = require("tightrope/array/uniq");
32
+ const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
32
33
  const constants_1 = require("../constants");
33
- const _R_1 = require("../get-context/$R");
34
+ const get_version_groups_1 = require("../get-version-groups");
34
35
  const log = __importStar(require("../lib/log"));
36
+ const sort_by_name_1 = require("../lib/sort-by-name");
35
37
  function list(ctx) {
36
- const hasUserGroups = ctx.versionGroups.length > 1;
37
- ctx.versionGroups.forEach((versionGroup, i) => {
38
- const instanceGroups = versionGroup.getAllInstanceGroups();
39
- // Nothing to do if empty
40
- if (instanceGroups.length === 0)
41
- 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) => {
42
41
  // Annotate each group
43
42
  hasUserGroups && log.versionGroupHeader(versionGroup, i);
44
- instanceGroups.forEach((instanceGroup) => {
45
- // Record that this project has mismatches, so that eg. the CLI can exit
46
- // with the correct status code.
47
- 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)
48
49
  ctx.isInvalid = true;
49
- if (versionGroup.isBanned())
50
- return logBanned(instanceGroup);
51
- if (versionGroup.isIgnored())
52
- return logIgnored(instanceGroup);
53
- if (versionGroup.isUnpinned())
54
- return logUnpinned(instanceGroup);
55
- if (instanceGroup.hasMismatchingVersions()) {
56
- return instanceGroup.hasUnsupportedVersion()
57
- ? logUnsupportedMismatches(instanceGroup)
58
- : 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)));
59
95
  }
60
- logVersionMatch(instanceGroup);
61
96
  });
62
97
  });
63
98
  return ctx;
64
- function logVersionMatch(instanceGroup) {
65
- console.log((0, chalk_1.default) `{dim -} {white ${instanceGroup.name}} {dim ${instanceGroup.getUniqueVersions()}}`);
66
- }
67
- function logVersionMismatch(instanceGroup) {
68
- (0, ts_belt_1.pipe)(instanceGroup.getExpectedVersion(), ts_belt_1.R.tap((expectedVersion) => {
69
- const uniqueVersions = instanceGroup.getUniqueVersions();
70
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} ${uniqueVersions
71
- .map((version) => version === expectedVersion
72
- ? chalk_1.default.green(version)
73
- : chalk_1.default.red(version))
74
- .join(chalk_1.default.dim(', '))}`);
75
- }), _R_1.$R.tapErrVerbose);
76
- }
77
- function logIgnored(instanceGroup) {
78
- console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip} ${instanceGroup.name}} is ignored in this version group`);
79
- }
80
- function logBanned(instanceGroup) {
81
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red is banned in this version group}`);
82
- }
83
- function logUnpinned(instanceGroup) {
84
- const pinVersion = ts_belt_1.O.getExn(instanceGroup.versionGroup.getPinnedVersion());
85
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red is pinned to ${pinVersion} in this version group}`);
86
- }
87
- function logUnsupportedMismatches(instanceGroup) {
88
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red has mismatched versions which syncpack cannot fix: ${instanceGroup
89
- .getUniqueVersions()
90
- .map((version) => chalk_1.default.yellow(version))
91
- .join(chalk_1.default.dim(', '))}}`);
92
- }
93
99
  }
94
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;