syncpack 10.2.0 → 10.6.1

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 (180) hide show
  1. package/dist/bin-fix-mismatches/effects.d.ts +2 -0
  2. package/dist/bin-fix-mismatches/effects.js +112 -0
  3. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +4 -2
  4. package/dist/bin-fix-mismatches/fix-mismatches.js +38 -50
  5. package/dist/bin-fix-mismatches/index.js +28 -4
  6. package/dist/bin-format/format-cli.d.ts +4 -3
  7. package/dist/bin-format/format-cli.js +35 -4
  8. package/dist/bin-format/format.d.ts +3 -2
  9. package/dist/bin-format/format.js +25 -1
  10. package/dist/bin-format/index.js +27 -3
  11. package/dist/bin-lint/index.js +28 -4
  12. package/dist/bin-lint/lint.d.ts +4 -0
  13. package/dist/bin-lint/lint.js +44 -0
  14. package/dist/bin-lint-semver-ranges/effects.d.ts +2 -0
  15. package/dist/bin-lint-semver-ranges/effects.js +70 -0
  16. package/dist/bin-lint-semver-ranges/index.js +28 -4
  17. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +4 -2
  18. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +14 -39
  19. package/dist/bin-list/effects.d.ts +2 -0
  20. package/dist/bin-list/effects.js +112 -0
  21. package/dist/bin-list/index.js +28 -4
  22. package/dist/bin-list/list.d.ts +4 -2
  23. package/dist/bin-list/list.js +14 -72
  24. package/dist/bin-list-mismatches/effects.d.ts +2 -0
  25. package/dist/bin-list-mismatches/effects.js +136 -0
  26. package/dist/bin-list-mismatches/index.js +28 -4
  27. package/dist/bin-list-mismatches/list-mismatches.d.ts +4 -2
  28. package/dist/bin-list-mismatches/list-mismatches.js +14 -82
  29. package/dist/bin-prompt/effects.d.ts +2 -0
  30. package/dist/bin-prompt/effects.js +110 -0
  31. package/dist/bin-prompt/index.d.ts +2 -0
  32. package/dist/bin-prompt/index.js +80 -0
  33. package/dist/bin-prompt/prompt.d.ts +4 -0
  34. package/dist/bin-prompt/prompt.js +42 -0
  35. package/dist/bin-set-semver-ranges/effects.d.ts +2 -0
  36. package/dist/bin-set-semver-ranges/effects.js +61 -0
  37. package/dist/bin-set-semver-ranges/index.js +28 -4
  38. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +4 -2
  39. package/dist/bin-set-semver-ranges/set-semver-ranges.js +39 -22
  40. package/dist/bin.js +3 -0
  41. package/dist/config/get-custom-types.d.ts +2 -2
  42. package/dist/config/get-enabled-types.d.ts +12 -2
  43. package/dist/config/get-enabled-types.js +38 -4
  44. package/dist/config/get-filter.d.ts +2 -2
  45. package/dist/config/get-indent.d.ts +2 -2
  46. package/dist/config/get-semver-range.d.ts +2 -2
  47. package/dist/config/get-semver-range.js +4 -4
  48. package/dist/config/get-sort-az.d.ts +2 -2
  49. package/dist/config/get-sort-az.js +1 -0
  50. package/dist/config/get-sort-first.d.ts +2 -2
  51. package/dist/config/get-source.d.ts +2 -2
  52. package/dist/config/get-source.js +1 -2
  53. package/dist/config/types.d.ts +15 -7
  54. package/dist/config/types.js +26 -0
  55. package/dist/constants.d.ts +1 -1
  56. package/dist/constants.js +1 -1
  57. package/dist/create-program/effects.d.ts +42 -0
  58. package/dist/create-program/effects.js +2 -0
  59. package/dist/create-program/semver-ranges.d.ts +7 -0
  60. package/dist/create-program/semver-ranges.js +43 -0
  61. package/dist/create-program/versions.d.ts +7 -0
  62. package/dist/create-program/versions.js +48 -0
  63. package/dist/env/create-env.d.ts +21 -0
  64. package/dist/env/create-env.js +60 -0
  65. package/dist/env/default-env.d.ts +18 -0
  66. package/dist/env/default-env.js +95 -0
  67. package/dist/env/exit-if-invalid.d.ts +4 -0
  68. package/dist/env/exit-if-invalid.js +34 -0
  69. package/dist/env/tags.d.ts +58 -0
  70. package/dist/env/tags.js +50 -0
  71. package/dist/env/write-if-changed.d.ts +11 -0
  72. package/dist/env/write-if-changed.js +73 -0
  73. package/dist/error-handlers/create-error-handlers.d.ts +19 -0
  74. package/dist/error-handlers/create-error-handlers.js +57 -0
  75. package/dist/error-handlers/default-error-handlers.d.ts +2 -0
  76. package/dist/error-handlers/default-error-handlers.js +57 -0
  77. package/dist/get-context/index.d.ts +11 -8
  78. package/dist/get-context/index.js +31 -9
  79. package/dist/get-package-json-files/get-file-paths.d.ts +17 -8
  80. package/dist/get-package-json-files/get-file-paths.js +40 -20
  81. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +4 -3
  82. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +31 -8
  83. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +4 -3
  84. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +36 -14
  85. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +4 -3
  86. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +37 -9
  87. package/dist/get-package-json-files/get-patterns/index.d.ts +4 -4
  88. package/dist/get-package-json-files/get-patterns/index.js +37 -18
  89. package/dist/get-package-json-files/get-patterns/read-json-safe.d.ts +15 -3
  90. package/dist/get-package-json-files/get-patterns/read-json-safe.js +36 -10
  91. package/dist/get-package-json-files/index.d.ts +7 -4
  92. package/dist/get-package-json-files/index.js +27 -9
  93. package/dist/get-package-json-files/instance.js +2 -2
  94. package/dist/get-package-json-files/package-json-file.d.ts +6 -10
  95. package/dist/get-package-json-files/package-json-file.js +5 -21
  96. package/dist/get-semver-groups/filtered-out.d.ts +12 -6
  97. package/dist/get-semver-groups/filtered-out.js +40 -14
  98. package/dist/get-semver-groups/ignored.d.ts +10 -4
  99. package/dist/get-semver-groups/ignored.js +34 -8
  100. package/dist/get-semver-groups/index.d.ts +80 -28
  101. package/dist/get-semver-groups/index.js +93 -44
  102. package/dist/get-semver-groups/with-range.d.ts +12 -5
  103. package/dist/get-semver-groups/with-range.js +49 -25
  104. package/dist/get-version-groups/banned.d.ts +10 -4
  105. package/dist/get-version-groups/banned.js +34 -8
  106. package/dist/get-version-groups/filtered-out.d.ts +12 -6
  107. package/dist/get-version-groups/filtered-out.js +40 -14
  108. package/dist/get-version-groups/ignored.d.ts +10 -4
  109. package/dist/get-version-groups/ignored.js +34 -8
  110. package/dist/get-version-groups/index.d.ts +132 -50
  111. package/dist/get-version-groups/index.js +130 -51
  112. package/dist/get-version-groups/lib/get-highest-version.js +2 -2
  113. package/dist/get-version-groups/lib/get-lowest-version.js +2 -2
  114. package/dist/get-version-groups/lib/get-range-score.js +1 -3
  115. package/dist/get-version-groups/lib/sort.js +3 -3
  116. package/dist/get-version-groups/pinned.d.ts +10 -4
  117. package/dist/get-version-groups/pinned.js +39 -16
  118. package/dist/get-version-groups/same-range.d.ts +17 -0
  119. package/dist/get-version-groups/same-range.js +70 -0
  120. package/dist/get-version-groups/snapped-to.d.ts +10 -4
  121. package/dist/get-version-groups/snapped-to.js +41 -16
  122. package/dist/get-version-groups/standard.d.ts +12 -5
  123. package/dist/get-version-groups/standard.js +63 -39
  124. package/dist/guards/can-add-to-group.d.ts +4 -0
  125. package/dist/guards/can-add-to-group.js +15 -0
  126. package/dist/guards/is-loose-semver.d.ts +1 -0
  127. package/dist/guards/is-loose-semver.js +9 -0
  128. package/dist/guards/is-semver.d.ts +1 -0
  129. package/dist/guards/is-semver.js +16 -0
  130. package/dist/guards/is-supported.d.ts +1 -0
  131. package/dist/guards/is-supported.js +17 -0
  132. package/dist/guards/is-valid-semver-range.d.ts +2 -0
  133. package/dist/guards/is-valid-semver-range.js +17 -0
  134. package/dist/lib/$R.js +2 -2
  135. package/dist/lib/log-group-header.d.ts +6 -0
  136. package/dist/lib/log-group-header.js +34 -0
  137. package/dist/lib/log-verbose.d.ts +1 -0
  138. package/dist/lib/log-verbose.js +24 -0
  139. package/dist/lib/set-semver-range.js +5 -5
  140. package/dist/lib/split-name-and-version.d.ts +5 -0
  141. package/dist/lib/split-name-and-version.js +12 -0
  142. package/dist/option.js +1 -4
  143. package/dist/strategy/lib/get-non-empty-string-prop.js +2 -2
  144. package/dist/strategy/name-and-version-props.js +5 -5
  145. package/dist/strategy/named-version-string.js +5 -5
  146. package/dist/strategy/unnamed-version-string.js +4 -4
  147. package/dist/strategy/versions-by-name.js +3 -3
  148. package/package.json +28 -17
  149. package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +0 -3
  150. package/dist/bin-fix-mismatches/fix-mismatches-cli.js +0 -12
  151. package/dist/bin-lint/lint-cli.d.ts +0 -3
  152. package/dist/bin-lint/lint-cli.js +0 -12
  153. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.d.ts +0 -3
  154. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +0 -11
  155. package/dist/bin-list/list-cli.d.ts +0 -3
  156. package/dist/bin-list/list-cli.js +0 -11
  157. package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +0 -3
  158. package/dist/bin-list-mismatches/list-mismatches-cli.js +0 -11
  159. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +0 -3
  160. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +0 -11
  161. package/dist/get-package-json-files/get-patterns/read-yaml-safe.d.ts +0 -3
  162. package/dist/get-package-json-files/get-patterns/read-yaml-safe.js +0 -12
  163. package/dist/get-semver-groups/catch-all.d.ts +0 -4
  164. package/dist/get-semver-groups/catch-all.js +0 -11
  165. package/dist/get-version-groups/catch-all.d.ts +0 -4
  166. package/dist/get-version-groups/catch-all.js +0 -11
  167. package/dist/lib/disk.d.ts +0 -14
  168. package/dist/lib/disk.js +0 -68
  169. package/dist/lib/exit-if-invalid.d.ts +0 -2
  170. package/dist/lib/exit-if-invalid.js +0 -10
  171. package/dist/lib/is-semver.d.ts +0 -6
  172. package/dist/lib/is-semver.js +0 -49
  173. package/dist/lib/log.d.ts +0 -5
  174. package/dist/lib/log.js +0 -51
  175. package/dist/lib/newlines.d.ts +0 -6
  176. package/dist/lib/newlines.js +0 -24
  177. package/dist/lib/print-strings.d.ts +0 -1
  178. package/dist/lib/print-strings.js +0 -7
  179. package/dist/lib/write-if-changed.d.ts +0 -2
  180. package/dist/lib/write-if-changed.js +0 -21
