syncpack 10.9.3 → 12.0.0-alpha.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.
- package/dist/bin-fix-mismatches/fix-mismatches.d.ts +15 -3
- package/dist/bin-fix-mismatches/fix-mismatches.js +120 -36
- package/dist/bin-fix-mismatches/index.js +12 -32
- package/dist/bin-format/format.d.ts +11 -3
- package/dist/bin-format/format.js +46 -61
- package/dist/bin-format/index.js +11 -31
- package/dist/bin-lint/index.js +8 -28
- package/dist/bin-lint/lint.d.ts +10 -3
- package/dist/bin-lint/lint.js +12 -36
- package/dist/bin-lint-semver-ranges/index.js +11 -39
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +15 -3
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +94 -35
- package/dist/bin-list/index.js +11 -31
- package/dist/bin-list/list.d.ts +11 -3
- package/dist/bin-list/list.js +121 -35
- package/dist/bin-list-mismatches/index.js +11 -31
- package/dist/bin-list-mismatches/list-mismatches.d.ts +18 -3
- package/dist/bin-list-mismatches/list-mismatches.js +254 -35
- package/dist/bin-prompt/index.js +15 -31
- package/dist/bin-prompt/prompt.d.ts +10 -3
- package/dist/bin-prompt/prompt.js +83 -34
- package/dist/bin-set-semver-ranges/index.js +12 -40
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +10 -3
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +50 -36
- package/dist/bin-update/effects.d.ts +45 -5
- package/dist/bin-update/effects.js +214 -128
- package/dist/bin-update/index.js +4 -27
- package/dist/bin-update/update.d.ts +5 -3
- package/dist/bin-update/update.js +52 -38
- package/dist/bin.js +0 -1
- package/dist/config/get-custom-types.d.ts +11 -1
- package/dist/config/get-custom-types.js +26 -21
- package/dist/config/get-enabled-types.d.ts +10 -6
- package/dist/config/get-enabled-types.js +84 -66
- package/dist/config/get-indent.js +1 -1
- package/dist/config/tag.d.ts +3 -0
- package/dist/config/tag.js +5 -0
- package/dist/config/types.d.ts +8 -11
- package/dist/config/types.js +0 -26
- package/dist/constants.d.ts +7 -5
- package/dist/constants.js +15 -14
- package/dist/create-program/effects.d.ts +51 -29
- package/dist/error-handlers/default-error-handlers.d.ts +38 -2
- package/dist/error-handlers/default-error-handlers.js +83 -35
- package/dist/get-context/index.d.ts +12 -6
- package/dist/get-context/index.js +13 -30
- package/dist/get-context/lib/key-by.d.ts +6 -0
- package/dist/get-context/lib/key-by.js +16 -0
- package/dist/get-instances/index.d.ts +14 -0
- package/dist/get-instances/index.js +46 -0
- package/dist/get-instances/instance.d.ts +25 -0
- package/dist/get-instances/instance.js +20 -0
- package/dist/get-package-json-files/get-file-paths.d.ts +6 -7
- package/dist/get-package-json-files/get-file-paths.js +10 -33
- package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +3 -4
- package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +6 -32
- package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +3 -4
- package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +6 -32
- package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +3 -4
- package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +11 -40
- package/dist/get-package-json-files/get-patterns/index.d.ts +3 -5
- package/dist/get-package-json-files/get-patterns/index.js +6 -33
- package/dist/get-package-json-files/index.d.ts +6 -5
- package/dist/get-package-json-files/index.js +4 -28
- package/dist/get-package-json-files/package-json-file.d.ts +16 -16
- package/dist/get-package-json-files/package-json-file.js +13 -18
- package/dist/guards/can-add-to-group.d.ts +5 -4
- package/dist/guards/can-add-to-group.js +40 -6
- package/dist/guards/is-semver.d.ts +1 -1
- package/dist/guards/is-semver.js +1 -1
- package/dist/guards/is-valid-semver-range.d.ts +1 -1
- package/dist/guards/is-valid-semver-range.js +1 -1
- package/dist/io/ask-for-choice.d.ts +14 -0
- package/dist/io/ask-for-choice.js +22 -0
- package/dist/io/ask-for-input.d.ts +13 -0
- package/dist/io/ask-for-input.js +19 -0
- package/dist/io/exit-if-invalid.d.ts +4 -0
- package/dist/io/exit-if-invalid.js +13 -0
- package/dist/io/glob-sync.d.ts +11 -0
- package/dist/io/glob-sync.js +19 -0
- package/dist/io/index.d.ts +28 -0
- package/dist/{env/exit-if-invalid.js → io/index.js} +27 -9
- package/dist/io/read-config-file-sync.d.ts +7 -0
- package/dist/io/read-config-file-sync.js +26 -0
- package/dist/io/read-file-sync.d.ts +12 -0
- package/dist/io/read-file-sync.js +14 -0
- package/dist/io/read-json-file-sync.d.ts +30 -0
- package/dist/io/read-json-file-sync.js +25 -0
- package/dist/io/read-yaml-file-sync.d.ts +12 -0
- package/dist/io/read-yaml-file-sync.js +14 -0
- package/dist/io/write-file-sync.d.ts +12 -0
- package/dist/io/write-file-sync.js +15 -0
- package/dist/{env → io}/write-if-changed.d.ts +4 -4
- package/dist/io/write-if-changed.js +45 -0
- package/dist/lib/get-group-header.d.ts +10 -0
- package/dist/lib/get-group-header.js +31 -0
- package/dist/lib/get.d.ts +11 -0
- package/dist/lib/get.js +40 -0
- package/dist/lib/pad-start.d.ts +1 -0
- package/dist/lib/pad-start.js +7 -0
- package/dist/lib/ring-buffer.d.ts +10 -0
- package/dist/lib/ring-buffer.js +22 -0
- package/dist/lib/set-semver-range.d.ts +1 -1
- package/dist/lib/set-semver-range.js +7 -11
- package/dist/lib/with-logger.d.ts +2 -0
- package/dist/lib/with-logger.js +35 -0
- package/dist/option.d.ts +0 -1
- package/dist/option.js +0 -4
- package/dist/report.d.ts +166 -0
- package/dist/report.js +67 -0
- package/dist/schema.json +392 -0
- package/dist/semver-group/create-semver-groups.d.ts +4 -0
- package/dist/semver-group/create-semver-groups.js +77 -0
- package/dist/semver-group/disabled.d.ts +26 -0
- package/dist/semver-group/disabled.js +34 -0
- package/dist/semver-group/filtered-out.d.ts +27 -0
- package/dist/semver-group/filtered-out.js +40 -0
- package/dist/semver-group/ignored.d.ts +22 -0
- package/dist/semver-group/ignored.js +30 -0
- package/dist/semver-group/index.d.ts +22 -0
- package/dist/semver-group/index.js +10 -0
- package/dist/semver-group/with-range.d.ts +22 -0
- package/dist/semver-group/with-range.js +57 -0
- package/dist/specifier/alias.d.ts +15 -0
- package/dist/specifier/alias.js +25 -0
- package/dist/specifier/base.d.ts +39 -0
- package/dist/specifier/base.js +38 -0
- package/dist/specifier/delete.d.ts +15 -0
- package/dist/specifier/delete.js +16 -0
- package/dist/specifier/file.d.ts +6 -0
- package/dist/specifier/file.js +12 -0
- package/dist/specifier/hosted-git.d.ts +13 -0
- package/dist/specifier/hosted-git.js +27 -0
- package/dist/specifier/index.d.ts +27 -0
- package/dist/specifier/index.js +62 -0
- package/dist/specifier/lib/non-semver-error.d.ts +11 -0
- package/dist/specifier/lib/non-semver-error.js +10 -0
- package/dist/specifier/lib/parse-specifier.d.ts +14 -0
- package/dist/specifier/lib/parse-specifier.js +23 -0
- package/dist/specifier/lib/specific-registry-result.d.ts +9 -0
- package/dist/specifier/lib/specific-registry-result.js +2 -0
- package/dist/specifier/range.d.ts +18 -0
- package/dist/specifier/range.js +26 -0
- package/dist/specifier/tag.d.ts +9 -0
- package/dist/specifier/tag.js +15 -0
- package/dist/specifier/unsupported.d.ts +5 -0
- package/dist/specifier/unsupported.js +12 -0
- package/dist/specifier/url.d.ts +6 -0
- package/dist/specifier/url.js +13 -0
- package/dist/specifier/version.d.ts +18 -0
- package/dist/specifier/version.js +26 -0
- package/dist/specifier/workspace-protocol.d.ts +17 -0
- package/dist/specifier/workspace-protocol.js +38 -0
- package/dist/strategy/lib/get-non-empty-string-prop.d.ts +2 -2
- package/dist/strategy/lib/get-non-empty-string-prop.js +4 -5
- package/dist/strategy/name-and-version-props.d.ts +4 -4
- package/dist/strategy/name-and-version-props.js +32 -21
- package/dist/strategy/named-version-string.d.ts +4 -4
- package/dist/strategy/named-version-string.js +22 -24
- package/dist/strategy/unnamed-version-string.d.ts +4 -4
- package/dist/strategy/unnamed-version-string.js +20 -21
- package/dist/strategy/versions-by-name.d.ts +4 -4
- package/dist/strategy/versions-by-name.js +9 -11
- package/dist/version-group/banned.d.ts +17 -0
- package/dist/version-group/banned.js +32 -0
- package/dist/version-group/create-version-groups.d.ts +4 -0
- package/dist/version-group/create-version-groups.js +107 -0
- package/dist/version-group/filtered-out.d.ts +19 -0
- package/dist/version-group/filtered-out.js +34 -0
- package/dist/version-group/ignored.d.ts +17 -0
- package/dist/version-group/ignored.js +27 -0
- package/dist/version-group/index.d.ts +28 -0
- package/dist/version-group/index.js +10 -0
- package/dist/version-group/lib/get-highest-version.d.ts +6 -0
- package/dist/version-group/lib/get-highest-version.js +12 -0
- package/dist/version-group/lib/get-lowest-version.d.ts +6 -0
- package/dist/version-group/lib/get-lowest-version.js +12 -0
- package/dist/version-group/lib/get-preferred-version.d.ts +5 -0
- package/dist/{get-version-groups/lib/compare-semver.js → version-group/lib/get-preferred-version.js} +14 -2
- package/dist/version-group/lib/group-by.d.ts +5 -0
- package/dist/{get-version-groups → version-group}/lib/group-by.js +4 -0
- package/dist/version-group/pinned.d.ts +17 -0
- package/dist/version-group/pinned.js +30 -0
- package/dist/version-group/same-range.d.ts +19 -0
- package/dist/version-group/same-range.js +108 -0
- package/dist/version-group/snapped-to.d.ts +17 -0
- package/dist/version-group/snapped-to.js +83 -0
- package/dist/version-group/standard.d.ts +18 -0
- package/dist/version-group/standard.js +131 -0
- package/package.json +28 -25
- package/dist/bin-fix-mismatches/effects.d.ts +0 -2
- package/dist/bin-fix-mismatches/effects.js +0 -112
- package/dist/bin-format/format-cli.d.ts +0 -4
- package/dist/bin-format/format-cli.js +0 -42
- package/dist/bin-lint-semver-ranges/effects.d.ts +0 -2
- package/dist/bin-lint-semver-ranges/effects.js +0 -70
- package/dist/bin-list/effects.d.ts +0 -2
- package/dist/bin-list/effects.js +0 -114
- package/dist/bin-list-mismatches/effects.d.ts +0 -2
- package/dist/bin-list-mismatches/effects.js +0 -136
- package/dist/bin-prompt/effects.d.ts +0 -2
- package/dist/bin-prompt/effects.js +0 -110
- package/dist/bin-set-semver-ranges/effects.d.ts +0 -2
- package/dist/bin-set-semver-ranges/effects.js +0 -61
- package/dist/config/get-semver-range.d.ts +0 -3
- package/dist/config/get-semver-range.js +0 -12
- package/dist/create-program/semver-ranges.d.ts +0 -7
- package/dist/create-program/semver-ranges.js +0 -55
- package/dist/create-program/versions.d.ts +0 -7
- package/dist/create-program/versions.js +0 -70
- package/dist/env/create-env.d.ts +0 -21
- package/dist/env/create-env.js +0 -81
- package/dist/env/default-env.d.ts +0 -18
- package/dist/env/default-env.js +0 -96
- package/dist/env/exit-if-invalid.d.ts +0 -4
- package/dist/env/tags.d.ts +0 -58
- package/dist/env/tags.js +0 -50
- package/dist/env/write-if-changed.js +0 -73
- package/dist/error-handlers/create-error-handlers.d.ts +0 -19
- package/dist/error-handlers/create-error-handlers.js +0 -57
- package/dist/get-package-json-files/get-patterns/read-json-safe.d.ts +0 -23
- package/dist/get-package-json-files/get-patterns/read-json-safe.js +0 -43
- package/dist/get-semver-groups/filtered-out.d.ts +0 -19
- package/dist/get-semver-groups/filtered-out.js +0 -55
- package/dist/get-semver-groups/ignored.d.ts +0 -17
- package/dist/get-semver-groups/ignored.js +0 -48
- package/dist/get-semver-groups/index.d.ts +0 -84
- package/dist/get-semver-groups/index.js +0 -139
- package/dist/get-semver-groups/with-range.d.ts +0 -18
- package/dist/get-semver-groups/with-range.js +0 -79
- package/dist/get-version-groups/banned.d.ts +0 -17
- package/dist/get-version-groups/banned.js +0 -50
- package/dist/get-version-groups/filtered-out.d.ts +0 -19
- package/dist/get-version-groups/filtered-out.js +0 -57
- package/dist/get-version-groups/ignored.d.ts +0 -17
- package/dist/get-version-groups/ignored.js +0 -50
- package/dist/get-version-groups/index.d.ts +0 -187
- package/dist/get-version-groups/index.js +0 -246
- package/dist/get-version-groups/lib/compare-semver.d.ts +0 -1
- package/dist/get-version-groups/lib/get-highest-version.d.ts +0 -2
- package/dist/get-version-groups/lib/get-highest-version.js +0 -13
- package/dist/get-version-groups/lib/get-lowest-version.d.ts +0 -2
- package/dist/get-version-groups/lib/get-lowest-version.js +0 -13
- package/dist/get-version-groups/lib/get-unique-specifiers.d.ts +0 -2
- package/dist/get-version-groups/lib/get-unique-specifiers.js +0 -11
- package/dist/get-version-groups/lib/group-by.d.ts +0 -1
- package/dist/get-version-groups/pinned.d.ts +0 -17
- package/dist/get-version-groups/pinned.js +0 -66
- package/dist/get-version-groups/same-range.d.ts +0 -17
- package/dist/get-version-groups/same-range.js +0 -73
- package/dist/get-version-groups/snapped-to.d.ts +0 -17
- package/dist/get-version-groups/snapped-to.js +0 -78
- package/dist/get-version-groups/standard.d.ts +0 -18
- package/dist/get-version-groups/standard.js +0 -109
- package/dist/guards/is-loose-semver.d.ts +0 -2
- package/dist/guards/is-loose-semver.js +0 -10
- package/dist/instance/create.d.ts +0 -4
- package/dist/instance/create.js +0 -142
- package/dist/instance/index.d.ts +0 -122
- package/dist/instance/index.js +0 -154
- package/dist/lib/$R.d.ts +0 -12
- package/dist/lib/$R.js +0 -34
- package/dist/lib/log-group-header.d.ts +0 -6
- package/dist/lib/log-group-header.js +0 -34
- package/dist/lib/log-verbose.d.ts +0 -1
- package/dist/lib/log-verbose.js +0 -24
- package/dist/lib/split-name-and-version.d.ts +0 -5
- package/dist/lib/split-name-and-version.js +0 -12
- /package/dist/{get-version-groups → version-group}/lib/clean.d.ts +0 -0
- /package/dist/{get-version-groups → version-group}/lib/clean.js +0 -0
- /package/dist/{get-version-groups → version-group}/lib/delete.d.ts +0 -0
- /package/dist/{get-version-groups → version-group}/lib/delete.js +0 -0
- /package/dist/{get-version-groups → version-group}/lib/get-range-score.d.ts +0 -0
- /package/dist/{get-version-groups → version-group}/lib/get-range-score.js +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SameRangeVersionGroup = void 0;
|
|
7
|
+
const effect_1 = require("effect");
|
|
8
|
+
const intersects_1 = __importDefault(require("semver/ranges/intersects"));
|
|
9
|
+
const uniq_1 = require("tightrope/array/uniq");
|
|
10
|
+
const report_1 = require("../report");
|
|
11
|
+
const specifier_1 = require("../specifier");
|
|
12
|
+
const group_by_1 = require("./lib/group-by");
|
|
13
|
+
class SameRangeVersionGroup extends effect_1.Data.TaggedClass('SameRange') {
|
|
14
|
+
constructor(ctx, config) {
|
|
15
|
+
super({
|
|
16
|
+
ctx,
|
|
17
|
+
config,
|
|
18
|
+
instances: [],
|
|
19
|
+
});
|
|
20
|
+
this.groupType = 'versionGroup';
|
|
21
|
+
}
|
|
22
|
+
canAdd(_) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
inspectAll() {
|
|
26
|
+
return effect_1.Effect.all(Object.entries((0, group_by_1.groupBy)('name', this.instances)).flatMap(([name, instances]) => (0, effect_1.pipe)(instances, effect_1.Effect.partition((instance) => (0, effect_1.pipe)(effect_1.Effect.succeed(specifier_1.Specifier.create(instance, instance.rawSpecifier)), effect_1.Effect.flatMap((specifier) => (0, effect_1.pipe)(specifier.getSemver(), effect_1.Effect.matchEffect({
|
|
27
|
+
onFailure: () => effect_1.Effect.fail(
|
|
28
|
+
// ✘ expected version is not semver
|
|
29
|
+
// ✘ is a mismatch we can't auto-fix
|
|
30
|
+
new report_1.Report.UnsupportedMismatch({ unfixable: specifier.instance })),
|
|
31
|
+
onSuccess: () => (0, effect_1.pipe)(specifier.instance.semverGroup.getFixed(specifier), effect_1.Effect.matchEffect({
|
|
32
|
+
onFailure: () => effect_1.Effect.fail(
|
|
33
|
+
// ✓ expected version is semver
|
|
34
|
+
// ✘ expected version is not fixable by its semver group
|
|
35
|
+
// ✘ is a mismatch we can't auto-fix
|
|
36
|
+
new report_1.Report.UnsupportedMismatch({
|
|
37
|
+
unfixable: specifier.instance,
|
|
38
|
+
})),
|
|
39
|
+
onSuccess: (valid) => specifier.instance.rawSpecifier === valid.raw
|
|
40
|
+
? effect_1.Effect.succeed(
|
|
41
|
+
// ✓ expected version is semver
|
|
42
|
+
// ✓ expected version matches its semver group
|
|
43
|
+
// ✓ current version matches expected
|
|
44
|
+
new report_1.Report.Valid({ specifier }))
|
|
45
|
+
: effect_1.Effect.fail(
|
|
46
|
+
// ✓ expected version is semver
|
|
47
|
+
// ✓ expected version matches its semver group
|
|
48
|
+
// ✘ current version mismatches expected
|
|
49
|
+
// ✓ is a mismatch we can auto-fix
|
|
50
|
+
new report_1.Report.SemverRangeMismatch({ fixable: valid })),
|
|
51
|
+
})),
|
|
52
|
+
}))))), effect_1.Effect.map(([allMismatches, allMatches]) => allMismatches.length === 0
|
|
53
|
+
? allMatches.map((thisMatch) => {
|
|
54
|
+
if (thisMatch.specifier.instance.strategy.name === 'local') {
|
|
55
|
+
// ✓ every instance is valid on its own
|
|
56
|
+
// ✓ expected version is semver
|
|
57
|
+
// ! is the original local package
|
|
58
|
+
// ✓ others must match this, not the other way around
|
|
59
|
+
return thisMatch;
|
|
60
|
+
}
|
|
61
|
+
const mismatches = getRangeMismatches(this.ctx, thisMatch, allMatches);
|
|
62
|
+
if (mismatches.length === 0) {
|
|
63
|
+
// ✓ every instance is valid on its own
|
|
64
|
+
// ✓ expected version is semver
|
|
65
|
+
// ✓ expected version matches its semver group
|
|
66
|
+
// ✓ current version matches expected
|
|
67
|
+
// ! is not the original local package
|
|
68
|
+
// ✓ current specifier matches every other specifier
|
|
69
|
+
return thisMatch;
|
|
70
|
+
}
|
|
71
|
+
// ✓ every instance is valid on its own
|
|
72
|
+
// ✓ expected version is semver
|
|
73
|
+
// ✓ expected version matches its semver group
|
|
74
|
+
// ✓ current version matches expected
|
|
75
|
+
// ! is not the original local package
|
|
76
|
+
// ✘ current specifier does not match every other specifier
|
|
77
|
+
return new report_1.Report.SameRangeMismatch({
|
|
78
|
+
unfixable: thisMatch.specifier.instance,
|
|
79
|
+
mismatches: (0, uniq_1.uniq)(mismatches.map((report) => report.specifier.instance.rawSpecifier)),
|
|
80
|
+
});
|
|
81
|
+
})
|
|
82
|
+
: // ✘ not every instance is valid on its own
|
|
83
|
+
// ! report on their validity individually ! when all are valid
|
|
84
|
+
// they can progress to being checked for having compatible
|
|
85
|
+
// ranges
|
|
86
|
+
[...allMatches, ...allMismatches]), effect_1.Effect.map((reports) => ({ name, reports })))));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.SameRangeVersionGroup = SameRangeVersionGroup;
|
|
90
|
+
/** Find all ranges/versions which this semver version does not cover */
|
|
91
|
+
function getRangeMismatches(ctx, report, others) {
|
|
92
|
+
return others.filter((other) => !matchesRange(ctx, report, other));
|
|
93
|
+
}
|
|
94
|
+
/** Does semver version `a` match semver version `b`? */
|
|
95
|
+
function matchesRange(ctx, a, b) {
|
|
96
|
+
const loose = true;
|
|
97
|
+
return (0, intersects_1.default)(unwrapSemver(ctx, a.specifier), unwrapSemver(ctx, b.specifier), loose);
|
|
98
|
+
}
|
|
99
|
+
/** Get the semver version synchronously from a specifier known to contain semver */
|
|
100
|
+
function unwrapSemver(ctx, specifier) {
|
|
101
|
+
if (specifier._tag === 'RangeSpecifier' || specifier._tag === 'VersionSpecifier') {
|
|
102
|
+
return specifier.raw;
|
|
103
|
+
}
|
|
104
|
+
if (specifier._tag === 'WorkspaceProtocolSpecifier') {
|
|
105
|
+
return effect_1.Effect.runSync(specifier.getSemverEquivalent(ctx));
|
|
106
|
+
}
|
|
107
|
+
return effect_1.Effect.runSync(specifier.getSemver());
|
|
108
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Data, Effect } from 'effect';
|
|
2
|
+
import type { VersionGroupConfig } from '../config/types';
|
|
3
|
+
import type { Instance } from '../get-instances/instance';
|
|
4
|
+
import { Report } from '../report';
|
|
5
|
+
declare const SnappedToVersionGroup_base: new <A extends Record<string, any>>(args: import("effect/Types").Equals<Omit<A, keyof import("effect/dist/declarations/src/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("effect/dist/declarations/src/Equal").Equal>) => Data.Data<A & {
|
|
6
|
+
readonly _tag: "SnappedTo";
|
|
7
|
+
}>;
|
|
8
|
+
export declare class SnappedToVersionGroup extends SnappedToVersionGroup_base<{
|
|
9
|
+
config: VersionGroupConfig.SnappedTo;
|
|
10
|
+
instances: Instance[];
|
|
11
|
+
}> {
|
|
12
|
+
groupType: string;
|
|
13
|
+
constructor(config: VersionGroupConfig.SnappedTo);
|
|
14
|
+
canAdd(_: Instance): boolean;
|
|
15
|
+
inspectAll(): Effect.Effect<never, never, Report.Version.Group[]>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnappedToVersionGroup = void 0;
|
|
4
|
+
const effect_1 = require("effect");
|
|
5
|
+
const report_1 = require("../report");
|
|
6
|
+
const specifier_1 = require("../specifier");
|
|
7
|
+
const group_by_1 = require("./lib/group-by");
|
|
8
|
+
class SnappedToVersionGroup extends effect_1.Data.TaggedClass('SnappedTo') {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super({
|
|
11
|
+
config,
|
|
12
|
+
instances: [],
|
|
13
|
+
});
|
|
14
|
+
this.groupType = 'versionGroup';
|
|
15
|
+
}
|
|
16
|
+
canAdd(_) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
inspectAll() {
|
|
20
|
+
return effect_1.Effect.all(Object.entries((0, group_by_1.groupBy)('name', this.instances)).flatMap(([name, instances]) => (0, effect_1.pipe)(findSnappedToInstance(name, this.config.snapTo, instances), effect_1.Effect.matchEffect({
|
|
21
|
+
onFailure: () => effect_1.Effect.succeed(instances.map((instance) =>
|
|
22
|
+
// ✘ none of the snapTo packages contain this dependency
|
|
23
|
+
// ✘ is a user configuration error we can't auto-fix
|
|
24
|
+
new report_1.Report.MissingSnappedToMismatch({ unfixable: instance }))),
|
|
25
|
+
onSuccess: (expected) => (0, effect_1.pipe)(instances, effect_1.Effect.forEach((instance) => (0, effect_1.pipe)(effect_1.Effect.Do, effect_1.Effect.bind('specifier', () => effect_1.Effect.succeed(specifier_1.Specifier.create(instance, instance.rawSpecifier))), effect_1.Effect.bind('expected', () => effect_1.Effect.succeed(specifier_1.Specifier.create(instance, expected.rawSpecifier))), effect_1.Effect.flatMap(({ expected, specifier }) => (0, effect_1.pipe)(expected.getSemver(), effect_1.Effect.matchEffect({
|
|
26
|
+
onFailure: () => (0, effect_1.pipe)(specifier.replaceWith(expected), specifier.instance.semverGroup.getFixed, effect_1.Effect.match({
|
|
27
|
+
onFailure: () =>
|
|
28
|
+
// ✘ expected version is not semver
|
|
29
|
+
// ✘ semver group expects semver
|
|
30
|
+
// ✘ is a mismatch we can't auto-fix
|
|
31
|
+
new report_1.Report.UnsupportedMismatch({
|
|
32
|
+
unfixable: specifier.instance,
|
|
33
|
+
}),
|
|
34
|
+
onSuccess: (valid) => specifier.instance.rawSpecifier === valid.raw
|
|
35
|
+
? // ! expected version is not semver
|
|
36
|
+
// ✓ semver group is disabled/ignored
|
|
37
|
+
// ✓ current version matches expected
|
|
38
|
+
new report_1.Report.Valid({ specifier })
|
|
39
|
+
: // ! expected version is not semver
|
|
40
|
+
// ✓ semver group is disabled/ignored
|
|
41
|
+
// ✘ current version mismatches expected
|
|
42
|
+
// ✓ is a mismatch we can auto-fix by replacing with the non-semver version
|
|
43
|
+
new report_1.Report.SnappedToMismatch({
|
|
44
|
+
fixable: valid,
|
|
45
|
+
localInstance: expected.instance,
|
|
46
|
+
}),
|
|
47
|
+
})),
|
|
48
|
+
onSuccess: () => (0, effect_1.pipe)(specifier.replaceWith(expected), specifier.instance.semverGroup.getFixed, effect_1.Effect.match({
|
|
49
|
+
onFailure: /* istanbul ignore next */ () =>
|
|
50
|
+
// ✓ expected version is semver
|
|
51
|
+
// ✘ expected version is not fixable by its semver group
|
|
52
|
+
// ✘ is a mismatch we can't auto-fix
|
|
53
|
+
// ✘ this should be impossible - we already proved the local version is exact semver
|
|
54
|
+
new report_1.Report.UnsupportedMismatch({
|
|
55
|
+
unfixable: specifier.instance,
|
|
56
|
+
}),
|
|
57
|
+
onSuccess: (valid) => specifier.instance.rawSpecifier === valid.raw
|
|
58
|
+
? // ✓ expected version is semver
|
|
59
|
+
// ✓ expected version matches its semver group
|
|
60
|
+
// ✓ current version matches expected
|
|
61
|
+
new report_1.Report.Valid({ specifier })
|
|
62
|
+
: // ✓ expected version is semver
|
|
63
|
+
// ✓ expected version matches its semver group
|
|
64
|
+
// ✘ current version mismatches expected
|
|
65
|
+
// ✓ is a mismatch we can auto-fix
|
|
66
|
+
new report_1.Report.SnappedToMismatch({
|
|
67
|
+
fixable: valid,
|
|
68
|
+
localInstance: expected.instance,
|
|
69
|
+
}),
|
|
70
|
+
})),
|
|
71
|
+
})))))),
|
|
72
|
+
}), effect_1.Effect.map((reports) => ({ name, reports })))));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.SnappedToVersionGroup = SnappedToVersionGroup;
|
|
76
|
+
function findSnappedToInstance(name, snapTo, instances) {
|
|
77
|
+
for (const instance of instances) {
|
|
78
|
+
if (snapTo.includes(instance.pkgName) && instance.rawSpecifier) {
|
|
79
|
+
return (0, effect_1.pipe)(effect_1.Effect.succeed(instance), effect_1.Effect.tap(() => effect_1.Effect.logDebug(`found snapped to version ${instance.rawSpecifier} for ${name} in <${instance.packageJsonFile.jsonFile.shortPath}>`)));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return (0, effect_1.pipe)(effect_1.Effect.fail('getSnappedTo found nothing'), effect_1.Effect.tapError(() => effect_1.Effect.logError(`failed to get snapped to version for ${name} using ${JSON.stringify(snapTo)}`)));
|
|
83
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Data, Effect } from 'effect';
|
|
2
|
+
import type { VersionGroupConfig } from '../config/types';
|
|
3
|
+
import type { Instance } from '../get-instances/instance';
|
|
4
|
+
import { Report } from '../report';
|
|
5
|
+
declare const StandardVersionGroup_base: new <A extends Record<string, any>>(args: import("effect/Types").Equals<Omit<A, keyof import("effect/dist/declarations/src/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("effect/dist/declarations/src/Equal").Equal>) => Data.Data<A & {
|
|
6
|
+
readonly _tag: "Standard";
|
|
7
|
+
}>;
|
|
8
|
+
export declare class StandardVersionGroup extends StandardVersionGroup_base<{
|
|
9
|
+
config: VersionGroupConfig.Standard;
|
|
10
|
+
instances: Instance[];
|
|
11
|
+
isCatchAll: boolean;
|
|
12
|
+
}> {
|
|
13
|
+
groupType: string;
|
|
14
|
+
constructor(isCatchAll: boolean, config: VersionGroupConfig.Standard);
|
|
15
|
+
canAdd(_: Instance): boolean;
|
|
16
|
+
inspectAll(): Effect.Effect<never, never, Report.Version.Group[]>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StandardVersionGroup = void 0;
|
|
4
|
+
const effect_1 = require("effect");
|
|
5
|
+
const uniq_1 = require("tightrope/array/uniq");
|
|
6
|
+
const report_1 = require("../report");
|
|
7
|
+
const specifier_1 = require("../specifier");
|
|
8
|
+
const get_preferred_version_1 = require("./lib/get-preferred-version");
|
|
9
|
+
const group_by_1 = require("./lib/group-by");
|
|
10
|
+
class StandardVersionGroup extends effect_1.Data.TaggedClass('Standard') {
|
|
11
|
+
constructor(isCatchAll, config) {
|
|
12
|
+
super({
|
|
13
|
+
config,
|
|
14
|
+
instances: [],
|
|
15
|
+
isCatchAll,
|
|
16
|
+
});
|
|
17
|
+
this.groupType = 'versionGroup';
|
|
18
|
+
}
|
|
19
|
+
canAdd(_) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
inspectAll() {
|
|
23
|
+
return effect_1.Effect.all(Object.entries((0, group_by_1.groupBy)('name', this.instances)).flatMap(([name, instances]) => {
|
|
24
|
+
const localInstance = getLocalInstance(instances);
|
|
25
|
+
if (localInstance) {
|
|
26
|
+
const localVersion = localInstance?.rawSpecifier;
|
|
27
|
+
return localVersion === 'PACKAGE_JSON_HAS_NO_VERSION'
|
|
28
|
+
? effect_1.Effect.succeed({
|
|
29
|
+
name,
|
|
30
|
+
reports: instances.map((instance) =>
|
|
31
|
+
// ! dependency is a package developed in this repo
|
|
32
|
+
// ✘ local package is missing a .version property
|
|
33
|
+
// ✘ is a mismatch we can't auto-fix
|
|
34
|
+
new report_1.Report.MissingLocalVersion({
|
|
35
|
+
localInstance,
|
|
36
|
+
unfixable: instance,
|
|
37
|
+
})),
|
|
38
|
+
})
|
|
39
|
+
: (0, effect_1.pipe)(effect_1.Effect.succeed(specifier_1.Specifier.create(localInstance, localVersion)), effect_1.Effect.flatMap((local) => effect_1.Effect.all(local._tag !== 'VersionSpecifier'
|
|
40
|
+
? instances.map((instance) =>
|
|
41
|
+
// ! dependency is a package developed in this repo
|
|
42
|
+
// ✘ local package has an invalid .version property
|
|
43
|
+
// ✘ is a mismatch we can't auto-fix
|
|
44
|
+
effect_1.Effect.succeed(new report_1.Report.MissingLocalVersion({
|
|
45
|
+
localInstance,
|
|
46
|
+
unfixable: instance,
|
|
47
|
+
})))
|
|
48
|
+
: instances.flatMap((instance) => (0, effect_1.pipe)(effect_1.Effect.succeed(specifier_1.Specifier.create(instance, instance.rawSpecifier)), effect_1.Effect.flatMap((specifier) => specifier.instance === localInstance
|
|
49
|
+
? // ✓ this is the local package which the others should match
|
|
50
|
+
// ! its version must always remain as exact semver
|
|
51
|
+
// ! other instances need to be adjusted for their semver groups
|
|
52
|
+
effect_1.Effect.succeed(new report_1.Report.Valid({ specifier }))
|
|
53
|
+
: (0, effect_1.pipe)(specifier.replaceWith(local), specifier.instance.semverGroup.getFixed, effect_1.Effect.match({
|
|
54
|
+
onFailure: /* istanbul ignore next */ () =>
|
|
55
|
+
// ! is not the local package instance
|
|
56
|
+
// ✘ local version is not fixable by this semver group
|
|
57
|
+
// ✘ is a mismatch we can't auto-fix
|
|
58
|
+
// ✘ this should be impossible - we already proved the local version is exact semver
|
|
59
|
+
new report_1.Report.UnsupportedMismatch({
|
|
60
|
+
unfixable: specifier.instance,
|
|
61
|
+
}),
|
|
62
|
+
onSuccess: (valid) => specifier.instance.rawSpecifier === valid.raw
|
|
63
|
+
? // ! is not the local package instance
|
|
64
|
+
// ✓ local version matches this semver group
|
|
65
|
+
// ✓ current version matches local
|
|
66
|
+
new report_1.Report.Valid({ specifier })
|
|
67
|
+
: // ! is not the local package instance
|
|
68
|
+
// ✓ local version matches this semver group
|
|
69
|
+
// ✘ current version mismatches local
|
|
70
|
+
new report_1.Report.LocalPackageMismatch({
|
|
71
|
+
fixable: valid,
|
|
72
|
+
localInstance,
|
|
73
|
+
}),
|
|
74
|
+
}))))))), effect_1.Effect.map((reports) => ({ name, reports })));
|
|
75
|
+
}
|
|
76
|
+
const PreferredMismatch = this.config.preferVersion === 'lowestSemver'
|
|
77
|
+
? report_1.Report.LowestSemverMismatch
|
|
78
|
+
: report_1.Report.HighestSemverMismatch;
|
|
79
|
+
return (0, effect_1.pipe)(effect_1.Effect.succeed(instances.map((instance) => specifier_1.Specifier.create(instance, instance.rawSpecifier))), effect_1.Effect.flatMap((specifiers) => (0, effect_1.pipe)((0, get_preferred_version_1.getPreferredVersion)(this.config.preferVersion, specifiers), effect_1.Effect.matchEffect({
|
|
80
|
+
onFailure: () => effect_1.Effect.succeed((0, uniq_1.uniq)(specifiers.map((specifier) => specifier.instance.rawSpecifier)).length ===
|
|
81
|
+
1
|
|
82
|
+
? specifiers.map((specifier) =>
|
|
83
|
+
// ✘ not every version is semver
|
|
84
|
+
// ✓ every version is identical
|
|
85
|
+
// ✓ is a match
|
|
86
|
+
new report_1.Report.Valid({ specifier }))
|
|
87
|
+
: instances.map((instance) =>
|
|
88
|
+
// ✘ not every version is semver
|
|
89
|
+
// ✘ some versions are not identical
|
|
90
|
+
// ✘ is a mismatch we can't auto-fix
|
|
91
|
+
new report_1.Report.UnsupportedMismatch({ unfixable: instance }))),
|
|
92
|
+
onSuccess: (expectedVersion) => (0, effect_1.pipe)(specifiers, effect_1.Effect.forEach((current) => (0, effect_1.pipe)(current.replaceWith(expectedVersion), current.instance.semverGroup.getFixed, effect_1.Effect.match({
|
|
93
|
+
onFailure: /* istanbul ignore next */ () =>
|
|
94
|
+
// ✓ every version is semver
|
|
95
|
+
// ✘ expected version is not fixable by its semver group
|
|
96
|
+
// ✘ is a mismatch we can't auto-fix
|
|
97
|
+
// ✘ this should be impossible - any valid semver is fixable by a semver group
|
|
98
|
+
new report_1.Report.UnsupportedMismatch({ unfixable: current.instance }),
|
|
99
|
+
onSuccess: (expectedRange) => current.instance.rawSpecifier === expectedRange.raw
|
|
100
|
+
? // ✓ every version is semver
|
|
101
|
+
// ✓ current version matches expected semver
|
|
102
|
+
// ✓ current version matches expected version
|
|
103
|
+
new report_1.Report.Valid({ specifier: current })
|
|
104
|
+
: current.instance.rawSpecifier === expectedVersion.raw
|
|
105
|
+
? // ✓ every version is semver
|
|
106
|
+
// ✓ current version matches expected version
|
|
107
|
+
// ✘ current version does not match expected semver
|
|
108
|
+
// ✓ is a mismatch we can auto-fix
|
|
109
|
+
new report_1.Report.SemverRangeMismatch({ fixable: expectedRange })
|
|
110
|
+
: // ✓ every version is semver
|
|
111
|
+
// ✘ current version does not match expected version
|
|
112
|
+
// ✘ expected version does not match expected semver
|
|
113
|
+
// ✓ is a mismatch we can auto-fix
|
|
114
|
+
new PreferredMismatch({ fixable: expectedRange }),
|
|
115
|
+
})))),
|
|
116
|
+
}))), effect_1.Effect.map((reports) => ({ name, reports })));
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.StandardVersionGroup = StandardVersionGroup;
|
|
121
|
+
/**
|
|
122
|
+
* If this dependency is developed in this monorepo, get the instance which
|
|
123
|
+
* represents the canonical .version property of its package.json file.
|
|
124
|
+
*/
|
|
125
|
+
function getLocalInstance(instances) {
|
|
126
|
+
return instances.find(isLocalInstance);
|
|
127
|
+
}
|
|
128
|
+
/** Is this dependency developed in this monorepo */
|
|
129
|
+
function isLocalInstance(instance) {
|
|
130
|
+
return instance.strategy.name === 'local';
|
|
131
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "syncpack",
|
|
3
3
|
"description": "Consistent dependency versions in large JavaScript Monorepos",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "12.0.0-alpha.0",
|
|
5
5
|
"author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",
|
|
6
6
|
"bin": {
|
|
7
7
|
"syncpack": "dist/bin.js",
|
|
@@ -31,18 +31,16 @@
|
|
|
31
31
|
"Tom Fletcher (https://github.com/tom-fletcher)"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@effect/
|
|
35
|
-
"@effect/
|
|
36
|
-
"@effect/match": "0.31.0",
|
|
37
|
-
"@effect/schema": "0.32.0",
|
|
34
|
+
"@effect/match": "0.40.0",
|
|
35
|
+
"@effect/schema": "0.43.0",
|
|
38
36
|
"chalk": "4.1.2",
|
|
39
37
|
"commander": "11.0.0",
|
|
40
|
-
"cosmiconfig": "8.
|
|
38
|
+
"cosmiconfig": "8.3.6",
|
|
39
|
+
"effect": "2.0.0-next.48",
|
|
41
40
|
"enquirer": "2.4.1",
|
|
42
|
-
"fs-extra": "11.1.1",
|
|
43
41
|
"globby": "11.1.0",
|
|
44
42
|
"minimatch": "9.0.3",
|
|
45
|
-
"npm-package-arg": "
|
|
43
|
+
"npm-package-arg": "11.0.1",
|
|
46
44
|
"ora": "5.4.1",
|
|
47
45
|
"prompts": "2.4.2",
|
|
48
46
|
"read-yaml-file": "2.1.0",
|
|
@@ -51,25 +49,27 @@
|
|
|
51
49
|
"ts-toolbelt": "9.6.0"
|
|
52
50
|
},
|
|
53
51
|
"devDependencies": {
|
|
54
|
-
"@tsconfig/node18": "18.2.
|
|
55
|
-
"@types/
|
|
56
|
-
"@types/jest": "29.5.3",
|
|
52
|
+
"@tsconfig/node18": "18.2.2",
|
|
53
|
+
"@types/jest": "29.5.5",
|
|
57
54
|
"@types/node": "14.18.36",
|
|
58
|
-
"@types/npm-package-arg": "6.1.
|
|
59
|
-
"@types/prompts": "2.4.
|
|
60
|
-
"@types/semver": "7.5.
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
62
|
-
"@typescript-eslint/parser": "6.
|
|
63
|
-
"eslint": "8.
|
|
64
|
-
"eslint-plugin-import": "2.28.
|
|
65
|
-
"eslint-plugin-jest": "27.2
|
|
55
|
+
"@types/npm-package-arg": "6.1.2",
|
|
56
|
+
"@types/prompts": "2.4.5",
|
|
57
|
+
"@types/semver": "7.5.3",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "6.7.5",
|
|
59
|
+
"@typescript-eslint/parser": "6.7.5",
|
|
60
|
+
"eslint": "8.51.0",
|
|
61
|
+
"eslint-plugin-import": "2.28.1",
|
|
62
|
+
"eslint-plugin-jest": "27.4.2",
|
|
66
63
|
"expect-more-jest": "5.5.0",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
64
|
+
"immer": "10.0.3",
|
|
65
|
+
"jest": "29.7.0",
|
|
66
|
+
"memfs": "4.6.0",
|
|
67
|
+
"prettier": "3.0.3",
|
|
68
|
+
"rimraf": "5.0.5",
|
|
70
69
|
"ts-jest": "29.1.1",
|
|
71
70
|
"ts-node": "10.9.1",
|
|
72
|
-
"typescript": "5.
|
|
71
|
+
"typescript": "5.2.2",
|
|
72
|
+
"typescript-json-schema": "0.61.0"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=16"
|
|
@@ -109,7 +109,10 @@
|
|
|
109
109
|
"wrap-ansi": "<8.0.0"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
|
-
"build": "
|
|
112
|
+
"build": "yarn clean && yarn build:source && yarn build:json-schema",
|
|
113
|
+
"build:json-schema": "typescript-json-schema --noExtraProps src/index.ts RcFile --out dist/schema.json",
|
|
114
|
+
"build:source": "tsc --project tsconfig.build.json",
|
|
115
|
+
"clean": "rm -rf ./dist",
|
|
113
116
|
"format": "yarn format:lint && yarn format:source",
|
|
114
117
|
"format:lint": "yarn lint --fix",
|
|
115
118
|
"format:source": "prettier --write .",
|
|
@@ -117,7 +120,7 @@
|
|
|
117
120
|
"lint:eslint": "eslint --ext .ts .",
|
|
118
121
|
"lint:ts": "tsc --noEmit --project tsconfig.json",
|
|
119
122
|
"prepack": "yarn build",
|
|
120
|
-
"test": "jest
|
|
123
|
+
"test": "jest"
|
|
121
124
|
},
|
|
122
125
|
"types": "dist/index.d.ts"
|
|
123
126
|
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.fixMismatchesEffects = void 0;
|
|
30
|
-
const Function_1 = require("@effect/data/Function");
|
|
31
|
-
const Effect = __importStar(require("@effect/io/Effect"));
|
|
32
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
33
|
-
const os_1 = require("os");
|
|
34
|
-
const is_object_1 = require("tightrope/guard/is-object");
|
|
35
|
-
const is_undefined_1 = require("tightrope/guard/is-undefined");
|
|
36
|
-
const constants_1 = require("../constants");
|
|
37
|
-
const delete_1 = require("../get-version-groups/lib/delete");
|
|
38
|
-
const log_group_header_1 = require("../lib/log-group-header");
|
|
39
|
-
exports.fixMismatchesEffects = {
|
|
40
|
-
onFilteredOut() {
|
|
41
|
-
return Effect.unit;
|
|
42
|
-
},
|
|
43
|
-
onIgnored() {
|
|
44
|
-
return Effect.unit;
|
|
45
|
-
},
|
|
46
|
-
onValid() {
|
|
47
|
-
return Effect.unit;
|
|
48
|
-
},
|
|
49
|
-
onBanned(input) {
|
|
50
|
-
return Effect.sync(() => removeVersions(input));
|
|
51
|
-
},
|
|
52
|
-
onHighestSemverMismatch(input) {
|
|
53
|
-
return Effect.sync(() => setVersions(input));
|
|
54
|
-
},
|
|
55
|
-
onLowestSemverMismatch(input) {
|
|
56
|
-
return Effect.sync(() => setVersions(input));
|
|
57
|
-
},
|
|
58
|
-
onPinnedMismatch(input) {
|
|
59
|
-
return Effect.sync(() => setVersions(input));
|
|
60
|
-
},
|
|
61
|
-
onSameRangeMismatch(input) {
|
|
62
|
-
return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logSameRangeMismatch));
|
|
63
|
-
},
|
|
64
|
-
onSnappedToMismatch(input) {
|
|
65
|
-
return Effect.sync(() => setVersions(input));
|
|
66
|
-
},
|
|
67
|
-
onNonSemverMismatch(input) {
|
|
68
|
-
return Effect.sync(() => (0, Function_1.pipe)(input, logHeader, logNonSemverMismatch));
|
|
69
|
-
},
|
|
70
|
-
onLocalPackageMismatch(input) {
|
|
71
|
-
return Effect.sync(() => setVersions(input));
|
|
72
|
-
},
|
|
73
|
-
onComplete(ctx) {
|
|
74
|
-
return Effect.sync(() => deleteEmptyObjects(ctx));
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
function logHeader(input) {
|
|
78
|
-
if (input.index === 0) {
|
|
79
|
-
log_group_header_1.logGroupHeader.versionGroup(input.group, input.index);
|
|
80
|
-
}
|
|
81
|
-
return input;
|
|
82
|
-
}
|
|
83
|
-
function setVersions({ report }) {
|
|
84
|
-
report.instances.forEach((instance) => {
|
|
85
|
-
instance.setSpecifier(report.expectedVersion);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
function removeVersions({ report }) {
|
|
89
|
-
report.instances.forEach((instance) => {
|
|
90
|
-
instance.setSpecifier(delete_1.DELETE);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function logSameRangeMismatch({ ctx, report }) {
|
|
94
|
-
ctx.isInvalid = true;
|
|
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
|
-
}
|
|
97
|
-
function logNonSemverMismatch({ ctx, report }) {
|
|
98
|
-
ctx.isInvalid = true;
|
|
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
|
-
}
|
|
101
|
-
/** Remove empty objects such as `{"dependencies": {}}` left after deleting */
|
|
102
|
-
function deleteEmptyObjects(ctx) {
|
|
103
|
-
ctx.packageJsonFiles.forEach((packageJsonFile) => {
|
|
104
|
-
const contents = packageJsonFile.contents;
|
|
105
|
-
Object.keys(contents).forEach((key) => {
|
|
106
|
-
const value = contents[key];
|
|
107
|
-
if ((0, is_object_1.isObject)(value) && Object.values(value).every(is_undefined_1.isUndefined)) {
|
|
108
|
-
delete contents[key];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as Effect from '@effect/io/Effect';
|
|
2
|
-
import { type CliConfig } from '../config/types';
|
|
3
|
-
import type { DefaultEnv } from '../env/default-env';
|
|
4
|
-
export declare function formatCli(cli: Partial<CliConfig>, env: DefaultEnv): Effect.Effect<never, never, void | import("../get-context").Ctx>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.formatCli = void 0;
|
|
27
|
-
const Context = __importStar(require("@effect/data/Context"));
|
|
28
|
-
const Function_1 = require("@effect/data/Function");
|
|
29
|
-
const Effect = __importStar(require("@effect/io/Effect"));
|
|
30
|
-
const types_1 = require("../config/types");
|
|
31
|
-
const create_env_1 = require("../env/create-env");
|
|
32
|
-
const exit_if_invalid_1 = require("../env/exit-if-invalid");
|
|
33
|
-
const tags_1 = require("../env/tags");
|
|
34
|
-
const write_if_changed_1 = require("../env/write-if-changed");
|
|
35
|
-
const create_error_handlers_1 = require("../error-handlers/create-error-handlers");
|
|
36
|
-
const default_error_handlers_1 = require("../error-handlers/default-error-handlers");
|
|
37
|
-
const get_context_1 = require("../get-context");
|
|
38
|
-
const format_1 = require("./format");
|
|
39
|
-
function formatCli(cli, env) {
|
|
40
|
-
return (0, Function_1.pipe)((0, get_context_1.getContext)(), Effect.flatMap(format_1.format), 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.provideContext((0, Function_1.pipe)(Context.empty(), Context.add(types_1.CliConfigTag, cli), Context.add(tags_1.EnvTag, (0, create_env_1.createEnv)(env)))));
|
|
41
|
-
}
|
|
42
|
-
exports.formatCli = formatCli;
|