syncpack 10.7.3 → 10.9.3

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 (67) hide show
  1. package/dist/bin-fix-mismatches/effects.js +9 -9
  2. package/dist/bin-format/format.js +4 -3
  3. package/dist/bin-lint-semver-ranges/effects.js +10 -10
  4. package/dist/bin-list/effects.js +16 -14
  5. package/dist/bin-list-mismatches/effects.js +22 -22
  6. package/dist/bin-prompt/effects.js +15 -15
  7. package/dist/bin-set-semver-ranges/effects.js +10 -10
  8. package/dist/bin-update/effects.js +36 -30
  9. package/dist/bin-update/update.js +1 -1
  10. package/dist/config/get-enabled-types.js +1 -1
  11. package/dist/create-program/effects.d.ts +4 -4
  12. package/dist/create-program/semver-ranges.js +6 -6
  13. package/dist/create-program/versions.js +6 -6
  14. package/dist/env/create-env.js +28 -7
  15. package/dist/env/default-env.js +2 -1
  16. package/dist/env/exit-if-invalid.js +1 -1
  17. package/dist/env/write-if-changed.js +1 -1
  18. package/dist/get-context/index.js +1 -1
  19. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +1 -1
  20. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +1 -1
  21. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +9 -6
  22. package/dist/get-package-json-files/get-patterns/read-json-safe.js +5 -2
  23. package/dist/get-package-json-files/package-json-file.d.ts +4 -2
  24. package/dist/get-package-json-files/package-json-file.js +5 -4
  25. package/dist/get-semver-groups/filtered-out.d.ts +3 -3
  26. package/dist/get-semver-groups/ignored.d.ts +3 -3
  27. package/dist/get-semver-groups/index.d.ts +16 -16
  28. package/dist/get-semver-groups/index.js +5 -5
  29. package/dist/get-semver-groups/with-range.d.ts +4 -4
  30. package/dist/get-semver-groups/with-range.js +9 -9
  31. package/dist/get-version-groups/banned.d.ts +3 -3
  32. package/dist/get-version-groups/filtered-out.d.ts +3 -3
  33. package/dist/get-version-groups/ignored.d.ts +3 -3
  34. package/dist/get-version-groups/index.d.ts +70 -22
  35. package/dist/get-version-groups/index.js +53 -5
  36. package/dist/get-version-groups/lib/{sort.js → compare-semver.js} +0 -5
  37. package/dist/get-version-groups/lib/get-highest-version.js +2 -2
  38. package/dist/get-version-groups/lib/get-lowest-version.js +2 -2
  39. package/dist/get-version-groups/lib/get-unique-specifiers.d.ts +2 -0
  40. package/dist/get-version-groups/lib/get-unique-specifiers.js +11 -0
  41. package/dist/get-version-groups/pinned.d.ts +3 -3
  42. package/dist/get-version-groups/pinned.js +1 -1
  43. package/dist/get-version-groups/same-range.d.ts +3 -3
  44. package/dist/get-version-groups/same-range.js +1 -1
  45. package/dist/get-version-groups/snapped-to.d.ts +3 -3
  46. package/dist/get-version-groups/snapped-to.js +4 -3
  47. package/dist/get-version-groups/standard.d.ts +4 -4
  48. package/dist/get-version-groups/standard.js +19 -18
  49. package/dist/guards/can-add-to-group.d.ts +2 -2
  50. package/dist/guards/is-loose-semver.d.ts +1 -0
  51. package/dist/guards/is-loose-semver.js +1 -0
  52. package/dist/guards/is-semver.d.ts +1 -0
  53. package/dist/guards/is-semver.js +1 -0
  54. package/dist/guards/is-valid-semver-range.d.ts +1 -0
  55. package/dist/guards/is-valid-semver-range.js +1 -0
  56. package/dist/instance/create.d.ts +4 -0
  57. package/dist/instance/create.js +142 -0
  58. package/dist/instance/index.d.ts +122 -0
  59. package/dist/instance/index.js +154 -0
  60. package/package.json +18 -16
  61. package/dist/get-package-json-files/instance.d.ts +0 -21
  62. package/dist/get-package-json-files/instance.js +0 -23
  63. package/dist/get-version-groups/lib/get-unique-versions.d.ts +0 -2
  64. package/dist/get-version-groups/lib/get-unique-versions.js +0 -8
  65. package/dist/guards/is-supported.d.ts +0 -1
  66. package/dist/guards/is-supported.js +0 -17
  67. /package/dist/get-version-groups/lib/{sort.d.ts → compare-semver.d.ts} +0 -0
@@ -38,13 +38,13 @@ const delete_1 = require("../get-version-groups/lib/delete");
38
38
  const log_group_header_1 = require("../lib/log-group-header");
39
39
  exports.fixMismatchesEffects = {
40
40
  onFilteredOut() {
41
- return Effect.unit();
41
+ return Effect.unit;
42
42
  },
43
43
  onIgnored() {
44
- return Effect.unit();
44
+ return Effect.unit;
45
45
  },
46
46
  onValid() {
47
- return Effect.unit();
47
+ return Effect.unit;
48
48
  },
49
49
  onBanned(input) {
50
50
  return Effect.sync(() => removeVersions(input));
@@ -64,10 +64,10 @@ exports.fixMismatchesEffects = {
64
64
  onSnappedToMismatch(input) {
65
65
  return Effect.sync(() => setVersions(input));
66
66
  },
67
- onUnsupportedMismatch(input) {
68
- return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logUnsupportedMismatch));
67
+ onNonSemverMismatch(input) {
68
+ return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logNonSemverMismatch));
69
69
  },