@@ -2,15 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setSemverRange = void 0;
4
4
  const constants_1 = require("../constants");
5
- const is_semver_1 = require("./is-semver");
5
+ const is_loose_semver_1 = require("../guards/is-loose-semver");
6
+ const is_semver_1 = require("../guards/is-semver");
7
+ const is_valid_semver_range_1 = require("../guards/is-valid-semver-range");
6
8
  function setSemverRange(semverRange, version) {
7
- if (!(0, is_semver_1.isSemver)(version) || !(0, is_semver_1.isValidSemverRange)(semverRange))
9
+ if (!(0, is_semver_1.isSemver)(version) || !(0, is_valid_semver_range_1.isValidSemverRange)(semverRange))
8
10
  return version;
9
11
  if (semverRange === '*')
10
12
  return semverRange;
11
- const nextVersion = (0, is_semver_1.isLooseSemver)(version)
12
- ? version.replace(/\.x/g, '.0')
13
- : version;
13
+ const nextVersion = (0, is_loose_semver_1.isLooseSemver)(version) ? version.replace(/\.x/g, '.0') : version;
14
14
  const from1stNumber = nextVersion.search(/[0-9]/);
15
15
  const from1stDot = nextVersion.indexOf('.');
16
16
  return semverRange === constants_1.RANGE.LOOSE
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Split string by first occurring "@" which is not the first character in the
3
+ * string (used by scoped npm packages).
4
+ */
5
+ export declare function splitNameAndVersion(value: string): [string, string];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitNameAndVersion = void 0;
4
+ /**
5
+ * Split string by first occurring "@" which is not the first character in the
6
+ * string (used by scoped npm packages).
7
+ */
8
+ function splitNameAndVersion(value) {
9
+ const ix = value.search(/(?!^)@/);
10
+ return [value.slice(0, ix), value.slice(ix + 1)];
11
+ }
12
+ exports.splitNameAndVersion = splitNameAndVersion;
package/dist/option.js CHANGED
@@ -12,10 +12,7 @@ exports.option = {
12
12
  '-f, --filter [pattern]',
13
13
  (0, chalk_1.default) `only include dependencies whose {yellow name} matches this regex`,
14
14
  ],
15
- indent: [
16
- '-i, --indent [value]',
17
- `override indentation. defaults to "${constants_1.DEFAULT_CONFIG.indent}"`,
18
- ],
15
+ indent: ['-i, --indent [value]', `override indentation. defaults to "${constants_1.DEFAULT_CONFIG.indent}"`],
19
16
  semverRange: [
20
17
  '-r, --semver-range <range>',
21
18
  `see supported ranges below. defaults to "${constants_1.DEFAULT_CONFIG.semverRange}"`,
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNonEmptyStringProp = void 0;
4
+ const Function_1 = require("@effect/data/Function");
4
5
  const get_1 = require("tightrope/fn/get");
5
- const pipe_1 = require("tightrope/fn/pipe");
6
6
  const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
7
7
  const filter_1 = require("tightrope/result/filter");
8
8
  const map_err_1 = require("tightrope/result/map-err");
9
9
  function getNonEmptyStringProp(propPath, file) {
10
- return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...propPath.split('.')), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString, ''), (0, map_err_1.mapErr)(() => new Error(`Failed to get ${propPath} in ${file.shortPath}`)));
10
+ return (0, Function_1.pipe)((0, get_1.get)(file.contents, ...propPath.split('.')), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString, ''), (0, map_err_1.mapErr)(() => new Error(`Failed to get ${propPath} in ${file.shortPath}`)));
11
11
  }
