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,66 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const write_if_changed_1 = require("../io/write-if-changed");
|
|
18
|
-
const with_logger_1 = require("../lib/with-logger");
|
|
19
|
-
const specifier_1 = require("../specifier");
|
|
20
|
-
const effects_1 = require("./effects");
|
|
21
|
-
function update(io, cli, effects = effects_1.updateEffects, errorHandlers = default_error_handlers_1.defaultErrorHandlers) {
|
|
22
|
-
return (0, effect_1.pipe)(effect_1.Effect.Do, effect_1.Effect.bind('ctx', () => (0, get_context_1.getContext)({ io, cli, errorHandlers })), effect_1.Effect.bind('instances', ({ ctx }) => (0, get_instances_1.getInstances)(ctx, io, errorHandlers)), effect_1.Effect.bind('update', ({ instances }) => (0, effect_1.pipe)(effect_1.Effect.succeed(instances.all), effect_1.Effect.map((instances) => {
|
|
1
|
+
import chalk from 'chalk-template';
|
|
2
|
+
import { Context, Effect, flow, pipe } from 'effect';
|
|
3
|
+
import { gtr } from 'semver';
|
|
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 { writeIfChanged } from '../io/write-if-changed.js';
|
|
12
|
+
import { withLogger } from '../lib/with-logger.js';
|
|
13
|
+
import { Specifier } from '../specifier/index.js';
|
|
14
|
+
import { updateEffects } from './effects.js';
|
|
15
|
+
export function update(io, cli, effects = updateEffects, errorHandlers = defaultErrorHandlers) {
|
|
16
|
+
return pipe(Effect.Do, Effect.bind('ctx', () => getContext({ io, cli, errorHandlers })), Effect.bind('instances', ({ ctx }) => getInstances(ctx, io, errorHandlers)), Effect.bind('updateable', ({ instances }) => {
|
|
23
17
|
const isVisitedByName = {};
|
|
24
18
|
const updateable = [];
|
|
25
|
-
instances.forEach((instance) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const specifier = specifier_1.Specifier.create(instance, instance.rawSpecifier.raw);
|
|
19
|
+
instances.all.forEach((instance) => {
|
|
20
|
+
const _tag = instance.versionGroup._tag;
|
|
21
|
+
if (!isVisitedByName[instance.name] && (_tag === 'SameRange' || _tag === 'Standard')) {
|
|
22
|
+
const specifier = Specifier.create(instance, instance.rawSpecifier.raw);
|
|
30
23
|
if (specifier._tag === 'Range' || specifier._tag === 'Exact') {
|
|
31
24
|
isVisitedByName[instance.name] = true;
|
|
32
25
|
updateable.push(instance);
|
|
33
26
|
}
|
|
34
27
|
}
|
|
35
28
|
});
|
|
36
|
-
return updateable;
|
|
37
|
-
}),
|
|
38
|
-
onFailure: () =>
|
|
39
|
-
onSuccess: ({ versions }) =>
|
|
29
|
+
return Effect.succeed(updateable);
|
|
30
|
+
}), Effect.bind('update', ({ updateable }) => pipe(Effect.succeed(updateable), Effect.tap(effects.onFetchAllStart), Effect.flatMap((instances) => pipe(instances, Effect.partition((instance) => pipe(Effect.succeed(instance), Effect.tap(() => effects.onFetchStart(instance, instances.length)), Effect.flatMap(effects.fetchLatestVersions), Effect.tapBoth({
|
|
31
|
+
onFailure: () => effects.onFetchEnd(instance),
|
|
32
|
+
onSuccess: ({ versions }) => effects.onFetchEnd(instance, versions),
|
|
40
33
|
}),
|
|
41
34
|
// move up to date dependencies to error channel
|
|
42
|
-
|
|
43
|
-
?
|
|
44
|
-
:
|
|
35
|
+
Effect.flatMap((updateable) => gtr(updateable.versions.latest, String(instance.rawSpecifier.raw))
|
|
36
|
+
? pipe(effects.onOutdated(instance, updateable.versions.latest), Effect.map(() => updateable))
|
|
37
|
+
: pipe(effects.onUpToDate(instance), Effect.flatMap(() => Effect.fail(updateable)))),
|
|
45
38
|
// log error but don't catch it
|
|
46
|
-
|
|
39
|
+
Effect.tapErrorTag('HttpError', ({ error }) => Effect.logError(chalk `{red ${ICON.cross} ${error}}`)),
|
|
47
40
|
// log error but don't catch it
|
|
48
|
-
|
|
41
|
+
Effect.tapErrorTag('NpmRegistryError', ({ error }) => Effect.logError(chalk `{red ${ICON.cross} ${error}}`))), { concurrency: 10 }),
|
|
49
42
|
// discard errors and up to date dependencies
|
|
50
|
-
|
|
43
|
+
Effect.flatMap(([_, outOfDate]) => Effect.succeed(outOfDate)))),
|
|
51
44
|
// always remove the spinner when we're done
|
|
52
|
-
|
|
53
|
-
onFailure:
|
|
54
|
-
onSuccess:
|
|
45
|
+
Effect.tapBoth({
|
|
46
|
+
onFailure: effects.onFetchAllEnd,
|
|
47
|
+
onSuccess: effects.onFetchAllEnd,
|
|
55
48
|
}),
|
|
56
49
|
// ask the user which updates they want
|
|
57
|
-
|
|
50
|
+
Effect.flatMap(effects.promptForUpdates),
|
|
58
51
|
// if we think the user cancelled, say so
|
|
59
|
-
|
|
60
|
-
WriteFileError:
|
|
52
|
+
Effect.catchTag('PromptCancelled', () => Effect.logInfo(chalk `{red ${ICON.panic}} aborting after {blue syncpack update} was cancelled`)))), Effect.flatMap(({ ctx }) => pipe(writeIfChanged(ctx), Effect.catchTags({
|
|
53
|
+
WriteFileError: flow(errorHandlers.WriteFileError, Effect.map(() => {
|
|
61
54
|
ctx.isInvalid = true;
|
|
62
55
|
return ctx;
|
|
63
56
|
})),
|
|
64
|
-
}))),
|
|
57
|
+
}))), Effect.flatMap(exitIfInvalid), Effect.withConcurrency(10), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
|
|
65
58
|
}
|
|
66
|
-
exports.update = update;
|
package/dist/bin.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
program
|
|
9
|
+
.version(JSON.parse(fs.readFileSync(`${__dirname}/../package.json`, 'utf8')).version)
|
|
7
10
|
.command('fix-mismatches', 'set dependencies used with different versions to the same version', {
|
|
8
11
|
executableFile: './bin-fix-mismatches/index.js',
|
|
9
12
|
})
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Ctx } from '../get-context';
|
|
3
|
-
import { NameAndVersionPropsStrategy } from '../strategy/name-and-version-props';
|
|
4
|
-
import { NamedVersionStringStrategy } from '../strategy/named-version-string';
|
|
5
|
-
import { UnnamedVersionStringStrategy } from '../strategy/unnamed-version-string';
|
|
6
|
-
import { VersionsByNameStrategy } from '../strategy/versions-by-name';
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import type { Ctx } from '../get-context/index.js';
|
|
3
|
+
import { NameAndVersionPropsStrategy } from '../strategy/name-and-version-props.js';
|
|
4
|
+
import { NamedVersionStringStrategy } from '../strategy/named-version-string.js';
|
|
5
|
+
import { UnnamedVersionStringStrategy } from '../strategy/unnamed-version-string.js';
|
|
6
|
+
import { VersionsByNameStrategy } from '../strategy/versions-by-name.js';
|
|
7
7
|
export declare namespace Strategy {
|
|
8
8
|
type Any = NameAndVersionPropsStrategy | NamedVersionStringStrategy | UnnamedVersionStringStrategy | VersionsByNameStrategy;
|
|
9
9
|
}
|
|
10
|
-
declare const InvalidCustomTypeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
10
|
+
declare const InvalidCustomTypeError_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> & {
|
|
11
11
|
readonly _tag: "InvalidCustomTypeError";
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
export declare class InvalidCustomTypeError extends InvalidCustomTypeError_base<{
|
|
14
14
|
readonly config: unknown;
|
|
15
15
|
readonly reason: string;
|
|
16
16
|
}> {
|
|
17
17
|
}
|
|
18
|
-
export declare function getCustomTypes({ rcFile, }: Ctx['config']): Effect.Effect<
|
|
18
|
+
export declare function getCustomTypes({ rcFile, }: Ctx['config']): Effect.Effect<Strategy.Any[], InvalidCustomTypeError>;
|
|
19
19
|
export {};
|
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const unnamed_version_string_1 = require("../strategy/unnamed-version-string");
|
|
12
|
-
const versions_by_name_1 = require("../strategy/versions-by-name");
|
|
13
|
-
class InvalidCustomTypeError extends effect_1.Data.TaggedClass('InvalidCustomTypeError') {
|
|
1
|
+
import { Data, Effect } from 'effect';
|
|
2
|
+
import { isNonEmptyObject } from 'tightrope/guard/is-non-empty-object.js';
|
|
3
|
+
import { isNonEmptyString } from 'tightrope/guard/is-non-empty-string.js';
|
|
4
|
+
import { isObject } from 'tightrope/guard/is-object.js';
|
|
5
|
+
import { DEFAULT_CONFIG } from '../constants.js';
|
|
6
|
+
import { NameAndVersionPropsStrategy } from '../strategy/name-and-version-props.js';
|
|
7
|
+
import { NamedVersionStringStrategy } from '../strategy/named-version-string.js';
|
|
8
|
+
import { UnnamedVersionStringStrategy } from '../strategy/unnamed-version-string.js';
|
|
9
|
+
import { VersionsByNameStrategy } from '../strategy/versions-by-name.js';
|
|
10
|
+
export class InvalidCustomTypeError extends Data.TaggedClass('InvalidCustomTypeError') {
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return effect_1.Effect.all([...Object.entries(rcFile.customTypes), ...Object.entries(constants_1.DEFAULT_CONFIG.customTypes)].map(([name, config]) => {
|
|
12
|
+
export function getCustomTypes({ rcFile, }) {
|
|
13
|
+
if (!isNonEmptyObject(rcFile.customTypes))
|
|
14
|
+
return Effect.succeed([]);
|
|
15
|
+
return Effect.all([...Object.entries(rcFile.customTypes), ...Object.entries(DEFAULT_CONFIG.customTypes)].map(([name, config]) => {
|
|
20
16
|
const ERR_OBJ = 'Invalid customType';
|
|
21
17
|
const ERR_PATH = 'Invalid customType.path';
|
|
22
18
|
const ERR_NAME_PATH = 'Invalid customType.namePath';
|
|
23
19
|
const ERR_STRATEGY = 'Invalid customType.strategy';
|
|
24
|
-
if (!
|
|
20
|
+
if (!isObject(config))
|
|
25
21
|
return createError(config, ERR_OBJ);
|
|
26
|
-
if (!
|
|
22
|
+
if (!isNonEmptyString(config.path))
|
|
27
23
|
return createError(config, ERR_PATH);
|
|
28
24
|
const path = config.path;
|
|
29
25
|
const strategy = config.strategy;
|
|
30
26
|
switch (strategy) {
|
|
31
27
|
case 'name~version': {
|
|
32
28
|
const namePath = config.namePath;
|
|
33
|
-
if (!
|
|
29
|
+
if (!isNonEmptyString(namePath))
|
|
34
30
|
return createError(config, ERR_NAME_PATH);
|
|
35
|
-
return
|
|
31
|
+
return Effect.succeed(new NameAndVersionPropsStrategy(name, path, namePath));
|
|
36
32
|
}
|
|
37
33
|
case 'name@version': {
|
|
38
|
-
return
|
|
34
|
+
return Effect.succeed(new NamedVersionStringStrategy(name, path));
|
|
39
35
|
}
|
|
40
36
|
case 'version': {
|
|
41
|
-
return
|
|
37
|
+
return Effect.succeed(new UnnamedVersionStringStrategy(name, path));
|
|
42
38
|
}
|
|
43
39
|
case 'versionsByName': {
|
|
44
|
-
return
|
|
40
|
+
return Effect.succeed(new VersionsByNameStrategy(name, path));
|
|
45
41
|
}
|
|
46
42
|
default: {
|
|
47
43
|
return createError(config, ERR_STRATEGY);
|
|
@@ -49,7 +45,6 @@ function getCustomTypes({ rcFile, }) {
|
|
|
49
45
|
}
|
|
50
46
|
}));
|
|
51
47
|
}
|
|
52
|
-
exports.getCustomTypes = getCustomTypes;
|
|
53
48
|
function createError(config, reason) {
|
|
54
|
-
return
|
|
49
|
+
return Effect.fail(new InvalidCustomTypeError({ config, reason }));
|
|
55
50
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Ctx } from '../get-context';
|
|
3
|
-
import type { InvalidCustomTypeError, Strategy } from './get-custom-types';
|
|
4
|
-
declare const DeprecatedTypesError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import type { Ctx } from '../get-context/index.js';
|
|
3
|
+
import type { InvalidCustomTypeError, Strategy } from './get-custom-types.js';
|
|
4
|
+
declare const DeprecatedTypesError_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> & {
|
|
5
5
|
readonly _tag: "DeprecatedTypesError";
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
7
|
export declare class DeprecatedTypesError extends DeprecatedTypesError_base<{
|
|
8
8
|
readonly types: string[];
|
|
9
9
|
}> {
|
|
10
10
|
}
|
|
11
|
-
declare const RenamedWorkspaceTypeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
11
|
+
declare const RenamedWorkspaceTypeError_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> & {
|
|
12
12
|
readonly _tag: "RenamedWorkspaceTypeError";
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
export declare class RenamedWorkspaceTypeError extends RenamedWorkspaceTypeError_base<Record<string, never>> {
|
|
15
15
|
}
|
|
16
|
-
export declare function getEnabledTypes({ cli, rcFile, }: Ctx['config']): Effect.Effect<
|
|
16
|
+
export declare function getEnabledTypes({ cli, rcFile, }: Ctx['config']): Effect.Effect<Strategy.Any[], DeprecatedTypesError | InvalidCustomTypeError | RenamedWorkspaceTypeError>;
|
|
17
17
|
export {};
|
|
@@ -1,70 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const versions_by_name_1 = require("../strategy/versions-by-name");
|
|
13
|
-
const get_custom_types_1 = require("./get-custom-types");
|
|
14
|
-
class DeprecatedTypesError extends effect_1.Data.TaggedClass('DeprecatedTypesError') {
|
|
1
|
+
import { Data, Effect, pipe } from 'effect';
|
|
2
|
+
import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
|
|
3
|
+
import { isBoolean } from 'tightrope/guard/is-boolean.js';
|
|
4
|
+
import { isEmptyArray } from 'tightrope/guard/is-empty-array.js';
|
|
5
|
+
import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
|
|
6
|
+
import { isNonEmptyString } from 'tightrope/guard/is-non-empty-string.js';
|
|
7
|
+
import { INTERNAL_TYPES } from '../constants.js';
|
|
8
|
+
import { NameAndVersionPropsStrategy } from '../strategy/name-and-version-props.js';
|
|
9
|
+
import { VersionsByNameStrategy } from '../strategy/versions-by-name.js';
|
|
10
|
+
import { getCustomTypes } from './get-custom-types.js';
|
|
11
|
+
export class DeprecatedTypesError extends Data.TaggedClass('DeprecatedTypesError') {
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
class RenamedWorkspaceTypeError extends effect_1.Data.TaggedClass('RenamedWorkspaceTypeError') {
|
|
13
|
+
export class RenamedWorkspaceTypeError extends Data.TaggedClass('RenamedWorkspaceTypeError') {
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return (0, effect_1.pipe)(
|
|
15
|
+
export function getEnabledTypes({ cli, rcFile, }) {
|
|
16
|
+
return pipe(
|
|
22
17
|
// Look for dependency types defined using the old `{ prod: true }` syntax
|
|
23
18
|
// deprecated in syncpack@9.0.0
|
|
24
|
-
|
|
19
|
+
Effect.succeed(INTERNAL_TYPES.filter((key) => isBoolean(rcFile[key]))),
|
|
25
20
|
// Short-circuit and quit if deprecated config is used
|
|
26
|
-
|
|
27
|
-
?
|
|
28
|
-
:
|
|
21
|
+
Effect.flatMap((deprecatedTypeProps) => deprecatedTypeProps.length > 0
|
|
22
|
+
? Effect.fail(new DeprecatedTypesError({ types: deprecatedTypeProps }))
|
|
23
|
+
: Effect.void), Effect.flatMap(() => pipe(Effect.Do,
|
|
29
24
|
// Get index of every available strategy, keyed by their names as
|
|
30
25
|
// they're referred to in config
|
|
31
|
-
|
|
26
|
+
Effect.bind('allStrategiesByName', () => pipe(
|
|
32
27
|
// Get custom types if any are defined, short-circuit and quit if
|
|
33
28
|
// any are invalid
|
|
34
|
-
|
|
29
|
+
getCustomTypes({ cli, rcFile }),
|
|
35
30
|
// Combine them with the default/internal dependency types
|
|
36
|
-
|
|
37
|
-
['dev', new
|
|
38
|
-
['local', new
|
|
39
|
-
['overrides', new
|
|
40
|
-
['peer', new
|
|
41
|
-
['pnpmOverrides', new
|
|
42
|
-
['prod', new
|
|
43
|
-
['resolutions', new
|
|
31
|
+
Effect.map((customTypes) => Object.fromEntries([
|
|
32
|
+
['dev', new VersionsByNameStrategy('dev', 'devDependencies')],
|
|
33
|
+
['local', new NameAndVersionPropsStrategy('local', 'version', 'name')],
|
|
34
|
+
['overrides', new VersionsByNameStrategy('overrides', 'overrides')],
|
|
35
|
+
['peer', new VersionsByNameStrategy('peer', 'peerDependencies')],
|
|
36
|
+
['pnpmOverrides', new VersionsByNameStrategy('pnpmOverrides', 'pnpm.overrides')],
|
|
37
|
+
['prod', new VersionsByNameStrategy('prod', 'dependencies')],
|
|
38
|
+
['resolutions', new VersionsByNameStrategy('resolutions', 'resolutions')],
|
|
44
39
|
...customTypes.map((type) => [type.name, type]),
|
|
45
40
|
])))),
|
|
46
41
|
// The names of every available strategy
|
|
47
|
-
|
|
42
|
+
Effect.bind('allStrategyNames', ({ allStrategiesByName }) => Effect.succeed(Object.keys(allStrategiesByName))),
|
|
48
43
|
// Create groupings to assign each provided dependencyType to
|
|
49
|
-
|
|
50
|
-
provided: (
|
|
44
|
+
Effect.bind('strategyNamesByStatus', () => Effect.succeed({
|
|
45
|
+
provided: (isNonEmptyString(cli.types)
|
|
51
46
|
? cli.types.split(',')
|
|
52
|
-
:
|
|
47
|
+
: isArrayOfStrings(rcFile.dependencyTypes)
|
|
53
48
|
? rcFile.dependencyTypes
|
|
54
|
-
: []).filter(
|
|
49
|
+
: []).filter(isNonEmptyString),
|
|
55
50
|
enabled: [],
|
|
56
51
|
positive: [],
|
|
57
52
|
negative: [],
|
|
58
|
-
})))),
|
|
53
|
+
})))), Effect.tap(({ strategyNamesByStatus }) => Effect.logDebug(`dependency types provided by user: ${JSON.stringify(strategyNamesByStatus.provided)}`)),
|
|
59
54
|
// Determine which dependencyTypes should be enabled based on:
|
|
60
55
|
// * which are defined
|
|
61
56
|
// * which were listed to be enabled
|
|
62
57
|
// * which were listed but !negated
|
|
63
58
|
// * etc.
|
|
64
|
-
|
|
65
|
-
if (
|
|
59
|
+
Effect.flatMap(({ allStrategiesByName, allStrategyNames, strategyNamesByStatus }) => {
|
|
60
|
+
if (isEmptyArray(strategyNamesByStatus.provided) ||
|
|
66
61
|
strategyNamesByStatus.provided.join('') === '**') {
|
|
67
|
-
return
|
|
62
|
+
return Effect.succeed(allStrategyNames.map(getStrategyByName));
|
|
68
63
|
}
|
|
69
64
|
strategyNamesByStatus.provided.forEach((name) => {
|
|
70
65
|
if (name.startsWith('!')) {
|
|
@@ -74,14 +69,14 @@ function getEnabledTypes({ cli, rcFile, }) {
|
|
|
74
69
|
strategyNamesByStatus.positive.push(name);
|
|
75
70
|
}
|
|
76
71
|
});
|
|
77
|
-
if (
|
|
72
|
+
if (isNonEmptyArray(strategyNamesByStatus.negative)) {
|
|
78
73
|
allStrategyNames.forEach((name) => {
|
|
79
74
|
if (!strategyNamesByStatus.negative.includes(name)) {
|
|
80
75
|
strategyNamesByStatus.enabled.push(name);
|
|
81
76
|
}
|
|
82
77
|
});
|
|
83
78
|
}
|
|
84
|
-
if (
|
|
79
|
+
if (isNonEmptyArray(strategyNamesByStatus.positive)) {
|
|
85
80
|
strategyNamesByStatus.positive.forEach((name) => {
|
|
86
81
|
if (!strategyNamesByStatus.enabled.includes(name)) {
|
|
87
82
|
strategyNamesByStatus.enabled.push(name);
|
|
@@ -89,12 +84,11 @@ function getEnabledTypes({ cli, rcFile, }) {
|
|
|
89
84
|
});
|
|
90
85
|
}
|
|
91
86
|
if (strategyNamesByStatus.enabled.includes('workspace')) {
|
|
92
|
-
return
|
|
87
|
+
return Effect.fail(new RenamedWorkspaceTypeError({}));
|
|
93
88
|
}
|
|
94
|
-
return
|
|
89
|
+
return Effect.succeed(strategyNamesByStatus.enabled.map(getStrategyByName));
|
|
95
90
|
function getStrategyByName(type) {
|
|
96
91
|
return allStrategiesByName[type];
|
|
97
92
|
}
|
|
98
|
-
}),
|
|
93
|
+
}), Effect.tap((enabledTypes) => Effect.logDebug(`enabled dependency types determined to be: ${JSON.stringify(enabledTypes)}`)));
|
|
99
94
|
}
|
|
100
|
-
exports.getEnabledTypes = getEnabledTypes;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Ctx } from '../get-context';
|
|
1
|
+
import type { Ctx } from '../get-context/index.js';
|
|
2
2
|
export declare function getFilter({ cli, rcFile }: Ctx['config']): string;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
|
-
function getFilter({ cli, rcFile }) {
|
|
1
|
+
import { isNonEmptyString } from 'tightrope/guard/is-non-empty-string.js';
|
|
2
|
+
import { DEFAULT_CONFIG } from '../constants.js';
|
|
3
|
+
export function getFilter({ cli, rcFile }) {
|
|
7
4
|
// @TODO Deprecate `filter` in .syncpackrc
|
|
8
|
-
return
|
|
5
|
+
return isNonEmptyString(cli.filter)
|
|
9
6
|
? cli.filter
|
|
10
|
-
:
|
|
7
|
+
: isNonEmptyString(rcFile.filter)
|
|
11
8
|
? rcFile.filter
|
|
12
|
-
:
|
|
9
|
+
: DEFAULT_CONFIG.filter;
|
|
13
10
|
}
|
|
14
|
-
exports.getFilter = getFilter;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Ctx } from '../get-context';
|
|
1
|
+
import type { Ctx } from '../get-context/index.js';
|
|
2
2
|
export declare function getIndent({ cli, rcFile }: Ctx['config']): string;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
|
-
function getIndent({ cli, rcFile }) {
|
|
7
|
-
return (0, is_non_empty_string_1.isNonEmptyString)(cli.indent)
|
|
1
|
+
import { isNonEmptyString } from 'tightrope/guard/is-non-empty-string.js';
|
|
2
|
+
import { DEFAULT_CONFIG } from '../constants.js';
|
|
3
|
+
export function getIndent({ cli, rcFile }) {
|
|
4
|
+
return isNonEmptyString(cli.indent)
|
|
8
5
|
? cli.indent.replaceAll('\\t', '\t')
|
|
9
|
-
:
|
|
6
|
+
: isNonEmptyString(rcFile.indent)
|
|
10
7
|
? rcFile.indent
|
|
11
|
-
:
|
|
8
|
+
: DEFAULT_CONFIG.indent;
|
|
12
9
|
}
|
|
13
|
-
exports.getIndent = getIndent;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Ctx } from '../get-context';
|
|
1
|
+
import type { Ctx } from '../get-context/index.js';
|
|
2
2
|
export declare function getSortAz({ rcFile }: Ctx['config']): string[];
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
function getSortAz({ rcFile }) {
|
|
8
|
-
return (0, is_array_of_strings_1.isArrayOfStrings)(rcFile.sortAz) || (0, is_empty_array_1.isEmptyArray)(rcFile.sortAz)
|
|
1
|
+
import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
|
|
2
|
+
import { isEmptyArray } from 'tightrope/guard/is-empty-array.js';
|
|
3
|
+
import { DEFAULT_CONFIG } from '../constants.js';
|
|
4
|
+
export function getSortAz({ rcFile }) {
|
|
5
|
+
return isArrayOfStrings(rcFile.sortAz) || isEmptyArray(rcFile.sortAz)
|
|
9
6
|
? rcFile.sortAz
|
|
10
|
-
:
|
|
7
|
+
: DEFAULT_CONFIG.sortAz;
|
|
11
8
|
}
|
|
12
|
-
exports.getSortAz = getSortAz;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Ctx } from '../get-context';
|
|
1
|
+
import type { Ctx } from '../get-context/index.js';
|
|
2
2
|
export declare function getSortExports({ rcFile }: Ctx['config']): string[];
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
function getSortExports({ rcFile }) {
|
|
8
|
-
return (0, is_array_of_strings_1.isArrayOfStrings)(rcFile.sortExports) || (0, is_empty_array_1.isEmptyArray)(rcFile.sortExports)
|
|
1
|
+
import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
|
|
2
|
+
import { isEmptyArray } from 'tightrope/guard/is-empty-array.js';
|
|
3
|
+
import { DEFAULT_CONFIG } from '../constants.js';
|
|
4
|
+
export function getSortExports({ rcFile }) {
|
|
5
|
+
return isArrayOfStrings(rcFile.sortExports) || isEmptyArray(rcFile.sortExports)
|
|
9
6
|
? rcFile.sortExports
|
|
10
|
-
:
|
|
7
|
+
: DEFAULT_CONFIG.sortExports;
|
|
11
8
|
}
|
|
12
|
-
exports.getSortExports = getSortExports;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Ctx } from '../get-context';
|
|
1
|
+
import type { Ctx } from '../get-context/index.js';
|
|
2
2
|
export declare function getSortFirst({ rcFile }: Ctx['config']): string[];
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
function getSortFirst({ rcFile }) {
|
|
8
|
-
return (0, is_array_of_strings_1.isArrayOfStrings)(rcFile.sortFirst) || (0, is_empty_array_1.isEmptyArray)(rcFile.sortFirst)
|
|
1
|
+
import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
|
|
2
|
+
import { isEmptyArray } from 'tightrope/guard/is-empty-array.js';
|
|
3
|
+
import { DEFAULT_CONFIG } from '../constants.js';
|
|
4
|
+
export function getSortFirst({ rcFile }) {
|
|
5
|
+
return isArrayOfStrings(rcFile.sortFirst) || isEmptyArray(rcFile.sortFirst)
|
|
9
6
|
? rcFile.sortFirst
|
|
10
|
-
:
|
|
7
|
+
: DEFAULT_CONFIG.sortFirst;
|
|
11
8
|
}
|
|
12
|
-
exports.getSortFirst = getSortFirst;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Ctx } from '../get-context';
|
|
1
|
+
import type { Ctx } from '../get-context/index.js';
|
|
2
2
|
export declare function getSource({ cli, rcFile }: Ctx['config']): string[];
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
|
|
5
|
-
function getSource({ cli, rcFile }) {
|
|
6
|
-
return (0, is_array_of_strings_1.isArrayOfStrings)(cli.source)
|
|
1
|
+
import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
|
|
2
|
+
export function getSource({ cli, rcFile }) {
|
|
3
|
+
return isArrayOfStrings(cli.source)
|
|
7
4
|
? cli.source
|
|
8
|
-
:
|
|
5
|
+
: isArrayOfStrings(rcFile.source)
|
|
9
6
|
? rcFile.source
|
|
10
7
|
: [];
|
|
11
8
|
}
|
|
12
|
-
exports.getSource = getSource;
|
package/dist/config/tag.d.ts
CHANGED
package/dist/config/tag.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.CliConfigTag = void 0;
|
|
4
|
-
const effect_1 = require("effect");
|
|
5
|
-
exports.CliConfigTag = effect_1.Context.Tag();
|
|
1
|
+
import { Context } from 'effect';
|
|
2
|
+
export const CliConfigTag = Context.GenericTag('@services/CliConfigTag');
|
package/dist/config/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CUSTOM_TYPES } from '../constants';
|
|
2
|
-
import type { Specifier } from '../specifier';
|
|
1
|
+
import type { CUSTOM_TYPES } from '../constants.js';
|
|
2
|
+
import type { Specifier } from '../specifier/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Aliases for semver range formats supported by syncpack
|
|
5
5
|
*
|
|
@@ -58,9 +58,6 @@ export declare namespace VersionGroupConfig {
|
|
|
58
58
|
interface SameRange extends GroupConfig {
|
|
59
59
|
policy: 'sameRange';
|
|
60
60
|
}
|
|
61
|
-
interface SnappedTo extends GroupConfig {
|
|
62
|
-
snapTo: string[];
|
|
63
|
-
}
|
|
64
61
|
interface Standard extends GroupConfig {
|
|
65
62
|
preferVersion?: 'highestSemver' | 'lowestSemver';
|
|
66
63
|
}
|
package/dist/config/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|