syncpack 10.0.0 → 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 +5 -0
- 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.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,11 @@ Organise package.json files according to a conventional format, where fields app
|
|
|
26
26
|
order and nested fields are ordered alphabetically. Shorthand properties are used where available,
|
|
27
27
|
such as the `"repository"` and `"bugs"` fields.
|
|
28
28
|
|
|
29
|
+
### [lint](https://jamiemason.github.io/syncpack/lint)
|
|
30
|
+
|
|
31
|
+
Lint all versions and ranges and exit with 0 or 1 based on whether all files match your Syncpack
|
|
32
|
+
configuration file.
|
|
33
|
+
|
|
29
34
|
### [lint-semver-ranges](https://jamiemason.github.io/syncpack/lint-semver-ranges)
|
|
30
35
|
|
|
31
36
|
Check whether dependency versions used within "dependencies", "devDependencies", etc follow a
|
|
@@ -0,0 +1,39 @@
|
|
|
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 lint_cli_1 = require("./lint-cli");
|
|
13
|
+
commander_1.program.description(' lint all versions and ranges');
|
|
14
|
+
commander_1.program.on('--help', () => {
|
|
15
|
+
console.log((0, chalk_1.default) `
|
|
16
|
+
Examples:
|
|
17
|
+
{dim # uses config file for resolving packages}
|
|
18
|
+
syncpack lint
|
|
19
|
+
{dim # uses config file defined by --config when provided}
|
|
20
|
+
syncpack lint --config {yellow ./config/.syncpackrc}
|
|
21
|
+
|
|
22
|
+
Resolving Packages:
|
|
23
|
+
1. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
24
|
+
2. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
25
|
+
3. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
26
|
+
4. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
27
|
+
|
|
28
|
+
Reference:
|
|
29
|
+
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
30
|
+
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
31
|
+
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
32
|
+
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
33
|
+
`);
|
|
34
|
+
});
|
|
35
|
+
(0, show_help_on_error_1.showHelpOnError)(commander_1.program);
|
|
36
|
+
commander_1.program.option(...option_1.option.config).parse(process.argv);
|
|
37
|
+
(0, lint_cli_1.lintCli)({
|
|
38
|
+
configPath: commander_1.program.opts().config,
|
|
39
|
+
}, disk_1.disk);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lintCli = void 0;
|
|
4
|
+
const pipe_1 = require("tightrope/fn/pipe");
|
|
5
|
+
const get_context_1 = require("../get-context");
|
|
6
|
+
const exit_if_invalid_1 = require("../lib/exit-if-invalid");
|
|
7
|
+
const lint_1 = require("./lint");
|
|
8
|
+
function lintCli(input, disk) {
|
|
9
|
+
(0, pipe_1.pipe)((0, get_context_1.getContext)(input, disk), lint_1.lint, exit_if_invalid_1.exitIfInvalid);
|
|
10
|
+
}
|
|
11
|
+
exports.lintCli = lintCli;
|
|
@@ -0,0 +1,116 @@
|
|
|
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.lint = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const get_semver_groups_1 = require("../get-semver-groups");
|
|
10
|
+
const get_version_groups_1 = require("../get-version-groups");
|
|
11
|
+
function lint(ctx) {
|
|
12
|
+
let totalInstances = 0;
|
|
13
|
+
const instanceCounts = {};
|
|
14
|
+
const versionGroups = (0, get_version_groups_1.getVersionGroups)(ctx);
|
|
15
|
+
const versionCounts = {
|
|
16
|
+
BANNED: 0,
|
|
17
|
+
FILTERED_OUT: 0,
|
|
18
|
+
HIGHEST_SEMVER_MISMATCH: 0,
|
|
19
|
+
IGNORED: 0,
|
|
20
|
+
LOWEST_SEMVER_MISMATCH: 0,
|
|
21
|
+
PINNED_MISMATCH: 0,
|
|
22
|
+
SEMVER_UNSATISFIED: 0,
|
|
23
|
+
SNAPPED_TO_MISMATCH: 0,
|
|
24
|
+
UNSUPPORTED_MISMATCH: 0,
|
|
25
|
+
VALID: 0,
|
|
26
|
+
WORKSPACE_MISMATCH: 0,
|
|
27
|
+
WORKSPACE_UNSATISFIED: 0,
|
|
28
|
+
};
|
|
29
|
+
versionGroups.forEach((group) => {
|
|
30
|
+
group.inspect().forEach((report) => {
|
|
31
|
+
if (!report.isValid)
|
|
32
|
+
ctx.isInvalid = true;
|
|
33
|
+
if (!versionCounts[report.status]) {
|
|
34
|
+
versionCounts[report.status] = 0;
|
|
35
|
+
}
|
|
36
|
+
versionCounts[report.status]++;
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const semverGroups = (0, get_semver_groups_1.getSemverGroups)(ctx);
|
|
40
|
+
const semverCounts = {
|
|
41
|
+
FILTERED_OUT: 0,
|
|
42
|
+
IGNORED: 0,
|
|
43
|
+
VALID: 0,
|
|
44
|
+
WORKSPACE_SEMVER_RANGE_MISMATCH: 0,
|
|
45
|
+
SEMVER_RANGE_MISMATCH: 0,
|
|
46
|
+
UNSUPPORTED_VERSION: 0,
|
|
47
|
+
};
|
|
48
|
+
semverGroups.forEach((group) => {
|
|
49
|
+
group.inspect().forEach((report) => {
|
|
50
|
+
const status = report.status;
|
|
51
|
+
const strategyName = report.instance.strategy.name;
|
|
52
|
+
if (!report.isValid)
|
|
53
|
+
ctx.isInvalid = true;
|
|
54
|
+
if (!semverCounts[status])
|
|
55
|
+
semverCounts[status] = 0;
|
|
56
|
+
semverCounts[status]++;
|
|
57
|
+
if (!instanceCounts[strategyName])
|
|
58
|
+
instanceCounts[strategyName] = 0;
|
|
59
|
+
instanceCounts[strategyName]++;
|
|
60
|
+
totalInstances++;
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const fileCount = ctx.packageJsonFiles.length;
|
|
64
|
+
info(fileCount, `package.json file${fileCount > 1 ? 's' : ''}`);
|
|
65
|
+
info(totalInstances, 'total dependences');
|
|
66
|
+
Object.entries(instanceCounts).forEach(([name, count]) => {
|
|
67
|
+
info(count, `in package.${name
|
|
68
|
+
.replace(/^dev$/, 'devDependencies')
|
|
69
|
+
.replace(/^peer$/, 'peerDependencies')
|
|
70
|
+
.replace(/^pnpmOverrides$/, 'pnpm.overrides')
|
|
71
|
+
.replace(/^prod$/, 'dependencies')
|
|
72
|
+
.replace(/^workspace$/, 'version')}`);
|
|
73
|
+
});
|
|
74
|
+
console.log(chalk_1.default.blue('Version mismatches'));
|
|
75
|
+
expectSome(versionCounts.VALID, 'are valid');
|
|
76
|
+
expectNone(versionCounts.HIGHEST_SEMVER_MISMATCH, 'should have matching versions (prefer highest semver)');
|
|
77
|
+
expectNone(versionCounts.LOWEST_SEMVER_MISMATCH, 'should have matching versions (prefer lowest semver)');
|
|
78
|
+
expectNone(versionCounts.WORKSPACE_MISMATCH, 'should match workspace package version');
|
|
79
|
+
expectNone(versionCounts.BANNED, 'are banned from use');
|
|
80
|
+
expectNone(versionCounts.PINNED_MISMATCH, 'should be pinned to a specific version');
|
|
81
|
+
expectNone(versionCounts.SNAPPED_TO_MISMATCH, 'should snap to version used by another package');
|
|
82
|
+
info(versionCounts.FILTERED_OUT, 'are filtered out');
|
|
83
|
+
info(versionCounts.IGNORED, 'are ignored');
|
|
84
|
+
info(versionCounts.UNSUPPORTED_MISMATCH, 'have unsupported version format');
|
|
85
|
+
console.log(chalk_1.default.blue('Semver range mismatches'));
|
|
86
|
+
expectSome(semverCounts.VALID, 'are valid');
|
|
87
|
+
expectNone(semverCounts.SEMVER_RANGE_MISMATCH, 'should use specific semver range');
|
|
88
|
+
expectNone(semverCounts.WORKSPACE_SEMVER_RANGE_MISMATCH, 'should use exact version in version property of package.json');
|
|
89
|
+
info(semverCounts.FILTERED_OUT, 'are filtered out');
|
|
90
|
+
info(semverCounts.IGNORED, 'are ignored');
|
|
91
|
+
info(semverCounts.UNSUPPORTED_VERSION, 'have unsupported version format');
|
|
92
|
+
return ctx;
|
|
93
|
+
function expectNone(count = 0, ...rest) {
|
|
94
|
+
if (count === 0) {
|
|
95
|
+
console.log(chalk_1.default.dim(constants_1.ICON.skip), pad(count), ...rest);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.log(chalk_1.default.red(constants_1.ICON.cross, pad(count), ...rest));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function expectSome(count = 0, ...rest) {
|
|
102
|
+
if (count > 0) {
|
|
103
|
+
console.log(chalk_1.default.dim(constants_1.ICON.skip), pad(count), ...rest);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
console.log(chalk_1.default.red(constants_1.ICON.cross, pad(count), ...rest));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function info(count = 0, ...rest) {
|
|
110
|
+
console.log(chalk_1.default.dim(constants_1.ICON.skip), pad(count), ...rest);
|
|
111
|
+
}
|
|
112
|
+
function pad(count) {
|
|
113
|
+
return String(count).padStart(String(totalInstances).length, ' ');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.lint = lint;
|
package/dist/bin.js
CHANGED
|
@@ -9,6 +9,9 @@ commander_1.program
|
|
|
9
9
|
})
|
|
10
10
|
.command('format', 'sort and shorten properties according to a convention', {
|
|
11
11
|
executableFile: './bin-format/index.js',
|
|
12
|
+
})
|
|
13
|
+
.command('lint', 'lint all versions and ranges', {
|
|
14
|
+
executableFile: './bin-lint/index.js',
|
|
12
15
|
})
|
|
13
16
|
.command('lint-semver-ranges', 'check dependency versions comply with the given semver range format', {
|
|
14
17
|
executableFile: './bin-lint-semver-ranges/index.js',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "syncpack",
|
|
3
3
|
"description": "Consistent dependency versions in large JavaScript Monorepos",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.1.0",
|
|
5
5
|
"author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",
|
|
6
6
|
"bin": {
|
|
7
7
|
"syncpack": "dist/bin.js",
|