syncpack 9.8.6 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -19
- package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +2 -2
- package/dist/bin-fix-mismatches/fix-mismatches-cli.js +3 -1
- package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -2
- package/dist/bin-fix-mismatches/fix-mismatches.js +42 -24
- package/dist/bin-format/format-cli.d.ts +2 -2
- package/dist/bin-format/format-cli.js +2 -1
- package/dist/bin-format/format.d.ts +2 -2
- package/dist/bin-format/format.js +4 -1
- package/dist/bin-lint/index.d.ts +2 -0
- package/dist/bin-lint/index.js +39 -0
- package/dist/bin-lint/lint-cli.d.ts +3 -0
- package/dist/bin-lint/lint-cli.js +11 -0
- package/dist/bin-lint/lint.d.ts +2 -0
- package/dist/bin-lint/lint.js +116 -0
- package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.d.ts +2 -2
- package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +2 -1
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -2
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +29 -25
- package/dist/bin-list/list-cli.d.ts +2 -2
- package/dist/bin-list/list-cli.js +2 -1
- package/dist/bin-list/list.d.ts +2 -2
- package/dist/bin-list/list.js +58 -54
- package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +2 -2
- package/dist/bin-list-mismatches/list-mismatches-cli.js +2 -1
- package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -2
- package/dist/bin-list-mismatches/list-mismatches.js +72 -106
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +2 -2
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +2 -1
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -2
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +17 -3
- package/dist/bin.js +3 -0
- package/dist/config/get-custom-types.d.ts +9 -0
- package/dist/config/get-custom-types.js +49 -0
- package/dist/config/get-enabled-types.d.ts +3 -0
- package/dist/config/get-enabled-types.js +48 -0
- package/dist/config/get-filter.d.ts +2 -0
- package/dist/config/get-filter.js +13 -0
- package/dist/config/get-indent.d.ts +2 -0
- package/dist/config/get-indent.js +12 -0
- package/dist/config/get-semver-range.d.ts +3 -0
- package/dist/config/get-semver-range.js +12 -0
- package/dist/config/get-sort-az.d.ts +2 -0
- package/dist/config/get-sort-az.js +18 -0
- package/dist/config/get-sort-first.d.ts +2 -0
- package/dist/config/get-sort-first.js +10 -0
- package/dist/config/get-source.d.ts +2 -0
- package/dist/config/get-source.js +13 -0
- package/dist/config/types.d.ts +106 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/get-context/index.d.ts +8 -16
- package/dist/get-context/index.js +7 -33
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.d.ts +3 -3
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.js +4 -4
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-lerna-patterns.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-lerna-patterns.js +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-pnpm-patterns.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-pnpm-patterns.js +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-yarn-patterns.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-yarn-patterns.js +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.d.ts +3 -3
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.js +4 -3
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-json-safe.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-yaml-safe.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/index.d.ts +3 -3
- package/dist/{get-context/get-package-json-files → get-package-json-files}/index.js +1 -1
- package/dist/{get-context/get-package-json-files/package-json-file → get-package-json-files}/instance.d.ts +6 -8
- package/dist/get-package-json-files/instance.js +23 -0
- package/dist/{get-context/get-package-json-files/package-json-file/index.d.ts → get-package-json-files/package-json-file.d.ts} +7 -9
- package/dist/get-package-json-files/package-json-file.js +45 -0
- package/dist/get-semver-groups/catch-all.d.ts +4 -0
- package/dist/get-semver-groups/catch-all.js +11 -0
- package/dist/get-semver-groups/filtered-out.d.ts +13 -0
- package/dist/get-semver-groups/filtered-out.js +29 -0
- package/dist/get-semver-groups/ignored.d.ts +11 -0
- package/dist/get-semver-groups/ignored.js +22 -0
- package/dist/get-semver-groups/index.d.ts +32 -0
- package/dist/get-semver-groups/index.js +90 -0
- package/dist/get-semver-groups/with-range.d.ts +11 -0
- package/dist/get-semver-groups/with-range.js +55 -0
- package/dist/get-version-groups/banned.d.ts +11 -0
- package/dist/get-version-groups/banned.js +24 -0
- package/dist/get-version-groups/catch-all.d.ts +4 -0
- package/dist/get-version-groups/catch-all.js +11 -0
- package/dist/get-version-groups/filtered-out.d.ts +13 -0
- package/dist/get-version-groups/filtered-out.js +31 -0
- package/dist/get-version-groups/ignored.d.ts +11 -0
- package/dist/get-version-groups/ignored.js +24 -0
- package/dist/get-version-groups/index.d.ts +57 -0
- package/dist/get-version-groups/index.js +119 -0
- package/dist/get-version-groups/lib/delete.d.ts +2 -0
- package/dist/get-version-groups/lib/delete.js +4 -0
- package/dist/get-version-groups/lib/get-highest-version.js +13 -0
- package/dist/get-version-groups/lib/get-lowest-version.js +13 -0
- package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.js +3 -2
- package/dist/get-version-groups/lib/get-unique-versions.d.ts +2 -0
- package/dist/get-version-groups/lib/get-unique-versions.js +8 -0
- package/dist/get-version-groups/lib/group-by.d.ts +1 -0
- package/dist/get-version-groups/lib/group-by.js +11 -0
- package/dist/get-version-groups/lib/sort.d.ts +1 -0
- package/dist/get-version-groups/lib/sort.js +44 -0
- package/dist/get-version-groups/pinned.d.ts +11 -0
- package/dist/get-version-groups/pinned.js +43 -0
- package/dist/get-version-groups/snapped-to.d.ts +11 -0
- package/dist/get-version-groups/snapped-to.js +52 -0
- package/dist/get-version-groups/standard.d.ts +11 -0
- package/dist/get-version-groups/standard.js +95 -0
- package/dist/index.d.ts +2 -0
- package/dist/{get-context → lib}/$R.d.ts +2 -2
- package/dist/{get-context → lib}/$R.js +3 -4
- package/dist/lib/disk.d.ts +3 -2
- package/dist/lib/exit-if-invalid.d.ts +2 -2
- package/dist/lib/is-semver.d.ts +5 -3
- package/dist/lib/is-semver.js +17 -3
- package/dist/lib/log.d.ts +4 -8
- package/dist/lib/log.js +3 -29
- package/dist/lib/set-semver-range.d.ts +2 -2
- package/dist/lib/write-if-changed.d.ts +2 -2
- package/dist/lib/write-if-changed.js +6 -25
- package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.d.ts +1 -1
- package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.js +1 -2
- package/dist/strategy/name-and-version-props.d.ts +12 -0
- package/dist/strategy/name-and-version-props.js +50 -0
- package/dist/strategy/named-version-string.d.ts +11 -0
- package/dist/{get-context/get-config/path-strategy/name-and-version-string.js → strategy/named-version-string.js} +26 -22
- package/dist/strategy/unnamed-version-string.d.ts +11 -0
- package/dist/strategy/unnamed-version-string.js +48 -0
- package/dist/strategy/versions-by-name.d.ts +11 -0
- package/dist/strategy/versions-by-name.js +29 -0
- package/package.json +8 -4
- package/dist/get-context/get-config/get-core-types.d.ts +0 -36
- package/dist/get-context/get-config/get-core-types.js +0 -38
- package/dist/get-context/get-config/get-custom-types.d.ts +0 -4
- package/dist/get-context/get-config/get-custom-types.js +0 -16
- package/dist/get-context/get-config/get-enabled-types.d.ts +0 -4
- package/dist/get-context/get-config/get-enabled-types.js +0 -17
- package/dist/get-context/get-config/index.d.ts +0 -8
- package/dist/get-context/get-config/index.js +0 -98
- package/dist/get-context/get-config/path-strategy/index.d.ts +0 -8
- package/dist/get-context/get-config/path-strategy/index.js +0 -18
- package/dist/get-context/get-config/path-strategy/name-and-version-props.d.ts +0 -2
- package/dist/get-context/get-config/path-strategy/name-and-version-props.js +0 -44
- package/dist/get-context/get-config/path-strategy/name-and-version-string.d.ts +0 -2
- package/dist/get-context/get-config/path-strategy/types.d.ts +0 -14
- package/dist/get-context/get-config/path-strategy/version-string.d.ts +0 -2
- package/dist/get-context/get-config/path-strategy/version-string.js +0 -49
- package/dist/get-context/get-config/path-strategy/versions-by-name.d.ts +0 -2
- package/dist/get-context/get-config/path-strategy/versions-by-name.js +0 -21
- package/dist/get-context/get-config/schema/base-group.d.ts +0 -7
- package/dist/get-context/get-config/schema/base-group.js +0 -10
- package/dist/get-context/get-config/schema/index.d.ts +0 -1540
- package/dist/get-context/get-config/schema/index.js +0 -81
- package/dist/get-context/get-config/schema/lib/non-empty-string.d.ts +0 -2
- package/dist/get-context/get-config/schema/lib/non-empty-string.js +0 -5
- package/dist/get-context/get-config/schema/paths.d.ts +0 -89
- package/dist/get-context/get-config/schema/paths.js +0 -33
- package/dist/get-context/get-config/schema/semver-group.d.ts +0 -119
- package/dist/get-context/get-config/schema/semver-group.js +0 -43
- package/dist/get-context/get-config/schema/semver-range.d.ts +0 -2
- package/dist/get-context/get-config/schema/semver-range.js +0 -16
- package/dist/get-context/get-config/schema/version-group.d.ts +0 -230
- package/dist/get-context/get-config/schema/version-group.js +0 -36
- package/dist/get-context/get-groups/base-group.d.ts +0 -22
- package/dist/get-context/get-groups/base-group.js +0 -39
- package/dist/get-context/get-groups/index.d.ts +0 -11
- package/dist/get-context/get-groups/index.js +0 -53
- package/dist/get-context/get-groups/semver-group.d.ts +0 -15
- package/dist/get-context/get-groups/semver-group.js +0 -46
- package/dist/get-context/get-groups/version-group/index.d.ts +0 -15
- package/dist/get-context/get-groups/version-group/index.js +0 -40
- package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +0 -42
- package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.js +0 -44
- package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +0 -34
- package/dist/get-context/get-groups/version-group/instance-group/index.js +0 -103
- package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +0 -4
- package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +0 -38
- package/dist/get-context/get-package-json-files/package-json-file/index.js +0 -65
- package/dist/get-context/get-package-json-files/package-json-file/instance.js +0 -46
- package/dist/lib/error.d.ts +0 -12
- package/dist/lib/error.js +0 -25
- package/dist/types.d.ts +0 -90
- /package/dist/{get-context/get-config/path-strategy → config}/types.js +0 -0
- /package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-json-safe.js +0 -0
- /package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-yaml-safe.js +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.d.ts +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.js +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups/lib}/get-highest-version.d.ts +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups/lib}/get-lowest-version.d.ts +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.d.ts +0 -0
- /package/dist/{types.js → index.js} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PinnedVersionGroup = void 0;
|
|
4
|
+
const group_by_1 = require("./lib/group-by");
|
|
5
|
+
class PinnedVersionGroup {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this._tag = 'Pinned';
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.instances = [];
|
|
10
|
+
}
|
|
11
|
+
canAdd(_) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
inspect() {
|
|
15
|
+
const report = [];
|
|
16
|
+
const instancesByName = (0, group_by_1.groupBy)('name', this.instances);
|
|
17
|
+
const expectedVersion = this.config.pinVersion;
|
|
18
|
+
Object.entries(instancesByName).forEach(([name, instances]) => {
|
|
19
|
+
if (hasMismatch(expectedVersion, instances)) {
|
|
20
|
+
report.push({
|
|
21
|
+
expectedVersion,
|
|
22
|
+
instances,
|
|
23
|
+
isValid: false,
|
|
24
|
+
name,
|
|
25
|
+
status: 'PINNED_MISMATCH',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
report.push({
|
|
30
|
+
instances,
|
|
31
|
+
isValid: true,
|
|
32
|
+
name,
|
|
33
|
+
status: 'VALID',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return report;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.PinnedVersionGroup = PinnedVersionGroup;
|
|
41
|
+
function hasMismatch(pinVersion, instances) {
|
|
42
|
+
return instances.some((instance) => instance.version !== pinVersion);
|
|
43
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { VersionGroupReport } from '.';
|
|
2
|
+
import type { VersionGroupConfig } from '../config/types';
|
|
3
|
+
import type { Instance } from '../get-package-json-files/instance';
|
|
4
|
+
export declare class SnappedToVersionGroup {
|
|
5
|
+
_tag: string;
|
|
6
|
+
config: VersionGroupConfig.SnappedTo;
|
|
7
|
+
instances: Instance[];
|
|
8
|
+
constructor(config: VersionGroupConfig.SnappedTo);
|
|
9
|
+
canAdd(_: Instance): boolean;
|
|
10
|
+
inspect(): VersionGroupReport[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnappedToVersionGroup = void 0;
|
|
4
|
+
const group_by_1 = require("./lib/group-by");
|
|
5
|
+
class SnappedToVersionGroup {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this._tag = 'SnappedTo';
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.instances = [];
|
|
10
|
+
}
|
|
11
|
+
canAdd(_) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
inspect() {
|
|
15
|
+
const report = [];
|
|
16
|
+
const instancesByName = (0, group_by_1.groupBy)('name', this.instances);
|
|
17
|
+
Object.entries(instancesByName).forEach(([name, instances]) => {
|
|
18
|
+
const snapTo = this.config.snapTo;
|
|
19
|
+
const expectedVersion = getExpectedVersion(snapTo, instances);
|
|
20
|
+
if (hasMismatch(expectedVersion, instances)) {
|
|
21
|
+
report.push({
|
|
22
|
+
expectedVersion,
|
|
23
|
+
instances,
|
|
24
|
+
isValid: false,
|
|
25
|
+
name,
|
|
26
|
+
status: 'SNAPPED_TO_MISMATCH',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
report.push({
|
|
31
|
+
instances,
|
|
32
|
+
isValid: true,
|
|
33
|
+
name,
|
|
34
|
+
status: 'VALID',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return report;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.SnappedToVersionGroup = SnappedToVersionGroup;
|
|
42
|
+
function getExpectedVersion(snapTo, instances) {
|
|
43
|
+
const expectedVersion = instances
|
|
44
|
+
.filter((i) => snapTo.includes(i.pkgName))
|
|
45
|
+
.find((i) => i.version)?.version;
|
|
46
|
+
if (expectedVersion)
|
|
47
|
+
return expectedVersion;
|
|
48
|
+
throw new Error('versionGroup.snapTo does not match any package versions');
|
|
49
|
+
}
|
|
50
|
+
function hasMismatch(expectedVersion, instances) {
|
|
51
|
+
return instances.some((instance) => instance.version !== expectedVersion);
|
|
52
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { VersionGroupReport } from '.';
|
|
2
|
+
import type { VersionGroupConfig } from '../config/types';
|
|
3
|
+
import type { Instance } from '../get-package-json-files/instance';
|
|
4
|
+
export declare class StandardVersionGroup {
|
|
5
|
+
_tag: string;
|
|
6
|
+
config: VersionGroupConfig.Standard;
|
|
7
|
+
instances: Instance[];
|
|
8
|
+
constructor(config: VersionGroupConfig.Standard);
|
|
9
|
+
canAdd(_: Instance): boolean;
|
|
10
|
+
inspect(): VersionGroupReport[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StandardVersionGroup = void 0;
|
|
4
|
+
const unwrap_1 = require("tightrope/result/unwrap");
|
|
5
|
+
const is_semver_1 = require("../lib/is-semver");
|
|
6
|
+
const get_highest_version_1 = require("./lib/get-highest-version");
|
|
7
|
+
const get_lowest_version_1 = require("./lib/get-lowest-version");
|
|
8
|
+
const get_unique_versions_1 = require("./lib/get-unique-versions");
|
|
9
|
+
const group_by_1 = require("./lib/group-by");
|
|
10
|
+
class StandardVersionGroup {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this._tag = 'Standard';
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.instances = [];
|
|
15
|
+
}
|
|
16
|
+
canAdd(_) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
inspect() {
|
|
20
|
+
const report = [];
|
|
21
|
+
const instancesByName = (0, group_by_1.groupBy)('name', this.instances);
|
|
22
|
+
Object.entries(instancesByName).forEach(([name, instances]) => {
|
|
23
|
+
if (!hasMismatch(instances)) {
|
|
24
|
+
return report.push({
|
|
25
|
+
status: 'VALID',
|
|
26
|
+
instances,
|
|
27
|
+
isValid: true,
|
|
28
|
+
name,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const wsInstance = getWorkspaceInstance(instances);
|
|
32
|
+
const wsFile = wsInstance?.packageJsonFile;
|
|
33
|
+
const wsVersion = wsFile?.contents?.version;
|
|
34
|
+
const isWorkspacePackage = wsInstance && wsVersion;
|
|
35
|
+
if (isWorkspacePackage) {
|
|
36
|
+
const nonWsInstances = getNonWorkspaceInstances(instances);
|
|
37
|
+
if (!hasMismatch(nonWsInstances)) {
|
|
38
|
+
return report.push({
|
|
39
|
+
status: 'VALID',
|
|
40
|
+
instances,
|
|
41
|
+
isValid: true,
|
|
42
|
+
name,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return report.push({
|
|
46
|
+
status: 'WORKSPACE_MISMATCH',
|
|
47
|
+
expectedVersion: wsVersion,
|
|
48
|
+
instances,
|
|
49
|
+
isValid: false,
|
|
50
|
+
name,
|
|
51
|
+
workspaceInstance: wsInstance,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (hasUnsupported(instances)) {
|
|
55
|
+
return report.push({
|
|
56
|
+
status: 'UNSUPPORTED_MISMATCH',
|
|
57
|
+
instances,
|
|
58
|
+
isValid: false,
|
|
59
|
+
name,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const preferVersion = this.config.preferVersion;
|
|
63
|
+
const expectedVersion = getExpectedVersion(preferVersion, instances);
|
|
64
|
+
return report.push({
|
|
65
|
+
status: preferVersion === 'highestSemver'
|
|
66
|
+
? 'HIGHEST_SEMVER_MISMATCH'
|
|
67
|
+
: 'LOWEST_SEMVER_MISMATCH',
|
|
68
|
+
expectedVersion,
|
|
69
|
+
instances,
|
|
70
|
+
isValid: false,
|
|
71
|
+
name,
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
return report;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.StandardVersionGroup = StandardVersionGroup;
|
|
78
|
+
function getExpectedVersion(preferVersion, instances) {
|
|
79
|
+
const versions = (0, get_unique_versions_1.getUniqueVersions)(instances);
|
|
80
|
+
return (0, unwrap_1.unwrap)(preferVersion === 'highestSemver'
|
|
81
|
+
? (0, get_highest_version_1.getHighestVersion)(versions)
|
|
82
|
+
: (0, get_lowest_version_1.getLowestVersion)(versions));
|
|
83
|
+
}
|
|
84
|
+
function hasMismatch(instances) {
|
|
85
|
+
return (0, get_unique_versions_1.getUniqueVersions)(instances).length > 1;
|
|
86
|
+
}
|
|
87
|
+
function hasUnsupported(instances) {
|
|
88
|
+
return instances.some((instance) => !(0, is_semver_1.isSupported)(instance.version));
|
|
89
|
+
}
|
|
90
|
+
function getWorkspaceInstance(instances) {
|
|
91
|
+
return instances.find((instance) => instance.strategy.name === 'workspace');
|
|
92
|
+
}
|
|
93
|
+
function getNonWorkspaceInstances(instances) {
|
|
94
|
+
return instances.filter((instance) => instance.strategy.name !== 'workspace');
|
|
95
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -4,9 +4,9 @@ export declare const $R: {
|
|
|
4
4
|
/**
|
|
5
5
|
* Return a single `Ok<output[]>` containing an array of the output of every
|
|
6
6
|
* `Result` returned by `getResult(input)` which succeeded, or a single
|
|
7
|
-
* `Err<
|
|
7
|
+
* `Err<Error>` if none succeeded.
|
|
8
8
|
*/
|
|
9
|
-
onlyOk<Input, Output = Input>(getResult: (value: Input) => Result<Output
|
|
9
|
+
onlyOk<Input, Output = Input>(getResult: (value: Input) => Result<Output>): (inputs: Input[]) => Result<Output[]>;
|
|
10
10
|
/** Log verbose only when Result is an Err */
|
|
11
11
|
tapErrVerbose<T extends AnyResult>(result: T): T;
|
|
12
12
|
};
|
|
@@ -4,13 +4,12 @@ exports.$R = void 0;
|
|
|
4
4
|
const result_1 = require("tightrope/result");
|
|
5
5
|
const is_err_1 = require("tightrope/result/is-err");
|
|
6
6
|
const unwrap_1 = require("tightrope/result/unwrap");
|
|
7
|
-
const
|
|
8
|
-
const log_1 = require("../lib/log");
|
|
7
|
+
const log_1 = require("./log");
|
|
9
8
|
exports.$R = {
|
|
10
9
|
/**
|
|
11
10
|
* Return a single `Ok<output[]>` containing an array of the output of every
|
|
12
11
|
* `Result` returned by `getResult(input)` which succeeded, or a single
|
|
13
|
-
* `Err<
|
|
12
|
+
* `Err<Error>` if none succeeded.
|
|
14
13
|
*/
|
|
15
14
|
onlyOk(getResult) {
|
|
16
15
|
return (inputs) => {
|
|
@@ -23,7 +22,7 @@ exports.$R = {
|
|
|
23
22
|
}
|
|
24
23
|
return outputs.length > 0
|
|
25
24
|
? new result_1.Ok(outputs)
|
|
26
|
-
: new result_1.Err(new
|
|
25
|
+
: new result_1.Err(new Error('No Ok() returned by $R.onlyOk'));
|
|
27
26
|
};
|
|
28
27
|
},
|
|
29
28
|
/** Log verbose only when Result is an Err */
|
package/dist/lib/disk.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { O } from 'ts-toolbelt';
|
|
2
|
+
import type { RcConfig } from '../config/types';
|
|
2
3
|
export type Disk = {
|
|
3
4
|
process: {
|
|
4
5
|
exit: (code: number) => void;
|
|
5
6
|
};
|
|
6
7
|
globSync: (pattern: string) => string[];
|
|
7
|
-
readConfigFileSync: (configPath?: string) => Partial<
|
|
8
|
+
readConfigFileSync: (configPath?: string) => O.Partial<RcConfig, 'deep'>;
|
|
8
9
|
readFileSync: (filePath: string) => string;
|
|
9
10
|
readYamlFileSync: <T = unknown>(filePath: string) => T;
|
|
10
11
|
removeSync: (filePath: string) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function exitIfInvalid(ctx:
|
|
1
|
+
import type { Context } from '../get-context';
|
|
2
|
+
export declare function exitIfInvalid(ctx: Context): Context;
|
package/dist/lib/is-semver.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function isValidSemverRange(value: unknown): value is
|
|
3
|
-
export declare function
|
|
1
|
+
import type { SemverRange } from '../config/types';
|
|
2
|
+
export declare function isValidSemverRange(value: unknown): value is SemverRange;
|
|
3
|
+
export declare function isSupported(version: unknown): version is string;
|
|
4
|
+
export declare function isWorkspaceProtocol(version: unknown): boolean;
|
|
5
|
+
export declare function isSemver(version: unknown): boolean;
|
|
4
6
|
export declare function isLooseSemver(version: unknown): boolean;
|
package/dist/lib/is-semver.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLooseSemver = exports.isSemver = exports.isValidSemverRange = void 0;
|
|
3
|
+
exports.isLooseSemver = exports.isSemver = exports.isWorkspaceProtocol = exports.isSupported = exports.isValidSemverRange = void 0;
|
|
4
4
|
const is_string_1 = require("tightrope/guard/is-string");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
function isValidSemverRange(value) {
|
|
@@ -12,9 +12,23 @@ function isValidSemverRange(value) {
|
|
|
12
12
|
value === constants_1.RANGE.LT ||
|
|
13
13
|
value === constants_1.RANGE.LTE ||
|
|
14
14
|
value === constants_1.RANGE.MINOR ||
|
|
15
|
-
value === constants_1.RANGE.PATCH
|
|
15
|
+
value === constants_1.RANGE.PATCH ||
|
|
16
|
+
value === constants_1.RANGE.WORKSPACE);
|
|
16
17
|
}
|
|
17
18
|
exports.isValidSemverRange = isValidSemverRange;
|
|
19
|
+
function isSupported(version) {
|
|
20
|
+
return version === '*' || isSemver(version) || isWorkspaceProtocol(version);
|
|
21
|
+
}
|
|
22
|
+
exports.isSupported = isSupported;
|
|
23
|
+
function isWorkspaceProtocol(version) {
|
|
24
|
+
if (!(0, is_string_1.isString)(version))
|
|
25
|
+
return false;
|
|
26
|
+
if (!version.startsWith('workspace:'))
|
|
27
|
+
return false;
|
|
28
|
+
const value = version.replace(/^workspace:/, '');
|
|
29
|
+
return value === '*' || isSemver(value);
|
|
30
|
+
}
|
|
31
|
+
exports.isWorkspaceProtocol = isWorkspaceProtocol;
|
|
18
32
|
function isSemver(version) {
|
|
19
33
|
const range = '(~|\\^|>=|>|<=|<)?';
|
|
20
34
|
const ints = '[0-9]+';
|
|
@@ -30,6 +44,6 @@ function isSemver(version) {
|
|
|
30
44
|
}
|
|
31
45
|
exports.isSemver = isSemver;
|
|
32
46
|
function isLooseSemver(version) {
|
|
33
|
-
return isSemver(version) && version.search(/\.x(\.|$)/) !== -1;
|
|
47
|
+
return ((0, is_string_1.isString)(version) && isSemver(version) && version.search(/\.x(\.|$)/) !== -1);
|
|
34
48
|
}
|
|
35
49
|
exports.isLooseSemver = isLooseSemver;
|
package/dist/lib/log.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AnySemverGroup } from '../get-semver-groups';
|
|
2
|
+
import type { AnyVersionGroup } from '../get-version-groups';
|
|
3
3
|
export declare function verbose(...values: unknown[]): void;
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function valid(message: string, comment?: string): void;
|
|
7
|
-
export declare function invalid(message: string, comment?: string): void;
|
|
8
|
-
export declare function semverGroupHeader(group: SemverGroup, i: number): void;
|
|
9
|
-
export declare function versionGroupHeader(group: VersionGroup, i: number): void;
|
|
4
|
+
export declare function semverGroupHeader(group: AnySemverGroup, i: number): void;
|
|
5
|
+
export declare function versionGroupHeader(group: AnyVersionGroup, i: number): void;
|
package/dist/lib/log.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.versionGroupHeader = exports.semverGroupHeader = exports.
|
|
6
|
+
exports.versionGroupHeader = exports.semverGroupHeader = exports.verbose = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const is_string_1 = require("tightrope/guard/is-string");
|
|
9
9
|
const util_1 = require("util");
|
|
@@ -22,32 +22,6 @@ function verbose(...values) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
exports.verbose = verbose;
|
|
25
|
-
function fixed(message) {
|
|
26
|
-
console.log((0, chalk_1.default) `{green ${constants_1.ICON.tick}}`, message);
|
|
27
|
-
}
|
|
28
|
-
exports.fixed = fixed;
|
|
29
|
-
function skip(message) {
|
|
30
|
-
console.log(chalk_1.default.dim(constants_1.ICON.skip), chalk_1.default.dim(message));
|
|
31
|
-
}
|
|
32
|
-
exports.skip = skip;
|
|
33
|
-
function valid(message, comment) {
|
|
34
|
-
if (comment) {
|
|
35
|
-
console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip}} ${message} {dim ${comment}}`);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip}} ${message}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.valid = valid;
|
|
42
|
-
function invalid(message, comment) {
|
|
43
|
-
if (comment) {
|
|
44
|
-
console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross}} ${message} {dim ${comment}}`);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross}} ${message}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.invalid = invalid;
|
|
51
25
|
function semverGroupHeader(group, i) {
|
|
52
26
|
logHeader(group, 'Semver', i);
|
|
53
27
|
}
|
|
@@ -57,8 +31,8 @@ function versionGroupHeader(group, i) {
|
|
|
57
31
|
}
|
|
58
32
|
exports.versionGroupHeader = versionGroupHeader;
|
|
59
33
|
function logHeader(group, type, i) {
|
|
60
|
-
const customLabel = group.
|
|
61
|
-
const labelWhenDefault = group.
|
|
34
|
+
const customLabel = group.config.label;
|
|
35
|
+
const labelWhenDefault = group._tag === 'CatchAll' ? `Default ${type} Group` : '';
|
|
62
36
|
const anonymousLabel = `${type} Group ${i + 1}`;
|
|
63
37
|
const label = (customLabel || labelWhenDefault || anonymousLabel).trim();
|
|
64
38
|
const hasNewLines = label.search(/[\r\n]/) !== -1;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function setSemverRange(semverRange:
|
|
1
|
+
import type { SemverRange } from '../config/types';
|
|
2
|
+
export declare function setSemverRange(semverRange: SemverRange, version: string): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function writeIfChanged(ctx:
|
|
1
|
+
import type { Context } from '../get-context';
|
|
2
|
+
export declare function writeIfChanged(ctx: Context): Context;
|
|
@@ -1,38 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.writeIfChanged = void 0;
|
|
27
|
-
const
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const constants_1 = require("../constants");
|
|
28
9
|
function writeIfChanged(ctx) {
|
|
29
10
|
ctx.packageJsonFiles.forEach((packageJsonFile) => {
|
|
30
11
|
if (packageJsonFile.hasChanged()) {
|
|
31
12
|
packageJsonFile.write();
|
|
32
|
-
log.
|
|
13
|
+
console.log((0, chalk_1.default) `{green ${constants_1.ICON.tick}}`, packageJsonFile.shortPath);
|
|
33
14
|
}
|
|
34
15
|
else {
|
|
35
|
-
log.skip(packageJsonFile.shortPath);
|
|
16
|
+
console.log(chalk_1.default.dim(constants_1.ICON.skip), chalk_1.default.dim(packageJsonFile.shortPath));
|
|
36
17
|
}
|
|
37
18
|
});
|
|
38
19
|
return ctx;
|
package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.d.ts
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Result } from 'tightrope/result';
|
|
2
|
-
import type { PackageJsonFile } from '
|
|
2
|
+
import type { PackageJsonFile } from '../../get-package-json-files/package-json-file';
|
|
3
3
|
export declare function getNonEmptyStringProp(propPath: string, file: PackageJsonFile): Result<string>;
|
package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.js
RENAMED
|
@@ -6,8 +6,7 @@ const pipe_1 = require("tightrope/fn/pipe");
|
|
|
6
6
|
const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
|
|
7
7
|
const filter_1 = require("tightrope/result/filter");
|
|
8
8
|
const map_err_1 = require("tightrope/result/map-err");
|
|
9
|
-
const error_1 = require("../../../../lib/error");
|
|
10
9
|
function getNonEmptyStringProp(propPath, file) {
|
|
11
|
-
return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...propPath.split('.')), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString, ''), (0, map_err_1.mapErr)(() => new
|
|
10
|
+
return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...propPath.split('.')), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString, ''), (0, map_err_1.mapErr)(() => new Error(`Failed to get ${propPath} in ${file.shortPath}`)));
|
|
12
11
|
}
|
|
13
12
|
exports.getNonEmptyStringProp = getNonEmptyStringProp;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Result } from 'tightrope/result';
|
|
2
|
+
import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
|
|
3
|
+
import type { Delete } from '../get-version-groups/lib/delete';
|
|
4
|
+
export declare class NameAndVersionPropsStrategy {
|
|
5
|
+
_tag: string;
|
|
6
|
+
name: string;
|
|
7
|
+
path: string;
|
|
8
|
+
namePath: string;
|
|
9
|
+
constructor(name: string, path: string, namePath: string);
|
|
10
|
+
read(file: PackageJsonFile): Result<[string, string][]>;
|
|
11
|
+
write(file: PackageJsonFile, [, version]: [string, string | Delete]): Result<PackageJsonFile>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NameAndVersionPropsStrategy = void 0;
|
|
4
|
+
const get_1 = require("tightrope/fn/get");
|
|
5
|
+
const pipe_1 = require("tightrope/fn/pipe");
|
|
6
|
+
const and_then_1 = require("tightrope/result/and-then");
|
|
7
|
+
const from_try_1 = require("tightrope/result/from-try");
|
|
8
|
+
const map_1 = require("tightrope/result/map");
|
|
9
|
+
const tap_1 = require("tightrope/result/tap");
|
|
10
|
+
const delete_1 = require("../get-version-groups/lib/delete");
|
|
11
|
+
const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
|
|
12
|
+
class NameAndVersionPropsStrategy {
|
|
13
|
+
constructor(name, path, namePath) {
|
|
14
|
+
this._tag = 'name~version';
|
|
15
|
+
this.name = name;
|
|
16
|
+
this.path = path;
|
|
17
|
+
this.namePath = namePath;
|
|
18
|
+
}
|
|
19
|
+
read(file) {
|
|
20
|
+
const path = this.path;
|
|
21
|
+
const namePath = this.namePath;
|
|
22
|
+
return (0, pipe_1.pipe)(
|
|
23
|
+
// get name prop
|
|
24
|
+
(0, get_non_empty_string_prop_1.getNonEmptyStringProp)(namePath, file),
|
|
25
|
+
// add the version prop
|
|
26
|
+
(0, and_then_1.andThen)((name) => (0, pipe_1.pipe)((0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file), (0, map_1.map)((version) => ({ name, version })))),
|
|
27
|
+
// if both are non empty strings, we can return them
|
|
28
|
+
(0, map_1.map)(({ name, version }) => [[name, version]]));
|
|
29
|
+
}
|
|
30
|
+
write(file, [, version]) {
|
|
31
|
+
const path = this.path;
|
|
32
|
+
const { contents } = file;
|
|
33
|
+
const isNestedPath = path.includes('.');
|
|
34
|
+
const nextValue = version === delete_1.DELETE ? undefined : version;
|
|
35
|
+
if (isNestedPath) {
|
|
36
|
+
const fullPath = path.split('.');
|
|
37
|
+
const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
|
|
38
|
+
const key = fullPath.slice(-1).join('');
|
|
39
|
+
return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
|
|
40
|
+
parent[key] = version;
|
|
41
|
+
}), (0, map_1.map)(() => file));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
|
|
45
|
+
contents[path] = nextValue;
|
|
46
|
+
}), (0, map_1.map)(() => file));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.NameAndVersionPropsStrategy = NameAndVersionPropsStrategy;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Result } from 'tightrope/result';
|
|
2
|
+
import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
|
|
3
|
+
import type { Delete } from '../get-version-groups/lib/delete';
|
|
4
|
+
export declare class NamedVersionStringStrategy {
|
|
5
|
+
_tag: string;
|
|
6
|
+
name: string;
|
|
7
|
+
path: string;
|
|
8
|
+
constructor(name: string, path: string);
|
|
9
|
+
read(file: PackageJsonFile): Result<[string, string][]>;
|
|
10
|
+
write(file: PackageJsonFile, [name, version]: [string, string | Delete]): Result<PackageJsonFile>;
|
|
11
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NamedVersionStringStrategy = void 0;
|
|
4
4
|
const get_1 = require("tightrope/fn/get");
|
|
5
5
|
const pipe_1 = require("tightrope/fn/pipe");
|
|
6
6
|
const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
|
|
@@ -8,42 +8,46 @@ const result_1 = require("tightrope/result");
|
|
|
8
8
|
const and_then_1 = require("tightrope/result/and-then");
|
|
9
9
|
const from_try_1 = require("tightrope/result/from-try");
|
|
10
10
|
const map_1 = require("tightrope/result/map");
|
|
11
|
-
const map_err_1 = require("tightrope/result/map-err");
|
|
12
11
|
const tap_1 = require("tightrope/result/tap");
|
|
13
|
-
const
|
|
12
|
+
const delete_1 = require("../get-version-groups/lib/delete");
|
|
14
13
|
const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
class NamedVersionStringStrategy {
|
|
15
|
+
constructor(name, path) {
|
|
16
|
+
this._tag = 'name@version';
|
|
17
|
+
this.name = name;
|
|
18
|
+
this.path = path;
|
|
19
|
+
}
|
|
20
|
+
read(file) {
|
|
21
|
+
const path = this.path;
|
|
17
22
|
return (0, pipe_1.pipe)(
|
|
18
23
|
// get version prop
|
|
19
|
-
(0, get_non_empty_string_prop_1.getNonEmptyStringProp)(
|
|
24
|
+
(0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file),
|
|
20
25
|
// if it is a non empty string, we can read it
|
|
21
26
|
(0, and_then_1.andThen)((value) => {
|
|
22
27
|
const [name, version] = value.split('@');
|
|
23
28
|
return (0, is_non_empty_string_1.isNonEmptyString)(name) && (0, is_non_empty_string_1.isNonEmptyString)(version)
|
|
24
29
|
? new result_1.Ok([[name, version]])
|
|
25
|
-
: new result_1.Err(new
|
|
30
|
+
: new result_1.Err(new Error(`Strategy<name@version> failed to get ${path} in ${file.shortPath}`));
|
|
26
31
|
}));
|
|
27
|
-
}
|
|
28
|
-
write(file,
|
|
29
|
-
const { contents
|
|
30
|
-
const
|
|
32
|
+
}
|
|
33
|
+
write(file, [name, version]) {
|
|
34
|
+
const { contents } = file;
|
|
35
|
+
const path = this.path;
|
|
36
|
+
const isNestedPath = path.includes('.');
|
|
37
|
+
const nextValue = version === delete_1.DELETE ? undefined : `${name}@${version}`;
|
|
31
38
|
if (isNestedPath) {
|
|
32
|
-
const fullPath =
|
|
39
|
+
const fullPath = path.split('.');
|
|
33
40
|
const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
|
|
34
41
|
const key = fullPath.slice(-1).join('');
|
|
35
42
|
return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
|
|
36
|
-
parent[key] =
|
|
37
|
-
}), (0,
|
|
43
|
+
parent[key] = nextValue;
|
|
44
|
+
}), (0, map_1.map)(() => file));
|
|
38
45
|
}
|
|
39
46
|
else {
|
|
40
47
|
return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
|
|
41
|
-
contents[
|
|
42
|
-
}), (0,
|
|
48
|
+
contents[path] = nextValue;
|
|
49
|
+
}), (0, map_1.map)(() => file));
|
|
43
50
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.NamedVersionStringStrategy = NamedVersionStringStrategy;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Result } from 'tightrope/result';
|
|
2
|
+
import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
|
|
3
|
+
import type { Delete } from '../get-version-groups/lib/delete';
|
|
4
|
+
export declare class UnnamedVersionStringStrategy {
|
|
5
|
+
_tag: string;
|
|
6
|
+
name: string;
|
|
7
|
+
path: string;
|
|
8
|
+
constructor(name: string, path: string);
|
|
9
|
+
read(file: PackageJsonFile): Result<[string, string][]>;
|
|
10
|
+
write(file: PackageJsonFile, [, version]: [string, string | Delete]): Result<PackageJsonFile>;
|
|
11
|
+
}
|