70
- onWorkspaceMismatch(input) {
70
+ onLocalPackageMismatch(input) {
71
71
  return Effect.sync(() => setVersions(input));
72
72
  },
73
73
  onComplete(ctx) {
@@ -82,19 +82,19 @@ function logHeader(input) {
82
82
  }
83
83
  function setVersions({ report }) {
84
84
  report.instances.forEach((instance) => {
85
- instance.setVersion(report.expectedVersion);
85
+ instance.setSpecifier(report.expectedVersion);
86
86
  });
87
87
  }
88
88
  function removeVersions({ report }) {
89
89
  report.instances.forEach((instance) => {
90
- instance.setVersion(delete_1.DELETE);
90
+ instance.setSpecifier(delete_1.DELETE);
91
91
  });
92
92
  }
93
93
  function logSameRangeMismatch({ ctx, report }) {
94
94
  ctx.isInvalid = true;
95
95
  console.log((0, chalk_1.default) `{yellow %s %s} {dim has mismatched versions under the "sameRange" policy which syncpack cannot auto fix}%s`, constants_1.ICON.panic, report.name, (0, chalk_1.default) `${os_1.EOL} use {blue syncpack prompt} to fix manually`);
96
96
  }
97
- function logUnsupportedMismatch({ ctx, report }) {
97
+ function logNonSemverMismatch({ ctx, report }) {
98
98
  ctx.isInvalid = true;
99
99
  console.log((0, chalk_1.default) `{yellow %s %s} {dim has mismatched unsupported versions which syncpack cannot auto fix}%s`, constants_1.ICON.panic, report.name, (0, chalk_1.default) `${os_1.EOL} use {blue syncpack prompt} to fix manually`);
100
100
  }
@@ -35,13 +35,14 @@ function format(ctx) {
35
35
  const sortAz = (0, get_sort_az_1.getSortAz)(ctx.config);
36
36
  const sortFirst = (0, get_sort_first_1.getSortFirst)(ctx.config);
37
37
  packageJsonFiles.forEach((packageJsonFile) => {
38
+ var _a, _b, _c;
38
39
  const { contents } = packageJsonFile;
39
40
  const sortedKeys = Object.keys(contents).sort();
40
41
  const keys = new Set(sortFirst.concat(sortedKeys));
41
42
  const optionalChaining = contents;
42
- const bugsUrl = optionalChaining?.bugs?.url;
43
- const repoUrl = optionalChaining?.repository?.url;
44
- const repoDir = optionalChaining?.repository?.directory;
43
+ const bugsUrl = (_a = optionalChaining === null || optionalChaining === void 0 ? void 0 : optionalChaining.bugs) === null || _a === void 0 ? void 0 : _a.url;
44
+ const repoUrl = (_b = optionalChaining === null || optionalChaining === void 0 ? void 0 : optionalChaining.repository) === null || _b === void 0 ? void 0 : _b.url;
45
+ const repoDir = (_c = optionalChaining === null || optionalChaining === void 0 ? void 0 : optionalChaining.repository) === null || _c === void 0 ? void 0 : _c.directory;
45
46
  if (bugsUrl) {
46
47
  contents.bugs = bugsUrl;
47
48
  }
@@ -34,25 +34,25 @@ const constants_1 = require("../constants");
34
34
  const log_group_header_1 = require("../lib/log-group-header");
35
35
  exports.lintSemverRangesEffects = {
36
36
  onFilteredOut() {
37
- return Effect.unit();
37
+ return Effect.unit;
38
38
  },
39
39
  onIgnored() {
40
- return Effect.unit();
40
+ return Effect.unit;
41
41
  },
42
42
  onValid() {
43
- return Effect.unit();
43
+ return Effect.unit;
44
44
  },
45
45
  onSemverRangeMismatch(input) {
46
46
  return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logRangeMismatch));
47
47
  },
48
- onUnsupportedVersion(input) {
49
- return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logUnsupportedVersion));
48
+ onNonSemverVersion(input) {
49
+ return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logNonSemverVersion));
50
50
  },
51
- onWorkspaceSemverRangeMismatch(input) {
51
+ onLocalPackageSemverRangeMismatch(input) {
52
52
  return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logRangeMismatch));
53
53
  },
54
54
  onComplete() {
55
- return Effect.unit();
55
+ return Effect.unit;
56
56
  },
57
57
  };
58
58
  function logHeader(input) {
@@ -63,8 +63,8 @@ function logHeader(input) {
63
63
  }
64
64
  function logRangeMismatch({ report, ctx }) {
65
65
  ctx.isInvalid = true;
66
- 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);
66
+ 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.specifier, constants_1.ICON.rightArrow, report.expectedVersion, report.instance.strategy.path, report.instance.packageJsonFile.shortPath);
67
67
  }
