syncpack 9.0.2 → 9.1.2
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 +24 -764
- package/dist/bin-fix-mismatches/fix-mismatches.js +16 -39
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +2 -5
- package/dist/bin-list/list.js +33 -17
- package/dist/bin-list-mismatches/list-mismatches.js +59 -30
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +1 -1
- package/dist/get-context/get-groups/base-group.d.ts +19 -0
- package/dist/get-context/get-groups/base-group.js +40 -0
- package/dist/get-context/get-groups/index.d.ts +8 -0
- package/dist/get-context/get-groups/index.js +47 -0
- package/dist/get-context/get-groups/semver-group.d.ts +16 -0
- package/dist/get-context/get-groups/semver-group.js +89 -0
- package/dist/get-context/get-groups/version-group/index.d.ts +9 -26
- package/dist/get-context/get-groups/version-group/index.js +67 -15
- package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +10 -20
- package/dist/get-context/get-groups/version-group/instance-group/index.js +49 -53
- package/dist/get-context/get-package-json-files/get-file-paths.js +2 -1
- package/dist/get-context/get-package-json-files/package-json-file/index.js +3 -2
- package/dist/get-context/get-package-json-files/package-json-file/instance.d.ts +2 -5
- package/dist/get-context/get-package-json-files/package-json-file/instance.js +3 -22
- package/dist/get-context/index.js +3 -8
- package/dist/lib/print-strings.d.ts +1 -0
- package/dist/lib/print-strings.js +7 -0
- package/package.json +2 -1
- package/dist/get-context/get-groups/get-semver-groups.d.ts +0 -4
- package/dist/get-context/get-groups/get-semver-groups.js +0 -46
- package/dist/get-context/get-groups/get-version-groups.d.ts +0 -4
- package/dist/get-context/get-groups/get-version-groups.js +0 -72
- package/dist/get-context/get-groups/semver-group/index.d.ts +0 -29
- package/dist/get-context/get-groups/semver-group/index.js +0 -56
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
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
2
|
exports.__esModule = true;
|
|
19
3
|
exports.fixMismatches = void 0;
|
|
20
4
|
var expect_more_1 = require("expect-more");
|
|
@@ -26,32 +10,25 @@ function fixMismatches(ctx) {
|
|
|
26
10
|
return;
|
|
27
11
|
// Set the correct version on each instance.
|
|
28
12
|
invalidGroups.forEach(function (instanceGroup) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
13
|
+
if (!instanceGroup.hasUnsupportedVersion()) {
|
|
14
|
+
var nextVersion_1 = instanceGroup.getExpectedVersion();
|
|
15
|
+
instanceGroup.instances.forEach(function (instance) {
|
|
16
|
+
return instance.setVersion(nextVersion_1);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
35
19
|
});
|
|
36
20
|
});
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
/** Remove eg `{"dependencies": {}, "devDependencies": {}}` */
|
|
22
|
+
ctx.packageJsonFiles.forEach(function (packageJsonFile) {
|
|
23
|
+
var contents = packageJsonFile.contents;
|
|
24
|
+
Object.keys(contents).forEach(function (key) {
|
|
25
|
+
var value = contents[key];
|
|
26
|
+
if ((0, expect_more_1.isObject)(value) &&
|
|
27
|
+
Object.values(value).every(expect_more_1.isUndefined)) {
|
|
28
|
+
delete contents[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
39
31
|
});
|
|
40
32
|
return ctx;
|
|
41
|
-
/** Remove eg { "dependencies": {}, "devDependencies": {} }` */
|
|
42
|
-
function removeEmptyObjects(parent) {
|
|
43
|
-
if ((0, expect_more_1.isObject)(parent)) {
|
|
44
|
-
Object.entries(parent).forEach(function (_a) {
|
|
45
|
-
var _b = __read(_a, 2), key = _b[0], child = _b[1];
|
|
46
|
-
if ((0, expect_more_1.isObject)(child) &&
|
|
47
|
-
((0, expect_more_1.isEmptyObject)(child) || Object.values(child).every(expect_more_1.isUndefined))) {
|
|
48
|
-
delete parent[key];
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
removeEmptyObjects(child);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
33
|
}
|
|
57
34
|
exports.fixMismatches = fixMismatches;
|
|
@@ -50,7 +50,6 @@ exports.lintSemverRanges = void 0;
|
|
|
50
50
|
var chalk_1 = __importDefault(require("chalk"));
|
|
51
51
|
var constants_1 = require("../constants");
|
|
52
52
|
var log = __importStar(require("../lib/log"));
|
|
53
|
-
var set_semver_range_1 = require("../lib/set-semver-range");
|
|
54
53
|
function lintSemverRanges(ctx) {
|
|
55
54
|
ctx.semverGroups.reverse().forEach(function (semverGroup, i) {
|
|
56
55
|
// Nothing to do if there are no mismatches
|
|
@@ -69,9 +68,7 @@ function lintSemverRanges(ctx) {
|
|
|
69
68
|
log.invalid(name);
|
|
70
69
|
// Log each of the dependencies mismatches
|
|
71
70
|
mismatches.forEach(function (instance) {
|
|
72
|
-
|
|
73
|
-
logSemverRangeMismatch(instance, semverGroup);
|
|
74
|
-
}
|
|
71
|
+
logSemverRangeMismatch(instance, semverGroup);
|
|
75
72
|
});
|
|
76
73
|
});
|
|
77
74
|
});
|
|
@@ -82,7 +79,7 @@ function logSemverRangeMismatch(instance, semverGroup) {
|
|
|
82
79
|
var path = instance.pathDef.path;
|
|
83
80
|
var shortPath = instance.packageJsonFile.shortPath;
|
|
84
81
|
var actual = instance.version;
|
|
85
|
-
var expected =
|
|
82
|
+
var expected = semverGroup.getExpectedVersion(instance);
|
|
86
83
|
console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject([" {red ", "} ", " {green ", "} {dim in ", " of ", "}"], [" {red ", "} ", " {green ", "} {dim in ", " of ", "}"])), actual, constants_1.ICON.rightArrow, expected, path, shortPath));
|
|
87
84
|
}
|
|
88
85
|
var templateObject_1;
|
package/dist/bin-list/list.js
CHANGED
|
@@ -39,30 +39,36 @@ function list(ctx) {
|
|
|
39
39
|
// Annotate user-defined version groups
|
|
40
40
|
if (!versionGroup.isDefault)
|
|
41
41
|
log.versionGroupHeader(i);
|
|
42
|
-
versionGroup.
|
|
43
|
-
var expected = instanceGroup.getExpectedVersion();
|
|
44
|
-
var uniques = instanceGroup.uniques;
|
|
42
|
+
versionGroup.getAllInstanceGroups().forEach(function (instanceGroup) {
|
|
45
43
|
// Record that this project has mismatches, so that eg. the CLI can exit
|
|
46
44
|
// with the correct status code.
|
|
47
|
-
if (instanceGroup.isInvalid)
|
|
45
|
+
if (instanceGroup.isInvalid())
|
|
48
46
|
ctx.isInvalid = true;
|
|
49
|
-
versionGroup.isBanned
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
if (versionGroup.isBanned())
|
|
48
|
+
return logBanned(instanceGroup);
|
|
49
|
+
if (versionGroup.isIgnored())
|
|
50
|
+
return logIgnored(instanceGroup);
|
|
51
|
+
if (versionGroup.isUnpinned())
|
|
52
|
+
return logUnpinned(instanceGroup);
|
|
53
|
+
if (instanceGroup.hasMismatchingVersions()) {
|
|
54
|
+
return instanceGroup.hasUnsupportedVersion()
|
|
55
|
+
? logUnsupportedMismatches(instanceGroup)
|
|
56
|
+
: logVersionMismatch(instanceGroup);
|
|
57
|
+
}
|
|
58
|
+
logVersionMatch(instanceGroup);
|
|
56
59
|
});
|
|
57
60
|
});
|
|
58
61
|
return ctx;
|
|
59
|
-
function logVersionMatch(instanceGroup
|
|
60
|
-
console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim -} {white ", "} {dim ", "}"], ["{dim -} {white ", "} {dim ", "}"])), instanceGroup.name,
|
|
62
|
+
function logVersionMatch(instanceGroup) {
|
|
63
|
+
console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim -} {white ", "} {dim ", "}"], ["{dim -} {white ", "} {dim ", "}"])), instanceGroup.name, instanceGroup.getUniqueVersions()));
|
|
61
64
|
}
|
|
62
|
-
function logVersionMismatch(instanceGroup
|
|
63
|
-
console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{red ", " ", "} ", ""], ["{red ", " ", "} ", ""])), constants_1.ICON.cross, instanceGroup.name,
|
|
65
|
+
function logVersionMismatch(instanceGroup) {
|
|
66
|
+
console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{red ", " ", "} ", ""], ["{red ", " ", "} ", ""])), constants_1.ICON.cross, instanceGroup.name, instanceGroup
|
|
67
|
+
.getUniqueVersions()
|
|
64
68
|
.map(function (version) {
|
|
65
|
-
return version ===
|
|
69
|
+
return version === instanceGroup.getExpectedVersion()
|
|
70
|
+
? chalk_1["default"].green(version)
|
|
71
|
+
: chalk_1["default"].red(version);
|
|
66
72
|
})
|
|
67
73
|
.join(chalk_1["default"].dim(', '))));
|
|
68
74
|
}
|
|
@@ -72,6 +78,16 @@ function list(ctx) {
|
|
|
72
78
|
function logBanned(instanceGroup) {
|
|
73
79
|
console.log((0, chalk_1["default"])(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{red ", " ", "} {dim.red is banned in this version group}"], ["{red ", " ", "} {dim.red is banned in this version group}"])), constants_1.ICON.cross, instanceGroup.name));
|
|
74
80
|
}
|
|
81
|
+
function logUnpinned(instanceGroup) {
|
|
82
|
+
var pinVersion = instanceGroup.versionGroup.getPinnedVersion();
|
|
83
|
+
console.log((0, chalk_1["default"])(templateObject_5 || (templateObject_5 = __makeTemplateObject(["{red ", " ", "} {dim.red is pinned to ", " in this version group}"], ["{red ", " ", "} {dim.red is pinned to ", " in this version group}"])), constants_1.ICON.cross, instanceGroup.name, pinVersion));
|
|
84
|
+
}
|
|
85
|
+
function logUnsupportedMismatches(instanceGroup) {
|
|
86
|
+
console.log((0, chalk_1["default"])(templateObject_6 || (templateObject_6 = __makeTemplateObject(["{red ", " ", "} {dim.red has mismatched versions which syncpack cannot fix: ", "}"], ["{red ", " ", "} {dim.red has mismatched versions which syncpack cannot fix: ", "}"])), constants_1.ICON.cross, instanceGroup.name, instanceGroup
|
|
87
|
+
.getUniqueVersions()
|
|
88
|
+
.map(function (version) { return chalk_1["default"].yellow(version); })
|
|
89
|
+
.join(chalk_1["default"].dim(', '))));
|
|
90
|
+
}
|
|
75
91
|
}
|
|
76
92
|
exports.list = list;
|
|
77
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
93
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -47,46 +47,69 @@ function listMismatches(ctx) {
|
|
|
47
47
|
log.versionGroupHeader(i);
|
|
48
48
|
// Log the mismatches
|
|
49
49
|
invalidGroups.forEach(function (instanceGroup) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
|
|
50
|
+
if (versionGroup.isBanned())
|
|
51
|
+
return logBanned(instanceGroup);
|
|
52
|
+
if (versionGroup.isUnpinned())
|
|
53
|
+
return logUnpinned(instanceGroup);
|
|
54
|
+
if (instanceGroup.hasUnsupportedVersion())
|
|
55
|
+
return logUnsupportedMismatches(instanceGroup);
|
|
56
|
+
if (instanceGroup.hasWorkspaceInstance()) {
|
|
57
|
+
return logWorkspaceMismatch(instanceGroup);
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
logPinVersionMismatch(name, versionGroup);
|
|
61
|
-
}
|
|
62
|
-
else if (workspaceInstance) {
|
|
63
|
-
logWorkspaceMismatch(workspaceInstance, expected, name);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
logHighestVersionMismatch(expected, name);
|
|
67
|
-
}
|
|
68
|
-
// Log each of the dependencies mismatches
|
|
69
|
-
instanceGroup.instances.forEach(function (instance) {
|
|
70
|
-
if (instance.version !== expected) {
|
|
71
|
-
logVersionMismatch(instance);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
59
|
+
logHighestVersionMismatch(instanceGroup);
|
|
74
60
|
});
|
|
75
61
|
});
|
|
76
62
|
return ctx;
|
|
77
|
-
function logBanned(
|
|
63
|
+
function logBanned(instanceGroup) {
|
|
64
|
+
var name = instanceGroup.name;
|
|
78
65
|
log.invalid(name, 'is banned in this version group');
|
|
66
|
+
// Log each of the dependencies mismatches
|
|
67
|
+
instanceGroup.instances.forEach(function (instance) {
|
|
68
|
+
logVersionMismatch(instance);
|
|
69
|
+
});
|
|
79
70
|
}
|
|
80
|
-
function
|
|
81
|
-
var
|
|
71
|
+
function logUnsupportedMismatches(instanceGroup) {
|
|
72
|
+
var name = instanceGroup.name;
|
|
73
|
+
log.invalid(name, 'has mismatched versions which syncpack cannot fix');
|
|
74
|
+
// Log each of the dependencies mismatches
|
|
75
|
+
instanceGroup.instances.forEach(function (instance) {
|
|
76
|
+
logUnsupportedVersionMismatch(instance);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function logUnpinned(instanceGroup) {
|
|
80
|
+
var name = instanceGroup.name;
|
|
81
|
+
var pinVersion = instanceGroup.versionGroup.getPinnedVersion();
|
|
82
82
|
log.invalid(name, (0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["is pinned in this version group at {reset.green ", "}"], ["is pinned in this version group at {reset.green ", "}"])), pinVersion));
|
|
83
|
+
// Log each of the dependencies mismatches
|
|
84
|
+
instanceGroup.instances.forEach(function (instance) {
|
|
85
|
+
if (instance.version !== pinVersion) {
|
|
86
|
+
logVersionMismatch(instance);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
83
89
|
}
|
|
84
|
-
function logWorkspaceMismatch(
|
|
85
|
-
var
|
|
90
|
+
function logWorkspaceMismatch(instanceGroup) {
|
|
91
|
+
var name = instanceGroup.name;
|
|
92
|
+
var workspaceInstance = instanceGroup.getWorkspaceInstance();
|
|
93
|
+
var shortPath = workspaceInstance === null || workspaceInstance === void 0 ? void 0 : workspaceInstance.packageJsonFile.shortPath;
|
|
94
|
+
var expected = instanceGroup.getExpectedVersion();
|
|
86
95
|
log.invalid(name, (0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{reset.green ", "} {dim is developed in this repo at ", "}"], ["{reset.green ", "} {dim is developed in this repo at ", "}"])), expected, shortPath));
|
|
96
|
+
// Log each of the dependencies mismatches
|
|
97
|
+
instanceGroup.instances.forEach(function (instance) {
|
|
98
|
+
if (instance.version !== expected) {
|
|
99
|
+
logVersionMismatch(instance);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
87
102
|
}
|
|
88
|
-
function logHighestVersionMismatch(
|
|
103
|
+
function logHighestVersionMismatch(instanceGroup) {
|
|
104
|
+
var name = instanceGroup.name;
|
|
105
|
+
var expected = instanceGroup.getExpectedVersion();
|
|
89
106
|
log.invalid(name, (0, chalk_1["default"])(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{reset.green ", "} {dim is the highest valid semver version in use}"], ["{reset.green ", "} {dim is the highest valid semver version in use}"])), expected));
|
|
107
|
+
// Log each of the dependencies mismatches
|
|
108
|
+
instanceGroup.instances.forEach(function (instance) {
|
|
109
|
+
if (instance.version !== expected) {
|
|
110
|
+
logVersionMismatch(instance);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
90
113
|
}
|
|
91
114
|
function logVersionMismatch(instance) {
|
|
92
115
|
var type = instance.pathDef.path;
|
|
@@ -94,6 +117,12 @@ function listMismatches(ctx) {
|
|
|
94
117
|
var actual = instance.version;
|
|
95
118
|
console.log((0, chalk_1["default"])(templateObject_4 || (templateObject_4 = __makeTemplateObject([" {red ", "} {dim in ", " of ", "}"], [" {red ", "} {dim in ", " of ", "}"])), actual, type, shortPath));
|
|
96
119
|
}
|
|
120
|
+
function logUnsupportedVersionMismatch(instance) {
|
|
121
|
+
var type = instance.pathDef.path;
|
|
122
|
+
var shortPath = instance.packageJsonFile.shortPath;
|
|
123
|
+
var actual = instance.version;
|
|
124
|
+
console.log((0, chalk_1["default"])(templateObject_5 || (templateObject_5 = __makeTemplateObject([" {yellow ", "} {dim in ", " of ", "}"], [" {yellow ", "} {dim in ", " of ", "}"])), actual, type, shortPath));
|
|
125
|
+
}
|
|
97
126
|
}
|
|
98
127
|
exports.listMismatches = listMismatches;
|
|
99
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
128
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -4,7 +4,7 @@ exports.setSemverRanges = void 0;
|
|
|
4
4
|
var setSemverRanges = function (ctx) {
|
|
5
5
|
ctx.semverGroups.reverse().forEach(function (semverGroup) {
|
|
6
6
|
semverGroup.instances.forEach(function (instance) {
|
|
7
|
-
instance.
|
|
7
|
+
instance.setVersion(semverGroup.getExpectedVersion(instance));
|
|
8
8
|
});
|
|
9
9
|
});
|
|
10
10
|
return ctx;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Syncpack } from '../../types';
|
|
2
|
+
import type { Instance } from '../get-package-json-files/package-json-file/instance';
|
|
3
|
+
export declare class BaseGroup<T extends Syncpack.Config.SemverGroup.Any | Syncpack.Config.VersionGroup.Any> {
|
|
4
|
+
/** Full config for this run of syncpack */
|
|
5
|
+
syncpackConfig: Syncpack.Config.Private;
|
|
6
|
+
/** The original config which created this `SemverGroup` */
|
|
7
|
+
groupConfig: T;
|
|
8
|
+
/** Instances which belong to this group */
|
|
9
|
+
instances: Instance[];
|
|
10
|
+
/** Instances which belong to this group, keyed by their .name property */
|
|
11
|
+
instancesByName: Record<string, Instance[]>;
|
|
12
|
+
/** Is this the catch-all group, not defined by the user? */
|
|
13
|
+
isDefault: boolean;
|
|
14
|
+
constructor(config: Syncpack.Config.Private, group: T);
|
|
15
|
+
/** Can this instance be added to this group? */
|
|
16
|
+
canAdd(instance: Instance): boolean;
|
|
17
|
+
/** Add this instance to this group */
|
|
18
|
+
add(instance: Instance): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.BaseGroup = void 0;
|
|
7
|
+
var expect_more_1 = require("expect-more");
|
|
8
|
+
var minimatch_1 = __importDefault(require("minimatch"));
|
|
9
|
+
var BaseGroup = /** @class */ (function () {
|
|
10
|
+
function BaseGroup(config, group) {
|
|
11
|
+
this.groupConfig = group;
|
|
12
|
+
this.instances = [];
|
|
13
|
+
this.instancesByName = {};
|
|
14
|
+
this.isDefault =
|
|
15
|
+
group === config.defaultSemverGroup ||
|
|
16
|
+
group === config.defaultVersionGroup;
|
|
17
|
+
this.syncpackConfig = config;
|
|
18
|
+
}
|
|
19
|
+
/** Can this instance be added to this group? */
|
|
20
|
+
BaseGroup.prototype.canAdd = function (instance) {
|
|
21
|
+
var _a = this.groupConfig, dependencies = _a.dependencies, dependencyTypes = _a.dependencyTypes, packages = _a.packages;
|
|
22
|
+
return ((!(0, expect_more_1.isNonEmptyArray)(dependencyTypes) ||
|
|
23
|
+
dependencyTypes.includes(instance.pathDef.name)) &&
|
|
24
|
+
(!(0, expect_more_1.isNonEmptyArray)(packages) ||
|
|
25
|
+
packages.some(function (pattern) { return (0, minimatch_1["default"])(instance.pkgName, pattern); })) &&
|
|
26
|
+
(!(0, expect_more_1.isNonEmptyArray)(dependencies) ||
|
|
27
|
+
dependencies.some(function (pattern) { return (0, minimatch_1["default"])(instance.name, pattern); })));
|
|
28
|
+
};
|
|
29
|
+
/** Add this instance to this group */
|
|
30
|
+
BaseGroup.prototype.add = function (instance) {
|
|
31
|
+
var _a;
|
|
32
|
+
if (!this.instancesByName[instance.name]) {
|
|
33
|
+
this.instancesByName[instance.name] = [];
|
|
34
|
+
}
|
|
35
|
+
(_a = this.instancesByName[instance.name]) === null || _a === void 0 ? void 0 : _a.push(instance);
|
|
36
|
+
this.instances.push(instance);
|
|
37
|
+
};
|
|
38
|
+
return BaseGroup;
|
|
39
|
+
}());
|
|
40
|
+
exports.BaseGroup = BaseGroup;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Syncpack } from '../../types';
|
|
2
|
+
import type { Instance } from '../get-package-json-files/package-json-file/instance';
|
|
3
|
+
import { SemverGroup } from './semver-group';
|
|
4
|
+
import { VersionGroup } from './version-group';
|
|
5
|
+
export declare function getGroups(config: Syncpack.Config.Private, instances: Instance[]): {
|
|
6
|
+
semverGroups: SemverGroup[];
|
|
7
|
+
versionGroups: VersionGroup[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
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;
|
|
14
|
+
exports.getGroups = void 0;
|
|
15
|
+
var semver_group_1 = require("./semver-group");
|
|
16
|
+
var version_group_1 = require("./version-group");
|
|
17
|
+
function getGroups(config, instances) {
|
|
18
|
+
var groupsByName = {
|
|
19
|
+
semverGroups: config.semverGroups.map(function (group) { return new semver_group_1.SemverGroup(config, group); }),
|
|
20
|
+
versionGroups: config.versionGroups.map(function (group) { return new version_group_1.VersionGroup(config, group); })
|
|
21
|
+
};
|
|
22
|
+
instances.forEach(function (instance) {
|
|
23
|
+
var name = instance.name, pkgName = instance.pkgName;
|
|
24
|
+
Object.keys(groupsByName).forEach(function (key) {
|
|
25
|
+
var e_1, _a;
|
|
26
|
+
try {
|
|
27
|
+
for (var _b = __values(groupsByName[key]), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
28
|
+
var group = _c.value;
|
|
29
|
+
if (group.canAdd(instance)) {
|
|
30
|
+
group.add(instance);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36
|
+
finally {
|
|
37
|
+
try {
|
|
38
|
+
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
|
|
39
|
+
}
|
|
40
|
+
finally { if (e_1) throw e_1.error; }
|
|
41
|
+
}
|
|
42
|
+
throw new Error("".concat(name, " in ").concat(pkgName, " did not match any ").concat(key));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return groupsByName;
|
|
46
|
+
}
|
|
47
|
+
exports.getGroups = getGroups;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Syncpack } from '../../types';
|
|
2
|
+
import type { Instance } from '../get-package-json-files/package-json-file/instance';
|
|
3
|
+
import { BaseGroup } from './base-group';
|
|
4
|
+
type MismatchesByName = [string, Instance[]];
|
|
5
|
+
export declare class SemverGroup extends BaseGroup<Syncpack.Config.SemverGroup.Any> {
|
|
6
|
+
constructor(config: Syncpack.Config.Private, semverGroup: Syncpack.Config.SemverGroup.Any);
|
|
7
|
+
getExpectedVersion(instance: Instance): string;
|
|
8
|
+
/** Does this `Instance` have a version which does not follow the rules? */
|
|
9
|
+
isMismatch(instance: Instance): boolean;
|
|
10
|
+
/** 1+ `Instance` has a version which does not follow the rules */
|
|
11
|
+
hasMismatches(): boolean;
|
|
12
|
+
isIgnored(): boolean;
|
|
13
|
+
/** Get every `Instance` with a version which does not follow the rules */
|
|
14
|
+
getMismatches(): MismatchesByName[];
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
18
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
+
if (!m) return o;
|
|
20
|
+
var i = m.call(o), r, ar = [], e;
|
|
21
|
+
try {
|
|
22
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
23
|
+
}
|
|
24
|
+
catch (error) { e = { error: error }; }
|
|
25
|
+
finally {
|
|
26
|
+
try {
|
|
27
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
28
|
+
}
|
|
29
|
+
finally { if (e) throw e.error; }
|
|
30
|
+
}
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
exports.__esModule = true;
|
|
34
|
+
exports.SemverGroup = void 0;
|
|
35
|
+
var is_semver_1 = require("../../lib/is-semver");
|
|
36
|
+
var set_semver_range_1 = require("../../lib/set-semver-range");
|
|
37
|
+
var base_group_1 = require("./base-group");
|
|
38
|
+
var SemverGroup = /** @class */ (function (_super) {
|
|
39
|
+
__extends(SemverGroup, _super);
|
|
40
|
+
function SemverGroup(config, semverGroup) {
|
|
41
|
+
return _super.call(this, config, semverGroup) || this;
|
|
42
|
+
}
|
|
43
|
+
SemverGroup.prototype.getExpectedVersion = function (instance) {
|
|
44
|
+
var version = instance.version;
|
|
45
|
+
// leave ignored versions alone
|
|
46
|
+
if (this.isIgnored())
|
|
47
|
+
return version;
|
|
48
|
+
// leave unsupported versions alone
|
|
49
|
+
if (!(0, is_semver_1.isSemver)(version))
|
|
50
|
+
return version;
|
|
51
|
+
// version property of package.json must always be exact
|
|
52
|
+
if (instance.isWorkspace())
|
|
53
|
+
return (0, set_semver_range_1.setSemverRange)('', version);
|
|
54
|
+
// otherwise we can change it
|
|
55
|
+
var range = this.groupConfig.range;
|
|
56
|
+
return (0, set_semver_range_1.setSemverRange)(range, version);
|
|
57
|
+
};
|
|
58
|
+
/** Does this `Instance` have a version which does not follow the rules? */
|
|
59
|
+
SemverGroup.prototype.isMismatch = function (instance) {
|
|
60
|
+
return instance.version !== this.getExpectedVersion(instance);
|
|
61
|
+
};
|
|
62
|
+
/** 1+ `Instance` has a version which does not follow the rules */
|
|
63
|
+
SemverGroup.prototype.hasMismatches = function () {
|
|
64
|
+
return this.getMismatches().length > 0;
|
|
65
|
+
};
|
|
66
|
+
SemverGroup.prototype.isIgnored = function () {
|
|
67
|
+
return this.groupConfig.isIgnored === true;
|
|
68
|
+
};
|
|
69
|
+
/** Get every `Instance` with a version which does not follow the rules */
|
|
70
|
+
SemverGroup.prototype.getMismatches = function () {
|
|
71
|
+
var _this = this;
|
|
72
|
+
return this.isIgnored()
|
|
73
|
+
? []
|
|
74
|
+
: Object.entries(this.instancesByName)
|
|
75
|
+
.map(function (_a) {
|
|
76
|
+
var _b = __read(_a, 2), name = _b[0], instances = _b[1];
|
|
77
|
+
return [
|
|
78
|
+
name,
|
|
79
|
+
instances.filter(function (instance) { return _this.isMismatch(instance); }),
|
|
80
|
+
];
|
|
81
|
+
})
|
|
82
|
+
.filter(function (_a) {
|
|
83
|
+
var _b = __read(_a, 2), arr = _b[1];
|
|
84
|
+
return arr.length > 0;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
return SemverGroup;
|
|
88
|
+
}(base_group_1.BaseGroup));
|
|
89
|
+
exports.SemverGroup = SemverGroup;
|
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
import type { Syncpack } from '../../../types';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export declare class VersionGroup {
|
|
5
|
-
|
|
6
|
-
dependencies: string[];
|
|
7
|
-
/** Optionally limit this group to dependencies at these named paths */
|
|
8
|
-
dependencyTypes: Syncpack.TypeName[];
|
|
9
|
-
/** */
|
|
10
|
-
input: Syncpack.Config.Private;
|
|
11
|
-
/** */
|
|
12
|
-
instanceGroups: InstanceGroup[];
|
|
13
|
-
/** */
|
|
14
|
-
instances: Instance[];
|
|
15
|
-
/** */
|
|
16
|
-
instancesByName: Record<string, Instance[]>;
|
|
17
|
-
/** */
|
|
18
|
-
isBanned: boolean;
|
|
19
|
-
/** */
|
|
20
|
-
isDefault: boolean;
|
|
21
|
-
/** */
|
|
22
|
-
isIgnored: boolean;
|
|
23
|
-
/** */
|
|
24
|
-
packages: string[];
|
|
25
|
-
/** Optionally force all dependencies in this group to have this version */
|
|
26
|
-
pinVersion?: string;
|
|
27
|
-
constructor(input: Syncpack.Config.Private, versionGroup: Syncpack.Config.VersionGroup.Any);
|
|
2
|
+
import { BaseGroup } from '../base-group';
|
|
3
|
+
import { InstanceGroup } from './instance-group';
|
|
4
|
+
export declare class VersionGroup extends BaseGroup<Syncpack.Config.VersionGroup.Any> {
|
|
5
|
+
getAllInstanceGroups(): InstanceGroup[];
|
|
28
6
|
getInvalidInstanceGroups(): InstanceGroup[];
|
|
7
|
+
isBanned(): boolean;
|
|
8
|
+
isIgnored(): boolean;
|
|
9
|
+
hasPinnedVersion(): boolean;
|
|
10
|
+
getPinnedVersion(): string;
|
|
11
|
+
isUnpinned(): boolean;
|
|
29
12
|
}
|
|
@@ -1,23 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
18
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
+
if (!m) return o;
|
|
20
|
+
var i = m.call(o), r, ar = [], e;
|
|
21
|
+
try {
|
|
22
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
23
|
+
}
|
|
24
|
+
catch (error) { e = { error: error }; }
|
|
25
|
+
finally {
|
|
26
|
+
try {
|
|
27
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
28
|
+
}
|
|
29
|
+
finally { if (e) throw e.error; }
|
|
30
|
+
}
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
2
33
|
exports.__esModule = true;
|
|
3
34
|
exports.VersionGroup = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this
|
|
11
|
-
this.instancesByName = {};
|
|
12
|
-
this.isBanned = versionGroup.isBanned === true;
|
|
13
|
-
this.isDefault = versionGroup === input.defaultVersionGroup;
|
|
14
|
-
this.isIgnored = versionGroup.isIgnored === true;
|
|
15
|
-
this.packages = versionGroup.packages;
|
|
16
|
-
this.pinVersion = versionGroup.pinVersion;
|
|
35
|
+
var expect_more_1 = require("expect-more");
|
|
36
|
+
var base_group_1 = require("../base-group");
|
|
37
|
+
var instance_group_1 = require("./instance-group");
|
|
38
|
+
var VersionGroup = /** @class */ (function (_super) {
|
|
39
|
+
__extends(VersionGroup, _super);
|
|
40
|
+
function VersionGroup() {
|
|
41
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
17
42
|
}
|
|
43
|
+
VersionGroup.prototype.getAllInstanceGroups = function () {
|
|
44
|
+
var _this = this;
|
|
45
|
+
return Object.entries(this.instancesByName).map(function (_a) {
|
|
46
|
+
var _b = __read(_a, 2), name = _b[0], instances = _b[1];
|
|
47
|
+
return new instance_group_1.InstanceGroup(_this, name, instances);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
18
50
|
VersionGroup.prototype.getInvalidInstanceGroups = function () {
|
|
19
|
-
return this.
|
|
51
|
+
return this.getAllInstanceGroups().filter(function (group) { return group.isInvalid(); });
|
|
52
|
+
};
|
|
53
|
+
VersionGroup.prototype.isBanned = function () {
|
|
54
|
+
return this.groupConfig.isBanned === true;
|
|
55
|
+
};
|
|
56
|
+
VersionGroup.prototype.isIgnored = function () {
|
|
57
|
+
return this.groupConfig.isIgnored === true;
|
|
58
|
+
};
|
|
59
|
+
VersionGroup.prototype.hasPinnedVersion = function () {
|
|
60
|
+
return (0, expect_more_1.isNonEmptyString)(this.getPinnedVersion());
|
|
61
|
+
};
|
|
62
|
+
VersionGroup.prototype.getPinnedVersion = function () {
|
|
63
|
+
return this.groupConfig.pinVersion;
|
|
64
|
+
};
|
|
65
|
+
VersionGroup.prototype.isUnpinned = function () {
|
|
66
|
+
var pinVersion = this.groupConfig.pinVersion;
|
|
67
|
+
return ((0, expect_more_1.isNonEmptyString)(pinVersion) &&
|
|
68
|
+
this.instances.some(function (_a) {
|
|
69
|
+
var version = _a.version;
|
|
70
|
+
return version !== pinVersion;
|
|
71
|
+
}));
|
|
20
72
|
};
|
|
21
73
|
return VersionGroup;
|
|
22
|
-
}());
|
|
74
|
+
}(base_group_1.BaseGroup));
|
|
23
75
|
exports.VersionGroup = VersionGroup;
|