syncpack 10.2.0 → 10.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-fix-mismatches/fix-mismatches.js +1 -2
- package/dist/bin-list/list.js +7 -4
- package/dist/bin-list-mismatches/list-mismatches.js +7 -2
- package/dist/bin-prompt/index.d.ts +2 -0
- package/dist/bin-prompt/index.js +56 -0
- package/dist/bin-prompt/prompt-cli.d.ts +3 -0
- package/dist/bin-prompt/prompt-cli.js +50 -0
- package/dist/bin.js +3 -0
- package/dist/config/get-sort-az.js +1 -0
- package/dist/config/types.d.ts +7 -1
- package/dist/get-semver-groups/index.js +3 -6
- package/dist/get-version-groups/index.d.ts +3 -5
- package/dist/get-version-groups/index.js +13 -6
- package/dist/get-version-groups/same-range.d.ts +11 -0
- package/dist/get-version-groups/same-range.js +47 -0
- package/dist/lib/disk.d.ts +8 -1
- package/dist/lib/disk.js +16 -5
- package/dist/lib/split-name-and-version.d.ts +5 -0
- package/dist/lib/split-name-and-version.js +12 -0
- package/dist/strategy/named-version-string.js +1 -1
- package/package.json +18 -12
|
@@ -26,13 +26,12 @@ function fixMismatches(ctx) {
|
|
|
26
26
|
instance.setVersion(delete_1.DELETE);
|
|
27
27
|
break;
|
|
28
28
|
}
|
|
29
|
+
case 'SAME_RANGE_MISMATCH':
|
|
29
30
|
case 'UNSUPPORTED_MISMATCH': {
|
|
30
31
|
// @TODO Output something when fix-mismatches faces an unsupported mismatch
|
|
31
32
|
ctx.isInvalid = true;
|
|
32
33
|
break;
|
|
33
34
|
}
|
|
34
|
-
// @TODO case 'SEMVER_UNSATISFIED': break;
|
|
35
|
-
// @TODO case 'WORKSPACE_UNSATISFIED': break;
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
37
|
}
|
package/dist/bin-list/list.js
CHANGED
|
@@ -32,6 +32,8 @@ const uniq_1 = require("tightrope/array/uniq");
|
|
|
32
32
|
const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
|
|
33
33
|
const constants_1 = require("../constants");
|
|
34
34
|
const get_version_groups_1 = require("../get-version-groups");
|
|
35
|
+
const get_unique_versions_1 = require("../get-version-groups/lib/get-unique-versions");
|
|
36
|
+
const is_semver_1 = require("../lib/is-semver");
|
|
35
37
|
const log = __importStar(require("../lib/log"));
|
|
36
38
|
const sort_by_name_1 = require("../lib/sort-by-name");
|
|
37
39
|
function list(ctx) {
|
|
@@ -71,14 +73,15 @@ function list(ctx) {
|
|
|
71
73
|
console.log((0, chalk_1.default) `{dim -} {white %s} {dim %s}`, report.name, report.instances?.[0]?.version);
|
|
72
74
|
break;
|
|
73
75
|
}
|
|
76
|
+
case 'SAME_RANGE_MISMATCH':
|
|
74
77
|
case 'UNSUPPORTED_MISMATCH': {
|
|
75
|
-
console.log((0, chalk_1.default) `{red %s %s} %s`, constants_1.ICON.cross, report.name, report.instances
|
|
76
|
-
.map((
|
|
78
|
+
console.log((0, chalk_1.default) `{red %s %s} %s`, constants_1.ICON.cross, report.name, (0, get_unique_versions_1.getUniqueVersions)(report.instances)
|
|
79
|
+
.map((version) => (0, is_semver_1.isSupported)(version)
|
|
80
|
+
? chalk_1.default.red(version)
|
|
81
|
+
: chalk_1.default.yellow(version))
|
|
77
82
|
.join(chalk_1.default.dim(', ')));
|
|
78
83
|
break;
|
|
79
84
|
}
|
|
80
|
-
// @TODO case 'SEMVER_UNSATISFIED': break;
|
|
81
|
-
// @TODO case 'WORKSPACE_UNSATISFIED': break;
|
|
82
85
|
}
|
|
83
86
|
function listColouredVersions(pinVersion, instances) {
|
|
84
87
|
return getAllVersions(pinVersion, instances)
|
|
@@ -84,6 +84,13 @@ function listMismatches(ctx) {
|
|
|
84
84
|
});
|
|
85
85
|
break;
|
|
86
86
|
}
|
|
87
|
+
case 'SAME_RANGE_MISMATCH': {
|
|
88
|
+
console.log((0, chalk_1.default) `{red %s} %s {dim has mismatched semver range versions which syncpack cannot fix}`, constants_1.ICON.cross, report.name);
|
|
89
|
+
report.instances.forEach((instance) => {
|
|
90
|
+
console.log((0, chalk_1.default) ` {yellow %s} {dim in %s of %s}`, instance.version, instance.strategy.path, instance.packageJsonFile.shortPath);
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
87
94
|
case 'UNSUPPORTED_MISMATCH': {
|
|
88
95
|
console.log((0, chalk_1.default) `{red %s} %s {dim has mismatched versions which syncpack cannot fix}`, constants_1.ICON.cross, report.name);
|
|
89
96
|
report.instances.forEach((instance) => {
|
|
@@ -100,8 +107,6 @@ function listMismatches(ctx) {
|
|
|
100
107
|
});
|
|
101
108
|
break;
|
|
102
109
|
}
|
|
103
|
-
// @TODO case 'SEMVER_UNSATISFIED': break;
|
|
104
|
-
// @TODO case 'WORKSPACE_UNSATISFIED': break;
|
|
105
110
|
}
|
|
106
111
|
});
|
|
107
112
|
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const disk_1 = require("../lib/disk");
|
|
10
|
+
const show_help_on_error_1 = require("../lib/show-help-on-error");
|
|
11
|
+
const option_1 = require("../option");
|
|
12
|
+
const prompt_cli_1 = require("./prompt-cli");
|
|
13
|
+
commander_1.program.description(' displays a series of prompts to fix mismatches which syncpack cannot fix automatically');
|
|
14
|
+
commander_1.program.on('--help', () => {
|
|
15
|
+
console.log((0, chalk_1.default) `
|
|
16
|
+
Examples:
|
|
17
|
+
{dim # uses defaults for resolving packages}
|
|
18
|
+
syncpack prompt
|
|
19
|
+
{dim # uses packages defined by --source when provided}
|
|
20
|
+
syncpack prompt --source {yellow "apps/*/package.json"}
|
|
21
|
+
{dim # multiple globs can be provided like this}
|
|
22
|
+
syncpack prompt --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
|
|
23
|
+
{dim # uses dependencies regular expression defined by --filter when provided}
|
|
24
|
+
syncpack prompt --filter {yellow "typescript|tslint"}
|
|
25
|
+
{dim # only inspect "devDependencies"}
|
|
26
|
+
syncpack prompt --types dev
|
|
27
|
+
{dim # only inspect "devDependencies" and "peerDependencies"}
|
|
28
|
+
syncpack prompt --types dev,peer
|
|
29
|
+
|
|
30
|
+
Resolving Packages:
|
|
31
|
+
1. If {yellow --source} globs are provided, use those.
|
|
32
|
+
2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
33
|
+
3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
34
|
+
4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
35
|
+
5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
36
|
+
|
|
37
|
+
Reference:
|
|
38
|
+
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
39
|
+
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
40
|
+
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
41
|
+
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
42
|
+
`);
|
|
43
|
+
});
|
|
44
|
+
(0, show_help_on_error_1.showHelpOnError)(commander_1.program);
|
|
45
|
+
commander_1.program
|
|
46
|
+
.option(...option_1.option.source)
|
|
47
|
+
.option(...option_1.option.filter)
|
|
48
|
+
.option(...option_1.option.config)
|
|
49
|
+
.option(...option_1.option.types)
|
|
50
|
+
.parse(process.argv);
|
|
51
|
+
(0, prompt_cli_1.promptCli)({
|
|
52
|
+
configPath: commander_1.program.opts().config,
|
|
53
|
+
filter: commander_1.program.opts().filter,
|
|
54
|
+
source: commander_1.program.opts().source,
|
|
55
|
+
types: commander_1.program.opts().types,
|
|
56
|
+
}, disk_1.disk);
|
|
@@ -0,0 +1,50 @@
|
|
|
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.promptCli = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const get_context_1 = require("../get-context");
|
|
9
|
+
const get_version_groups_1 = require("../get-version-groups");
|
|
10
|
+
const get_unique_versions_1 = require("../get-version-groups/lib/get-unique-versions");
|
|
11
|
+
const sort_by_name_1 = require("../lib/sort-by-name");
|
|
12
|
+
const write_if_changed_1 = require("../lib/write-if-changed");
|
|
13
|
+
async function promptCli(input, disk) {
|
|
14
|
+
const ctx = (0, get_context_1.getContext)(input, disk);
|
|
15
|
+
const versionGroups = (0, get_version_groups_1.getVersionGroups)(ctx);
|
|
16
|
+
for (const versionGroup of versionGroups) {
|
|
17
|
+
const reports = versionGroup.inspect().sort(sort_by_name_1.sortByName);
|
|
18
|
+
for (const report of reports) {
|
|
19
|
+
switch (report.status) {
|
|
20
|
+
case 'SAME_RANGE_MISMATCH':
|
|
21
|
+
case 'UNSUPPORTED_MISMATCH': {
|
|
22
|
+
const OTHER = chalk_1.default.dim('Other');
|
|
23
|
+
const SKIP = chalk_1.default.dim('Skip this dependency');
|
|
24
|
+
const chosenVersion = await disk.askForChoice({
|
|
25
|
+
message: (0, chalk_1.default) `${report.name} {dim Choose a version to replace the others}`,
|
|
26
|
+
choices: [...(0, get_unique_versions_1.getUniqueVersions)(report.instances), OTHER, SKIP],
|
|
27
|
+
});
|
|
28
|
+
if (chosenVersion === SKIP) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
else if (chosenVersion === OTHER) {
|
|
32
|
+
const newVersion = await disk.askForInput({
|
|
33
|
+
message: (0, chalk_1.default) `${report.name} {dim Enter a new version to replace the others}`,
|
|
34
|
+
});
|
|
35
|
+
report.instances.forEach((instance) => {
|
|
36
|
+
instance.setVersion(newVersion);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
report.instances.forEach((instance) => {
|
|
41
|
+
instance.setVersion(chosenVersion);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
(0, write_if_changed_1.writeIfChanged)(ctx);
|
|
49
|
+
}
|
|
50
|
+
exports.promptCli = promptCli;
|
package/dist/bin.js
CHANGED
|
@@ -22,6 +22,9 @@ commander_1.program
|
|
|
22
22
|
.command('list', 'list every dependency used in your packages', {
|
|
23
23
|
executableFile: './bin-list/index.js',
|
|
24
24
|
isDefault: true,
|
|
25
|
+
})
|
|
26
|
+
.command('prompt', 'fix mismatches which syncpack cannot fix automatically', {
|
|
27
|
+
executableFile: './bin-prompt/index.js',
|
|
25
28
|
})
|
|
26
29
|
.command('set-semver-ranges', 'set semver ranges to the given format', {
|
|
27
30
|
executableFile: './bin-set-semver-ranges/index.js',
|
package/dist/config/types.d.ts
CHANGED
|
@@ -48,10 +48,16 @@ export declare namespace VersionGroupConfig {
|
|
|
48
48
|
interface SnappedTo extends GroupConfig {
|
|
49
49
|
snapTo: string[];
|
|
50
50
|
}
|
|
51
|
+
interface SameRange extends GroupConfig {
|
|
52
|
+
policy: 'sameRange';
|
|
53
|
+
}
|
|
54
|
+
interface SnappedTo extends GroupConfig {
|
|
55
|
+
snapTo: string[];
|
|
56
|
+
}
|
|
51
57
|
interface Standard extends GroupConfig {
|
|
52
58
|
preferVersion?: 'highestSemver' | 'lowestSemver';
|
|
53
59
|
}
|
|
54
|
-
type Any = Union.Strict<
|
|
60
|
+
type Any = Union.Strict<Banned | Ignored | Pinned | SameRange | SnappedTo | Standard>;
|
|
55
61
|
}
|
|
56
62
|
declare namespace CustomTypeConfig {
|
|
57
63
|
interface NameAndVersionProps {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getSemverGroups = void 0;
|
|
7
|
-
const minimatch_1 =
|
|
4
|
+
const minimatch_1 = require("minimatch");
|
|
8
5
|
const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
|
|
9
6
|
const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
|
|
10
7
|
const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
|
|
@@ -28,9 +25,9 @@ function getSemverGroups(ctx) {
|
|
|
28
25
|
(!(0, is_non_empty_array_1.isNonEmptyArray)(dependencyTypes) ||
|
|
29
26
|
dependencyTypes.includes(instance.strategy.name)) &&
|
|
30
27
|
(!(0, is_non_empty_array_1.isNonEmptyArray)(packages) ||
|
|
31
|
-
packages.some((pattern) => (0, minimatch_1.
|
|
28
|
+
packages.some((pattern) => (0, minimatch_1.minimatch)(instance.pkgName, pattern))) &&
|
|
32
29
|
(!(0, is_non_empty_array_1.isNonEmptyArray)(dependencies) ||
|
|
33
|
-
dependencies.some((pattern) => (0, minimatch_1.
|
|
30
|
+
dependencies.some((pattern) => (0, minimatch_1.minimatch)(instance.name, pattern)))) {
|
|
34
31
|
group.instances.push(instance);
|
|
35
32
|
return;
|
|
36
33
|
}
|
|
@@ -5,9 +5,10 @@ import { CatchAllVersionGroup } from './catch-all';
|
|
|
5
5
|
import { FilteredOutVersionGroup } from './filtered-out';
|
|
6
6
|
import { IgnoredVersionGroup } from './ignored';
|
|
7
7
|
import { PinnedVersionGroup } from './pinned';
|
|
8
|
+
import { SameRangeVersionGroup } from './same-range';
|
|
8
9
|
import { SnappedToVersionGroup } from './snapped-to';
|
|
9
10
|
import { StandardVersionGroup } from './standard';
|
|
10
|
-
export type AnyVersionGroup = BannedVersionGroup | CatchAllVersionGroup | FilteredOutVersionGroup | IgnoredVersionGroup | PinnedVersionGroup | SnappedToVersionGroup | StandardVersionGroup;
|
|
11
|
+
export type AnyVersionGroup = BannedVersionGroup | CatchAllVersionGroup | FilteredOutVersionGroup | IgnoredVersionGroup | PinnedVersionGroup | SameRangeVersionGroup | SnappedToVersionGroup | StandardVersionGroup;
|
|
11
12
|
export type VersionGroupReport = {
|
|
12
13
|
name: string;
|
|
13
14
|
instances: Instance[];
|
|
@@ -33,7 +34,7 @@ export type VersionGroupReport = {
|
|
|
33
34
|
isValid: false;
|
|
34
35
|
expectedVersion: string;
|
|
35
36
|
} | {
|
|
36
|
-
status: '
|
|
37
|
+
status: 'SAME_RANGE_MISMATCH';
|
|
37
38
|
isValid: false;
|
|
38
39
|
} | {
|
|
39
40
|
status: 'SNAPPED_TO_MISMATCH';
|
|
@@ -50,8 +51,5 @@ export type VersionGroupReport = {
|
|
|
50
51
|
isValid: false;
|
|
51
52
|
expectedVersion: string;
|
|
52
53
|
workspaceInstance: Instance;
|
|
53
|
-
} | {
|
|
54
|
-
status: 'WORKSPACE_UNSATISFIED';
|
|
55
|
-
isValid: false;
|
|
56
54
|
});
|
|
57
55
|
export declare function getVersionGroups(ctx: Context): AnyVersionGroup[];
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getVersionGroups = void 0;
|
|
7
|
-
const minimatch_1 =
|
|
4
|
+
const minimatch_1 = require("minimatch");
|
|
8
5
|
const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
|
|
9
6
|
const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
|
|
10
7
|
const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
|
|
@@ -15,6 +12,7 @@ const catch_all_1 = require("./catch-all");
|
|
|
15
12
|
const filtered_out_1 = require("./filtered-out");
|
|
16
13
|
const ignored_1 = require("./ignored");
|
|
17
14
|
const pinned_1 = require("./pinned");
|
|
15
|
+
const same_range_1 = require("./same-range");
|
|
18
16
|
const snapped_to_1 = require("./snapped-to");
|
|
19
17
|
const standard_1 = require("./standard");
|
|
20
18
|
function getVersionGroups(ctx) {
|
|
@@ -29,9 +27,9 @@ function getVersionGroups(ctx) {
|
|
|
29
27
|
(!(0, is_non_empty_array_1.isNonEmptyArray)(dependencyTypes) ||
|
|
30
28
|
dependencyTypes.includes(instance.strategy.name)) &&
|
|
31
29
|
(!(0, is_non_empty_array_1.isNonEmptyArray)(packages) ||
|
|
32
|
-
packages.some((pattern) => (0, minimatch_1.
|
|
30
|
+
packages.some((pattern) => (0, minimatch_1.minimatch)(instance.pkgName, pattern))) &&
|
|
33
31
|
(!(0, is_non_empty_array_1.isNonEmptyArray)(dependencies) ||
|
|
34
|
-
dependencies.some((pattern) => (0, minimatch_1.
|
|
32
|
+
dependencies.some((pattern) => (0, minimatch_1.minimatch)(instance.name, pattern)))) {
|
|
35
33
|
group.instances.push(instance);
|
|
36
34
|
return;
|
|
37
35
|
}
|
|
@@ -97,6 +95,15 @@ function createVersionGroups(ctx) {
|
|
|
97
95
|
snapTo: config.snapTo,
|
|
98
96
|
}));
|
|
99
97
|
}
|
|
98
|
+
else if (config.policy === 'sameRange') {
|
|
99
|
+
versionGroups.push(new same_range_1.SameRangeVersionGroup({
|
|
100
|
+
dependencies,
|
|
101
|
+
dependencyTypes,
|
|
102
|
+
label,
|
|
103
|
+
packages,
|
|
104
|
+
policy: config.policy,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
100
107
|
else {
|
|
101
108
|
versionGroups.push(new standard_1.StandardVersionGroup({
|
|
102
109
|
dependencies,
|
|
@@ -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 SameRangeVersionGroup {
|
|
5
|
+
_tag: string;
|
|
6
|
+
config: VersionGroupConfig.SameRange;
|
|
7
|
+
instances: Instance[];
|
|
8
|
+
constructor(config: VersionGroupConfig.SameRange);
|
|
9
|
+
canAdd(_: Instance): boolean;
|
|
10
|
+
inspect(): VersionGroupReport[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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.SameRangeVersionGroup = void 0;
|
|
7
|
+
const intersects_1 = __importDefault(require("semver/ranges/intersects"));
|
|
8
|
+
const group_by_1 = require("./lib/group-by");
|
|
9
|
+
class SameRangeVersionGroup {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this._tag = 'SameRange';
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.instances = [];
|
|
14
|
+
}
|
|
15
|
+
canAdd(_) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
inspect() {
|
|
19
|
+
const report = [];
|
|
20
|
+
const instancesByName = (0, group_by_1.groupBy)('name', this.instances);
|
|
21
|
+
Object.entries(instancesByName).forEach(([name, instances]) => {
|
|
22
|
+
if (hasMismatch(instances)) {
|
|
23
|
+
report.push({
|
|
24
|
+
instances,
|
|
25
|
+
isValid: false,
|
|
26
|
+
name,
|
|
27
|
+
status: 'SAME_RANGE_MISMATCH',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
report.push({
|
|
32
|
+
instances,
|
|
33
|
+
isValid: true,
|
|
34
|
+
name,
|
|
35
|
+
status: 'VALID',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return report;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.SameRangeVersionGroup = SameRangeVersionGroup;
|
|
43
|
+
/** Every range must fall within every other range */
|
|
44
|
+
function hasMismatch(instances) {
|
|
45
|
+
const loose = true;
|
|
46
|
+
return instances.some((a) => instances.some((b) => !(0, intersects_1.default)(a.version, b.version, loose)));
|
|
47
|
+
}
|
package/dist/lib/disk.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { O } from 'ts-toolbelt';
|
|
2
2
|
import type { RcConfig } from '../config/types';
|
|
3
3
|
export type Disk = {
|
|
4
|
+
askForChoice: (opts: {
|
|
5
|
+
message: string;
|
|
6
|
+
choices: string[];
|
|
7
|
+
}) => Promise<string>;
|
|
8
|
+
askForInput: (opts: {
|
|
9
|
+
message: string;
|
|
10
|
+
}) => Promise<string>;
|
|
11
|
+
globSync: (pattern: string) => string[];
|
|
4
12
|
process: {
|
|
5
13
|
exit: (code: number) => void;
|
|
6
14
|
};
|
|
7
|
-
globSync: (pattern: string) => string[];
|
|
8
15
|
readConfigFileSync: (configPath?: string) => O.Partial<RcConfig, 'deep'>;
|
|
9
16
|
readFileSync: (filePath: string) => string;
|
|
10
17
|
readYamlFileSync: <T = unknown>(filePath: string) => T;
|
package/dist/lib/disk.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.disk = void 0;
|
|
4
4
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// @ts-ignore Select *does* exist
|
|
7
|
+
const enquirer_1 = require("enquirer");
|
|
5
8
|
const fs_extra_1 = require("fs-extra");
|
|
6
9
|
const glob_1 = require("glob");
|
|
7
10
|
const path_1 = require("path");
|
|
@@ -11,11 +14,13 @@ const constants_1 = require("../constants");
|
|
|
11
14
|
const log_1 = require("./log");
|
|
12
15
|
const client = (0, cosmiconfig_1.cosmiconfigSync)('syncpack');
|
|
13
16
|
exports.disk = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
askForChoice({ message, choices }) {
|
|
18
|
+
return new enquirer_1.Select({ name: 'choice', message, choices })
|
|
19
|
+
.run()
|
|
20
|
+
.catch(console.error);
|
|
21
|
+
},
|
|
22
|
+
askForInput({ message }) {
|
|
23
|
+
return new enquirer_1.Input({ message }).run().catch(console.error);
|
|
19
24
|
},
|
|
20
25
|
globSync(pattern) {
|
|
21
26
|
(0, log_1.verbose)('globSync(', pattern, ')');
|
|
@@ -25,6 +30,12 @@ exports.disk = {
|
|
|
25
30
|
cwd: constants_1.CWD,
|
|
26
31
|
});
|
|
27
32
|
},
|
|
33
|
+
process: {
|
|
34
|
+
exit(code) {
|
|
35
|
+
(0, log_1.verbose)('exit(', code, ')');
|
|
36
|
+
process.exit(code);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
28
39
|
readConfigFileSync(configPath) {
|
|
29
40
|
(0, log_1.verbose)('readConfigFileSync(', configPath, ')');
|
|
30
41
|
try {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitNameAndVersion = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Split string by first occurring "@" which is not the first character in the
|
|
6
|
+
* string (used by scoped npm packages).
|
|
7
|
+
*/
|
|
8
|
+
function splitNameAndVersion(value) {
|
|
9
|
+
const ix = value.search(/(?!^)@/);
|
|
10
|
+
return [value.slice(0, ix), value.slice(ix + 1)];
|
|
11
|
+
}
|
|
12
|
+
exports.splitNameAndVersion = splitNameAndVersion;
|
|
@@ -24,7 +24,7 @@ class NamedVersionStringStrategy {
|
|
|
24
24
|
(0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file),
|
|
25
25
|
// if it is a non empty string, we can read it
|
|
26
26
|
(0, and_then_1.andThen)((value) => {
|
|
27
|
-
const [name, version] = value.split(
|
|
27
|
+
const [name, version] = value.split(/@(.*)/);
|
|
28
28
|
return (0, is_non_empty_string_1.isNonEmptyString)(name) && (0, is_non_empty_string_1.isNonEmptyString)(version)
|
|
29
29
|
? new result_1.Ok([[name, version]])
|
|
30
30
|
: new result_1.Err(new Error(`Strategy<name@version> failed to get ${path} in ${file.shortPath}`));
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "syncpack",
|
|
3
3
|
"description": "Consistent dependency versions in large JavaScript Monorepos",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.5.1",
|
|
5
5
|
"author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",
|
|
6
6
|
"bin": {
|
|
7
7
|
"syncpack": "dist/bin.js",
|
|
8
8
|
"syncpack-fix-mismatches": "dist/bin-fix-mismatches/index.js",
|
|
9
9
|
"syncpack-format": "dist/bin-format/index.js",
|
|
10
|
+
"syncpack-lint": "dist/bin-lint/index.js",
|
|
10
11
|
"syncpack-lint-semver-ranges": "dist/bin-lint-semver-ranges/index.js",
|
|
11
12
|
"syncpack-list": "dist/bin-list/index.js",
|
|
12
13
|
"syncpack-list-mismatches": "dist/bin-list-mismatches/index.js",
|
|
14
|
+
"syncpack-prompt": "dist/bin-prompt/index.js",
|
|
13
15
|
"syncpack-set-semver-ranges": "dist/bin-set-semver-ranges/index.js"
|
|
14
16
|
},
|
|
15
17
|
"bugs": "https://github.com/JamieMason/syncpack/issues",
|
|
@@ -31,11 +33,12 @@
|
|
|
31
33
|
"chalk": "4.1.2",
|
|
32
34
|
"commander": "10.0.1",
|
|
33
35
|
"cosmiconfig": "8.1.3",
|
|
36
|
+
"enquirer": "2.3.6",
|
|
34
37
|
"fs-extra": "11.1.1",
|
|
35
|
-
"glob": "
|
|
36
|
-
"minimatch": "
|
|
38
|
+
"glob": "10.2.6",
|
|
39
|
+
"minimatch": "9.0.1",
|
|
37
40
|
"read-yaml-file": "2.1.0",
|
|
38
|
-
"semver": "7.5.
|
|
41
|
+
"semver": "7.5.1",
|
|
39
42
|
"tightrope": "0.1.0",
|
|
40
43
|
"ts-toolbelt": "9.6.0"
|
|
41
44
|
},
|
|
@@ -43,21 +46,21 @@
|
|
|
43
46
|
"@tsconfig/node14": "1.0.3",
|
|
44
47
|
"@types/fs-extra": "11.0.1",
|
|
45
48
|
"@types/glob": "8.1.0",
|
|
46
|
-
"@types/jest": "29.5.
|
|
49
|
+
"@types/jest": "29.5.2",
|
|
47
50
|
"@types/node": "14.18.36",
|
|
48
|
-
"@types/semver": "7.
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "5.59.
|
|
50
|
-
"@typescript-eslint/parser": "5.59.
|
|
51
|
-
"eslint": "8.
|
|
51
|
+
"@types/semver": "7.5.0",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "5.59.8",
|
|
53
|
+
"@typescript-eslint/parser": "5.59.8",
|
|
54
|
+
"eslint": "8.42.0",
|
|
52
55
|
"eslint-plugin-import": "2.27.5",
|
|
53
56
|
"eslint-plugin-jest": "27.2.1",
|
|
54
57
|
"expect-more-jest": "5.5.0",
|
|
55
58
|
"jest": "29.5.0",
|
|
56
59
|
"prettier": "2.8.8",
|
|
57
|
-
"rimraf": "
|
|
60
|
+
"rimraf": "5.0.1",
|
|
58
61
|
"ts-jest": "29.1.0",
|
|
59
62
|
"ts-node": "10.9.1",
|
|
60
|
-
"typescript": "5.
|
|
63
|
+
"typescript": "5.1.3"
|
|
61
64
|
},
|
|
62
65
|
"engines": {
|
|
63
66
|
"node": ">=14"
|
|
@@ -90,7 +93,10 @@
|
|
|
90
93
|
"main": "dist/index.js",
|
|
91
94
|
"repository": "JamieMason/syncpack",
|
|
92
95
|
"resolutions": {
|
|
93
|
-
"chalk": "4.1.2"
|
|
96
|
+
"chalk": "4.1.2",
|
|
97
|
+
"string-width": "<5.0.0",
|
|
98
|
+
"strip-ansi": "<7.0.0",
|
|
99
|
+
"wrap-ansi": "<8.0.0"
|
|
94
100
|
},
|
|
95
101
|
"scripts": {
|
|
96
102
|
"build": "rm -rf ./dist && tsc --project .",
|