68
- function logUnsupportedVersion({ report }) {
69
- console.log((0, chalk_1.default) `{yellow %s} %s {yellow %s} {dim ignored as a format which syncpack cannot apply semver ranges to}`, constants_1.ICON.panic, report.name, report.instance.version);
68
+ function logNonSemverVersion({ report }) {
69
+ console.log((0, chalk_1.default) `{yellow %s} %s {yellow %s} {dim ignored as a format which syncpack cannot apply semver ranges to}`, constants_1.ICON.panic, report.name, report.instance.specifier);
70
70
  }
@@ -32,12 +32,11 @@ const Effect = __importStar(require("@effect/io/Effect"));
32
32
  const chalk_1 = __importDefault(require("chalk"));
33
33
  const uniq_1 = require("tightrope/array/uniq");
34
34
  const constants_1 = require("../constants");
35
- const get_unique_versions_1 = require("../get-version-groups/lib/get-unique-versions");
36
- const is_supported_1 = require("../guards/is-supported");
35
+ const get_unique_specifiers_1 = require("../get-version-groups/lib/get-unique-specifiers");
37
36
  const log_group_header_1 = require("../lib/log-group-header");
38
37
  exports.listEffects = {
39
38
  onFilteredOut() {
40
- return Effect.unit();
39
+ return Effect.unit;
41
40
  },
42
41
  onIgnored(input) {
43
42
  return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logIgnored));
@@ -63,14 +62,14 @@ exports.listEffects = {
63
62
  onSnappedToMismatch(input) {
64
63
  return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logFixableMismatch));
65
64
  },
66
- onUnsupportedMismatch(input) {
65
+ onNonSemverMismatch(input) {
67
66
  return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logUnfixableMismatch));
68
67
  },
69
- onWorkspaceMismatch(input) {
68
+ onLocalPackageMismatch(input) {
70
69
  return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logFixableMismatch));
71
70
  },
72
71
  onComplete() {
73
- return Effect.unit();
72
+ return Effect.unit;
74
73
  },
75
74
  };
76
75
  function logHeader(input) {
@@ -81,12 +80,14 @@ function logHeader(input) {
81
80
  }
82
81
  function logFixableMismatch({ report, ctx }) {
83
82
  ctx.isInvalid = true;
84
- console.log((0, chalk_1.default) `{red %s %s} %s`, constants_1.ICON.cross, report.name, listColouredVersions(report.expectedVersion, report.instances));
83
+ console.log((0, chalk_1.default) `{red %s %s} %s`, constants_1.ICON.cross, report.name, listColouredSpecifiers(report.expectedVersion, report.instances));
85
84
  }
86
85
  function logUnfixableMismatch({ report, ctx, }) {
87
86
  ctx.isInvalid = true;
88
- console.log((0, chalk_1.default) `{red %s %s} %s`, constants_1.ICON.cross, report.name, (0, get_unique_versions_1.getUniqueVersions)(report.instances)
89
- .map((version) => ((0, is_supported_1.isSupported)(version) ? chalk_1.default.red(version) : chalk_1.default.yellow(version)))
87
+ console.log((0, chalk_1.default) `{red %s %s} %s`, constants_1.ICON.cross, report.name, (0, get_unique_specifiers_1.getUniqueSpecifiers)(report.instances)
88
+ .map((instance) => instance.getSemverSpecifier() !== null
89
+ ? chalk_1.default.red(instance.specifier)
90
+ : chalk_1.default.yellow(instance.specifier))
90
91
  .join(chalk_1.default.dim(', ')));
91
92
  }
92
93
  function logBanned({ report, ctx }) {
@@ -97,16 +98,17 @@ function logIgnored({ report }) {
97
98
  console.log((0, chalk_1.default) `{dim -} {dim %s} {white is ignored in this version group}`, report.name);
98
99
  }
99
100
  function logValid({ report }) {
100
- console.log((0, chalk_1.default) `{dim -} {white %s} {dim %s}`, report.name, report.instances?.[0]?.version);
101
+ var _a, _b;
102
+ console.log((0, chalk_1.default) `{dim -} {white %s} {dim %s}`, report.name, (_b = (_a = report.instances) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.specifier);
101
103
  }
102
- function listColouredVersions(pinVersion, instances) {
103
- return getAllVersions(pinVersion, instances)
104
+ function listColouredSpecifiers(pinVersion, instances) {
105
+ return getAllSpecifiers(pinVersion, instances)
104
106
  .map((version) => withColour(pinVersion, version))
105
107
  .join(chalk_1.default.dim(', '));
106
108
  }
107
109
  function withColour(pinVersion, version) {
108
110
  return version === pinVersion ? chalk_1.default.green(version) : chalk_1.default.red(version);
109
111
  }
110
- function getAllVersions(pinVersion, instances) {
111
- return (0, uniq_1.uniq)([pinVersion].concat(instances.map((i) => i.version)));
112
+ function getAllSpecifiers(pinVersion, instances) {
113
+ return (0, uniq_1.uniq)([pinVersion].concat(instances.map((i) => i.specifier)));
112
114
  }
@@ -35,13 +35,13 @@ const constants_1 = require("../constants");
35
35
  const log_group_header_1 = require("../lib/log-group-header");
36
36
  exports.listMismatchesEffects = {
37
37
  onFilteredOut() {
38
- return Effect.unit();
38
+ return Effect.unit;
39
39
  },
40
40
  onIgnored() {
41
- return Effect.unit();
41
+ return Effect.unit;
42
42
  },
43
43
  onValid() {
44
- return Effect.unit();
44
+ return Effect.unit;
45
45
  },
46
46
  onBanned(input) {
47
47
  return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logBanned));
@@ -61,14 +61,14 @@ exports.listMismatchesEffects = {
61
61
  onSnappedToMismatch(input) {
62
62
  return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logSnappedToMismatch));
63
63
  },
64
- onUnsupportedMismatch(input) {
65
- return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logUnsupportedMismatch));
64
+ onNonSemverMismatch(input) {
65
+ return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logNonSemverMismatch));
66
66
  },
67
- onWorkspaceMismatch(input) {
68
- return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logWorkspaceMismatch));
67
+ onLocalPackageMismatch(input) {
68
+ return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logLocalPackageMismatch));
69
69
  },
