syncpack 12.3.0 → 12.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +37 -45
- 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,28 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const with_logger_1 = require("../lib/with-logger");
|
|
17
|
-
function setSemverRanges({ io, cli, errorHandlers = default_error_handlers_1.defaultErrorHandlers }) {
|
|
18
|
-
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* ($) {
|
|
1
|
+
import { Context, Effect, flow, pipe } from 'effect';
|
|
2
|
+
import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
|
|
3
|
+
import { fixMismatch, logAlreadyValidSize, logFixedSize, logUnfixableSize, } from '../bin-fix-mismatches/fix-mismatches.js';
|
|
4
|
+
import { logSemverGroupsDisabledWarning } from '../bin-lint-semver-ranges/lint-semver-ranges.js';
|
|
5
|
+
import { logUnsupportedMismatch } from '../bin-list-mismatches/list-mismatches.js';
|
|
6
|
+
import { CliConfigTag } from '../config/tag.js';
|
|
7
|
+
import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
8
|
+
import { getContext } from '../get-context/index.js';
|
|
9
|
+
import { getInstances } from '../get-instances/index.js';
|
|
10
|
+
import { exitIfInvalid } from '../io/exit-if-invalid.js';
|
|
11
|
+
import { IoTag } from '../io/index.js';
|
|
12
|
+
import { writeIfChanged } from '../io/write-if-changed.js';
|
|
13
|
+
import { withLogger } from '../lib/with-logger.js';
|
|
14
|
+
export function setSemverRanges({ io, cli, errorHandlers = defaultErrorHandlers }) {
|
|
15
|
+
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap((ctx) => pipe(Effect.gen(function* ($) {
|
|
19
16
|
// no semver groups have been configured, they are disabled by default
|
|
20
|
-
if (!
|
|
17
|
+
if (!isNonEmptyArray(ctx.config.rcFile.semverGroups)) {
|
|
21
18
|
ctx.isInvalid = true;
|
|
22
|
-
yield* $(
|
|
19
|
+
yield* $(logSemverGroupsDisabledWarning());
|
|
23
20
|
return ctx;
|
|
24
21
|
}
|
|
25
|
-
const { semverGroups } = yield* $(
|
|
22
|
+
const { semverGroups } = yield* $(getInstances(ctx, io, errorHandlers));
|
|
26
23
|
let fixedCount = 0;
|
|
27
24
|
let unfixableCount = 0;
|
|
28
25
|
let validCount = 0;
|
|
@@ -32,11 +29,11 @@ function setSemverRanges({ io, cli, errorHandlers = default_error_handlers_1.def
|
|
|
32
29
|
const report = yield* $(group.inspect(instance));
|
|
33
30
|
const _tag = report._tag;
|
|
34
31
|
if (_tag === 'SemverRangeMismatch') {
|
|
35
|
-
yield* $(
|
|
32
|
+
yield* $(fixMismatch(report));
|
|
36
33
|
fixedCount++;
|
|
37
34
|
}
|
|
38
35
|
else if (_tag === 'UnsupportedMismatch') {
|
|
39
|
-
yield* $(
|
|
36
|
+
yield* $(logUnsupportedMismatch(report));
|
|
40
37
|
unfixableCount++;
|
|
41
38
|
}
|
|
42
39
|
else {
|
|
@@ -46,17 +43,16 @@ function setSemverRanges({ io, cli, errorHandlers = default_error_handlers_1.def
|
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
if (validCount)
|
|
49
|
-
yield* $(
|
|
46
|
+
yield* $(logAlreadyValidSize(validCount));
|
|
50
47
|
if (fixedCount)
|
|
51
|
-
yield* $(
|
|
48
|
+
yield* $(logFixedSize(fixedCount));
|
|
52
49
|
if (unfixableCount)
|
|
53
|
-
yield* $(
|
|
50
|
+
yield* $(logUnfixableSize(unfixableCount));
|
|
54
51
|
return ctx;
|
|
55
|
-
}),
|
|
56
|
-
WriteFileError:
|
|
52
|
+
}), Effect.flatMap(writeIfChanged), Effect.catchTags({
|
|
53
|
+
WriteFileError: flow(errorHandlers.WriteFileError, Effect.map(() => {
|
|
57
54
|
ctx.isInvalid = true;
|
|
58
55
|
return ctx;
|
|
59
56
|
})),
|
|
60
|
-
}),
|
|
57
|
+
}), Effect.flatMap(exitIfInvalid))), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
|
|
61
58
|
}
|
|
62
|
-
exports.setSemverRanges = setSemverRanges;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Instance } from '../get-instances/instance';
|
|
3
|
-
declare const Releases_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import type { Instance } from '../get-instances/instance.js';
|
|
3
|
+
declare const Releases_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
4
4
|
readonly _tag: "Releases";
|
|
5
|
-
}
|
|
5
|
+
};
|
|
6
6
|
/** full release history from the npm registry for a given package */
|
|
7
7
|
declare class Releases extends Releases_base<{
|
|
8
8
|
instance: Instance;
|
|
@@ -13,40 +13,40 @@ declare class Releases extends Releases_base<{
|
|
|
13
13
|
repoUrl: string | undefined;
|
|
14
14
|
}> {
|
|
15
15
|
}
|
|
16
|
-
declare const PromptCancelled_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
16
|
+
declare const PromptCancelled_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
17
17
|
readonly _tag: "PromptCancelled";
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
declare class PromptCancelled extends PromptCancelled_base<{
|
|
20
20
|
name: string;
|
|
21
21
|
}> {
|
|
22
22
|
}
|
|
23
|
-
declare const HttpError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
23
|
+
declare const HttpError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
24
24
|
readonly _tag: "HttpError";
|
|
25
|
-
}
|
|
25
|
+
};
|
|
26
26
|
declare class HttpError extends HttpError_base<{
|
|
27
27
|
error: string;
|
|
28
28
|
}> {
|
|
29
29
|
}
|
|
30
|
-
declare const NpmRegistryError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
30
|
+
declare const NpmRegistryError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
31
31
|
readonly _tag: "NpmRegistryError";
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
33
|
declare class NpmRegistryError extends NpmRegistryError_base<{
|
|
34
34
|
error: string;
|
|
35
35
|
}> {
|
|
36
36
|
}
|
|
37
37
|
export declare const updateEffects: {
|
|
38
|
-
onFetchAllStart(): Effect.Effect<
|
|
39
|
-
onFetchStart(instance: Instance, totalCount: number): Effect.Effect<
|
|
40
|
-
onFetchEnd(instance: Instance, versions?: Releases['versions']): Effect.Effect<
|
|
38
|
+
onFetchAllStart(): Effect.Effect<void, never, never>;
|
|
39
|
+
onFetchStart(instance: Instance, totalCount: number): Effect.Effect<void, never, never>;
|
|
40
|
+
onFetchEnd(instance: Instance, versions?: Releases['versions']): Effect.Effect<void, never, never>;
|
|
41
41
|
/** After checking the registry, store this instance known to be up to date */
|
|
42
|
-
onUpToDate(instance: Instance): Effect.Effect<
|
|
42
|
+
onUpToDate(instance: Instance): Effect.Effect<void, never, never>;
|
|
43
43
|
/** After checking the registry, store this instance known to have newer versions available */
|
|
44
|
-
onOutdated(instance: Instance, latest: string): Effect.Effect<
|
|
44
|
+
onOutdated(instance: Instance, latest: string): Effect.Effect<void, never, never>;
|
|
45
45
|
/** As the last request completes, remove the progress information */
|
|
46
|
-
onFetchAllEnd(): Effect.Effect<
|
|
46
|
+
onFetchAllEnd(): Effect.Effect<void, never, never>;
|
|
47
47
|
/** Fetch available versions for a given package from the npm registry */
|
|
48
|
-
fetchLatestVersions(instance: Instance): Effect.Effect<
|
|
48
|
+
fetchLatestVersions(instance: Instance): Effect.Effect<Releases, HttpError | NpmRegistryError>;
|
|
49
49
|
/** Given responses from npm, ask the user which they want */
|
|
50
|
-
promptForUpdates(outdated: Releases[]): Effect.Effect<
|
|
50
|
+
promptForUpdates(outdated: Releases[]): Effect.Effect<void, PromptCancelled>;
|
|
51
51
|
};
|
|
52
52
|
export {};
|
|
@@ -1,57 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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.updateEffects = void 0;
|
|
30
|
-
const Schema = __importStar(require("@effect/schema/Schema"));
|
|
31
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
32
|
-
const effect_1 = require("effect");
|
|
33
|
-
const https_1 = __importDefault(require("https"));
|
|
34
|
-
const ora_1 = __importDefault(require("ora"));
|
|
35
|
-
const os_1 = require("os");
|
|
36
|
-
const prompts_1 = __importDefault(require("prompts"));
|
|
37
|
-
const semver_1 = require("semver");
|
|
38
|
-
const gtr_1 = __importDefault(require("semver/ranges/gtr"));
|
|
39
|
-
const is_array_1 = require("tightrope/guard/is-array");
|
|
40
|
-
const is_empty_object_1 = require("tightrope/guard/is-empty-object");
|
|
41
|
-
const constants_1 = require("../constants");
|
|
42
|
-
const format_repository_url_1 = require("../lib/format-repository-url");
|
|
43
|
-
const ring_buffer_1 = require("../lib/ring-buffer");
|
|
44
|
-
const set_semver_range_1 = require("../lib/set-semver-range");
|
|
45
|
-
const specifier_1 = require("../specifier");
|
|
1
|
+
import * as Schema from '@effect/schema/Schema';
|
|
2
|
+
import chalk from 'chalk-template';
|
|
3
|
+
import { Data, Effect, identity, pipe } from 'effect';
|
|
4
|
+
import https from 'https';
|
|
5
|
+
import ora from 'ora';
|
|
6
|
+
import { EOL } from 'os';
|
|
7
|
+
import prompts from 'prompts';
|
|
8
|
+
import { diff } from 'semver';
|
|
9
|
+
import gtr from 'semver/ranges/gtr.js';
|
|
10
|
+
import { isArray } from 'tightrope/guard/is-array.js';
|
|
11
|
+
import { isEmptyObject } from 'tightrope/guard/is-empty-object.js';
|
|
12
|
+
import { ICON } from '../constants.js';
|
|
13
|
+
import { formatRepositoryUrl } from '../lib/format-repository-url.js';
|
|
14
|
+
import { RingBuffer } from '../lib/ring-buffer.js';
|
|
15
|
+
import { setSemverRange } from '../lib/set-semver-range.js';
|
|
16
|
+
import { Specifier } from '../specifier/index.js';
|
|
46
17
|
/** full release history from the npm registry for a given package */
|
|
47
|
-
class Releases extends
|
|
18
|
+
class Releases extends Data.TaggedClass('Releases') {
|
|
48
19
|
}
|
|
49
20
|
// https://github.com/terkelg/prompts?tab=readme-ov-file#prompts
|
|
50
|
-
class PromptCancelled extends
|
|
21
|
+
class PromptCancelled extends Data.TaggedClass('PromptCancelled') {
|
|
51
22
|
}
|
|
52
|
-
class HttpError extends
|
|
23
|
+
class HttpError extends Data.TaggedClass('HttpError') {
|
|
53
24
|
}
|
|
54
|
-
class NpmRegistryError extends
|
|
25
|
+
class NpmRegistryError extends Data.TaggedClass('NpmRegistryError') {
|
|
55
26
|
}
|
|
56
27
|
/** the API client for the terminal spinner */
|
|
57
28
|
let spinner = null;
|
|
@@ -62,12 +33,12 @@ let outdatedCount = 0;
|
|
|
62
33
|
/** names of instances currently being fetched from npm */
|
|
63
34
|
const inFlight = new Set();
|
|
64
35
|
/** names of instances most recently finished being fetched from npm */
|
|
65
|
-
const mostRecent = new
|
|
36
|
+
const mostRecent = new RingBuffer(5);
|
|
66
37
|
/** page size when prompting */
|
|
67
38
|
const optionsPerPage = 50;
|
|
68
39
|
/** instance names in `inFlight` are formatted for display */
|
|
69
40
|
function format(instance) {
|
|
70
|
-
return
|
|
41
|
+
return chalk `{gray ${instance.name}}`;
|
|
71
42
|
}
|
|
72
43
|
/** we need to remove colours when sorting loading status output */
|
|
73
44
|
function stripAnsi(str) {
|
|
@@ -75,49 +46,49 @@ function stripAnsi(str) {
|
|
|
75
46
|
const ansiChars = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
76
47
|
return str.replace(ansiChars, '');
|
|
77
48
|
}
|
|
78
|
-
|
|
49
|
+
export const updateEffects = {
|
|
79
50
|
onFetchAllStart() {
|
|
80
51
|
if (!spinner)
|
|
81
|
-
spinner = (
|
|
52
|
+
spinner = ora().start();
|
|
82
53
|
fetchedCount = 0;
|
|
83
|
-
return
|
|
54
|
+
return Effect.void;
|
|
84
55
|
},
|
|
85
56
|
onFetchStart(instance, totalCount) {
|
|
86
57
|
inFlight.add(format(instance));
|
|
87
58
|
fetchedCount++;
|
|
88
59
|
if (spinner) {
|
|
89
|
-
const indent = `${
|
|
60
|
+
const indent = `${EOL} `;
|
|
90
61
|
const progress = new Set([...mostRecent.filter(Boolean), ...inFlight.values()]);
|
|
91
62
|
const sortedProgress = Array.from(progress).sort((a, b) => stripAnsi(a).localeCompare(stripAnsi(b)));
|
|
92
63
|
const suffixText = sortedProgress.join(indent);
|
|
93
|
-
spinner.text =
|
|
64
|
+
spinner.text = chalk `${outdatedCount} updates found in ${fetchedCount}/${totalCount} dependencies${indent}${suffixText}`;
|
|
94
65
|
}
|
|
95
|
-
return
|
|
66
|
+
return Effect.void;
|
|
96
67
|
},
|
|
97
68
|
onFetchEnd(instance, versions) {
|
|
98
69
|
inFlight.delete(format(instance));
|
|
99
70
|
const latest = versions?.latest;
|
|
100
71
|
if (latest) {
|
|
101
|
-
if ((
|
|
72
|
+
if (gtr(latest, String(instance.rawSpecifier.raw), true)) {
|
|
102
73
|
outdatedCount++;
|
|
103
|
-
mostRecent.push(
|
|
74
|
+
mostRecent.push(chalk `${instance.name} {gray {red ${instance.rawSpecifier.raw}} ${ICON.rightArrow}} {green ${latest}}`);
|
|
104
75
|
}
|
|
105
76
|
else {
|
|
106
|
-
mostRecent.push(
|
|
77
|
+
mostRecent.push(chalk `{green ${instance.name}}`);
|
|
107
78
|
}
|
|
108
79
|
}
|
|
109
|
-
return
|
|
80
|
+
return Effect.void;
|
|
110
81
|
},
|
|
111
82
|
/** After checking the registry, store this instance known to be up to date */
|
|
112
83
|
onUpToDate(instance) {
|
|
113
|
-
mostRecent.push(
|
|
114
|
-
return
|
|
84
|
+
mostRecent.push(chalk `{green ${instance.name}}`);
|
|
85
|
+
return Effect.void;
|
|
115
86
|
},
|
|
116
87
|
/** After checking the registry, store this instance known to have newer versions available */
|
|
117
88
|
onOutdated(instance, latest) {
|
|
118
89
|
outdatedCount++;
|
|
119
|
-
mostRecent.push(
|
|
120
|
-
return
|
|
90
|
+
mostRecent.push(chalk `${instance.name} {gray {red ${instance.rawSpecifier.raw}} ${ICON.rightArrow}} {green ${latest}}`);
|
|
91
|
+
return Effect.void;
|
|
121
92
|
},
|
|
122
93
|
/** As the last request completes, remove the progress information */
|
|
123
94
|
onFetchAllEnd() {
|
|
@@ -125,20 +96,20 @@ exports.updateEffects = {
|
|
|
125
96
|
spinner.stop();
|
|
126
97
|
spinner = null;
|
|
127
98
|
fetchedCount = 0;
|
|
128
|
-
return
|
|
99
|
+
return Effect.void;
|
|
129
100
|
},
|
|
130
101
|
/** Fetch available versions for a given package from the npm registry */
|
|
131
102
|
fetchLatestVersions(instance) {
|
|
132
|
-
return
|
|
103
|
+
return pipe(fetchJson(`https://registry.npmjs.org/${instance.name}`),
|
|
133
104
|
// parse and validate the specific data we expect
|
|
134
|
-
|
|
135
|
-
'dist-tags': Schema.
|
|
136
|
-
'time': Schema.
|
|
137
|
-
'homepage': Schema.optional(Schema.
|
|
138
|
-
'repository': Schema.optional(Schema.
|
|
105
|
+
Effect.flatMap(Schema.decodeUnknownEither(Schema.Struct({
|
|
106
|
+
'dist-tags': Schema.Struct({ latest: Schema.String }),
|
|
107
|
+
'time': Schema.Record(Schema.String, Schema.String),
|
|
108
|
+
'homepage': Schema.optional(Schema.String),
|
|
109
|
+
'repository': Schema.optional(Schema.Union(Schema.String, Schema.Struct({ url: Schema.optional(Schema.String) }))),
|
|
139
110
|
}))),
|
|
140
111
|
// transform it into something more appropriate
|
|
141
|
-
|
|
112
|
+
Effect.map((struct) => {
|
|
142
113
|
const rawRepoUrl = typeof struct.repository === 'object' ? struct.repository.url : struct.repository;
|
|
143
114
|
return new Releases({
|
|
144
115
|
instance,
|
|
@@ -146,42 +117,42 @@ exports.updateEffects = {
|
|
|
146
117
|
all: Object.keys(struct.time).filter((key) => key !== 'modified' && key !== 'created'),
|
|
147
118
|
latest: struct['dist-tags'].latest,
|
|
148
119
|
},
|
|
149
|
-
repoUrl:
|
|
120
|
+
repoUrl: formatRepositoryUrl(rawRepoUrl),
|
|
150
121
|
});
|
|
151
122
|
}),
|
|
152
123
|
// hide ParseErrors and just treat them as another kind of NpmRegistryError
|
|
153
|
-
|
|
154
|
-
ParseError: () =>
|
|
124
|
+
Effect.catchTags({
|
|
125
|
+
ParseError: () => Effect.fail(new NpmRegistryError({ error: `Invalid response for ${instance.name}` })),
|
|
155
126
|
}));
|
|
156
127
|
},
|
|
157
128
|
/** Given responses from npm, ask the user which they want */
|
|
158
129
|
promptForUpdates(outdated) {
|
|
159
|
-
return
|
|
130
|
+
return pipe(Effect.Do, Effect.bind('releasesByType', () => groupByReleaseType(outdated)),
|
|
160
131
|
// Create choices to ask if they want major, minor, patch etc
|
|
161
|
-
|
|
132
|
+
Effect.bind('releaseTypeQuestions', ({ releasesByType }) => Effect.succeed(Object.keys(releasesByType)
|
|
162
133
|
.filter((type) => releasesByType[type].length > 0)
|
|
163
134
|
.map((type) => ({
|
|
164
|
-
title:
|
|
135
|
+
title: chalk `${releasesByType[type].length} ${type}`,
|
|
165
136
|
selected: true,
|
|
166
137
|
value: type,
|
|
167
138
|
})))),
|
|
168
139
|
// Ask which release types (major, minor, patch etc) they want
|
|
169
|
-
|
|
170
|
-
?
|
|
171
|
-
try: () => (
|
|
140
|
+
Effect.bind('releaseTypeAnswers', ({ releaseTypeQuestions }) => releaseTypeQuestions.length > 0
|
|
141
|
+
? pipe(Effect.tryPromise({
|
|
142
|
+
try: () => prompts({
|
|
172
143
|
name: 'releaseTypeAnswers',
|
|
173
144
|
type: 'multiselect',
|
|
174
145
|
instructions: true,
|
|
175
146
|
message: `${outdated.length} updates are available`,
|
|
176
147
|
choices: releaseTypeQuestions,
|
|
177
148
|
}).then((res) => res?.releaseTypeAnswers || []),
|
|
178
|
-
catch:
|
|
179
|
-
}),
|
|
180
|
-
:
|
|
149
|
+
catch: identity,
|
|
150
|
+
}), Effect.catchAll(() => pipe(Effect.logError('Error when prompting for releaseTypeAnswers'), Effect.map(() => []))))
|
|
151
|
+
: Effect.succeed([])),
|
|
181
152
|
// For each chosen release type, list the available updates to choose from
|
|
182
|
-
|
|
153
|
+
Effect.bind('prepatchAnswers', (doState) => promptForReleaseType('prepatch', doState)), Effect.bind('patchAnswers', (doState) => promptForReleaseType('patch', doState)), Effect.bind('preminorAnswers', (doState) => promptForReleaseType('preminor', doState)), Effect.bind('minorAnswers', (doState) => promptForReleaseType('minor', doState)), Effect.bind('premajorAnswers', (doState) => promptForReleaseType('premajor', doState)), Effect.bind('majorAnswers', (doState) => promptForReleaseType('major', doState)), Effect.bind('prereleaseAnswers', (doState) => promptForReleaseType('prerelease', doState)),
|
|
183
154
|
/** Apply every update to the package.json files */
|
|
184
|
-
|
|
155
|
+
Effect.flatMap((doState) => pipe([
|
|
185
156
|
...doState.prepatchAnswers,
|
|
186
157
|
...doState.patchAnswers,
|
|
187
158
|
...doState.preminorAnswers,
|
|
@@ -189,7 +160,7 @@ exports.updateEffects = {
|
|
|
189
160
|
...doState.premajorAnswers,
|
|
190
161
|
...doState.majorAnswers,
|
|
191
162
|
...doState.prereleaseAnswers,
|
|
192
|
-
],
|
|
163
|
+
], Effect.forEach((release) => pipe(release.instance.versionGroup.instances, Effect.forEach((instance) => pipe(instance.semverGroup.getFixed(Specifier.create(instance, release.versions.latest)), Effect.flatMap((latestWithRange) => instance.write(latestWithRange.raw)), Effect.catchTag('NonSemverError', Effect.logError))))), Effect.flatMap(() => Effect.void))));
|
|
193
164
|
},
|
|
194
165
|
};
|
|
195
166
|
function promptForReleaseType(releaseType, doState) {
|
|
@@ -197,8 +168,8 @@ function promptForReleaseType(releaseType, doState) {
|
|
|
197
168
|
const prop = `${releaseType}Answers`;
|
|
198
169
|
const releases = releasesByType[releaseType];
|
|
199
170
|
return releaseTypeAnswers.includes(releaseType)
|
|
200
|
-
?
|
|
201
|
-
try: () => (
|
|
171
|
+
? pipe(Effect.tryPromise({
|
|
172
|
+
try: () => prompts({
|
|
202
173
|
name: prop,
|
|
203
174
|
type: 'multiselect',
|
|
204
175
|
instructions: false,
|
|
@@ -212,33 +183,33 @@ function promptForReleaseType(releaseType, doState) {
|
|
|
212
183
|
updateable.versions.latest.length;
|
|
213
184
|
const spacing = Array.from({ length: spacingValue }).fill(' ').join('');
|
|
214
185
|
const repoUrl = updateable.repoUrl
|
|
215
|
-
?
|
|
186
|
+
? chalk `${spacing} {white - ${updateable.repoUrl}}`
|
|
216
187
|
: '';
|
|
217
188
|
return {
|
|
218
|
-
title:
|
|
189
|
+
title: chalk `${updateable.instance.name} {gray ${updateable.instance.rawSpecifier.raw} ${ICON.rightArrow}} {green ${updateable.versions.latest}} ${repoUrl}`,
|
|
219
190
|
selected: true,
|
|
220
191
|
value: updateable,
|
|
221
192
|
};
|
|
222
193
|
}),
|
|
223
194
|
}),
|
|
224
|
-
catch:
|
|
195
|
+
catch: identity,
|
|
225
196
|
}),
|
|
226
197
|
// Paper over errors in terkelg/prompts for now
|
|
227
|
-
|
|
198
|
+
Effect.catchAll(() => pipe(Effect.logError(`terkelg/prompts errored while prompting for ${prop}`), Effect.map(() => ({ [prop]: [] })))),
|
|
228
199
|
// In terkelg/prompts, an empty object means that the user cancelled via
|
|
229
200
|
// ctrl+c or the escape key etc. Handle this case so we can skip any
|
|
230
201
|
// remaining steps.
|
|
231
|
-
|
|
232
|
-
?
|
|
233
|
-
:
|
|
234
|
-
:
|
|
202
|
+
Effect.flatMap((res) => isEmptyObject(res)
|
|
203
|
+
? Effect.fail(new PromptCancelled({ name: releaseType }))
|
|
204
|
+
: Effect.succeed(isArray(res?.[prop]) ? res?.[prop] : [])))
|
|
205
|
+
: Effect.succeed([]);
|
|
235
206
|
}
|
|
236
207
|
function groupByReleaseType(releases) {
|
|
237
|
-
return
|
|
238
|
-
const previous =
|
|
208
|
+
return Effect.succeed(releases.reduce((releasesByType, release) => {
|
|
209
|
+
const previous = setSemverRange('', String(release.instance.rawSpecifier.raw));
|
|
239
210
|
const latest = release.versions.latest;
|
|
240
211
|
try {
|
|
241
|
-
const type =
|
|
212
|
+
const type = diff(previous, latest);
|
|
242
213
|
if (type && releasesByType[type]) {
|
|
243
214
|
releasesByType[type].push(release);
|
|
244
215
|
}
|
|
@@ -259,7 +230,7 @@ function groupByReleaseType(releases) {
|
|
|
259
230
|
}
|
|
260
231
|
// @TODO: add a cache with a short TTL on disk in $TMPDIR
|
|
261
232
|
function fetchJson(url) {
|
|
262
|
-
return
|
|
233
|
+
return pipe(Effect.async((resume) => {
|
|
263
234
|
// setTimeout(
|
|
264
235
|
// () => {
|
|
265
236
|
// resume(
|
|
@@ -275,7 +246,7 @@ function fetchJson(url) {
|
|
|
275
246
|
// },
|
|
276
247
|
// Math.floor(Math.random() * 500) + 1,
|
|
277
248
|
// );
|
|
278
|
-
|
|
249
|
+
https
|
|
279
250
|
.get(url, (res) => {
|
|
280
251
|
let body = '';
|
|
281
252
|
res.setEncoding('utf8');
|
|
@@ -283,13 +254,13 @@ function fetchJson(url) {
|
|
|
283
254
|
body = `${body}${chunk}`;
|
|
284
255
|
});
|
|
285
256
|
res.on('end', () => {
|
|
286
|
-
resume(
|
|
257
|
+
resume(Effect.succeed(body));
|
|
287
258
|
});
|
|
288
259
|
})
|
|
289
260
|
.on('error', (err) => {
|
|
290
|
-
resume(
|
|
261
|
+
resume(Effect.fail(new HttpError({ error: `Node https threw on ${url}: ${String(err)}` })));
|
|
291
262
|
});
|
|
292
|
-
}),
|
|
263
|
+
}), Effect.flatMap((body) => Effect.try({
|
|
293
264
|
try: () => JSON.parse(body),
|
|
294
265
|
catch: () => new NpmRegistryError({ error: `JSON.parse threw on response from ${url}` }),
|
|
295
266
|
})));
|
package/dist/bin-update/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 update_1 = require("./update");
|
|
14
|
-
commander_1.program.description(' Update to the latest versions on the npm registry.');
|
|
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 { update } from './update.js';
|
|
9
|
+
program.description(' Update to the latest versions on the npm registry.');
|
|
10
|
+
program.on('--help', () => {
|
|
11
|
+
console.log(chalk `
|
|
17
12
|
Examples:
|
|
18
13
|
{dim # uses defaults for resolving packages}
|
|
19
14
|
syncpack update
|
|
@@ -42,18 +37,18 @@ Reference:
|
|
|
42
37
|
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
43
38
|
`);
|
|
44
39
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.option(...
|
|
48
|
-
.option(...
|
|
49
|
-
.option(...
|
|
50
|
-
.option(...
|
|
51
|
-
.option(...
|
|
40
|
+
showHelpOnError(program);
|
|
41
|
+
program
|
|
42
|
+
.option(...option.source)
|
|
43
|
+
.option(...option.filter)
|
|
44
|
+
.option(...option.config)
|
|
45
|
+
.option(...option.specs)
|
|
46
|
+
.option(...option.types)
|
|
52
47
|
.parse(process.argv);
|
|
53
|
-
|
|
54
|
-
configPath:
|
|
55
|
-
filter:
|
|
56
|
-
source:
|
|
57
|
-
specs:
|
|
58
|
-
types:
|
|
48
|
+
Effect.runPromise(update(io, {
|
|
49
|
+
configPath: program.opts().config,
|
|
50
|
+
filter: program.opts().filter,
|
|
51
|
+
source: program.opts().source,
|
|
52
|
+
specs: program.opts().specs,
|
|
53
|
+
types: program.opts().types,
|
|
59
54
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
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';
|
|
5
|
-
import { updateEffects } from './effects';
|
|
6
|
-
export declare function update(io: Io, cli: Partial<CliConfig>, effects?: typeof updateEffects, errorHandlers?: ErrorHandlers): Effect.Effect<
|
|
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
|
+
import { updateEffects } from './effects.js';
|
|
6
|
+
export declare function update(io: Io, cli: Partial<CliConfig>, effects?: typeof updateEffects, errorHandlers?: ErrorHandlers): Effect.Effect<unknown, never, never>;
|