syncpack 12.2.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/README.md +5 -5
- 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 -4
- package/dist/bin-format/format.js +78 -53
- 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 +51 -19
- 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 -9
- package/dist/config/get-indent.d.ts +1 -1
- package/dist/config/get-indent.js +6 -9
- package/dist/config/get-sort-az.d.ts +1 -1
- package/dist/config/get-sort-az.js +6 -17
- package/dist/config/get-sort-exports.d.ts +2 -0
- package/dist/config/get-sort-exports.js +8 -0
- package/dist/config/get-sort-first.d.ts +1 -1
- package/dist/config/get-sort-first.js +6 -8
- 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 +16 -5
- package/dist/config/types.js +1 -2
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +25 -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 +9 -0
- package/dist/io/to-json.js +29 -0
- 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 -10
- package/dist/io/write-if-changed.js +9 -44
- 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/schema.json +24 -0
- 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,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const specifier_1 = require("../specifier");
|
|
7
|
-
const group_by_1 = require("./lib/group-by");
|
|
8
|
-
class PinnedVersionGroup extends effect_1.Data.TaggedClass('Pinned') {
|
|
1
|
+
import { Data, Effect, pipe } from 'effect';
|
|
2
|
+
import { Report } from '../report.js';
|
|
3
|
+
import { Specifier } from '../specifier/index.js';
|
|
4
|
+
import { groupBy } from './lib/group-by.js';
|
|
5
|
+
export class PinnedVersionGroup extends Data.TaggedClass('Pinned') {
|
|
9
6
|
groupType = 'versionGroup';
|
|
10
7
|
constructor(config) {
|
|
11
8
|
super({
|
|
@@ -17,14 +14,13 @@ class PinnedVersionGroup extends effect_1.Data.TaggedClass('Pinned') {
|
|
|
17
14
|
return true;
|
|
18
15
|
}
|
|
19
16
|
inspectAll() {
|
|
20
|
-
return
|
|
17
|
+
return Effect.all(Object.entries(groupBy('name', this.instances)).map(([name, instances]) => pipe(instances, Effect.forEach((instance) => pipe(Effect.succeed(Specifier.create(instance, this.config.pinVersion)), Effect.map((expected) => instance.rawSpecifier.raw === expected.raw
|
|
21
18
|
? // ✓ pinned takes precedence over any semver group
|
|
22
19
|
// ✓ current version matches expected
|
|
23
|
-
new
|
|
20
|
+
new Report.Valid(expected)
|
|
24
21
|
: // ✓ pinned takes precedence over any semver group
|
|
25
22
|
// ✘ current version mismatches expected
|
|
26
23
|
// ✓ is a mismatch we can auto-fix
|
|
27
|
-
new
|
|
24
|
+
new Report.PinnedMismatch(expected)))), Effect.map((reports) => ({ name, reports })))));
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
exports.PinnedVersionGroup = PinnedVersionGroup;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { VersionGroupConfig } from '../config/types';
|
|
3
|
-
import type { Ctx } from '../get-context';
|
|
4
|
-
import type { Instance } from '../get-instances/instance';
|
|
5
|
-
import { Report } from '../report';
|
|
6
|
-
declare const SameRangeVersionGroup_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import type { VersionGroupConfig } from '../config/types.js';
|
|
3
|
+
import type { Ctx } from '../get-context/index.js';
|
|
4
|
+
import type { Instance } from '../get-instances/instance.js';
|
|
5
|
+
import { Report } from '../report.js';
|
|
6
|
+
declare const SameRangeVersionGroup_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> & {
|
|
7
7
|
readonly _tag: "SameRange";
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
export declare class SameRangeVersionGroup extends SameRangeVersionGroup_base<{
|
|
10
10
|
ctx: Ctx;
|
|
11
11
|
config: VersionGroupConfig.SameRange;
|
|
@@ -14,6 +14,6 @@ export declare class SameRangeVersionGroup extends SameRangeVersionGroup_base<{
|
|
|
14
14
|
groupType: string;
|
|
15
15
|
constructor(ctx: Ctx, config: VersionGroupConfig.SameRange);
|
|
16
16
|
canAdd(_: Instance): boolean;
|
|
17
|
-
inspectAll(): Effect.Effect<
|
|
17
|
+
inspectAll(): Effect.Effect<Report.Version.Group[]>;
|
|
18
18
|
}
|
|
19
19
|
export {};
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const intersects_1 = __importDefault(require("semver/ranges/intersects"));
|
|
9
|
-
const uniq_1 = require("tightrope/array/uniq");
|
|
10
|
-
const report_1 = require("../report");
|
|
11
|
-
const specifier_1 = require("../specifier");
|
|
12
|
-
const group_by_1 = require("./lib/group-by");
|
|
13
|
-
class SameRangeVersionGroup extends effect_1.Data.TaggedClass('SameRange') {
|
|
1
|
+
import { Data, Effect, pipe } from 'effect';
|
|
2
|
+
import intersects from 'semver/ranges/intersects.js';
|
|
3
|
+
import { uniq } from 'tightrope/array/uniq.js';
|
|
4
|
+
import { Report } from '../report.js';
|
|
5
|
+
import { Specifier } from '../specifier/index.js';
|
|
6
|
+
import { groupBy } from './lib/group-by.js';
|
|
7
|
+
export class SameRangeVersionGroup extends Data.TaggedClass('SameRange') {
|
|
14
8
|
groupType = 'versionGroup';
|
|
15
9
|
constructor(ctx, config) {
|
|
16
10
|
super({
|
|
@@ -23,31 +17,31 @@ class SameRangeVersionGroup extends effect_1.Data.TaggedClass('SameRange') {
|
|
|
23
17
|
return true;
|
|
24
18
|
}
|
|
25
19
|
inspectAll() {
|
|
26
|
-
return
|
|
27
|
-
onFailure: () =>
|
|
20
|
+
return Effect.all(Object.entries(groupBy('name', this.instances)).flatMap(([name, instances]) => pipe(instances, Effect.partition((instance) => pipe(Effect.succeed(Specifier.create(instance, instance.rawSpecifier.raw)), Effect.flatMap((specifier) => pipe(specifier.getSemver(), Effect.matchEffect({
|
|
21
|
+
onFailure: () => Effect.fail(
|
|
28
22
|
// ✘ expected version is not semver
|
|
29
23
|
// ✘ is a mismatch we can't auto-fix
|
|
30
|
-
new
|
|
31
|
-
onSuccess: () =>
|
|
32
|
-
onFailure: () =>
|
|
24
|
+
new Report.UnsupportedMismatch(specifier.instance)),
|
|
25
|
+
onSuccess: () => pipe(specifier.instance.semverGroup.getFixed(specifier), Effect.matchEffect({
|
|
26
|
+
onFailure: () => Effect.fail(
|
|
33
27
|
// ✓ expected version is semver
|
|
34
28
|
// ✘ expected version is not fixable by its semver group
|
|
35
29
|
// ✘ is a mismatch we can't auto-fix
|
|
36
|
-
new
|
|
30
|
+
new Report.UnsupportedMismatch(specifier.instance)),
|
|
37
31
|
onSuccess: (valid) => specifier.instance.rawSpecifier.raw === valid.raw
|
|
38
|
-
?
|
|
32
|
+
? Effect.succeed(
|
|
39
33
|
// ✓ expected version is semver
|
|
40
34
|
// ✓ expected version matches its semver group
|
|
41
35
|
// ✓ current version matches expected
|
|
42
|
-
new
|
|
43
|
-
:
|
|
36
|
+
new Report.Valid(specifier))
|
|
37
|
+
: Effect.fail(
|
|
44
38
|
// ✓ expected version is semver
|
|
45
39
|
// ✓ expected version matches its semver group
|
|
46
40
|
// ✘ current version mismatches expected
|
|
47
41
|
// ✓ is a mismatch we can auto-fix
|
|
48
|
-
new
|
|
42
|
+
new Report.SemverRangeMismatch(valid)),
|
|
49
43
|
})),
|
|
50
|
-
}))))),
|
|
44
|
+
}))))), Effect.map(([allMismatches, allMatches]) => allMismatches.length === 0
|
|
51
45
|
? allMatches.map((thisMatch) => {
|
|
52
46
|
if (thisMatch.specifier.instance.strategy.name === 'local') {
|
|
53
47
|
// ✓ every instance is valid on its own
|
|
@@ -72,16 +66,15 @@ class SameRangeVersionGroup extends effect_1.Data.TaggedClass('SameRange') {
|
|
|
72
66
|
// ✓ current version matches expected
|
|
73
67
|
// ! is not the original local package
|
|
74
68
|
// ✘ current specifier does not match every other specifier
|
|
75
|
-
return new
|
|
69
|
+
return new Report.SameRangeMismatch(thisMatch.specifier.instance, uniq(mismatches.map((report) => String(report.specifier.instance.rawSpecifier.raw))));
|
|
76
70
|
})
|
|
77
71
|
: // ✘ not every instance is valid on its own
|
|
78
72
|
// ! report on their validity individually ! when all are valid
|
|
79
73
|
// they can progress to being checked for having compatible
|
|
80
74
|
// ranges
|
|
81
|
-
[...allMatches, ...allMismatches]),
|
|
75
|
+
[...allMatches, ...allMismatches]), Effect.map((reports) => ({ name, reports })))));
|
|
82
76
|
}
|
|
83
77
|
}
|
|
84
|
-
exports.SameRangeVersionGroup = SameRangeVersionGroup;
|
|
85
78
|
/** Find all ranges/versions which this semver version does not cover */
|
|
86
79
|
function getRangeMismatches(ctx, report, others) {
|
|
87
80
|
return others.filter((other) => !matchesRange(ctx, report, other));
|
|
@@ -89,7 +82,7 @@ function getRangeMismatches(ctx, report, others) {
|
|
|
89
82
|
/** Does semver version `a` match semver version `b`? */
|
|
90
83
|
function matchesRange(ctx, a, b) {
|
|
91
84
|
const loose = true;
|
|
92
|
-
return (
|
|
85
|
+
return intersects(unwrapSemver(ctx, a.specifier), unwrapSemver(ctx, b.specifier), loose);
|
|
93
86
|
}
|
|
94
87
|
/** Get the semver version synchronously from a specifier known to contain semver */
|
|
95
88
|
function unwrapSemver(ctx, specifier) {
|
|
@@ -97,7 +90,7 @@ function unwrapSemver(ctx, specifier) {
|
|
|
97
90
|
return specifier.raw;
|
|
98
91
|
}
|
|
99
92
|
if (specifier._tag === 'WorkspaceProtocol') {
|
|
100
|
-
return
|
|
93
|
+
return Effect.runSync(specifier.getSemverEquivalent(ctx));
|
|
101
94
|
}
|
|
102
|
-
return
|
|
95
|
+
return Effect.runSync(specifier.getSemver());
|
|
103
96
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { VersionGroupConfig } from '../config/types';
|
|
3
|
-
import type { Instance } from '../get-instances/instance';
|
|
4
|
-
import { Report } from '../report';
|
|
5
|
-
declare const SnappedToVersionGroup_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import type { VersionGroupConfig } from '../config/types.js';
|
|
3
|
+
import type { Instance } from '../get-instances/instance.js';
|
|
4
|
+
import { Report } from '../report.js';
|
|
5
|
+
declare const SnappedToVersionGroup_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> & {
|
|
6
6
|
readonly _tag: "SnappedTo";
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
export declare class SnappedToVersionGroup extends SnappedToVersionGroup_base<{
|
|
9
9
|
config: VersionGroupConfig.SnappedTo;
|
|
10
10
|
instances: Instance[];
|
|
@@ -12,6 +12,6 @@ export declare class SnappedToVersionGroup extends SnappedToVersionGroup_base<{
|
|
|
12
12
|
groupType: string;
|
|
13
13
|
constructor(config: VersionGroupConfig.SnappedTo);
|
|
14
14
|
canAdd(_: Instance): boolean;
|
|
15
|
-
inspectAll(): Effect.Effect<
|
|
15
|
+
inspectAll(): Effect.Effect<Report.Version.Group[]>;
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const specifier_1 = require("../specifier");
|
|
7
|
-
const group_by_1 = require("./lib/group-by");
|
|
8
|
-
class SnappedToVersionGroup extends effect_1.Data.TaggedClass('SnappedTo') {
|
|
1
|
+
import { Data, Effect, pipe } from 'effect';
|
|
2
|
+
import { Report } from '../report.js';
|
|
3
|
+
import { Specifier } from '../specifier/index.js';
|
|
4
|
+
import { groupBy } from './lib/group-by.js';
|
|
5
|
+
export class SnappedToVersionGroup extends Data.TaggedClass('SnappedTo') {
|
|
9
6
|
groupType = 'versionGroup';
|
|
10
7
|
constructor(config) {
|
|
11
8
|
super({
|
|
@@ -17,57 +14,56 @@ class SnappedToVersionGroup extends effect_1.Data.TaggedClass('SnappedTo') {
|
|
|
17
14
|
return true;
|
|
18
15
|
}
|
|
19
16
|
inspectAll() {
|
|
20
|
-
return
|
|
21
|
-
onFailure: () =>
|
|
17
|
+
return Effect.all(Object.entries(groupBy('name', this.instances)).flatMap(([name, instances]) => pipe(findSnappedToInstance(name, this.config.snapTo, instances), Effect.matchEffect({
|
|
18
|
+
onFailure: () => Effect.succeed(instances.map((instance) =>
|
|
22
19
|
// ✘ none of the snapTo packages contain this dependency
|
|
23
20
|
// ✘ is a user configuration error we can't auto-fix
|
|
24
|
-
new
|
|
25
|
-
onSuccess: (expected) =>
|
|
26
|
-
onFailure: () =>
|
|
21
|
+
new Report.MissingSnappedToMismatch(instance))),
|
|
22
|
+
onSuccess: (expected) => pipe(instances, Effect.forEach((instance) => pipe(Effect.Do, Effect.bind('specifier', () => Effect.succeed(Specifier.create(instance, instance.rawSpecifier.raw))), Effect.bind('expected', () => Effect.succeed(Specifier.create(instance, expected.rawSpecifier.raw))), Effect.flatMap(({ expected, specifier }) => pipe(expected.getSemver(), Effect.matchEffect({
|
|
23
|
+
onFailure: () => pipe(specifier.replaceWith(expected), specifier.instance.semverGroup.getFixed, Effect.match({
|
|
27
24
|
onFailure: () =>
|
|
28
25
|
// ✘ expected version is not semver
|
|
29
26
|
// ✘ semver group expects semver
|
|
30
27
|
// ✘ is a mismatch we can't auto-fix
|
|
31
|
-
new
|
|
28
|
+
new Report.UnsupportedMismatch(specifier.instance),
|
|
32
29
|
onSuccess: (valid) => specifier.instance.rawSpecifier.raw === valid.raw
|
|
33
30
|
? // ! expected version is not semver
|
|
34
31
|
// ✓ semver group is disabled/ignored
|
|
35
32
|
// ✓ current version matches expected
|
|
36
|
-
new
|
|
33
|
+
new Report.Valid(specifier)
|
|
37
34
|
: // ! expected version is not semver
|
|
38
35
|
// ✓ semver group is disabled/ignored
|
|
39
36
|
// ✘ current version mismatches expected
|
|
40
37
|
// ✓ is a mismatch we can auto-fix by replacing with the non-semver version
|
|
41
|
-
new
|
|
38
|
+
new Report.SnappedToMismatch(valid, expected.instance),
|
|
42
39
|
})),
|
|
43
|
-
onSuccess: () =>
|
|
40
|
+
onSuccess: () => pipe(specifier.replaceWith(expected), specifier.instance.semverGroup.getFixed, Effect.match({
|
|
44
41
|
onFailure: /* istanbul ignore next */ () =>
|
|
45
42
|
// ✓ expected version is semver
|
|
46
43
|
// ✘ expected version is not fixable by its semver group
|
|
47
44
|
// ✘ is a mismatch we can't auto-fix
|
|
48
45
|
// ✘ this should be impossible - we already proved the local version is exact semver
|
|
49
|
-
new
|
|
46
|
+
new Report.UnsupportedMismatch(specifier.instance),
|
|
50
47
|
onSuccess: (valid) => specifier.instance.rawSpecifier.raw === valid.raw
|
|
51
48
|
? // ✓ expected version is semver
|
|
52
49
|
// ✓ expected version matches its semver group
|
|
53
50
|
// ✓ current version matches expected
|
|
54
|
-
new
|
|
51
|
+
new Report.Valid(specifier)
|
|
55
52
|
: // ✓ expected version is semver
|
|
56
53
|
// ✓ expected version matches its semver group
|
|
57
54
|
// ✘ current version mismatches expected
|
|
58
55
|
// ✓ is a mismatch we can auto-fix
|
|
59
|
-
new
|
|
56
|
+
new Report.SnappedToMismatch(valid, expected.instance),
|
|
60
57
|
})),
|
|
61
58
|
})))))),
|
|
62
|
-
}),
|
|
59
|
+
}), Effect.map((reports) => ({ name, reports })))));
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
|
-
exports.SnappedToVersionGroup = SnappedToVersionGroup;
|
|
66
62
|
function findSnappedToInstance(name, snapTo, instances) {
|
|
67
63
|
for (const instance of instances) {
|
|
68
64
|
if (snapTo.includes(instance.pkgName) && instance.rawSpecifier.raw) {
|
|
69
|
-
return
|
|
65
|
+
return pipe(Effect.succeed(instance), Effect.tap(() => Effect.logDebug(`found snapped to version ${String(instance.rawSpecifier.raw)} for ${name} in <${instance.packageJsonFile.jsonFile.shortPath}>`)));
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
|
-
return
|
|
68
|
+
return pipe(Effect.fail('getSnappedTo found nothing'), Effect.tapError(() => Effect.logError(`failed to get snapped to version for ${name} using ${JSON.stringify(snapTo)}`)));
|
|
73
69
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { VersionGroupConfig } from '../config/types';
|
|
3
|
-
import type { Instance } from '../get-instances/instance';
|
|
4
|
-
import { Report } from '../report';
|
|
5
|
-
declare const StandardVersionGroup_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import type { VersionGroupConfig } from '../config/types.js';
|
|
3
|
+
import type { Instance } from '../get-instances/instance.js';
|
|
4
|
+
import { Report } from '../report.js';
|
|
5
|
+
declare const StandardVersionGroup_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> & {
|
|
6
6
|
readonly _tag: "Standard";
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
export declare class StandardVersionGroup extends StandardVersionGroup_base<{
|
|
9
9
|
config: VersionGroupConfig.Standard;
|
|
10
10
|
instances: Instance[];
|
|
@@ -13,6 +13,6 @@ export declare class StandardVersionGroup extends StandardVersionGroup_base<{
|
|
|
13
13
|
groupType: string;
|
|
14
14
|
constructor(isCatchAll: boolean, config: VersionGroupConfig.Standard);
|
|
15
15
|
canAdd(_: Instance): boolean;
|
|
16
|
-
inspectAll(): Effect.Effect<
|
|
16
|
+
inspectAll(): Effect.Effect<Report.Version.Group[]>;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const get_preferred_version_1 = require("./lib/get-preferred-version");
|
|
9
|
-
const group_by_1 = require("./lib/group-by");
|
|
10
|
-
class StandardVersionGroup extends effect_1.Data.TaggedClass('Standard') {
|
|
1
|
+
import { Data, Effect, pipe } from 'effect';
|
|
2
|
+
import { uniq } from 'tightrope/array/uniq.js';
|
|
3
|
+
import { Report } from '../report.js';
|
|
4
|
+
import { Specifier } from '../specifier/index.js';
|
|
5
|
+
import { getPreferredVersion } from './lib/get-preferred-version.js';
|
|
6
|
+
import { groupBy } from './lib/group-by.js';
|
|
7
|
+
export class StandardVersionGroup extends Data.TaggedClass('Standard') {
|
|
11
8
|
groupType = 'versionGroup';
|
|
12
9
|
constructor(isCatchAll, config) {
|
|
13
10
|
super({
|
|
@@ -20,93 +17,92 @@ class StandardVersionGroup extends effect_1.Data.TaggedClass('Standard') {
|
|
|
20
17
|
return true;
|
|
21
18
|
}
|
|
22
19
|
inspectAll() {
|
|
23
|
-
return
|
|
20
|
+
return Effect.all(Object.entries(groupBy('name', this.instances)).flatMap(([name, instances]) => {
|
|
24
21
|
const localInstance = getLocalInstance(instances);
|
|
25
22
|
if (localInstance) {
|
|
26
23
|
const localVersion = localInstance?.rawSpecifier.raw;
|
|
27
|
-
return
|
|
24
|
+
return pipe(Effect.succeed(Specifier.create(localInstance, localVersion)), Effect.flatMap((local) => Effect.all(local._tag !== 'Exact' && instances.length > 1
|
|
28
25
|
? instances.map((instance) =>
|
|
29
26
|
// ! dependency is a package developed in this repo
|
|
30
27
|
// ✘ local package has an invalid .version property
|
|
31
28
|
// ✘ is a mismatch we can't auto-fix
|
|
32
|
-
|
|
29
|
+
Effect.succeed(new Report.MissingLocalVersion(instance, localInstance)))
|
|
33
30
|
: instances.flatMap((instance) =>
|
|
34
31
|
// instances.flatMap((instance) =>
|
|
35
|
-
|
|
32
|
+
pipe(Effect.succeed(Specifier.create(instance, instance.rawSpecifier.raw)), Effect.flatMap((specifier) => specifier.instance === localInstance
|
|
36
33
|
? // ✓ this is the local package which the others should match
|
|
37
34
|
// ! its version must always remain as exact semver
|
|
38
35
|
// ! other instances need to be adjusted for their semver groups
|
|
39
|
-
|
|
40
|
-
:
|
|
36
|
+
Effect.succeed(new Report.Valid(specifier))
|
|
37
|
+
: pipe(specifier.replaceWith(local), specifier.instance.semverGroup.getFixed, Effect.match({
|
|
41
38
|
onFailure: /* istanbul ignore next */ () =>
|
|
42
39
|
// ! is not the local package instance
|
|
43
40
|
// ✘ local version is not fixable by this semver group
|
|
44
41
|
// ✘ is a mismatch we can't auto-fix
|
|
45
42
|
// ✘ this should be impossible - we already proved the local version is exact semver
|
|
46
|
-
new
|
|
43
|
+
new Report.UnsupportedMismatch(specifier.instance),
|
|
47
44
|
onSuccess: (valid) => specifier.instance.rawSpecifier.raw === valid.raw
|
|
48
45
|
? // ! is not the local package instance
|
|
49
46
|
// ✓ local version matches this semver group
|
|
50
47
|
// ✓ current version matches local
|
|
51
|
-
new
|
|
48
|
+
new Report.Valid(specifier)
|
|
52
49
|
: localVersion === 'PACKAGE_JSON_HAS_NO_VERSION'
|
|
53
50
|
? // ! is not the local package instance
|
|
54
51
|
// ✘ local package has a version defined
|
|
55
52
|
// ✓ local version matches this semver group
|
|
56
53
|
// ✘ current version mismatches local
|
|
57
|
-
new
|
|
54
|
+
new Report.MissingLocalVersion(specifier.instance, localInstance)
|
|
58
55
|
: // ! is not the local package instance
|
|
59
56
|
// ✓ local package has a version defined
|
|
60
57
|
// ✓ local version matches this semver group
|
|
61
58
|
// ✘ current version mismatches local
|
|
62
|
-
new
|
|
63
|
-
}))))))),
|
|
59
|
+
new Report.LocalPackageMismatch(valid, localInstance),
|
|
60
|
+
}))))))), Effect.map((reports) => ({ name, reports })));
|
|
64
61
|
}
|
|
65
62
|
const PreferredMismatch = this.config.preferVersion === 'lowestSemver'
|
|
66
|
-
?
|
|
67
|
-
:
|
|
68
|
-
return
|
|
69
|
-
onFailure: () =>
|
|
63
|
+
? Report.LowestSemverMismatch
|
|
64
|
+
: Report.HighestSemverMismatch;
|
|
65
|
+
return pipe(Effect.succeed(instances.map((instance) => Specifier.create(instance, instance.rawSpecifier.raw))), Effect.flatMap((specifiers) => pipe(getPreferredVersion(this.config.preferVersion, specifiers), Effect.matchEffect({
|
|
66
|
+
onFailure: () => Effect.succeed(uniq(specifiers.map((specifier) => specifier.instance.rawSpecifier.raw))
|
|
70
67
|
.length === 1
|
|
71
68
|
? specifiers.map((specifier) =>
|
|
72
69
|
// ✘ not every version is semver
|
|
73
70
|
// ✓ every version is identical
|
|
74
71
|
// ✓ is a match
|
|
75
|
-
new
|
|
72
|
+
new Report.Valid(specifier))
|
|
76
73
|
: instances.map((instance) =>
|
|
77
74
|
// ✘ not every version is semver
|
|
78
75
|
// ✘ some versions are not identical
|
|
79
76
|
// ✘ is a mismatch we can't auto-fix
|
|
80
|
-
new
|
|
81
|
-
onSuccess: (expectedVersion) =>
|
|
77
|
+
new Report.UnsupportedMismatch(instance))),
|
|
78
|
+
onSuccess: (expectedVersion) => pipe(specifiers, Effect.forEach((current) => pipe(current.replaceWith(expectedVersion), current.instance.semverGroup.getFixed, Effect.match({
|
|
82
79
|
onFailure: /* istanbul ignore next */ () =>
|
|
83
80
|
// ✓ every version is semver
|
|
84
81
|
// ✘ expected version is not fixable by its semver group
|
|
85
82
|
// ✘ is a mismatch we can't auto-fix
|
|
86
83
|
// ✘ this should be impossible - any valid semver is fixable by a semver group
|
|
87
|
-
new
|
|
84
|
+
new Report.UnsupportedMismatch(current.instance),
|
|
88
85
|
onSuccess: (expectedRange) => current.instance.rawSpecifier.raw === expectedRange.raw
|
|
89
86
|
? // ✓ every version is semver
|
|
90
87
|
// ✓ current version matches expected semver
|
|
91
88
|
// ✓ current version matches expected version
|
|
92
|
-
new
|
|
89
|
+
new Report.Valid(current)
|
|
93
90
|
: current.instance.rawSpecifier.raw === expectedVersion.raw
|
|
94
91
|
? // ✓ every version is semver
|
|
95
92
|
// ✓ current version matches expected version
|
|
96
93
|
// ✘ current version does not match expected semver
|
|
97
94
|
// ✓ is a mismatch we can auto-fix
|
|
98
|
-
new
|
|
95
|
+
new Report.SemverRangeMismatch(expectedRange)
|
|
99
96
|
: // ✓ every version is semver
|
|
100
97
|
// ✘ current version does not match expected version
|
|
101
98
|
// ✘ expected version does not match expected semver
|
|
102
99
|
// ✓ is a mismatch we can auto-fix
|
|
103
100
|
new PreferredMismatch(expectedRange),
|
|
104
101
|
})))),
|
|
105
|
-
}))),
|
|
102
|
+
}))), Effect.map((reports) => ({ name, reports })));
|
|
106
103
|
}));
|
|
107
104
|
}
|
|
108
105
|
}
|
|
109
|
-
exports.StandardVersionGroup = StandardVersionGroup;
|
|
110
106
|
/**
|
|
111
107
|
* If this dependency is developed in this monorepo, get the instance which
|
|
112
108
|
* represents the canonical .version property of its package.json file.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "syncpack",
|
|
3
3
|
"description": "Consistent dependency versions in large JavaScript Monorepos",
|
|
4
|
-
"version": "12.
|
|
4
|
+
"version": "12.3.1",
|
|
5
5
|
"author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",
|
|
6
6
|
"bin": {
|
|
7
7
|
"syncpack": "dist/bin.js",
|
|
@@ -33,51 +33,53 @@
|
|
|
33
33
|
"Tom Fletcher (https://github.com/tom-fletcher)"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@effect/schema": "0.
|
|
37
|
-
"chalk": "
|
|
38
|
-
"
|
|
36
|
+
"@effect/schema": "0.66.5",
|
|
37
|
+
"chalk": "5.3.0",
|
|
38
|
+
"chalk-template": "1.1.0",
|
|
39
|
+
"commander": "12.0.0",
|
|
39
40
|
"cosmiconfig": "9.0.0",
|
|
40
|
-
"effect": "
|
|
41
|
+
"effect": "3.0.3",
|
|
41
42
|
"enquirer": "2.4.1",
|
|
42
|
-
"fast-check": "3.
|
|
43
|
-
"globby": "
|
|
44
|
-
"minimatch": "9.0.
|
|
45
|
-
"npm-package-arg": "11.0.
|
|
46
|
-
"ora": "
|
|
43
|
+
"fast-check": "3.17.2",
|
|
44
|
+
"globby": "14.0.1",
|
|
45
|
+
"minimatch": "9.0.4",
|
|
46
|
+
"npm-package-arg": "11.0.2",
|
|
47
|
+
"ora": "8.0.1",
|
|
47
48
|
"prompts": "2.4.2",
|
|
48
49
|
"read-yaml-file": "2.1.0",
|
|
49
|
-
"semver": "7.
|
|
50
|
-
"tightrope": "0.
|
|
50
|
+
"semver": "7.6.0",
|
|
51
|
+
"tightrope": "0.2.0",
|
|
51
52
|
"ts-toolbelt": "9.6.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@release-it/conventional-changelog": "8.0.1",
|
|
55
|
-
"@tsconfig/node18": "18.2.
|
|
56
|
-
"@types/node": "20.
|
|
56
|
+
"@tsconfig/node18": "18.2.4",
|
|
57
|
+
"@types/node": "20.12.7",
|
|
57
58
|
"@types/npm-package-arg": "6.1.4",
|
|
58
59
|
"@types/prompts": "2.4.9",
|
|
59
|
-
"@types/semver": "7.5.
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
61
|
-
"@typescript-eslint/parser": "6.
|
|
62
|
-
"@vitest/coverage-v8": "1.
|
|
60
|
+
"@types/semver": "7.5.8",
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "6.19.0",
|
|
62
|
+
"@typescript-eslint/parser": "6.19.0",
|
|
63
|
+
"@vitest/coverage-v8": "1.5.0",
|
|
63
64
|
"auto-changelog": "2.4.0",
|
|
64
65
|
"eslint": "8.56.0",
|
|
65
66
|
"eslint-plugin-import": "2.29.1",
|
|
66
|
-
"memfs": "4.
|
|
67
|
-
"prettier": "3.
|
|
68
|
-
"prettier-plugin-astro": "0.
|
|
67
|
+
"memfs": "4.8.2",
|
|
68
|
+
"prettier": "3.2.5",
|
|
69
|
+
"prettier-plugin-astro": "0.13.0",
|
|
69
70
|
"quill-delta": "5.1.0",
|
|
70
|
-
"release-it": "17.0
|
|
71
|
+
"release-it": "17.2.0",
|
|
71
72
|
"rxjs": "7.8.1",
|
|
72
73
|
"ts-node": "10.9.2",
|
|
73
74
|
"tslib": "2.6.2",
|
|
74
|
-
"typescript": "5.
|
|
75
|
-
"typescript-json-schema": "0.
|
|
76
|
-
"vitest": "1.
|
|
75
|
+
"typescript": "5.4.5",
|
|
76
|
+
"typescript-json-schema": "0.63.0",
|
|
77
|
+
"vitest": "1.5.0"
|
|
77
78
|
},
|
|
78
79
|
"engines": {
|
|
79
80
|
"node": ">=16"
|
|
80
81
|
},
|
|
82
|
+
"exports": "./dist/index.js",
|
|
81
83
|
"files": [
|
|
82
84
|
"dist"
|
|
83
85
|
],
|
|
@@ -103,20 +105,10 @@
|
|
|
103
105
|
"yarn"
|
|
104
106
|
],
|
|
105
107
|
"license": "MIT",
|
|
106
|
-
"main": "dist/index.js",
|
|
107
|
-
"pnpm": {
|
|
108
|
-
"overrides": {
|
|
109
|
-
"chalk": "4.1.2",
|
|
110
|
-
"effect": "2.0.0-next.62",
|
|
111
|
-
"string-width": "<5.0.0",
|
|
112
|
-
"strip-ansi": "<7.0.0",
|
|
113
|
-
"wrap-ansi": "<8.0.0"
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
108
|
"repository": "JamieMason/syncpack",
|
|
117
109
|
"scripts": {
|
|
118
110
|
"build": "pnpm run clean && pnpm run build:source && pnpm run build:json-schema",
|
|
119
|
-
"build:json-schema": "typescript-json-schema --esModuleInterop --noExtraProps src/index.ts RcFile --out dist/schema.json",
|
|
111
|
+
"build:json-schema": "typescript-json-schema --esModuleInterop --noExtraProps --ignoreErrors src/index.ts RcFile --out dist/schema.json",
|
|
120
112
|
"build:source": "tsc --project tsconfig.build.json",
|
|
121
113
|
"clean": "rm -rf ./dist",
|
|
122
114
|
"format": "pnpm run format:lint && pnpm run format:source",
|
|
@@ -128,5 +120,6 @@
|
|
|
128
120
|
"prepack": "pnpm run build",
|
|
129
121
|
"release": "release-it",
|
|
130
122
|
"test": "vitest run --config vitest.config.ts"
|
|
131
|
-
}
|
|
123
|
+
},
|
|
124
|
+
"type": "module"
|
|
132
125
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { O } from 'ts-toolbelt';
|
|
3
|
-
import type { Io } from '.';
|
|
4
|
-
import type { RcConfig } from '../config/types';
|
|
5
|
-
type UnverifiedRcConfig = O.Partial<RcConfig, 'deep'>;
|
|
6
|
-
export declare function readConfigFileSync(io: Io, configPath?: string): Effect.Effect<never, never, UnverifiedRcConfig>;
|
|
7
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readConfigFileSync = void 0;
|
|
4
|
-
const effect_1 = require("effect");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
|
|
7
|
-
const read_json_file_sync_1 = require("./read-json-file-sync");
|
|
8
|
-
const getOptionOfNonEmptyObject = effect_1.Option.liftPredicate((is_non_empty_object_1.isNonEmptyObject));
|
|
9
|
-
function readConfigFileSync(io, configPath) {
|
|
10
|
-
return (0, effect_1.pipe)(effect_1.Effect.try(() => io.cosmiconfig.cosmiconfig('syncpack')), effect_1.Effect.flatMap((client) => effect_1.Effect.tryPromise(() => (configPath ? client.load(configPath) : client.search()))), effect_1.Effect.flatMap((result) => result !== null ? getValueFromCosmiconfig(result) : findConfigInPackageJson(io)), effect_1.Effect.tap((config) => effect_1.Effect.logDebug(`config file found: ${JSON.stringify(config)}`)), effect_1.Effect.tapError(() => effect_1.Effect.logDebug('no config file found, will use defaults')), effect_1.Effect.catchAll(() => effect_1.Effect.succeed({})));
|
|
11
|
-
}
|
|
12
|
-
exports.readConfigFileSync = readConfigFileSync;
|
|
13
|
-
/**
|
|
14
|
-
* Look for a .config.syncpack property in the root package.json.
|
|
15
|
-
* @see https://github.com/JamieMason/syncpack/issues/86
|
|
16
|
-
*/
|
|
17
|
-
function findConfigInPackageJson(io) {
|
|
18
|
-
return (0, effect_1.pipe)(effect_1.Effect.Do, effect_1.Effect.bind('rcPath', () => effect_1.Effect.succeed((0, path_1.join)(io.process.cwd(), 'package.json'))), effect_1.Effect.bind('packageJson', ({ rcPath }) => (0, read_json_file_sync_1.readJsonFileSync)(io, rcPath)), effect_1.Effect.bind('config', ({ packageJson }) => effect_1.Effect.try(() => packageJson.contents?.config?.syncpack)), effect_1.Effect.flatMap(({ config }) => getOptionOfNonEmptyObject(config)), effect_1.Effect.tapBoth({
|
|
19
|
-
onSuccess: () => effect_1.Effect.logDebug('config found in <package.json>.config.syncpack'),
|
|
20
|
-
onFailure: () => effect_1.Effect.logDebug('config not found in <package.json>.config.syncpack'),
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
/** Extract the value from a successful search by cosmiconfig */
|
|
24
|
-
function getValueFromCosmiconfig(result) {
|
|
25
|
-
return (0, effect_1.pipe)(effect_1.Effect.succeed(result), effect_1.Effect.tap((result) => effect_1.Effect.logDebug(`cosmiconfig found ${result.filepath}`)), effect_1.Effect.flatMap((result) => getOptionOfNonEmptyObject(result.config)));
|
|
26
|
-
}
|