12
12
  exports.getNonEmptyStringProp = getNonEmptyStringProp;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NameAndVersionPropsStrategy = void 0;
4
+ const Function_1 = require("@effect/data/Function");
4
5
  const get_1 = require("tightrope/fn/get");
5
- const pipe_1 = require("tightrope/fn/pipe");
6
6
  const and_then_1 = require("tightrope/result/and-then");
7
7
  const from_try_1 = require("tightrope/result/from-try");
8
8
  const map_1 = require("tightrope/result/map");
@@ -19,11 +19,11 @@ class NameAndVersionPropsStrategy {
19
19
  read(file) {
20
20
  const path = this.path;
21
21
  const namePath = this.namePath;
22
- return (0, pipe_1.pipe)(
22
+ return (0, Function_1.pipe)(
23
23
  // get name prop
24
24
  (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(namePath, file),
25
25
  // add the version prop
26
- (0, and_then_1.andThen)((name) => (0, pipe_1.pipe)((0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file), (0, map_1.map)((version) => ({ name, version })))),
26
+ (0, and_then_1.andThen)((name) => (0, Function_1.pipe)((0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file), (0, map_1.map)((version) => ({ name, version })))),
27
27
  // if both are non empty strings, we can return them
28
28
  (0, map_1.map)(({ name, version }) => [[name, version]]));
29
29
  }
@@ -36,12 +36,12 @@ class NameAndVersionPropsStrategy {
36
36
  const fullPath = path.split('.');
37
37
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
38
38
  const key = fullPath.slice(-1).join('');
39
- return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
39
+ return (0, Function_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
40
40
  parent[key] = version;
41
41
  }), (0, map_1.map)(() => file));
42
42
  }
43
43
  else {
44
- return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
44
+ return (0, Function_1.pipe)((0, from_try_1.fromTry)(() => {
45
45
  contents[path] = nextValue;
46
46
  }), (0, map_1.map)(() => file));
47
47
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NamedVersionStringStrategy = void 0;
4
+ const Function_1 = require("@effect/data/Function");
4
5
  const get_1 = require("tightrope/fn/get");
5
- const pipe_1 = require("tightrope/fn/pipe");
6
6
  const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
7
7
  const result_1 = require("tightrope/result");
8
8
  const and_then_1 = require("tightrope/result/and-then");
@@ -19,12 +19,12 @@ class NamedVersionStringStrategy {
19
19
  }
20
20
  read(file) {
21
21
  const path = this.path;
22
- return (0, pipe_1.pipe)(
22
+ return (0, Function_1.pipe)(
23
23
  // get version prop
24
24
  (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file),
25
25
  // if it is a non empty string, we can read it
26
26
  (0, and_then_1.andThen)((value) => {
27
- const [name, version] = value.split('@');
27
+ const [name, version] = value.split(/@(.*)/);
28
28
  return (0, is_non_empty_string_1.isNonEmptyString)(name) && (0, is_non_empty_string_1.isNonEmptyString)(version)
29
29
  ? new result_1.Ok([[name, version]])
30
30
  : new result_1.Err(new Error(`Strategy<name@version> failed to get ${path} in ${file.shortPath}`));
@@ -39,12 +39,12 @@ class NamedVersionStringStrategy {
39
39
  const fullPath = path.split('.');
40
40
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
41
41
  const key = fullPath.slice(-1).join('');
42
- return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
42
+ return (0, Function_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
43
43
  parent[key] = nextValue;
44
44
  }), (0, map_1.map)(() => file));
45
45
  }
46
46
  else {
47
- return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
47
+ return (0, Function_1.pipe)((0, from_try_1.fromTry)(() => {
48
48
  contents[path] = nextValue;
49
49
  }), (0, map_1.map)(() => file));
50
50
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnnamedVersionStringStrategy = void 0;
4
+ const Function_1 = require("@effect/data/Function");
4
5
  const get_1 = require("tightrope/fn/get");
5
- const pipe_1 = require("tightrope/fn/pipe");
6
6
  const from_try_1 = require("tightrope/result/from-try");
7
7
  const map_1 = require("tightrope/result/map");
8
8
  const tap_1 = require("tightrope/result/tap");
@@ -16,7 +16,7 @@ class UnnamedVersionStringStrategy {
16
16
  }
17
17
  read(file) {
18
18
  const path = this.path;
19
- return (0, pipe_1.pipe)(
19
+ return (0, Function_1.pipe)(
20
20
  // get version prop
21
21
  (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file),
22
22
  // if it is a non empty string, we can read it
@@ -34,12 +34,12 @@ class UnnamedVersionStringStrategy {
34
34
  const fullPath = path.split('.');
35
35
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
36
36
  const key = fullPath.slice(-1).join('');
37
- return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
37
+ return (0, Function_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
38
38
  parent[key] = nextValue;
39
39
  }), (0, map_1.map)(() => file));
40
40
  }
41
41
  else {
42
- return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
42
+ return (0, Function_1.pipe)((0, from_try_1.fromTry)(() => {
43
43
  contents[path] = nextValue;
44
44
  }), (0, map_1.map)(() => file));
45
45
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VersionsByNameStrategy = void 0;
4
+ const Function_1 = require("@effect/data/Function");
4
5
  const get_1 = require("tightrope/fn/get");
5
- const pipe_1 = require("tightrope/fn/pipe");
6
6
  const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
7
7
  const filter_1 = require("tightrope/result/filter");
8
8
  const map_1 = require("tightrope/result/map");
@@ -16,12 +16,12 @@ class VersionsByNameStrategy {
16
16
  }
17
17
  read(file) {
18
18
  const path = this.path;
19
- return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...path.split('.')), (0, filter_1.filter)((is_non_empty_object_1.isNonEmptyObject), ''), (0, map_1.map)((Object.entries)));
19
+ return (0, Function_1.pipe)((0, get_1.get)(file.contents, ...path.split('.')), (0, filter_1.filter)((is_non_empty_object_1.isNonEmptyObject), ''), (0, map_1.map)((Object.entries)));
20
20
  }
21
21
  write(file, [name, version]) {
22
22
  const path = this.path;
23
23
  const nextValue = version === delete_1.DELETE ? undefined : version;
24
- return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...path.split('.')), (0, tap_1.tap)((parent) => {
24
+ return (0, Function_1.pipe)((0, get_1.get)(file.contents, ...path.split('.')), (0, tap_1.tap)((parent) => {
25
25
  parent[name] = nextValue;
26
26
  }), (0, map_1.map)(() => file));
27
27
  }
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "syncpack",
3
3
  "description": "Consistent dependency versions in large JavaScript Monorepos",
4
- "version": "10.2.0",
4
+ "version": "10.6.1",
5
5
  "author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",
6
6
  "bin": {
7
7
  "syncpack": "dist/bin.js",
8
8
  "syncpack-fix-mismatches": "dist/bin-fix-mismatches/index.js",
9
9
  "syncpack-format": "dist/bin-format/index.js",
10
+ "syncpack-lint": "dist/bin-lint/index.js",
10
11
  "syncpack-lint-semver-ranges": "dist/bin-lint-semver-ranges/index.js",
11
12
  "syncpack-list": "dist/bin-list/index.js",
12
13
  "syncpack-list-mismatches": "dist/bin-list-mismatches/index.js",
14
+ "syncpack-prompt": "dist/bin-prompt/index.js",
13
15
  "syncpack-set-semver-ranges": "dist/bin-set-semver-ranges/index.js"
14
16
  },
15
17
  "bugs": "https://github.com/JamieMason/syncpack/issues",
@@ -28,36 +30,39 @@
28
30
  "Tom Fletcher (https://github.com/tom-fletcher)"
29
31
  ],
30
32
  "dependencies": {
33
+ "@effect/data": "0.12.5",
34
+ "@effect/io": "0.26.0",
35
+ "@effect/match": "0.24.4",
31
36
  "chalk": "4.1.2",
32
- "commander": "10.0.1",
33
- "cosmiconfig": "8.1.3",
37
+ "commander": "11.0.0",
38
+ "cosmiconfig": "8.2.0",
39
+ "enquirer": "2.3.6",
34
40
  "fs-extra": "11.1.1",
35
- "glob": "8.1.0",
36
- "minimatch": "6.2.0",
41
+ "globby": "11.1.0",
42
+ "minimatch": "9.0.1",
37
43
  "read-yaml-file": "2.1.0",
38
- "semver": "7.5.0",
44
+ "semver": "7.5.2",
39
45
  "tightrope": "0.1.0",
40
46
  "ts-toolbelt": "9.6.0"
41
47
  },
42
48
  "devDependencies": {
43
49
  "@tsconfig/node14": "1.0.3",
44
50
  "@types/fs-extra": "11.0.1",
45
- "@types/glob": "8.1.0",
46
- "@types/jest": "29.5.1",
51
+ "@types/jest": "29.5.2",
47
52
  "@types/node": "14.18.36",
48
- "@types/semver": "7.3.13",
49
- "@typescript-eslint/eslint-plugin": "5.59.0",
50
- "@typescript-eslint/parser": "5.59.0",
51
- "eslint": "8.39.0",
53
+ "@types/semver": "7.5.0",
54
+ "@typescript-eslint/eslint-plugin": "5.59.11",
55
+ "@typescript-eslint/parser": "5.59.11",
56
+ "eslint": "8.43.0",
52
57
  "eslint-plugin-import": "2.27.5",
53
58
  "eslint-plugin-jest": "27.2.1",
54
59
  "expect-more-jest": "5.5.0",
55
60
  "jest": "29.5.0",
56
61
  "prettier": "2.8.8",
57
- "rimraf": "4.4.1",
62
+ "rimraf": "5.0.1",
58
63
  "ts-jest": "29.1.0",
59
64
  "ts-node": "10.9.1",
60
- "typescript": "5.0.4"
65
+ "typescript": "5.1.3"
61
66
  },
62
67
  "engines": {
63
68
  "node": ">=14"
@@ -90,14 +95,20 @@
90
95
  "main": "dist/index.js",
91
96
  "repository": "JamieMason/syncpack",
92
97
  "resolutions": {
93
- "chalk": "4.1.2"
98
+ "chalk": "4.1.2",
99
+ "globby": "11.1.0",
100
+ "string-width": "<5.0.0",
101
+ "strip-ansi": "<7.0.0",
102
+ "wrap-ansi": "<8.0.0"
94
103
  },
95
104
  "scripts": {
96
- "build": "rm -rf ./dist && tsc --project .",
105
+ "build": "rm -rf ./dist && tsc --project tsconfig.build.json",
97
106
  "format": "yarn format:lint && yarn format:source",
98
107
  "format:lint": "yarn lint --fix",
99
108
  "format:source": "prettier --write .",
100
- "lint": "eslint --ext .ts .",
109
+ "lint": "yarn lint:ts && yarn lint:eslint",
110
+ "lint:eslint": "eslint --ext .ts .",
111
+ "lint:ts": "tsc --noEmit --project tsconfig.json",
101
112
  "prepack": "yarn build",
102
113
  "test": "jest src test"
103
114
  },
@@ -1,3 +0,0 @@
1
- import type { CliConfig } from '../config/types';
2
- import type { Disk } from '../lib/disk';
3
- export declare function fixMismatchesCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fixMismatchesCli = void 0;
4
- const pipe_1 = require("tightrope/fn/pipe");
5
- const get_context_1 = require("../get-context");
6
- const exit_if_invalid_1 = require("../lib/exit-if-invalid");
7
- const write_if_changed_1 = require("../lib/write-if-changed");
8
- const fix_mismatches_1 = require("./fix-mismatches");
9
- function fixMismatchesCli(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);
11
- }
12
- exports.fixMismatchesCli = fixMismatchesCli;
@@ -1,3 +0,0 @@
1
- import type { CliConfig } from '../config/types';
2
- import type { Disk } from '../lib/disk';
3
- export declare function lintCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lintCli = void 0;
4
- const pipe_1 = require("tightrope/fn/pipe");
5
- const lint_semver_ranges_1 = require("../bin-lint-semver-ranges/lint-semver-ranges");
6
- const list_mismatches_1 = require("../bin-list-mismatches/list-mismatches");
7
- const get_context_1 = require("../get-context");
8
- const exit_if_invalid_1 = require("../lib/exit-if-invalid");
9
- function lintCli(input, disk) {
10
- (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), list_mismatches_1.listMismatches, lint_semver_ranges_1.lintSemverRanges, exit_if_invalid_1.exitIfInvalid);
11
- }
12
- exports.lintCli = lintCli;
@@ -1,3 +0,0 @@
1
- import type { CliConfig } from '../config/types';
2
- import type { Disk } from '../lib/disk';
3
- export declare function lintSemverRangesCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lintSemverRangesCli = void 0;
4
- const pipe_1 = require("tightrope/fn/pipe");
5
- const get_context_1 = require("../get-context");
6
- const exit_if_invalid_1 = require("../lib/exit-if-invalid");
7
- const lint_semver_ranges_1 = require("./lint-semver-ranges");
8
- function lintSemverRangesCli(input, disk) {
9
- (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), lint_semver_ranges_1.lintSemverRanges, exit_if_invalid_1.exitIfInvalid);
10
- }
11
- exports.lintSemverRangesCli = lintSemverRangesCli;
@@ -1,3 +0,0 @@
1
- import type { CliConfig } from '../config/types';
2
- import type { Disk } from '../lib/disk';
3
- export declare function listCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listCli = void 0;
4
- const pipe_1 = require("tightrope/fn/pipe");
5
- const get_context_1 = require("../get-context");
6
- const exit_if_invalid_1 = require("../lib/exit-if-invalid");
7
- const list_1 = require("./list");
8
- function listCli(input, disk) {
9
- (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), list_1.list, exit_if_invalid_1.exitIfInvalid);
10
- }
11
- exports.listCli = listCli;
@@ -1,3 +0,0 @@
1
- import type { CliConfig } from '../config/types';
2
- import type { Disk } from '../lib/disk';
3
- export declare function listMismatchesCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listMismatchesCli = void 0;
4
- const pipe_1 = require("tightrope/fn/pipe");
5
- const get_context_1 = require("../get-context");
6
- const exit_if_invalid_1 = require("../lib/exit-if-invalid");
7
- const list_mismatches_1 = require("./list-mismatches");
8
- function listMismatchesCli(input, disk) {
9
- (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), list_mismatches_1.listMismatches, exit_if_invalid_1.exitIfInvalid);
10
- }
11
- exports.listMismatchesCli = listMismatchesCli;
@@ -1,3 +0,0 @@
1
- import type { CliConfig } from '../config/types';
2
- import type { Disk } from '../lib/disk';
3
- export declare function setSemverRangesCli(input: Partial<CliConfig>, disk: Disk): void;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setSemverRangesCli = void 0;
4
- const pipe_1 = require("tightrope/fn/pipe");
5
- const get_context_1 = require("../get-context");
6
- const write_if_changed_1 = require("../lib/write-if-changed");
7
- const set_semver_ranges_1 = require("./set-semver-ranges");
8
- function setSemverRangesCli(input, disk) {
9
- (0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), set_semver_ranges_1.setSemverRanges, write_if_changed_1.writeIfChanged);
10
- }
11
- exports.setSemverRangesCli = setSemverRangesCli;
@@ -1,3 +0,0 @@
1
- import type { Result } from 'tightrope/result';
2
- import type { Disk } from '../../lib/disk';
3
- export declare function readYamlSafe<T = unknown>(disk: Disk): (filePath: string) => Result<T>;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readYamlSafe = void 0;
4
- const pipe_1 = require("tightrope/fn/pipe");
5
- const from_try_1 = require("tightrope/result/from-try");
6
- const map_err_1 = require("tightrope/result/map-err");
7
- function readYamlSafe(disk) {
8
- return function readYamlSafe(filePath) {
9
- return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => disk.readYamlFileSync(filePath)), (0, map_err_1.mapErr)(() => new Error(`Failed to read YAML file at ${filePath}`)));
10
- };
11
- }
12
- exports.readYamlSafe = readYamlSafe;
@@ -1,4 +0,0 @@
1
- import { WithRangeSemverGroup } from './with-range';
2
- export declare class CatchAllSemverGroup extends WithRangeSemverGroup {
3
- _tag: string;
4
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatchAllSemverGroup = void 0;
4
- const with_range_1 = require("./with-range");
5
- class CatchAllSemverGroup extends with_range_1.WithRangeSemverGroup {
6
- constructor() {
7
- super(...arguments);
8
- this._tag = 'CatchAll';
9
- }
10
- }
11
- exports.CatchAllSemverGroup = CatchAllSemverGroup;
@@ -1,4 +0,0 @@
1
- import { StandardVersionGroup } from './standard';
2
- export declare class CatchAllVersionGroup extends StandardVersionGroup {
3
- _tag: string;
4
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatchAllVersionGroup = void 0;
4
- const standard_1 = require("./standard");
5
- class CatchAllVersionGroup extends standard_1.StandardVersionGroup {
6
- constructor() {
7
- super(...arguments);
8
- this._tag = 'CatchAll';
9
- }
10
- }
11
- exports.CatchAllVersionGroup = CatchAllVersionGroup;
@@ -1,14 +0,0 @@
1
- import type { O } from 'ts-toolbelt';
2
- import type { RcConfig } from '../config/types';
3
- export type Disk = {
4
- process: {
5
- exit: (code: number) => void;
6
- };
7
- globSync: (pattern: string) => string[];
8
- readConfigFileSync: (configPath?: string) => O.Partial<RcConfig, 'deep'>;
9
- readFileSync: (filePath: string) => string;
10
- readYamlFileSync: <T = unknown>(filePath: string) => T;
11
- removeSync: (filePath: string) => void;
12
- writeFileSync: (filePath: string, contents: string) => void;
13
- };
14
- export declare const disk: Disk;
package/dist/lib/disk.js DELETED
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.disk = void 0;
4
- const cosmiconfig_1 = require("cosmiconfig");
5
- const fs_extra_1 = require("fs-extra");
6
- const glob_1 = require("glob");
7
- const path_1 = require("path");
8
- const read_yaml_file_1 = require("read-yaml-file");
9
- const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
10
- const constants_1 = require("../constants");
11
- const log_1 = require("./log");
12
- const client = (0, cosmiconfig_1.cosmiconfigSync)('syncpack');
13
- exports.disk = {
14
- process: {
15
- exit(code) {
16
- (0, log_1.verbose)('exit(', code, ')');
17
- process.exit(code);
18
- },
19
- },
20
- globSync(pattern) {
21
- (0, log_1.verbose)('globSync(', pattern, ')');
22
- return (0, glob_1.sync)(pattern, {
23
- ignore: '**/node_modules/**',
24
- absolute: true,
25
- cwd: constants_1.CWD,
26
- });
27
- },
28
- readConfigFileSync(configPath) {
29
- (0, log_1.verbose)('readConfigFileSync(', configPath, ')');
30
- try {
31
- const result = configPath ? client.load(configPath) : client.search();
32
- if (result === null) {
33
- const rcPath = (0, path_1.join)(constants_1.CWD, 'package.json');
34
- const pjson = (0, fs_extra_1.readJsonSync)(rcPath, { throws: false });
35
- const rcConfig = pjson?.config?.syncpack;
36
- if ((0, is_non_empty_object_1.isNonEmptyObject)(rcConfig))
37
- return rcConfig;
38
- (0, log_1.verbose)('no config file found');
39
- return {};
40
- }
41
- const rcPath = result.filepath;
42
- const rcConfig = result.config;
43
- (0, log_1.verbose)('.syncpackrc path:', rcPath);
44
- (0, log_1.verbose)('.syncpackrc contents:', rcConfig);
45
- return rcConfig;
46
- }
47
- catch (err) {
48
- (0, log_1.verbose)('no config file found at:', configPath);
49
- return {};
50
- }
51
- },
52
- readFileSync(filePath) {
53
- (0, log_1.verbose)('readFileSync(', filePath, ')');
54
- return (0, fs_extra_1.readFileSync)(filePath, { encoding: 'utf8' });
55
- },
56
- readYamlFileSync(filePath) {
57
- (0, log_1.verbose)('readYamlFileSync(', filePath, ')');
58
- return (0, read_yaml_file_1.sync)(filePath);
59
- },
60
- removeSync(filePath) {
61
- (0, log_1.verbose)('removeSync(', filePath, ')');
62
- (0, fs_extra_1.removeSync)(filePath);
63
- },
64
- writeFileSync(filePath, contents) {
65
- (0, log_1.verbose)('writeFileSync(', filePath, contents, ')');
66
- (0, fs_extra_1.writeFileSync)(filePath, contents);
67
- },
68
- };
@@ -1,2 +0,0 @@
1
- import type { Context } from '../get-context';
2
- export declare function exitIfInvalid(ctx: Context): Context;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exitIfInvalid = void 0;
4
- function exitIfInvalid(ctx) {
5
- if (ctx.isInvalid) {
6
- ctx.disk.process.exit(1);
7
- }
8
- return ctx;
9
- }
10
- exports.exitIfInvalid = exitIfInvalid;
@@ -1,6 +0,0 @@
1
- import type { SemverRange } from '../config/types';
2
- export declare function isValidSemverRange(value: unknown): value is SemverRange;
3
- export declare function isSupported(version: unknown): version is string;
4
- export declare function isWorkspaceProtocol(version: unknown): boolean;
5
- export declare function isSemver(version: unknown): boolean;
6
- export declare function isLooseSemver(version: unknown): boolean;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLooseSemver = exports.isSemver = exports.isWorkspaceProtocol = exports.isSupported = exports.isValidSemverRange = void 0;
4
- const is_string_1 = require("tightrope/guard/is-string");
5
- const constants_1 = require("../constants");
6
- function isValidSemverRange(value) {
7
- return (value === constants_1.RANGE.ANY ||
8
- value === constants_1.RANGE.EXACT ||
9
- value === constants_1.RANGE.GT ||
10
- value === constants_1.RANGE.GTE ||
11
- value === constants_1.RANGE.LOOSE ||
12
- value === constants_1.RANGE.LT ||
13
- value === constants_1.RANGE.LTE ||
14
- value === constants_1.RANGE.MINOR ||
15
- value === constants_1.RANGE.PATCH ||
16
- value === constants_1.RANGE.WORKSPACE);
17
- }
18
- exports.isValidSemverRange = isValidSemverRange;
19
- function isSupported(version) {
20
- return version === '*' || isSemver(version) || isWorkspaceProtocol(version);
21
- }
22
- exports.isSupported = isSupported;
23
- function isWorkspaceProtocol(version) {
24
- if (!(0, is_string_1.isString)(version))
25
- return false;
26
- if (!version.startsWith('workspace:'))
27
- return false;
28
- const value = version.replace(/^workspace:/, '');
29
- return value === '*' || isSemver(value);
30
- }
31
- exports.isWorkspaceProtocol = isWorkspaceProtocol;
32
- function isSemver(version) {
33
- const range = '(~|\\^|>=|>|<=|<)?';
34
- const ints = '[0-9]+';
35
- const intsOrX = '([0-9]+|x)';
36
- const dot = '\\.';
37
- const major = new RegExp(`^${range}${ints}$`);
38
- const minor = new RegExp(`^${range}${ints}${dot}${intsOrX}$`);
39
- const patch = new RegExp(`^${range}${ints}${dot}${intsOrX}${dot}${intsOrX}$`);
40
- return ((0, is_string_1.isString)(version) &&
41
- (version.search(major) !== -1 ||
42
- version.search(minor) !== -1 ||
43
- version.search(patch) !== -1));
44
- }
45
- exports.isSemver = isSemver;
46
- function isLooseSemver(version) {
47
- return ((0, is_string_1.isString)(version) && isSemver(version) && version.search(/\.x(\.|$)/) !== -1);
48
- }
49
- exports.isLooseSemver = isLooseSemver;
package/dist/lib/log.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { AnySemverGroup } from '../get-semver-groups';
2
- import type { AnyVersionGroup } from '../get-version-groups';
3
- export declare function verbose(...values: unknown[]): void;
4
- export declare function semverGroupHeader(group: AnySemverGroup, i: number): void;
5
- export declare function versionGroupHeader(group: AnyVersionGroup, i: number): void;