70
70
  onComplete() {
71
- return Effect.unit();
71
+ return Effect.unit;
72
72
  },
73
73
  };
74
74
  function logHeader(input) {
@@ -81,15 +81,15 @@ function logBanned({ report, ctx }) {
81
81
  ctx.isInvalid = true;
82
82
  console.log((0, chalk_1.default) ` {red %s} %s {dim is banned in this version group}`, constants_1.ICON.cross, report.name);
83
83
  report.instances.forEach((instance) => {
84
- console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.version, instance.strategy.path, instance.packageJsonFile.shortPath);
84
+ console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.specifier, instance.strategy.path, instance.packageJsonFile.shortPath);
85
85
  });
86
86
  }
87
87
  function logHighLowSemverMismatch({ report, ctx, }) {
88
88
  ctx.isInvalid = true;
89
89
  console.log((0, chalk_1.default) `{red %s} %s {green %s} {dim is the %s valid semver version in use}`, constants_1.ICON.cross, report.name, report.expectedVersion, report._tag === 'LowestSemverMismatch' ? 'lowest' : 'highest');
90
90
  report.instances.forEach((instance) => {
91
- if (instance.version !== report.expectedVersion) {
92
- console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.version, instance.strategy.path, instance.packageJsonFile.shortPath);
91
+ if (instance.specifier !== report.expectedVersion) {
92
+ console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.specifier, instance.strategy.path, instance.packageJsonFile.shortPath);
93
93
  }
94
94
  });
95
95
  }
@@ -97,8 +97,8 @@ function logPinnedMismatch({ report, ctx }) {
97
97
  ctx.isInvalid = true;
98
98
  console.log((0, chalk_1.default) `{red %s} %s {dim is pinned in this version group at} {green %s}`, constants_1.ICON.cross, report.name, report.expectedVersion);
99
99
  report.instances.forEach((instance) => {
100
- if (instance.version !== report.expectedVersion) {
101
- console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.version, instance.strategy.path, instance.packageJsonFile.shortPath);
100
+ if (instance.specifier !== report.expectedVersion) {
101
+ console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.specifier, instance.strategy.path, instance.packageJsonFile.shortPath);
102
102
  }
103
103
  });
104
104
  }
@@ -106,8 +106,8 @@ function logSnappedToMismatch({ report, ctx }) {
106
106
  ctx.isInvalid = true;
107
107
  console.log((0, chalk_1.default) `{red %s} %s {dim should snap to {reset.green %s}, used by %s}`, constants_1.ICON.cross, report.name, report.expectedVersion, report.snapTo.join(' || '));
108
108
  report.instances.forEach((instance) => {
109
- if (instance.version !== report.expectedVersion) {
110
- console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.version, instance.strategy.path, instance.packageJsonFile.shortPath);
109
+ if (instance.specifier !== report.expectedVersion) {
110
+ console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.specifier, instance.strategy.path, instance.packageJsonFile.shortPath);
111
111
  }
112
112
  });
113
113
  }
@@ -115,22 +115,22 @@ function logSameRangeMismatch({ report, ctx }) {
115
115
  ctx.isInvalid = true;
116
116
  console.log((0, chalk_1.default) `{yellow %s %s} {dim has mismatched versions under the "sameRange" policy which syncpack cannot auto fix}%s`, constants_1.ICON.panic, report.name, (0, chalk_1.default) `${os_1.EOL} use {blue syncpack prompt} to fix manually`);
117
117
  report.instances.forEach((instance) => {
118
- console.log((0, chalk_1.default) ` {yellow %s} {dim in %s of %s}`, instance.version, instance.strategy.path, instance.packageJsonFile.shortPath);
118
+ console.log((0, chalk_1.default) ` {yellow %s} {dim in %s of %s}`, instance.specifier, instance.strategy.path, instance.packageJsonFile.shortPath);
119
119
  });
120
120
  }
