syncpack 9.1.2 → 9.7.4
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-cli.js +4 -4
- package/dist/bin-fix-mismatches/fix-mismatches.js +14 -15
- package/dist/bin-fix-mismatches/index.js +50 -48
- package/dist/bin-format/format-cli.js +4 -4
- package/dist/bin-format/format.js +19 -18
- package/dist/bin-format/index.js +43 -46
- package/dist/bin-lint-semver-ranges/index.js +59 -48
- package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +4 -4
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +15 -37
- package/dist/bin-list/index.js +43 -46
- package/dist/bin-list/list-cli.js +4 -4
- package/dist/bin-list/list.js +26 -29
- package/dist/bin-list-mismatches/index.js +46 -47
- package/dist/bin-list-mismatches/list-mismatches-cli.js +4 -4
- package/dist/bin-list-mismatches/list-mismatches.js +51 -40
- package/dist/bin-set-semver-ranges/index.js +62 -49
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +4 -4
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +4 -4
- package/dist/bin.js +8 -8
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +6 -5
- package/dist/get-context/$R.js +14 -36
- package/dist/get-context/get-all-instances.js +3 -3
- package/dist/get-context/get-config/get-core-types.js +11 -41
- package/dist/get-context/get-config/get-custom-types.js +7 -19
- package/dist/get-context/get-config/get-enabled-types.js +9 -11
- package/dist/get-context/get-config/index.js +29 -59
- package/dist/get-context/get-config/path-strategy/index.js +8 -8
- package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.js +6 -6
- package/dist/get-context/get-config/path-strategy/name-and-version-props.js +23 -49
- package/dist/get-context/get-config/path-strategy/name-and-version-string.js +26 -42
- package/dist/get-context/get-config/path-strategy/types.js +1 -1
- package/dist/get-context/get-config/path-strategy/version-string.js +25 -41
- package/dist/get-context/get-config/path-strategy/versions-by-name.js +14 -30
- package/dist/get-context/get-config/schema/base-group.d.ts +2 -1
- package/dist/get-context/get-config/schema/base-group.js +5 -4
- package/dist/get-context/get-config/schema/index.d.ts +374 -148
- package/dist/get-context/get-config/schema/index.js +40 -63
- package/dist/get-context/get-config/schema/paths.js +12 -12
- package/dist/get-context/get-config/schema/semver-group.d.ts +42 -24
- package/dist/get-context/get-config/schema/semver-group.js +11 -18
- package/dist/get-context/get-config/schema/semver-range.js +4 -4
- package/dist/get-context/get-config/schema/version-group.d.ts +91 -24
- package/dist/get-context/get-config/schema/version-group.js +20 -21
- package/dist/get-context/get-groups/base-group.d.ts +4 -1
- package/dist/get-context/get-groups/base-group.js +18 -19
- package/dist/get-context/get-groups/index.d.ts +2 -1
- package/dist/get-context/get-groups/index.js +31 -37
- package/dist/get-context/get-groups/semver-group.d.ts +0 -1
- package/dist/get-context/get-groups/semver-group.js +23 -66
- package/dist/get-context/get-groups/version-group/index.d.ts +2 -1
- package/dist/get-context/get-groups/version-group/index.js +29 -68
- package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.d.ts +3 -1
- package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +36 -45
- package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +2 -1
- package/dist/get-context/get-groups/version-group/instance-group/index.js +55 -47
- package/dist/get-context/get-groups/version-group/instance-group/lib/clean.d.ts +2 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/clean.js +13 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +2 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +22 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/get-range-score.d.ts +2 -0
- package/dist/get-context/get-groups/version-group/instance-group/lib/get-range-score.js +23 -0
- package/dist/get-context/get-package-json-files/get-file-paths.js +18 -19
- package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +9 -12
- package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +9 -11
- package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +10 -13
- package/dist/get-context/get-package-json-files/get-patterns/index.js +15 -42
- package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.js +4 -6
- package/dist/get-context/get-package-json-files/get-patterns/props.js +9 -33
- package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.js +6 -9
- package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +4 -4
- package/dist/get-context/get-package-json-files/index.js +7 -7
- package/dist/get-context/get-package-json-files/package-json-file/index.js +32 -55
- package/dist/get-context/get-package-json-files/package-json-file/instance.js +14 -15
- package/dist/get-context/index.js +19 -24
- package/dist/lib/disk.js +28 -29
- package/dist/lib/error.js +13 -31
- package/dist/lib/exit-if-invalid.js +1 -1
- package/dist/lib/is-semver.d.ts +1 -1
- package/dist/lib/is-semver.js +15 -7
- package/dist/lib/log.d.ts +4 -2
- package/dist/lib/log.js +44 -60
- package/dist/lib/newlines.js +11 -11
- package/dist/lib/print-strings.js +2 -2
- package/dist/lib/set-semver-range.js +8 -8
- package/dist/lib/show-help-on-error.js +31 -8
- package/dist/lib/sort-by-name.js +1 -1
- package/dist/lib/write-if-changed.js +3 -3
- package/dist/option.js +8 -13
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -1
- package/package.json +20 -16
|
@@ -1,76 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InstanceGroup = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const error_1 = require("../../../../lib/error");
|
|
6
|
+
const is_semver_1 = require("../../../../lib/is-semver");
|
|
7
|
+
const print_strings_1 = require("../../../../lib/print-strings");
|
|
8
|
+
const get_highest_version_1 = require("./get-highest-version");
|
|
8
9
|
/** Every `Instance` of eg `"lodash"` for a given `VersionGroup` */
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
class InstanceGroup {
|
|
11
|
+
constructor(versionGroup, name, instances) {
|
|
11
12
|
this.instances = instances;
|
|
12
13
|
this.name = name;
|
|
13
14
|
this.versionGroup = versionGroup;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
return this.instances.some(
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return Array.from(new Set(this.instances.map(
|
|
20
|
-
}
|
|
21
|
-
|
|
16
|
+
hasUnsupportedVersion() {
|
|
17
|
+
return this.instances.some((obj) => !(0, is_semver_1.isSemver)(obj.version));
|
|
18
|
+
}
|
|
19
|
+
getUniqueVersions() {
|
|
20
|
+
return Array.from(new Set(this.instances.map((obj) => obj.version))).sort();
|
|
21
|
+
}
|
|
22
|
+
hasMismatchingVersions() {
|
|
22
23
|
return this.getUniqueVersions().length > 1;
|
|
23
|
-
}
|
|
24
|
-
|
|
24
|
+
}
|
|
25
|
+
isInvalid() {
|
|
25
26
|
return this.versionGroup.isIgnored()
|
|
26
27
|
? false
|
|
27
28
|
: this.versionGroup.isBanned() ||
|
|
28
29
|
this.versionGroup.isUnpinned() ||
|
|
29
30
|
this.hasMismatchingVersions();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
}
|
|
32
|
+
getExpectedVersion() {
|
|
33
|
+
const versionGroup = this.versionGroup;
|
|
34
|
+
const REMOVE_DEPENDENCY = undefined;
|
|
34
35
|
if (versionGroup.isBanned())
|
|
35
36
|
return REMOVE_DEPENDENCY;
|
|
36
37
|
if (versionGroup.isUnpinned())
|
|
37
38
|
return versionGroup.getPinnedVersion();
|
|
39
|
+
if (this.isUnsnapped())
|
|
40
|
+
return this.getSnappedVersion();
|
|
38
41
|
if (this.hasWorkspaceInstance())
|
|
39
42
|
return this.getWorkspaceVersion();
|
|
40
43
|
if (this.hasUnsupportedVersion()) {
|
|
41
|
-
throw new error_1.BaseError(
|
|
44
|
+
throw new error_1.BaseError(`${this.name} contains unsupported versions: ${(0, print_strings_1.printStrings)(this.getUniqueVersions())}`);
|
|
42
45
|
}
|
|
43
46
|
return this.getHighestVersion();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return (0, get_highest_version_1.getHighestVersion)(this.getUniqueVersions());
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
}
|
|
48
|
+
getHighestVersion() {
|
|
49
|
+
return (0, ts_belt_1.pipe)((0, get_highest_version_1.getHighestVersion)(this.getUniqueVersions()), ts_belt_1.R.getExn);
|
|
50
|
+
}
|
|
51
|
+
getSnappedVersion() {
|
|
52
|
+
const snapTo = this.versionGroup.getSnappedToPackages();
|
|
53
|
+
const version = this.instances
|
|
54
|
+
.filter(({ pkgName }) => snapTo.includes(pkgName))
|
|
55
|
+
.map((instance) => instance.version)
|
|
56
|
+
.find(Boolean);
|
|
57
|
+
if (!version) {
|
|
58
|
+
const pkgNames = (0, print_strings_1.printStrings)(snapTo);
|
|
59
|
+
throw new error_1.BaseError(`${this.name} is in a versionGroup with snapTo:[${pkgNames}], but ${this.name} was not found in those packages`);
|
|
60
|
+
}
|
|
61
|
+
return version;
|
|
62
|
+
}
|
|
63
|
+
isUnsnapped() {
|
|
64
|
+
if (!this.versionGroup.hasSnappedToPackages())
|
|
65
|
+
return false;
|
|
66
|
+
const targetVersion = this.getSnappedVersion();
|
|
67
|
+
return this.instances.some(({ version }) => version !== targetVersion);
|
|
68
|
+
}
|
|
56
69
|
/** Get version of dependency which is developed in this monorepo */
|
|
57
|
-
|
|
58
|
-
var _a;
|
|
70
|
+
getWorkspaceVersion() {
|
|
59
71
|
if (this.hasWorkspaceInstance()) {
|
|
60
|
-
return
|
|
72
|
+
return this.getWorkspaceInstance()?.packageJsonFile.contents.version;
|
|
61
73
|
}
|
|
62
74
|
throw new error_1.BaseError('getWorkspaceVersion invoked when there is none');
|
|
63
|
-
}
|
|
75
|
+
}
|
|
64
76
|
/** Find instance of this dependency which is developed in this monorepo */
|
|
65
|
-
|
|
66
|
-
return this.instances.find(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
InstanceGroup.prototype.hasWorkspaceInstance = function () {
|
|
77
|
+
getWorkspaceInstance() {
|
|
78
|
+
return this.instances.find(({ pathDef }) => pathDef.name === 'workspace');
|
|
79
|
+
}
|
|
80
|
+
hasWorkspaceInstance() {
|
|
72
81
|
return this.getWorkspaceInstance() !== undefined;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}());
|
|
82
|
+
}
|
|
83
|
+
}
|
|
76
84
|
exports.InstanceGroup = InstanceGroup;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.clean = void 0;
|
|
7
|
+
const coerce_1 = __importDefault(require("semver/functions/coerce"));
|
|
8
|
+
const valid_1 = __importDefault(require("semver/functions/valid"));
|
|
9
|
+
/** Convert eg "1" to "1.0.0" which the semver lib does not understand */
|
|
10
|
+
function clean(v) {
|
|
11
|
+
return (0, valid_1.default)((0, coerce_1.default)(v)) || '';
|
|
12
|
+
}
|
|
13
|
+
exports.clean = clean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.compareSemver = void 0;
|
|
7
|
+
const gt_1 = __importDefault(require("semver/functions/gt"));
|
|
8
|
+
const is_semver_1 = require("../../../../../lib/is-semver");
|
|
9
|
+
const clean_1 = require("./clean");
|
|
10
|
+
/** Is this next version to be inspected higher than the current highest? */
|
|
11
|
+
function compareSemver(next, highest) {
|
|
12
|
+
if (next === '*')
|
|
13
|
+
return '*';
|
|
14
|
+
if (!(0, is_semver_1.isSemver)(next))
|
|
15
|
+
return 'invalid';
|
|
16
|
+
if (!highest || (0, gt_1.default)((0, clean_1.clean)(next), highest))
|
|
17
|
+
return 'gt';
|
|
18
|
+
if ((0, gt_1.default)((0, clean_1.clean)(next), highest))
|
|
19
|
+
return 'lt';
|
|
20
|
+
return 'eq';
|
|
21
|
+
}
|
|
22
|
+
exports.compareSemver = compareSemver;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRangeScore = void 0;
|
|
4
|
+
const constants_1 = require("../../../../../constants");
|
|
5
|
+
const scoresByRange = {
|
|
6
|
+
[constants_1.RANGE.ANY]: 8,
|
|
7
|
+
[constants_1.RANGE.GT]: 7,
|
|
8
|
+
[constants_1.RANGE.GTE]: 6,
|
|
9
|
+
[constants_1.RANGE.MINOR]: 5,
|
|
10
|
+
[constants_1.RANGE.LOOSE]: 4,
|
|
11
|
+
[constants_1.RANGE.PATCH]: 3,
|
|
12
|
+
[constants_1.RANGE.EXACT]: 2,
|
|
13
|
+
[constants_1.RANGE.LTE]: 1,
|
|
14
|
+
[constants_1.RANGE.LT]: 0,
|
|
15
|
+
};
|
|
16
|
+
/** Rank a Semver Range according to its greediness */
|
|
17
|
+
function getRangeScore(version) {
|
|
18
|
+
const range = version.indexOf('.x') !== -1
|
|
19
|
+
? constants_1.RANGE.LOOSE
|
|
20
|
+
: version.slice(0, version.search(/[0-9]/));
|
|
21
|
+
return scoresByRange[range] || 0;
|
|
22
|
+
}
|
|
23
|
+
exports.getRangeScore = getRangeScore;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFilePaths = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const is_array_of_strings_1 = require("expect-more/dist/is-array-of-strings");
|
|
6
|
+
const is_empty_array_1 = require("expect-more/dist/is-empty-array");
|
|
7
|
+
const _R_1 = require("../$R");
|
|
8
|
+
const error_1 = require("../../lib/error");
|
|
9
|
+
const print_strings_1 = require("../../lib/print-strings");
|
|
10
|
+
const get_patterns_1 = require("./get-patterns");
|
|
10
11
|
/**
|
|
11
12
|
* Using --source options and/or config files on disk from npm/pnpm/yarn/lerna,
|
|
12
13
|
* return an array of absolute paths to every package.json file the user is
|
|
@@ -17,21 +18,19 @@ var get_patterns_1 = require("./get-patterns");
|
|
|
17
18
|
function getFilePaths(disk, program) {
|
|
18
19
|
return (0, ts_belt_1.pipe)(program, (0, get_patterns_1.getPatterns)(disk), ts_belt_1.R.flatMap(resolvePatterns));
|
|
19
20
|
function resolvePatterns(patterns) {
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const quoted = (0, print_strings_1.printStrings)(patterns);
|
|
22
|
+
const ERR_NO_MATCH = `No package.json files matched the patterns: ${quoted}`;
|
|
22
23
|
return (0, ts_belt_1.pipe)(patterns, _R_1.$R.onlyOk(resolvePattern), ts_belt_1.R.mapError(error_1.BaseError.map(ERR_NO_MATCH)), ts_belt_1.R.map((0, ts_belt_1.flow)(ts_belt_1.A.flat, ts_belt_1.A.uniq, removeReadonlyType)));
|
|
23
24
|
}
|
|
24
25
|
function resolvePattern(pattern) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
: ts_belt_1.R.Error(new error_1.BaseError(ERR_INVALID));
|
|
34
|
-
}));
|
|
26
|
+
const ERR_GLOB_MISS = `No package.json files match pattern "${pattern}"`;
|
|
27
|
+
const ERR_INVALID = `"glob" returned unexpected data on pattern "${pattern}"`;
|
|
28
|
+
const ERR_GLOB_THROW = `"glob" threw on pattern "${pattern}"`;
|
|
29
|
+
return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => disk.globSync(pattern)), ts_belt_1.R.mapError(error_1.BaseError.map(ERR_GLOB_THROW)), ts_belt_1.R.flatMap((filePaths) => (0, is_empty_array_1.isEmptyArray)(filePaths)
|
|
30
|
+
? ts_belt_1.R.Error(new error_1.BaseError(ERR_GLOB_MISS))
|
|
31
|
+
: (0, is_array_of_strings_1.isArrayOfStrings)(filePaths)
|
|
32
|
+
? ts_belt_1.R.Ok((0, ts_belt_1.pipe)(filePaths, ts_belt_1.A.flat, ts_belt_1.A.uniq, removeReadonlyType))
|
|
33
|
+
: ts_belt_1.R.Error(new error_1.BaseError(ERR_INVALID))));
|
|
35
34
|
}
|
|
36
35
|
/** Remove unwanted readonly type */
|
|
37
36
|
function removeReadonlyType(value) {
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLernaPatterns = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const constants_1 = require("../../../constants");
|
|
7
|
+
const error_1 = require("../../../lib/error");
|
|
8
|
+
const get_array_of_strings_1 = require("./lib/get-array-of-strings");
|
|
9
|
+
const read_json_safe_1 = require("./read-json-safe");
|
|
10
10
|
function getLernaPatterns(disk) {
|
|
11
|
-
|
|
11
|
+
const getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('packages');
|
|
12
12
|
return function getLernaPatterns() {
|
|
13
|
-
return (0, ts_belt_1.pipe)((0, path_1.join)(constants_1.CWD, 'lerna.json'), (0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.flatMap(
|
|
14
|
-
var contents = _a.contents;
|
|
15
|
-
return (0, ts_belt_1.pipe)(getPackages(contents), ts_belt_1.O.toResult(new error_1.BaseError('no lerna patterns found')));
|
|
16
|
-
}));
|
|
13
|
+
return (0, ts_belt_1.pipe)((0, path_1.join)(constants_1.CWD, 'lerna.json'), (0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.flatMap(({ contents }) => (0, ts_belt_1.pipe)(getPackages(contents), ts_belt_1.O.toResult(new error_1.BaseError('no lerna patterns found')))));
|
|
17
14
|
};
|
|
18
15
|
}
|
|
19
16
|
exports.getLernaPatterns = getLernaPatterns;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPnpmPatterns = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const constants_1 = require("../../../constants");
|
|
7
|
+
const error_1 = require("../../../lib/error");
|
|
8
|
+
const get_array_of_strings_1 = require("./lib/get-array-of-strings");
|
|
9
|
+
const read_yaml_safe_1 = require("./read-yaml-safe");
|
|
10
|
+
const getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('packages');
|
|
11
11
|
function getPnpmPatterns(disk) {
|
|
12
12
|
return function getPnpmPatterns() {
|
|
13
13
|
return (0, ts_belt_1.pipe)(
|
|
@@ -15,9 +15,7 @@ function getPnpmPatterns(disk) {
|
|
|
15
15
|
// - "packages/**"
|
|
16
16
|
// - "components/**"
|
|
17
17
|
// - "!**/test/**"
|
|
18
|
-
(0, path_1.join)(constants_1.CWD, 'pnpm-workspace.yaml'), (0, read_yaml_safe_1.readYamlSafe)(disk), ts_belt_1.R.flatMap(
|
|
19
|
-
return (0, ts_belt_1.pipe)(getPackages(packageJson), ts_belt_1.O.match(ts_belt_1.F.identity, function () { return getPackages(packageJson); }), ts_belt_1.O.toResult(new error_1.BaseError('no pnpm patterns found')));
|
|
20
|
-
}));
|
|
18
|
+
(0, path_1.join)(constants_1.CWD, 'pnpm-workspace.yaml'), (0, read_yaml_safe_1.readYamlSafe)(disk), ts_belt_1.R.flatMap((packageJson) => (0, ts_belt_1.pipe)(getPackages(packageJson), ts_belt_1.O.match(ts_belt_1.F.identity, () => getPackages(packageJson)), ts_belt_1.O.toResult(new error_1.BaseError('no pnpm patterns found')))));
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
21
|
exports.getPnpmPatterns = getPnpmPatterns;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getYarnPatterns = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const constants_1 = require("../../../constants");
|
|
7
|
+
const error_1 = require("../../../lib/error");
|
|
8
|
+
const get_array_of_strings_1 = require("./lib/get-array-of-strings");
|
|
9
|
+
const read_json_safe_1 = require("./read-json-safe");
|
|
10
10
|
function getYarnPatterns(disk) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('workspaces');
|
|
12
|
+
const getPackagesNested = (0, get_array_of_strings_1.getArrayOfStrings)('workspaces.packages');
|
|
13
13
|
return function getYarnPatterns() {
|
|
14
|
-
return (0, ts_belt_1.pipe)((0, path_1.join)(constants_1.CWD, 'package.json'), (0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.flatMap(
|
|
15
|
-
var contents = _a.contents;
|
|
16
|
-
return (0, ts_belt_1.pipe)(getPackages(contents), ts_belt_1.O.match(ts_belt_1.F.identity, function () { return getPackagesNested(contents); }), ts_belt_1.O.toResult(new error_1.BaseError('no yarn patterns found')));
|
|
17
|
-
}));
|
|
14
|
+
return (0, ts_belt_1.pipe)((0, path_1.join)(constants_1.CWD, 'package.json'), (0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.flatMap(({ contents }) => (0, ts_belt_1.pipe)(getPackages(contents), ts_belt_1.O.match(ts_belt_1.F.identity, () => getPackagesNested(contents)), ts_belt_1.O.toResult(new error_1.BaseError('no yarn patterns found')))));
|
|
18
15
|
};
|
|
19
16
|
}
|
|
20
17
|
exports.getYarnPatterns = getYarnPatterns;
|
|
@@ -1,38 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
exports.__esModule = true;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
3
|
exports.getPatterns = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const is_array_of_strings_1 = require("expect-more/dist/is-array-of-strings");
|
|
6
|
+
const constants_1 = require("../../../constants");
|
|
7
|
+
const error_1 = require("../../../lib/error");
|
|
8
|
+
const get_lerna_patterns_1 = require("./get-lerna-patterns");
|
|
9
|
+
const get_pnpm_patterns_1 = require("./get-pnpm-patterns");
|
|
10
|
+
const get_yarn_patterns_1 = require("./get-yarn-patterns");
|
|
36
11
|
/**
|
|
37
12
|
* Find every glob pattern which should be used to find package.json files for
|
|
38
13
|
* this monorepo.
|
|
@@ -41,29 +16,27 @@ var get_yarn_patterns_1 = require("./get-yarn-patterns");
|
|
|
41
16
|
*/
|
|
42
17
|
function getPatterns(disk) {
|
|
43
18
|
return function getPatterns(program) {
|
|
44
|
-
|
|
19
|
+
const getters = [
|
|
45
20
|
getCliPatterns,
|
|
46
21
|
(0, get_yarn_patterns_1.getYarnPatterns)(disk),
|
|
47
22
|
(0, get_pnpm_patterns_1.getPnpmPatterns)(disk),
|
|
48
23
|
(0, get_lerna_patterns_1.getLernaPatterns)(disk),
|
|
49
24
|
];
|
|
50
|
-
|
|
51
|
-
|
|
25
|
+
const initialResult = ts_belt_1.R.Error(new error_1.BaseError('getPatterns did not try any sources'));
|
|
26
|
+
const res = ts_belt_1.A.reduce(getters, initialResult, (previousResult, getNextResult) => {
|
|
52
27
|
if (ts_belt_1.R.isOk(previousResult))
|
|
53
28
|
return previousResult;
|
|
54
29
|
return getNextResult();
|
|
55
30
|
});
|
|
56
|
-
return (0, ts_belt_1.pipe)(res, ts_belt_1.R.map(addRootDir), ts_belt_1.R.map(limitToPackageJson), ts_belt_1.R.handleError(
|
|
31
|
+
return (0, ts_belt_1.pipe)(res, ts_belt_1.R.map(addRootDir), ts_belt_1.R.map(limitToPackageJson), ts_belt_1.R.handleError(() => constants_1.DEFAULT_SOURCES), ts_belt_1.R.mapError(ts_belt_1.F.identity));
|
|
57
32
|
function getCliPatterns() {
|
|
58
|
-
return ts_belt_1.R.fromPredicate(program.source,
|
|
33
|
+
return ts_belt_1.R.fromPredicate(program.source, is_array_of_strings_1.isArrayOfStrings, new error_1.BaseError('No --source options provided'));
|
|
59
34
|
}
|
|
60
35
|
function addRootDir(patterns) {
|
|
61
|
-
return
|
|
36
|
+
return ['package.json', ...patterns];
|
|
62
37
|
}
|
|
63
38
|
function limitToPackageJson(patterns) {
|
|
64
|
-
return patterns.map(
|
|
65
|
-
return pattern.includes('package.json') ? pattern : "".concat(pattern, "/package.json");
|
|
66
|
-
});
|
|
39
|
+
return patterns.map((pattern) => pattern.includes('package.json') ? pattern : `${pattern}/package.json`);
|
|
67
40
|
}
|
|
68
41
|
};
|
|
69
42
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getArrayOfStrings = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const is_array_of_strings_1 = require("expect-more/dist/is-array-of-strings");
|
|
5
|
+
const props_1 = require("../props");
|
|
6
6
|
// Yarn's config for this can be in more than one place
|
|
7
|
-
|
|
8
|
-
return (0, props_1.props)(path, expect_more_1.isArrayOfStrings);
|
|
9
|
-
};
|
|
7
|
+
const getArrayOfStrings = (path) => (0, props_1.props)(path, is_array_of_strings_1.isArrayOfStrings);
|
|
10
8
|
exports.getArrayOfStrings = getArrayOfStrings;
|
|
@@ -1,46 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
|
-
exports.__esModule = true;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.props = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return value !== null && typeof value !== 'undefined';
|
|
18
|
-
};
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const isWalkable = (value) => value !== null && typeof value !== 'undefined';
|
|
19
6
|
/**
|
|
20
7
|
* Safely read nested properties of any value.
|
|
21
8
|
* @param keys 'child.grandChild.greatGrandChild'
|
|
22
9
|
*/
|
|
23
10
|
function props(keys, predicate) {
|
|
24
11
|
return function getNestedProp(obj) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var key = _c.value;
|
|
30
|
-
if (isWalkable(next) && key in next) {
|
|
31
|
-
next = next[key];
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return ts_belt_1.O.None;
|
|
35
|
-
}
|
|
12
|
+
let next = obj;
|
|
13
|
+
for (const key of keys.split('.')) {
|
|
14
|
+
if (isWalkable(next) && key in next) {
|
|
15
|
+
next = next[key];
|
|
36
16
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
finally {
|
|
40
|
-
try {
|
|
41
|
-
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
|
|
17
|
+
else {
|
|
18
|
+
return ts_belt_1.O.None;
|
|
42
19
|
}
|
|
43
|
-
finally { if (e_1) throw e_1.error; }
|
|
44
20
|
}
|
|
45
21
|
return ts_belt_1.O.fromPredicate(next, predicate);
|
|
46
22
|
};
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readJsonSafe = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const error_1 = require("../../../lib/error");
|
|
6
6
|
function readJsonSafe(disk) {
|
|
7
7
|
return function readJsonSafe(filePath) {
|
|
8
|
-
return (0, ts_belt_1.pipe)(readFileSafe(filePath), ts_belt_1.R.flatMap((0, ts_belt_1.flow)((parseJsonSafe), ts_belt_1.R.mapError(error_1.BaseError.map(
|
|
9
|
-
var contents = _a.contents, json = _a.json;
|
|
10
|
-
return ({ contents: contents, filePath: filePath, json: json });
|
|
11
|
-
}))));
|
|
8
|
+
return (0, ts_belt_1.pipe)(readFileSafe(filePath), ts_belt_1.R.flatMap((0, ts_belt_1.flow)((parseJsonSafe), ts_belt_1.R.mapError(error_1.BaseError.map(`Failed to parse JSON file at ${filePath}`)), ts_belt_1.R.map(({ contents, json }) => ({ contents, filePath, json })))));
|
|
12
9
|
};
|
|
13
10
|
function readFileSafe(filePath) {
|
|
14
|
-
return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(
|
|
11
|
+
return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => disk.readFileSync(filePath)), ts_belt_1.R.mapError(error_1.BaseError.map(`Failed to read JSON file at ${filePath}`)));
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
14
|
exports.readJsonSafe = readJsonSafe;
|
|
18
15
|
function parseJsonSafe(json) {
|
|
19
|
-
return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(
|
|
16
|
+
return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => JSON.parse(json)), ts_belt_1.R.mapError(error_1.BaseError.map('Failed to parse JSON')), ts_belt_1.R.map((contents) => ({ contents, json })));
|
|
20
17
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readYamlSafe = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const error_1 = require("../../../lib/error");
|
|
6
6
|
function readYamlSafe(disk) {
|
|
7
7
|
return function readYamlSafe(filePath) {
|
|
8
|
-
return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(
|
|
8
|
+
return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => disk.readYamlFileSync(filePath)), ts_belt_1.R.mapError(error_1.BaseError.map(`Failed to read YAML file at ${filePath}`)));
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
exports.readYamlSafe = readYamlSafe;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPackageJsonFiles = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const ts_belt_1 = require("@mobily/ts-belt");
|
|
5
|
+
const _R_1 = require("../$R");
|
|
6
|
+
const get_file_paths_1 = require("./get-file-paths");
|
|
7
|
+
const read_json_safe_1 = require("./get-patterns/read-json-safe");
|
|
8
|
+
const package_json_file_1 = require("./package-json-file");
|
|
9
9
|
/** Create an API for every package.json file needed. */
|
|
10
10
|
function getPackageJsonFiles(disk, config) {
|
|
11
11
|
return (0, ts_belt_1.pipe)((0, get_file_paths_1.getFilePaths)(disk, config), ts_belt_1.R.flatMap(_R_1.$R.onlyOk(resolvePackageJson(disk))), ts_belt_1.R.getWithDefault([]));
|
|
12
12
|
function resolvePackageJson(disk) {
|
|
13
|
-
return (0, ts_belt_1.flow)((0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.map(
|
|
13
|
+
return (0, ts_belt_1.flow)((0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.map((jsonFile) => new package_json_file_1.PackageJsonFile(jsonFile, config, disk)));
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.getPackageJsonFiles = getPackageJsonFiles;
|