syncpack 12.3.0 → 12.3.2
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 +9 -9
- package/dist/bin-fix-mismatches/fix-mismatches.js +43 -54
- package/dist/bin-fix-mismatches/index.js +26 -31
- package/dist/bin-format/format.d.ts +6 -6
- package/dist/bin-format/format.js +27 -32
- package/dist/bin-format/index.js +20 -25
- package/dist/bin-lint/index.js +15 -20
- package/dist/bin-lint/lint.d.ts +4 -4
- package/dist/bin-lint/lint.js +28 -35
- package/dist/bin-lint-semver-ranges/index.js +24 -29
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +8 -8
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +34 -44
- package/dist/bin-list/index.js +24 -29
- package/dist/bin-list/list.d.ts +7 -7
- package/dist/bin-list/list.js +55 -64
- package/dist/bin-list-mismatches/index.js +24 -29
- package/dist/bin-list-mismatches/list-mismatches.d.ts +10 -10
- package/dist/bin-list-mismatches/list-mismatches.js +62 -70
- package/dist/bin-prompt/index.js +26 -31
- package/dist/bin-prompt/prompt.d.ts +4 -4
- package/dist/bin-prompt/prompt.js +41 -48
- package/dist/bin-set-semver-ranges/index.js +26 -31
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +4 -4
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +26 -30
- package/dist/bin-update/effects.d.ts +18 -18
- package/dist/bin-update/effects.js +77 -106
- package/dist/bin-update/index.js +23 -28
- package/dist/bin-update/update.d.ts +5 -5
- package/dist/bin-update/update.js +33 -40
- package/dist/bin.js +8 -5
- package/dist/config/get-custom-types.d.ts +9 -9
- package/dist/config/get-custom-types.js +22 -27
- package/dist/config/get-enabled-types.d.ts +8 -8
- package/dist/config/get-enabled-types.js +42 -48
- package/dist/config/get-filter.d.ts +1 -1
- package/dist/config/get-filter.js +6 -10
- package/dist/config/get-indent.d.ts +1 -1
- package/dist/config/get-indent.js +6 -10
- package/dist/config/get-sort-az.d.ts +1 -1
- package/dist/config/get-sort-az.js +6 -10
- package/dist/config/get-sort-exports.d.ts +1 -1
- package/dist/config/get-sort-exports.js +6 -10
- package/dist/config/get-sort-first.d.ts +1 -1
- package/dist/config/get-sort-first.js +6 -10
- package/dist/config/get-source.d.ts +1 -1
- package/dist/config/get-source.js +4 -8
- package/dist/config/tag.d.ts +1 -1
- package/dist/config/tag.js +2 -5
- package/dist/config/types.d.ts +2 -5
- package/dist/config/types.js +1 -2
- package/dist/constants.js +7 -10
- package/dist/error-handlers/default-error-handlers.d.ts +10 -10
- package/dist/error-handlers/default-error-handlers.js +55 -61
- package/dist/get-context/index.d.ts +5 -5
- package/dist/get-context/index.js +13 -17
- package/dist/get-context/lib/key-by.js +1 -5
- package/dist/get-instances/index.d.ts +7 -7
- package/dist/get-instances/index.js +19 -23
- package/dist/get-instances/instance.d.ts +7 -7
- package/dist/get-instances/instance.js +4 -8
- package/dist/get-package-json-files/get-file-paths.d.ts +7 -7
- package/dist/get-package-json-files/get-file-paths.js +10 -15
- package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +2 -2
- package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +8 -12
- package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +2 -2
- package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +8 -12
- package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +2 -2
- package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +14 -18
- package/dist/get-package-json-files/get-patterns/index.d.ts +3 -3
- package/dist/get-package-json-files/get-patterns/index.js +11 -15
- package/dist/get-package-json-files/index.d.ts +8 -8
- package/dist/get-package-json-files/index.js +6 -10
- package/dist/get-package-json-files/package-json-file.d.ts +6 -6
- package/dist/get-package-json-files/package-json-file.js +8 -12
- package/dist/guards/can-add-to-group.d.ts +4 -4
- package/dist/guards/can-add-to-group.js +10 -14
- package/dist/guards/is-semver.js +3 -7
- package/dist/guards/is-valid-semver-range.d.ts +1 -1
- package/dist/guards/is-valid-semver-range.js +12 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/io/ask-for-choice.d.ts +5 -5
- package/dist/io/ask-for-choice.js +5 -9
- package/dist/io/ask-for-input.d.ts +5 -5
- package/dist/io/ask-for-input.js +5 -9
- package/dist/io/exit-if-invalid.d.ts +3 -3
- package/dist/io/exit-if-invalid.js +5 -9
- package/dist/io/glob-sync.d.ts +5 -5
- package/dist/io/glob-sync.js +4 -9
- package/dist/io/index.d.ts +8 -8
- package/dist/io/index.js +12 -38
- package/dist/io/read-config-file.d.ts +7 -0
- package/dist/io/read-config-file.js +22 -0
- package/dist/io/read-file-sync.d.ts +5 -5
- package/dist/io/read-file-sync.js +4 -9
- package/dist/io/read-json-file-sync.d.ts +8 -8
- package/dist/io/read-json-file-sync.js +10 -16
- package/dist/io/read-yaml-file-sync.d.ts +5 -5
- package/dist/io/read-yaml-file-sync.js +4 -8
- package/dist/io/to-json.d.ts +2 -2
- package/dist/io/to-json.js +8 -12
- package/dist/io/write-file-sync.d.ts +5 -5
- package/dist/io/write-file-sync.js +5 -10
- package/dist/io/write-if-changed.d.ts +4 -4
- package/dist/io/write-if-changed.js +9 -16
- package/dist/lib/format-repository-url.js +1 -5
- package/dist/lib/get-group-header.d.ts +2 -2
- package/dist/lib/get-group-header.js +4 -12
- package/dist/lib/get.d.ts +10 -10
- package/dist/lib/get.js +15 -19
- package/dist/lib/pad-start.js +1 -5
- package/dist/lib/ring-buffer.js +1 -5
- package/dist/lib/set-semver-range.d.ts +1 -1
- package/dist/lib/set-semver-range.js +8 -12
- package/dist/lib/show-help-on-error.js +3 -10
- package/dist/lib/sort-by-name.js +1 -5
- package/dist/lib/with-logger.d.ts +1 -1
- package/dist/lib/with-logger.js +17 -24
- package/dist/option.d.ts +1 -1
- package/dist/option.js +8 -14
- package/dist/report.d.ts +2 -2
- package/dist/report.js +2 -5
- package/dist/semver-group/create-semver-groups.d.ts +3 -3
- package/dist/semver-group/create-semver-groups.js +28 -32
- package/dist/semver-group/disabled.d.ts +11 -11
- package/dist/semver-group/disabled.js +6 -10
- package/dist/semver-group/filtered-out.d.ts +12 -12
- package/dist/semver-group/filtered-out.js +8 -12
- package/dist/semver-group/ignored.d.ts +11 -11
- package/dist/semver-group/ignored.js +6 -10
- package/dist/semver-group/index.d.ts +6 -7
- package/dist/semver-group/index.js +4 -7
- package/dist/semver-group/with-range.d.ts +11 -11
- package/dist/semver-group/with-range.js +13 -17
- package/dist/specifier/alias.d.ts +5 -5
- package/dist/specifier/alias.js +9 -13
- package/dist/specifier/base.d.ts +7 -7
- package/dist/specifier/base.js +9 -13
- package/dist/specifier/delete.d.ts +5 -5
- package/dist/specifier/delete.js +5 -9
- package/dist/specifier/exact.d.ts +6 -6
- package/dist/specifier/exact.js +7 -11
- package/dist/specifier/file.d.ts +1 -1
- package/dist/specifier/file.js +2 -6
- package/dist/specifier/hosted-git.d.ts +5 -5
- package/dist/specifier/hosted-git.js +9 -13
- package/dist/specifier/index.d.ts +13 -13
- package/dist/specifier/index.js +28 -31
- package/dist/specifier/latest.d.ts +6 -6
- package/dist/specifier/latest.js +7 -11
- package/dist/specifier/lib/non-semver-error.d.ts +5 -5
- package/dist/specifier/lib/non-semver-error.js +3 -7
- package/dist/specifier/lib/parse-specifier.d.ts +1 -1
- package/dist/specifier/lib/parse-specifier.js +4 -11
- package/dist/specifier/lib/specific-registry-result.js +1 -2
- package/dist/specifier/range.d.ts +6 -6
- package/dist/specifier/range.js +7 -11
- package/dist/specifier/tag.d.ts +2 -2
- package/dist/specifier/tag.js +2 -6
- package/dist/specifier/unsupported.d.ts +1 -1
- package/dist/specifier/unsupported.js +2 -6
- package/dist/specifier/url.d.ts +1 -1
- package/dist/specifier/url.js +2 -6
- package/dist/specifier/workspace-protocol.d.ts +7 -7
- package/dist/specifier/workspace-protocol.js +9 -13
- package/dist/strategy/lib/get-non-empty-string-prop.d.ts +2 -2
- package/dist/strategy/lib/get-non-empty-string-prop.js +6 -10
- package/dist/strategy/name-and-version-props.d.ts +4 -4
- package/dist/strategy/name-and-version-props.js +19 -23
- package/dist/strategy/named-version-string.d.ts +4 -4
- package/dist/strategy/named-version-string.js +20 -24
- package/dist/strategy/unnamed-version-string.d.ts +4 -4
- package/dist/strategy/unnamed-version-string.js +17 -21
- package/dist/strategy/versions-by-name.d.ts +4 -4
- package/dist/strategy/versions-by-name.js +11 -15
- package/dist/version-group/banned.d.ts +7 -7
- package/dist/version-group/banned.js +8 -12
- package/dist/version-group/create-version-groups.d.ts +3 -3
- package/dist/version-group/create-version-groups.js +34 -38
- package/dist/version-group/filtered-out.d.ts +8 -8
- package/dist/version-group/filtered-out.js +8 -12
- package/dist/version-group/ignored.d.ts +7 -7
- package/dist/version-group/ignored.js +6 -10
- package/dist/version-group/index.d.ts +9 -10
- package/dist/version-group/index.js +4 -7
- package/dist/version-group/lib/clean.js +4 -11
- package/dist/version-group/lib/delete.js +1 -4
- package/dist/version-group/lib/get-highest-version.d.ts +2 -2
- package/dist/version-group/lib/get-highest-version.js +3 -7
- package/dist/version-group/lib/get-lowest-version.d.ts +2 -2
- package/dist/version-group/lib/get-lowest-version.js +3 -7
- package/dist/version-group/lib/get-preferred-version.d.ts +4 -4
- package/dist/version-group/lib/get-preferred-version.js +17 -24
- package/dist/version-group/lib/get-range-score.js +13 -17
- package/dist/version-group/lib/group-by.js +1 -5
- package/dist/version-group/pinned.d.ts +7 -7
- package/dist/version-group/pinned.js +8 -12
- package/dist/version-group/same-range.d.ts +8 -8
- package/dist/version-group/same-range.js +23 -30
- package/dist/version-group/snapped-to.d.ts +7 -7
- package/dist/version-group/snapped-to.js +20 -24
- package/dist/version-group/standard.d.ts +7 -7
- package/dist/version-group/standard.js +29 -33
- package/package.json +30 -37
- package/dist/io/read-config-file-sync.d.ts +0 -7
- package/dist/io/read-config-file-sync.js +0 -26
|
@@ -1,30 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const exit_if_invalid_1 = require("../io/exit-if-invalid");
|
|
17
|
-
const get_group_header_1 = require("../lib/get-group-header");
|
|
18
|
-
const pad_start_1 = require("../lib/pad-start");
|
|
19
|
-
const with_logger_1 = require("../lib/with-logger");
|
|
20
|
-
function listMismatches({ io, cli, errorHandlers = default_error_handlers_1.defaultErrorHandlers }) {
|
|
21
|
-
return (0, effect_1.pipe)((0, get_context_1.getContext)({ io, cli, errorHandlers }), effect_1.Effect.flatMap((ctx) => pipeline(ctx, io, errorHandlers)), effect_1.Effect.flatMap(exit_if_invalid_1.exitIfInvalid), effect_1.Effect.provide((0, effect_1.pipe)(effect_1.Context.empty(), effect_1.Context.add(tag_1.CliConfigTag, cli), effect_1.Context.add(io_1.IoTag, io))), with_logger_1.withLogger);
|
|
1
|
+
import chalk from 'chalk-template';
|
|
2
|
+
import { Context, Effect, pipe } from 'effect';
|
|
3
|
+
import { EOL } from 'os';
|
|
4
|
+
import { CliConfigTag } from '../config/tag.js';
|
|
5
|
+
import { ICON } from '../constants.js';
|
|
6
|
+
import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
7
|
+
import { getContext } from '../get-context/index.js';
|
|
8
|
+
import { getInstances } from '../get-instances/index.js';
|
|
9
|
+
import { exitIfInvalid } from '../io/exit-if-invalid.js';
|
|
10
|
+
import { IoTag } from '../io/index.js';
|
|
11
|
+
import { getVersionGroupHeader } from '../lib/get-group-header.js';
|
|
12
|
+
import { padStart } from '../lib/pad-start.js';
|
|
13
|
+
import { withLogger } from '../lib/with-logger.js';
|
|
14
|
+
export function listMismatches({ io, cli, errorHandlers = defaultErrorHandlers }) {
|
|
15
|
+
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap((ctx) => pipeline(ctx, io, errorHandlers)), Effect.flatMap(exitIfInvalid), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
|
|
22
16
|
}
|
|
23
|
-
exports.listMismatches = listMismatches;
|
|
24
17
|
/** Exported to be reused by `syncpack lint` */
|
|
25
|
-
function pipeline(ctx, io, errorHandlers) {
|
|
26
|
-
return
|
|
27
|
-
const { versionGroups } = yield* $(
|
|
18
|
+
export function pipeline(ctx, io, errorHandlers) {
|
|
19
|
+
return Effect.gen(function* ($) {
|
|
20
|
+
const { versionGroups } = yield* $(getInstances(ctx, io, errorHandlers));
|
|
28
21
|
let index = 0;
|
|
29
22
|
for (const group of versionGroups) {
|
|
30
23
|
const countByReportGroup = {
|
|
@@ -33,7 +26,7 @@ function pipeline(ctx, io, errorHandlers) {
|
|
|
33
26
|
Unfixable: 0,
|
|
34
27
|
Valid: 0,
|
|
35
28
|
};
|
|
36
|
-
yield* $(
|
|
29
|
+
yield* $(Effect.logInfo(getVersionGroupHeader({ group, index })));
|
|
37
30
|
for (const groupReport of yield* $(group.inspectAll())) {
|
|
38
31
|
for (const report of groupReport.reports) {
|
|
39
32
|
countByReportGroup[report._tagGroup]++;
|
|
@@ -53,31 +46,30 @@ function pipeline(ctx, io, errorHandlers) {
|
|
|
53
46
|
return ctx;
|
|
54
47
|
});
|
|
55
48
|
}
|
|
56
|
-
exports.pipeline = pipeline;
|
|
57
49
|
const onReportGroup = {
|
|
58
50
|
Excluded(amount) {
|
|
59
51
|
if (amount === 0)
|
|
60
|
-
return
|
|
61
|
-
const msg =
|
|
62
|
-
return
|
|
52
|
+
return Effect.void;
|
|
53
|
+
const msg = chalk `{gray ${padStart(amount)} ${ICON.rightArrow} ignored}`;
|
|
54
|
+
return Effect.logInfo(msg);
|
|
63
55
|
},
|
|
64
56
|
Fixable(amount) {
|
|
65
57
|
if (amount === 0)
|
|
66
|
-
return
|
|
67
|
-
const msg =
|
|
68
|
-
return
|
|
58
|
+
return Effect.void;
|
|
59
|
+
const msg = chalk `${padStart(amount)} {green ${ICON.tick}} can be auto-fixed`;
|
|
60
|
+
return Effect.logInfo(msg);
|
|
69
61
|
},
|
|
70
62
|
Unfixable(amount) {
|
|
71
63
|
if (amount === 0)
|
|
72
|
-
return
|
|
73
|
-
const msg =
|
|
74
|
-
return
|
|
64
|
+
return Effect.void;
|
|
65
|
+
const msg = chalk `{red ${padStart(amount)} ${ICON.panic} can be fixed manually using} {blue syncpack prompt}`;
|
|
66
|
+
return Effect.logInfo(msg);
|
|
75
67
|
},
|
|
76
68
|
Valid(amount) {
|
|
77
69
|
if (amount === 0)
|
|
78
|
-
return
|
|
79
|
-
const msg =
|
|
80
|
-
return
|
|
70
|
+
return Effect.void;
|
|
71
|
+
const msg = chalk `${padStart(amount)} {green ${ICON.tick}} already valid`;
|
|
72
|
+
return Effect.logInfo(msg);
|
|
81
73
|
},
|
|
82
74
|
};
|
|
83
75
|
const onReportTag = {
|
|
@@ -88,13 +80,13 @@ const onReportTag = {
|
|
|
88
80
|
const jsonFile = instance.packageJsonFile.jsonFile;
|
|
89
81
|
const path = instance.strategy.path;
|
|
90
82
|
const shortPath = jsonFile.shortPath;
|
|
91
|
-
return
|
|
83
|
+
return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red banned} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
|
|
92
84
|
},
|
|
93
85
|
Disabled(_report) {
|
|
94
|
-
return
|
|
86
|
+
return Effect.void;
|
|
95
87
|
},
|
|
96
88
|
FilteredOut(_report) {
|
|
97
|
-
return
|
|
89
|
+
return Effect.void;
|
|
98
90
|
},
|
|
99
91
|
HighestSemverMismatch(report) {
|
|
100
92
|
const _tag = report._tag;
|
|
@@ -106,10 +98,10 @@ const onReportTag = {
|
|
|
106
98
|
const name = instance.name;
|
|
107
99
|
const path = instance.strategy.path;
|
|
108
100
|
const shortPath = jsonFile.shortPath;
|
|
109
|
-
return
|
|
101
|
+
return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
|
|
110
102
|
},
|
|
111
103
|
Ignored(_report) {
|
|
112
|
-
return
|
|
104
|
+
return Effect.void;
|
|
113
105
|
},
|
|
114
106
|
LocalPackageMismatch(report) {
|
|
115
107
|
const _tag = report._tag;
|
|
@@ -120,7 +112,7 @@ const onReportTag = {
|
|
|
120
112
|
const name = instance.name;
|
|
121
113
|
const path = instance.strategy.path;
|
|
122
114
|
const shortPath = instance.packageJsonFile.jsonFile.shortPath;
|
|
123
|
-
return
|
|
115
|
+
return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
|
|
124
116
|
},
|
|
125
117
|
LowestSemverMismatch(report) {
|
|
126
118
|
const _tag = report._tag;
|
|
@@ -131,7 +123,7 @@ const onReportTag = {
|
|
|
131
123
|
const name = instance.name;
|
|
132
124
|
const path = instance.strategy.path;
|
|
133
125
|
const shortPath = instance.packageJsonFile.jsonFile.shortPath;
|
|
134
|
-
return
|
|
126
|
+
return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
|
|
135
127
|
},
|
|
136
128
|
MissingLocalVersion(report) {
|
|
137
129
|
const instance = report.unfixable;
|
|
@@ -141,10 +133,10 @@ const onReportTag = {
|
|
|
141
133
|
const name = instance.name;
|
|
142
134
|
const path = instance.strategy.path;
|
|
143
135
|
const shortPath = jsonFile.shortPath;
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
].join(
|
|
136
|
+
return Effect.logInfo([
|
|
137
|
+
chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {blue [MissingLocalVersion]}`,
|
|
138
|
+
chalk ` {red ${localPath} does not have a .version property which is exact semver}`,
|
|
139
|
+
].join(EOL));
|
|
148
140
|
},
|
|
149
141
|
MissingSnappedToMismatch(report) {
|
|
150
142
|
const instance = report.unfixable;
|
|
@@ -153,10 +145,10 @@ const onReportTag = {
|
|
|
153
145
|
const name = instance.name;
|
|
154
146
|
const path = instance.strategy.path;
|
|
155
147
|
const shortPath = jsonFile.shortPath;
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
].join(
|
|
148
|
+
return Effect.logInfo([
|
|
149
|
+
chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {blue [MissingSnappedToMismatch]}`,
|
|
150
|
+
chalk ` {red no package in this groups .snapTo array depend on ${name}}`,
|
|
151
|
+
].join(EOL));
|
|
160
152
|
},
|
|
161
153
|
PinnedMismatch(report) {
|
|
162
154
|
const _tag = report._tag;
|
|
@@ -167,7 +159,7 @@ const onReportTag = {
|
|
|
167
159
|
const name = instance.name;
|
|
168
160
|
const path = instance.strategy.path;
|
|
169
161
|
const shortPath = instance.packageJsonFile.jsonFile.shortPath;
|
|
170
|
-
return
|
|
162
|
+
return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
|
|
171
163
|
},
|
|
172
164
|
SameRangeMismatch(report) {
|
|
173
165
|
const instance = report.unfixable;
|
|
@@ -177,10 +169,10 @@ const onReportTag = {
|
|
|
177
169
|
const path = instance.strategy.path;
|
|
178
170
|
const shortPath = jsonFile.shortPath;
|
|
179
171
|
const mismatches = report.mismatches;
|
|
180
|
-
return
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
].join(
|
|
172
|
+
return Effect.logInfo([
|
|
173
|
+
chalk `{red ${ICON.cross}} ${name} {red range ${actual} does not include ${mismatches.join(', ')}} {gray ${shortPath} > ${path}} {blue [SameRangeMismatch]}`,
|
|
174
|
+
chalk ` {gray use {blue syncpack prompt} to fix this manually}`,
|
|
175
|
+
].join(EOL));
|
|
184
176
|
},
|
|
185
177
|
SemverRangeMismatch(report) {
|
|
186
178
|
const _tag = report._tag;
|
|
@@ -191,7 +183,7 @@ const onReportTag = {
|
|
|
191
183
|
const name = instance.name;
|
|
192
184
|
const path = instance.strategy.path;
|
|
193
185
|
const shortPath = instance.packageJsonFile.jsonFile.shortPath;
|
|
194
|
-
return
|
|
186
|
+
return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
|
|
195
187
|
},
|
|
196
188
|
SnappedToMismatch(report) {
|
|
197
189
|
const _tag = report._tag;
|
|
@@ -202,7 +194,7 @@ const onReportTag = {
|
|
|
202
194
|
const name = instance.name;
|
|
203
195
|
const path = instance.strategy.path;
|
|
204
196
|
const shortPath = instance.packageJsonFile.jsonFile.shortPath;
|
|
205
|
-
return
|
|
197
|
+
return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
|
|
206
198
|
},
|
|
207
199
|
UnsupportedMismatch(report) {
|
|
208
200
|
const instance = report.unfixable;
|
|
@@ -211,16 +203,16 @@ const onReportTag = {
|
|
|
211
203
|
const name = instance.name;
|
|
212
204
|
const path = instance.strategy.path;
|
|
213
205
|
const shortPath = jsonFile.shortPath;
|
|
214
|
-
return
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
].join(
|
|
206
|
+
return Effect.logInfo([
|
|
207
|
+
chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {blue [UnsupportedMismatch]}`,
|
|
208
|
+
chalk ` {red use {blue syncpack prompt} to fix this manually}`,
|
|
209
|
+
].join(EOL));
|
|
218
210
|
},
|
|
219
211
|
Valid(_report) {
|
|
220
|
-
return
|
|
212
|
+
return Effect.void;
|
|
221
213
|
},
|
|
222
214
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
215
|
+
export const logMissingLocalVersion = onReportTag.MissingLocalVersion;
|
|
216
|
+
export const logMissingSnappedToMismatch = onReportTag.MissingSnappedToMismatch;
|
|
217
|
+
export const logUnsupportedMismatch = onReportTag.UnsupportedMismatch;
|
|
218
|
+
export const logSameRangeMismatch = onReportTag.SameRangeMismatch;
|
package/dist/bin-prompt/index.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const option_1 = require("../option");
|
|
13
|
-
const prompt_1 = require("./prompt");
|
|
14
|
-
commander_1.program.description(' displays a series of prompts to fix mismatches which syncpack cannot fix automatically');
|
|
15
|
-
commander_1.program.on('--help', () => {
|
|
16
|
-
console.log((0, chalk_1.default) `
|
|
2
|
+
import chalk from 'chalk-template';
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import { Effect } from 'effect';
|
|
5
|
+
import { io } from '../io/index.js';
|
|
6
|
+
import { showHelpOnError } from '../lib/show-help-on-error.js';
|
|
7
|
+
import { option } from '../option.js';
|
|
8
|
+
import { prompt } from './prompt.js';
|
|
9
|
+
program.description(' displays a series of prompts to fix mismatches which syncpack cannot fix automatically');
|
|
10
|
+
program.on('--help', () => {
|
|
11
|
+
console.log(chalk `
|
|
17
12
|
Examples:
|
|
18
13
|
{dim # uses defaults for resolving packages}
|
|
19
14
|
syncpack prompt
|
|
@@ -44,23 +39,23 @@ Reference:
|
|
|
44
39
|
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
45
40
|
`);
|
|
46
41
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.option(...
|
|
50
|
-
.option(...
|
|
51
|
-
.option(...
|
|
52
|
-
.option(...
|
|
53
|
-
.option(...
|
|
54
|
-
.option(...
|
|
42
|
+
showHelpOnError(program);
|
|
43
|
+
program
|
|
44
|
+
.option(...option.source)
|
|
45
|
+
.option(...option.filter)
|
|
46
|
+
.option(...option.config)
|
|
47
|
+
.option(...option.specs)
|
|
48
|
+
.option(...option.types)
|
|
49
|
+
.option(...option.indent)
|
|
55
50
|
.parse(process.argv);
|
|
56
|
-
|
|
57
|
-
io
|
|
51
|
+
Effect.runPromise(prompt({
|
|
52
|
+
io,
|
|
58
53
|
cli: {
|
|
59
|
-
configPath:
|
|
60
|
-
filter:
|
|
61
|
-
source:
|
|
62
|
-
specs:
|
|
63
|
-
types:
|
|
64
|
-
indent:
|
|
54
|
+
configPath: program.opts().config,
|
|
55
|
+
filter: program.opts().filter,
|
|
56
|
+
source: program.opts().source,
|
|
57
|
+
specs: program.opts().specs,
|
|
58
|
+
types: program.opts().types,
|
|
59
|
+
indent: program.opts().indent,
|
|
65
60
|
},
|
|
66
61
|
}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import { type CliConfig } from '../config/types';
|
|
3
|
-
import type { ErrorHandlers } from '../error-handlers/default-error-handlers';
|
|
4
|
-
import type { Io } from '../io';
|
|
2
|
+
import { type CliConfig } from '../config/types.js';
|
|
3
|
+
import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
4
|
+
import type { Io } from '../io/index.js';
|
|
5
5
|
interface Input {
|
|
6
6
|
io: Io;
|
|
7
7
|
cli: Partial<CliConfig>;
|
|
8
8
|
errorHandlers?: ErrorHandlers;
|
|
9
9
|
}
|
|
10
|
-
export declare function prompt({ io, cli, errorHandlers }: Input): Effect.Effect<
|
|
10
|
+
export declare function prompt({ io, cli, errorHandlers }: Input): Effect.Effect<unknown, never, never>;
|
|
11
11
|
export {};
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const write_if_changed_1 = require("../io/write-if-changed");
|
|
22
|
-
const get_group_header_1 = require("../lib/get-group-header");
|
|
23
|
-
const with_logger_1 = require("../lib/with-logger");
|
|
24
|
-
function prompt({ io, cli, errorHandlers = default_error_handlers_1.defaultErrorHandlers }) {
|
|
25
|
-
return (0, effect_1.pipe)((0, get_context_1.getContext)({ io, cli, errorHandlers }), effect_1.Effect.flatMap((ctx) => (0, effect_1.pipe)(effect_1.Effect.gen(function* ($) {
|
|
26
|
-
const { versionGroups } = yield* $((0, get_instances_1.getInstances)(ctx, io, errorHandlers));
|
|
1
|
+
import chalk from 'chalk-template';
|
|
2
|
+
import { Context, Effect, flow, pipe } from 'effect';
|
|
3
|
+
import { uniq } from 'tightrope/array/uniq.js';
|
|
4
|
+
import { isString } from 'tightrope/guard/is-string.js';
|
|
5
|
+
import { logOtherCommands } from '../bin-list/list.js';
|
|
6
|
+
import { CliConfigTag } from '../config/tag.js';
|
|
7
|
+
import { ICON } from '../constants.js';
|
|
8
|
+
import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
9
|
+
import { getContext } from '../get-context/index.js';
|
|
10
|
+
import { getInstances } from '../get-instances/index.js';
|
|
11
|
+
import { askForChoice } from '../io/ask-for-choice.js';
|
|
12
|
+
import { askForInput } from '../io/ask-for-input.js';
|
|
13
|
+
import { exitIfInvalid } from '../io/exit-if-invalid.js';
|
|
14
|
+
import { IoTag } from '../io/index.js';
|
|
15
|
+
import { writeIfChanged } from '../io/write-if-changed.js';
|
|
16
|
+
import { getVersionGroupHeader } from '../lib/get-group-header.js';
|
|
17
|
+
import { withLogger } from '../lib/with-logger.js';
|
|
18
|
+
export function prompt({ io, cli, errorHandlers = defaultErrorHandlers }) {
|
|
19
|
+
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap((ctx) => pipe(Effect.gen(function* ($) {
|
|
20
|
+
const { versionGroups } = yield* $(getInstances(ctx, io, errorHandlers));
|
|
27
21
|
let unfixableCount = 0;
|
|
28
22
|
let index = 0;
|
|
29
23
|
for (const group of versionGroups) {
|
|
@@ -36,29 +30,28 @@ function prompt({ io, cli, errorHandlers = default_error_handlers_1.defaultError
|
|
|
36
30
|
}
|
|
37
31
|
if (unfixable.length) {
|
|
38
32
|
unfixableCount += unfixable.length;
|
|
39
|
-
|
|
33
|
+
Effect.logInfo(getVersionGroupHeader({ group, index }));
|
|
40
34
|
yield* $(askForNextVersion(groupReport, unfixable));
|
|
41
35
|
}
|
|
42
36
|
}
|
|
43
37
|
index++;
|
|
44
38
|
}
|
|
45
39
|
if (unfixableCount) {
|
|
46
|
-
yield* $(
|
|
40
|
+
yield* $(writeIfChanged(ctx));
|
|
47
41
|
}
|
|
48
42
|
else {
|
|
49
|
-
const msg =
|
|
50
|
-
yield* $(
|
|
51
|
-
yield* $(
|
|
43
|
+
const msg = chalk `{green ${ICON.tick}} no issues which syncpack cannot fix automatically`;
|
|
44
|
+
yield* $(Effect.logInfo(msg));
|
|
45
|
+
yield* $(logOtherCommands());
|
|
52
46
|
}
|
|
53
47
|
return ctx;
|
|
54
|
-
}),
|
|
55
|
-
WriteFileError:
|
|
48
|
+
}), Effect.catchTags({
|
|
49
|
+
WriteFileError: flow(errorHandlers.WriteFileError, Effect.map(() => {
|
|
56
50
|
ctx.isInvalid = true;
|
|
57
51
|
return ctx;
|
|
58
52
|
})),
|
|
59
|
-
}),
|
|
53
|
+
}), Effect.flatMap(exitIfInvalid))), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
|
|
60
54
|
}
|
|
61
|
-
exports.prompt = prompt;
|
|
62
55
|
function isUnfixable(report) {
|
|
63
56
|
return (report._tag === 'MissingLocalVersion' ||
|
|
64
57
|
report._tag === 'MissingSnappedToMismatch' ||
|
|
@@ -66,19 +59,19 @@ function isUnfixable(report) {
|
|
|
66
59
|
report._tag === 'UnsupportedMismatch');
|
|
67
60
|
}
|
|
68
61
|
function askForNextVersion(groupReport, unfixable) {
|
|
69
|
-
return
|
|
70
|
-
const choices =
|
|
62
|
+
return pipe(Effect.gen(function* ($) {
|
|
63
|
+
const choices = uniq(groupReport.reports.map((report) => report._tagGroup === 'Fixable'
|
|
71
64
|
? report.fixable.raw
|
|
72
65
|
: report._tagGroup === 'Unfixable'
|
|
73
66
|
? report.unfixable.rawSpecifier
|
|
74
67
|
: report._tagGroup === 'Valid'
|
|
75
68
|
? report.specifier.raw
|
|
76
|
-
: null)).filter(
|
|
77
|
-
const OTHER =
|
|
78
|
-
const SKIP =
|
|
79
|
-
const QUIT =
|
|
69
|
+
: null)).filter(isString);
|
|
70
|
+
const OTHER = chalk `{dim Other}`;
|
|
71
|
+
const SKIP = chalk `{dim Skip}`;
|
|
72
|
+
const QUIT = chalk `{dim Quit}`;
|
|
80
73
|
// Ask user to choose a version to align on
|
|
81
|
-
const choice = yield* $(
|
|
74
|
+
const choice = yield* $(askForChoice({
|
|
82
75
|
message: groupReport.name,
|
|
83
76
|
choices: [...choices, OTHER, SKIP, QUIT],
|
|
84
77
|
}));
|
|
@@ -88,13 +81,13 @@ function askForNextVersion(groupReport, unfixable) {
|
|
|
88
81
|
if (choice === QUIT)
|
|
89
82
|
return process.exit(0);
|
|
90
83
|
const nextVersion = choice === OTHER
|
|
91
|
-
? yield* $(
|
|
92
|
-
message:
|
|
84
|
+
? yield* $(askForInput({
|
|
85
|
+
message: chalk `${groupReport.name} {dim Enter a replacement version}`,
|
|
93
86
|
}))
|
|
94
87
|
: choice;
|
|
95
|
-
yield* $(
|
|
96
|
-
}),
|
|
97
|
-
AskForChoiceError:
|
|
98
|
-
AskForInputError:
|
|
88
|
+
yield* $(pipe(unfixable, Effect.forEach((report) => report.unfixable.write(nextVersion))));
|
|
89
|
+
}), Effect.catchTags({
|
|
90
|
+
AskForChoiceError: Effect.logDebug,
|
|
91
|
+
AskForInputError: Effect.logDebug,
|
|
99
92
|
}));
|
|
100
93
|
}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const io_1 = require("../io");
|
|
11
|
-
const show_help_on_error_1 = require("../lib/show-help-on-error");
|
|
12
|
-
const option_1 = require("../option");
|
|
13
|
-
const set_semver_ranges_1 = require("./set-semver-ranges");
|
|
14
|
-
commander_1.program.description((0, chalk_1.default) `
|
|
2
|
+
import chalk from 'chalk-template';
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import { Effect } from 'effect';
|
|
5
|
+
import { io } from '../io/index.js';
|
|
6
|
+
import { showHelpOnError } from '../lib/show-help-on-error.js';
|
|
7
|
+
import { option } from '../option.js';
|
|
8
|
+
import { setSemverRanges } from './set-semver-ranges.js';
|
|
9
|
+
program.description(chalk `
|
|
15
10
|
Ensure dependency versions within {yellow dependencies}, {yellow devDependencies},
|
|
16
11
|
{yellow peerDependencies}, {yellow overrides}, and {yellow resolutions} follow a consistent format.`.replace(/^\n/, ''));
|
|
17
|
-
|
|
18
|
-
console.log(
|
|
12
|
+
program.on('--help', () => {
|
|
13
|
+
console.log(chalk `
|
|
19
14
|
Examples:
|
|
20
15
|
{dim # uses defaults for resolving packages}
|
|
21
16
|
syncpack set-semver-ranges
|
|
@@ -52,23 +47,23 @@ Reference:
|
|
|
52
47
|
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
53
48
|
`);
|
|
54
49
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.option(...
|
|
58
|
-
.option(...
|
|
59
|
-
.option(...
|
|
60
|
-
.option(...
|
|
61
|
-
.option(...
|
|
62
|
-
.option(...
|
|
50
|
+
showHelpOnError(program);
|
|
51
|
+
program
|
|
52
|
+
.option(...option.source)
|
|
53
|
+
.option(...option.filter)
|
|
54
|
+
.option(...option.config)
|
|
55
|
+
.option(...option.specs)
|
|
56
|
+
.option(...option.types)
|
|
57
|
+
.option(...option.indent)
|
|
63
58
|
.parse(process.argv);
|
|
64
|
-
|
|
65
|
-
io
|
|
59
|
+
Effect.runPromise(setSemverRanges({
|
|
60
|
+
io,
|
|
66
61
|
cli: {
|
|
67
|
-
configPath:
|
|
68
|
-
filter:
|
|
69
|
-
indent:
|
|
70
|
-
source:
|
|
71
|
-
specs:
|
|
72
|
-
types:
|
|
62
|
+
configPath: program.opts().config,
|
|
63
|
+
filter: program.opts().filter,
|
|
64
|
+
indent: program.opts().indent,
|
|
65
|
+
source: program.opts().source,
|
|
66
|
+
specs: program.opts().specs,
|
|
67
|
+
types: program.opts().types,
|
|
73
68
|
},
|
|
74
69
|
}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import { type CliConfig } from '../config/types';
|
|
3
|
-
import type { ErrorHandlers } from '../error-handlers/default-error-handlers';
|
|
4
|
-
import type { Io } from '../io';
|
|
2
|
+
import { type CliConfig } from '../config/types.js';
|
|
3
|
+
import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
4
|
+
import type { Io } from '../io/index.js';
|
|
5
5
|
interface Input {
|
|
6
6
|
io: Io;
|
|
7
7
|
cli: Partial<CliConfig>;
|
|
8
8
|
errorHandlers?: ErrorHandlers;
|
|
9
9
|
}
|
|
10
|
-
export declare function setSemverRanges({ io, cli, errorHandlers }: Input): Effect.Effect<
|
|
10
|
+
export declare function setSemverRanges({ io, cli, errorHandlers }: Input): Effect.Effect<unknown, never, never>;
|
|
11
11
|
export {};
|