121
- function logUnsupportedMismatch({ report, ctx }) {
121
+ function logNonSemverMismatch({ report, ctx }) {
122
122
  ctx.isInvalid = true;
123
123
  console.log((0, chalk_1.default) `{yellow %s %s} {dim has mismatched unsupported versions which syncpack cannot auto fix}%s`, constants_1.ICON.panic, report.name, (0, chalk_1.default) `${os_1.EOL} use {blue syncpack prompt} to fix manually`);
124
124
  report.instances.forEach((instance) => {
125
- console.log((0, chalk_1.default) ` {yellow %s} {dim in %s of %s}`, instance.version, instance.strategy.path, instance.packageJsonFile.shortPath);
125
+ console.log((0, chalk_1.default) ` {yellow %s} {dim in %s of %s}`, instance.specifier, instance.strategy.path, instance.packageJsonFile.shortPath);
126
126
  });
127
127
  }
128
- function logWorkspaceMismatch({ report, ctx }) {
128
+ function logLocalPackageMismatch({ report, ctx }) {
129
129
  ctx.isInvalid = true;
130
- console.log((0, chalk_1.default) `{red %s} %s {green %s} {dim is developed in this repo at %s}`, constants_1.ICON.cross, report.name, report.expectedVersion, report.workspaceInstance.packageJsonFile.shortPath);
130
+ console.log((0, chalk_1.default) `{red %s} %s {green %s} {dim is developed in this repo at %s}`, constants_1.ICON.cross, report.name, report.expectedVersion, report.localPackageInstance.packageJsonFile.shortPath);
131
131
  report.instances.forEach((instance) => {
132
- if (instance.version !== report.expectedVersion) {
133
- console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.version, instance.strategy.path, instance.packageJsonFile.shortPath);
132
+ if (instance.specifier !== report.expectedVersion) {
133
+ console.log((0, chalk_1.default) ` {red %s} {dim in %s of %s}`, instance.specifier, instance.strategy.path, instance.packageJsonFile.shortPath);
134
134
  }
135
135
  });
136
136
  }
@@ -32,44 +32,44 @@ const Effect = __importStar(require("@effect/io/Effect"));
32
32
  const chalk_1 = __importDefault(require("chalk"));
33
33
  const constants_1 = require("../constants");
34
34
  const tags_1 = require("../env/tags");
35
- const get_unique_versions_1 = require("../get-version-groups/lib/get-unique-versions");
35
+ const get_unique_specifiers_1 = require("../get-version-groups/lib/get-unique-specifiers");
36
36
  const log_group_header_1 = require("../lib/log-group-header");
37
37
  exports.promptEffects = {
38
38
  onFilteredOut() {
39
- return Effect.unit();
39
+ return Effect.unit;
40
40
  },
41
41
  onIgnored() {
42
- return Effect.unit();
42
+ return Effect.unit;
43
43
  },
44
44
  onValid() {
45
- return Effect.unit();
45
+ return Effect.unit;
46
46
  },
47
47
  onBanned() {
48
- return Effect.unit();
48
+ return Effect.unit;
49
49
  },
50
50
  onHighestSemverMismatch() {
51
- return Effect.unit();
51
+ return Effect.unit;
52
52
  },
53
53
  onLowestSemverMismatch() {
54
- return Effect.unit();
54
+ return Effect.unit;
55
55
  },
56
56
  onPinnedMismatch() {
57
- return Effect.unit();
57
+ return Effect.unit;
58
58
  },
59
59
  onSameRangeMismatch(input) {
60
60
  return (0, Function_1.pipe)(Effect.sync(() => logHeader(input)), Effect.flatMap(askForNextVersion));
61
61
  },
62
62
  onSnappedToMismatch() {
63
- return Effect.unit();
63
+ return Effect.unit;
64
64
  },
65
- onUnsupportedMismatch(input) {
65
+ onNonSemverMismatch(input) {
66
66
  return (0, Function_1.pipe)(Effect.sync(() => logHeader(input)), Effect.flatMap(askForNextVersion));
67
67
  },
68
- onWorkspaceMismatch() {
69
- return Effect.unit();
68
+ onLocalPackageMismatch() {
69
+ return Effect.unit;
70
70
  },
71
71
  onComplete() {
72
- return Effect.unit();
72
+ return Effect.unit;
73
73
  },
74
74
  };
75
75
  function logHeader(input) {
@@ -85,7 +85,7 @@ function askForNextVersion({ report }) {
85
85
  const env = yield* $(tags_1.EnvTag);
86
86
  const choice = yield* $(env.askForChoice({
87
87
  message: (0, chalk_1.default) `${report.name} {dim Choose a version to replace the others}`,
88
- choices: [...(0, get_unique_versions_1.getUniqueVersions)(report.instances), OTHER, SKIP],
88
+ choices: [...(0, get_unique_specifiers_1.getUniqueSpecifiers)(report.instances).map((i) => i.specifier), OTHER, SKIP],
89
89
  }));
90
90
  if (choice === SKIP)
91
91
  return;
@@ -96,7 +96,7 @@ function askForNextVersion({ report }) {
96
96
  : choice;
97
97
  yield* $(Effect.sync(() => {
98
98
  report.instances.forEach((instance) => {
99
- instance.setVersion(nextVersion);
99
+ instance.setSpecifier(nextVersion);
100
100
  });
101
101
  }));
102
102
  }), Effect.catchTags({
@@ -32,30 +32,30 @@ const chalk_1 = __importDefault(require("chalk"));
32
32
  const constants_1 = require("../constants");
33
33
  exports.setSemverRangesEffects = {
34
34
  onFilteredOut() {
35
- return Effect.unit();
35
+ return Effect.unit;
36
36
  },
37
37
  onIgnored() {
38
- return Effect.unit();
38
+ return Effect.unit;
39
39
  },
40
40
  onValid() {
41
- return Effect.unit();
41
+ return Effect.unit;
42
42
  },
43
43
  onSemverRangeMismatch(input) {
44
44
  return Effect.sync(() => setVersions(input));
45
45
  },
46
- onUnsupportedVersion(input) {
47
- return Effect.sync(() => logUnsupportedVersion(input));
46
+ onNonSemverVersion(input) {
47
+ return Effect.sync(() => logNonSemverVersion(input));
48
48
  },
49
- onWorkspaceSemverRangeMismatch(input) {
49
+ onLocalPackageSemverRangeMismatch(input) {
50
50
  return Effect.sync(() => setVersions(input));
51
51
  },
52
52
  onComplete() {
53
- return Effect.unit();
53
+ return Effect.unit;
54
54
  },
55
55
  };
56
56
  function setVersions({ report }) {
57
- report.instance.setVersion(report.expectedVersion);
57
+ report.instance.setSpecifier(report.expectedVersion);
58
58
  }
59
- function logUnsupportedVersion({ report }) {
60
- console.log((0, chalk_1.default) `{yellow %s} %s {yellow %s} {dim ignored as a format which syncpack cannot apply semver ranges to}`, constants_1.ICON.panic, report.name, report.instance.version);
59
+ function logNonSemverVersion({ report }) {
60
+ console.log((0, chalk_1.default) `{yellow %s} %s {yellow %s} {dim ignored as a format which syncpack cannot apply semver ranges to}`, constants_1.ICON.panic, report.name, report.instance.specifier);
61
61
  }
@@ -38,44 +38,44 @@ const prompts_1 = __importDefault(require("prompts"));
38
38
  const unwrap_1 = require("tightrope/result/unwrap");
39
39
  const constants_1 = require("../constants");
40
40
  const get_highest_version_1 = require("../get-version-groups/lib/get-highest-version");
41
- const get_unique_versions_1 = require("../get-version-groups/lib/get-unique-versions");
41
+ const get_unique_specifiers_1 = require("../get-version-groups/lib/get-unique-specifiers");
42
42
  const log_verbose_1 = require("../lib/log-verbose");
43
43
  const set_semver_range_1 = require("../lib/set-semver-range");
44
44
  let spinner;
45
45
  let fetchCount = 0;
46
46
  exports.updateEffects = {
47
47
  onFilteredOut() {
48
- return Effect.unit();
48
+ return Effect.unit;
49
49
  },
50
50
  onIgnored() {
51
- return Effect.unit();
51
+ return Effect.unit;
52
52
  },
53
53
  onValid(input) {
54
54
  return fetchPackageVersions(input);
55
55
  },
56
56
  onBanned() {
57
- return Effect.unit();
57
+ return Effect.unit;
58
58
  },
59
59
  onHighestSemverMismatch(input) {
60
60
  return fetchPackageVersions(input);
61
61
  },
62
62
  onLowestSemverMismatch() {
63
- return Effect.unit();
63
+ return Effect.unit;
64
64
  },
65
65
  onPinnedMismatch() {
66
- return Effect.unit();
66
+ return Effect.unit;
67
67
  },
68
68
  onSameRangeMismatch(input) {
69
69
  return fetchPackageVersions(input);
70
70
  },
71
71
  onSnappedToMismatch() {
72
- return Effect.unit();
72
+ return Effect.unit;
73
73
  },
74
- onUnsupportedMismatch() {
75
- return Effect.unit();
74
+ onNonSemverMismatch() {
75
+ return Effect.unit;
76
76
  },
77
- onWorkspaceMismatch() {
78
- return Effect.unit();
77
+ onLocalPackageMismatch() {
78
+ return Effect.unit;
79
79
  },
80
80
  onComplete(ctx, results) {
81
81
  return promptForUpdates(results);
@@ -120,14 +120,14 @@ function fetchPackageVersions(input) {
120
120
  }
121
121
  function promptForUpdates(results) {
122
122
  spinner.stop();
123
- return (0, Function_1.pipe)(Effect.Do(), Effect.bind('choices', () => Effect.sync(() => results.reduce((arr, result) => {
123
+ return (0, Function_1.pipe)(Effect.Do, Effect.bind('choices', () => Effect.sync(() => results.reduce((arr, result) => {
124
124
  if (!result)
125
125
  return arr;
126
126
  if (!['SameRange', 'Standard'].includes(result.input.group._tag))
127
127
  return arr;
128
128
  const input = result.input;
129
129
  const latestVersion = result.versions.latest;
130
- const uniqueVersions = (0, get_unique_versions_1.getUniqueVersions)(input.report.instances);
130
+ const uniqueVersions = (0, get_unique_specifiers_1.getUniqueSpecifiers)(input.report.instances).map((i) => i.specifier);
131
131
  const highestVersion = (0, unwrap_1.unwrap)((0, get_highest_version_1.getHighestVersion)(uniqueVersions));
132
132
  const exactHighestVersion = (0, set_semver_range_1.setSemverRange)('', highestVersion);
133
133
  if (exactHighestVersion === latestVersion)
@@ -144,27 +144,30 @@ function promptForUpdates(results) {
144
144
  .replace('NEW', latestWithRange),
145
145
  });
146
146
  return arr;
147
- }, []))), Effect.bind('chosenUpdates', ({ choices }) => Effect.tryCatchPromise(() => (0, prompts_1.default)([
148
- {
149
- name: 'indexes',
150
- type: 'multiselect',
151
- message: 'Choose which packages to upgrade',
152
- instructions: true,
153
- // @ts-expect-error optionsPerPage *does* exist https://github.com/terkelg/prompts#options-7
154
- optionsPerPage: 50,
155
- choices: choices,
156
- },
157
- ])
158
- .then(({ indexes = [] }) => ({ choices, indexes }))
159
- .then(({ choices, indexes }) => indexes.map((i) => choices[i].result)), () => new Error('Prompt failed'))), Effect.flatMap(({ chosenUpdates }) => Effect.sync(() => {
147
+ }, []))), Effect.bind('chosenUpdates', ({ choices }) => Effect.tryPromise({
148
+ try: () => (0, prompts_1.default)([
149
+ {
150
+ name: 'indexes',
151
+ type: 'multiselect',
152
+ message: 'Choose which packages to upgrade',
153
+ instructions: true,
154
+ // @ts-expect-error optionsPerPage *does* exist https://github.com/terkelg/prompts#options-7
155
+ optionsPerPage: 50,
156
+ choices: choices,
157
+ },
158
+ ])
159
+ .then(({ indexes = [] }) => ({ choices, indexes }))
160
+ .then(({ choices, indexes }) => indexes.map((i) => choices[i].result)),
161
+ catch: () => new Error('Prompt failed'),
162
+ })), Effect.flatMap(({ chosenUpdates }) => Effect.sync(() => {
160
163
  chosenUpdates.forEach(({ input, versions }) => {
161
164
  input.report.instances.forEach((instance) => {
162
- const semverRange = (0, set_semver_range_1.getSemverRange)(instance.version);
165
+ const semverRange = (0, set_semver_range_1.getSemverRange)(instance.specifier);
163
166
  const latestWithRange = (0, set_semver_range_1.setSemverRange)(semverRange, versions.latest);
164
- instance.setVersion(latestWithRange);
167
+ instance.setSpecifier(latestWithRange);
165
168
  });
166
169
  });
167
- })), Effect.catchAll(() => Effect.unit()));
170
+ })), Effect.catchAll(() => Effect.unit));
168
171
  }
169
172
  // @TODO: add a cache with a short TTL on disk in $TMPDIR
170
173
  function fetchUrl(url) {
@@ -183,5 +186,8 @@ function fetchUrl(url) {
183
186
  .on('error', (err) => {
184
187
  resume(Effect.fail(new HttpError({ error: String(err) })));
185
188
  });
186
- }), Effect.flatMap((body) => Effect.tryCatch(() => JSON.parse(body), (err) => new JsonParseError({ error: String(err) }))));
189
+ }), Effect.flatMap((body) => Effect.try({
190
+ try: () => JSON.parse(body),
191
+ catch: (err) => new JsonParseError({ error: String(err) }),
192
+ })));
187
193
  }
@@ -42,6 +42,6 @@ const effects_1 = require("./effects");
42
42
  function update(cli, env) {
43
43
  return (0, Function_1.pipe)((0, get_context_1.getContext)(), Effect.flatMap((ctx) => (0, versions_1.createVersionsProgram)(ctx, effects_1.updateEffects)),
44
44
  // Effect.flatMap((ctx) => createSemverRangesProgram(ctx, setSemverRangesEffects)),
45
- Effect.flatMap(write_if_changed_1.writeIfChanged), Effect.flatMap(exit_if_invalid_1.exitIfInvalid), Effect.catchTags((0, create_error_handlers_1.createErrorHandlers)(default_error_handlers_1.defaultErrorHandlers)), Effect.withParallelism(10), Effect.provideContext((0, Function_1.pipe)(Context.empty(), Context.add(types_1.CliConfigTag, cli), Context.add(tags_1.EnvTag, (0, create_env_1.createEnv)(env)))));
45
+ Effect.flatMap(write_if_changed_1.writeIfChanged), Effect.flatMap(exit_if_invalid_1.exitIfInvalid), Effect.catchTags((0, create_error_handlers_1.createErrorHandlers)(default_error_handlers_1.defaultErrorHandlers)), Effect.withConcurrency(10), Effect.provideContext((0, Function_1.pipe)(Context.empty(), Context.add(types_1.CliConfigTag, cli), Context.add(tags_1.EnvTag, (0, create_env_1.createEnv)(env)))));
46
46
  }
47
47
  exports.update = update;
@@ -70,7 +70,7 @@ function getEnabledTypes({ cli, rcFile, }) {
70
70
  enabledTypes.push(new versions_by_name_1.VersionsByNameStrategy('resolutions', 'resolutions'));
71
71
  }
72
72
  if (useDefaults || enabledTypeNames.includes('workspace')) {
73
- enabledTypes.push(new name_and_version_props_1.NameAndVersionPropsStrategy('workspace', 'version', 'name'));
73
+ enabledTypes.push(new name_and_version_props_1.NameAndVersionPropsStrategy('localPackage', 'version', 'name'));
74
74
  }
75
75
  (0, get_custom_types_1.getCustomTypes)({ cli, rcFile }).forEach((customType) => {
76
76
  if (useDefaults || enabledTypeNames.includes(customType.name)) {
@@ -19,9 +19,9 @@ export interface SemverRangeEffects<A> {
19
19
  onFilteredOut: (input: SemverRangeEffectInput<SR.FilteredOut>) => Effect.Effect<Env | never, never, A>;
20
20
  onIgnored: (input: SemverRangeEffectInput<SR.Ignored>) => Effect.Effect<Env | never, never, A>;
21
21
  onSemverRangeMismatch: (input: SemverRangeEffectInput<SR.SemverRangeMismatch>) => Effect.Effect<Env | never, never, A>;
22
- onUnsupportedVersion: (input: SemverRangeEffectInput<SR.UnsupportedVersion>) => Effect.Effect<Env | never, never, A>;
22
+ onNonSemverVersion: (input: SemverRangeEffectInput<SR.NonSemverVersion>) => Effect.Effect<Env | never, never, A>;
23
23
  onValid: (input: SemverRangeEffectInput<SR.Valid>) => Effect.Effect<Env | never, never, A>;
24
- onWorkspaceSemverRangeMismatch: (input: SemverRangeEffectInput<SR.WorkspaceSemverRangeMismatch>) => Effect.Effect<Env | never, never, A>;
24
+ onLocalPackageSemverRangeMismatch: (input: SemverRangeEffectInput<SR.LocalPackageSemverRangeMismatch>) => Effect.Effect<Env | never, never, A>;
25
25
  onComplete: (ctx: Ctx, results: A[]) => Effect.Effect<Env | never, never, A>;
26
26
  }
27
27
  export interface VersionEffects<A> {
@@ -33,8 +33,8 @@ export interface VersionEffects<A> {
33
33
  onPinnedMismatch: (input: VersionEffectInput<VR.PinnedMismatch>) => Effect.Effect<Env | never, never, A>;
34
34
  onSameRangeMismatch: (input: VersionEffectInput<VR.SameRangeMismatch>) => Effect.Effect<Env | never, never, A>;
35
35
  onSnappedToMismatch: (input: VersionEffectInput<VR.SnappedToMismatch>) => Effect.Effect<Env | never, never, A>;
36
- onUnsupportedMismatch: (input: VersionEffectInput<VR.UnsupportedMismatch>) => Effect.Effect<Env | never, never, A>;
36
+ onNonSemverMismatch: (input: VersionEffectInput<VR.NonSemverMismatch>) => Effect.Effect<Env | never, never, A>;
37
37
  onValid: (input: VersionEffectInput<VR.Valid>) => Effect.Effect<Env | never, never, A>;
38
- onWorkspaceMismatch: (input: VersionEffectInput<VR.WorkspaceMismatch>) => Effect.Effect<Env | never, never, A>;
38
+ onLocalPackageMismatch: (input: VersionEffectInput<VR.LocalPackageMismatch>) => Effect.Effect<Env | never, never, A>;
39
39
  onComplete: (ctx: Ctx, results: A[]) => Effect.Effect<Env | never, never, A>;
40
40
  }
@@ -30,7 +30,7 @@ const Effect = __importStar(require("@effect/io/Effect"));
30
30
  const Match = __importStar(require("@effect/match"));
31
31
  const get_semver_groups_1 = require("../get-semver-groups");
32
32
  function createSemverRangesProgram(ctx, effects) {
33
- return (0, Function_1.pipe)((0, get_semver_groups_1.getSemverGroups)(ctx), Effect.flatMap((semverGroups) => Effect.allPar(semverGroups.flatMap((group) => group.inspect().map((reportEffect, index) => (0, Function_1.pipe)((0, Unify_1.unify)(reportEffect), Effect.flatMap((0, Function_1.pipe)(Match.type(), Match.tagsExhaustive({
33
+ return (0, Function_1.pipe)((0, get_semver_groups_1.getSemverGroups)(ctx), Effect.flatMap((semverGroups) => Effect.all(semverGroups.flatMap((group) => group.inspect().map((reportEffect, index) => (0, Function_1.pipe)((0, Unify_1.unify)(reportEffect), Effect.flatMap((0, Function_1.pipe)(Match.type(), Match.tagsExhaustive({
34
34
  FilteredOut(report) {
35
35
  return effects.onFilteredOut({ ctx, group, index, report });
36
36
  },
@@ -44,12 +44,12 @@ function createSemverRangesProgram(ctx, effects) {
44
44
  SemverRangeMismatch(report) {
45
45
  return effects.onSemverRangeMismatch({ ctx, group, index, report });
46
46
  },
47
- UnsupportedVersion(report) {
48
- return effects.onUnsupportedVersion({ ctx, group, index, report });
47
+ NonSemverVersion(report) {
48
+ return effects.onNonSemverVersion({ ctx, group, index, report });
49
49
  },
50
- WorkspaceSemverRangeMismatch(report) {
51
- return effects.onWorkspaceSemverRangeMismatch({ ctx, group, index, report });
50
+ LocalPackageSemverRangeMismatch(report) {
51
+ return effects.onLocalPackageSemverRangeMismatch({ ctx, group, index, report });
52
52
  },
53
- })))))), Effect.flatMap((results) => effects.onComplete(ctx, results)), Effect.map(() => ctx));
53
+ })))), { concurrency: 'inherit' })), Effect.flatMap((results) => effects.onComplete(ctx, results)), Effect.map(() => ctx));
54
54
  }
55
55
  exports.createSemverRangesProgram = createSemverRangesProgram;