syncpack 12.3.3 → 13.0.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 +1 -2
- package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -2
- package/dist/bin-fix-mismatches/fix-mismatches.js +13 -8
- package/dist/bin-fix-mismatches/index.js +1 -32
- package/dist/bin-format/format.d.ts +2 -2
- package/dist/bin-format/format.js +10 -7
- package/dist/bin-format/index.js +1 -26
- package/dist/bin-lint/index.js +1 -22
- package/dist/bin-lint/lint.d.ts +1 -1
- package/dist/bin-lint/lint.js +23 -23
- package/dist/bin-lint-semver-ranges/index.js +1 -36
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -2
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +5 -4
- package/dist/bin-list/index.js +1 -31
- package/dist/bin-list/list.d.ts +1 -1
- package/dist/bin-list/list.js +9 -5
- package/dist/bin-list-mismatches/index.js +1 -31
- package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -2
- package/dist/bin-list-mismatches/list-mismatches.js +15 -9
- package/dist/bin-prompt/index.js +1 -33
- package/dist/bin-prompt/prompt.d.ts +2 -2
- package/dist/bin-prompt/prompt.js +13 -11
- package/dist/bin-set-semver-ranges/index.js +1 -38
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -2
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +8 -5
- package/dist/bin-update/effects.d.ts +1 -1
- package/dist/bin-update/effects.js +46 -31
- package/dist/bin-update/index.js +1 -31
- package/dist/bin-update/update.d.ts +1 -1
- package/dist/bin-update/update.js +4 -4
- package/dist/bin.js +3 -3
- package/dist/config/get-custom-types.js +20 -13
- package/dist/config/get-enabled-types.js +27 -12
- package/dist/config/get-sort-exports.js +2 -1
- package/dist/config/types.d.ts +2 -0
- package/dist/error-handlers/default-error-handlers.js +2 -2
- package/dist/get-context/index.d.ts +2 -2
- package/dist/get-context/index.js +1 -1
- package/dist/get-instances/index.js +6 -6
- package/dist/get-instances/instance.js +6 -2
- package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +4 -2
- package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +1 -1
- package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +2 -2
- package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +2 -2
- package/dist/get-package-json-files/get-patterns/index.js +3 -3
- package/dist/get-package-json-files/index.js +1 -1
- package/dist/get-package-json-files/package-json-file.d.ts +7 -0
- package/dist/get-package-json-files/package-json-file.js +18 -3
- package/dist/guards/can-add-to-group.js +19 -13
- package/dist/guards/is-semver.js +3 -1
- package/dist/io/ask-for-choice.js +3 -3
- package/dist/io/ask-for-input.js +2 -2
- package/dist/io/exit-if-invalid.js +1 -1
- package/dist/io/glob-sync.js +1 -1
- package/dist/io/index.d.ts +1 -2
- package/dist/io/index.js +1 -1
- package/dist/io/read-config-file.js +5 -3
- package/dist/io/read-file-sync.js +1 -1
- package/dist/io/read-json-file-sync.d.ts +2 -1
- package/dist/io/read-json-file-sync.js +9 -5
- package/dist/io/read-yaml-file-sync.js +1 -1
- package/dist/io/{to-json.d.ts → to-formatted-json.d.ts} +1 -1
- package/dist/io/{to-json.js → to-formatted-json.js} +11 -8
- package/dist/io/write-file-sync.js +2 -2
- package/dist/io/write-if-changed.js +3 -4
- package/dist/lib/format-repository-url.js +8 -5
- package/dist/lib/get-group-header.js +3 -1
- package/dist/lib/get.js +20 -12
- package/dist/lib/ring-buffer.js +1 -1
- package/dist/lib/set-semver-range.js +8 -4
- package/dist/lib/with-logger.js +6 -6
- package/dist/option.js +4 -1
- package/dist/schema.json +3 -0
- package/dist/semver-group/create-semver-groups.js +7 -3
- package/dist/semver-group/disabled.js +1 -1
- package/dist/semver-group/filtered-out.js +1 -1
- package/dist/semver-group/ignored.js +1 -1
- package/dist/semver-group/with-range.js +3 -3
- package/dist/specifier/alias.js +3 -2
- package/dist/specifier/delete.d.ts +2 -2
- package/dist/specifier/exact.js +1 -1
- package/dist/specifier/hosted-git.js +5 -3
- package/dist/specifier/index.js +27 -15
- package/dist/specifier/latest.js +1 -1
- package/dist/specifier/lib/parse-specifier.js +3 -1
- package/dist/specifier/range.js +1 -1
- package/dist/specifier/workspace-protocol.js +2 -1
- package/dist/strategy/lib/get-non-empty-string-prop.js +1 -1
- package/dist/strategy/name-and-version-props.js +7 -7
- package/dist/strategy/named-version-string.js +11 -8
- package/dist/strategy/unnamed-version-string.js +6 -6
- package/dist/strategy/versions-by-name.js +4 -2
- package/dist/version-group/banned.js +1 -1
- package/dist/version-group/create-version-groups.js +11 -7
- package/dist/version-group/filtered-out.js +1 -1
- package/dist/version-group/ignored.js +1 -1
- package/dist/version-group/lib/get-preferred-version.js +22 -13
- package/dist/version-group/lib/get-range-score.js +3 -1
- package/dist/version-group/pinned.js +2 -2
- package/dist/version-group/same-range.js +6 -6
- package/dist/version-group/snapped-to.js +7 -5
- package/dist/version-group/standard.js +19 -16
- package/package.json +41 -33
package/README.md
CHANGED
|
@@ -55,5 +55,4 @@ Interactively update packages to the latest versions from the npm registry, wher
|
|
|
55
55
|
- [](https://ko-fi.com/C0C4PY4P)
|
|
56
56
|
- [](https://www.npmjs.com/package/syncpack)
|
|
57
57
|
- [](https://www.npmjs.com/package/syncpack)
|
|
58
|
-
- [](https://codeclimate.com/github/JamieMason/syncpack/maintainability)
|
|
58
|
+
- [](https://github.com/JamieMason/syncpack/actions)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import type { CliConfig } from '../config/types.js';
|
|
3
3
|
import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
4
4
|
import type { Io } from '../io/index.js';
|
|
5
5
|
import type { Report } from '../report.js';
|
|
@@ -8,7 +8,7 @@ interface Input {
|
|
|
8
8
|
cli: Partial<CliConfig>;
|
|
9
9
|
errorHandlers?: ErrorHandlers;
|
|
10
10
|
}
|
|
11
|
-
export declare function fixMismatches({ io, cli, errorHandlers }: Input): Effect.Effect<unknown, never, never>;
|
|
11
|
+
export declare function fixMismatches({ io, cli, errorHandlers, }: Input): Effect.Effect<unknown, never, never>;
|
|
12
12
|
export declare function fixMismatch(report: Report.Version.Fixable.Any): Effect.Effect<import("../get-package-json-files/package-json-file.js").PackageJsonFile, never, never>;
|
|
13
13
|
export declare function logAlreadyValidSize(amount: number): Effect.Effect<void, never, never>;
|
|
14
14
|
export declare function logFixedSize(amount: number): Effect.Effect<void, never, never>;
|
|
@@ -16,8 +16,8 @@ import { getVersionGroupHeader } from '../lib/get-group-header.js';
|
|
|
16
16
|
import { padStart } from '../lib/pad-start.js';
|
|
17
17
|
import { withLogger } from '../lib/with-logger.js';
|
|
18
18
|
import { DELETE } from '../version-group/lib/delete.js';
|
|
19
|
-
export function fixMismatches({ io, cli, errorHandlers = defaultErrorHandlers }) {
|
|
20
|
-
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(
|
|
19
|
+
export function fixMismatches({ io, cli, errorHandlers = defaultErrorHandlers, }) {
|
|
20
|
+
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(ctx => pipe(Effect.gen(function* ($) {
|
|
21
21
|
const { versionGroups } = yield* $(getInstances(ctx, io, errorHandlers));
|
|
22
22
|
let index = 0;
|
|
23
23
|
for (const group of versionGroups) {
|
|
@@ -62,12 +62,15 @@ export function fixMismatches({ io, cli, errorHandlers = defaultErrorHandlers })
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
if (validCount)
|
|
65
|
+
if (validCount) {
|
|
66
66
|
yield* $(logAlreadyValidSize(validCount));
|
|
67
|
-
|
|
67
|
+
}
|
|
68
|
+
if (fixedCount) {
|
|
68
69
|
yield* $(logFixedSize(fixedCount));
|
|
69
|
-
|
|
70
|
+
}
|
|
71
|
+
if (unfixableCount) {
|
|
70
72
|
yield* $(logUnfixableSize(unfixableCount));
|
|
73
|
+
}
|
|
71
74
|
index++;
|
|
72
75
|
}
|
|
73
76
|
yield* $(removeEmptyObjects(ctx));
|
|
@@ -85,11 +88,13 @@ export function fixMismatch(report) {
|
|
|
85
88
|
/** Remove empty objects such as `{"dependencies": {}}` left after deleting */
|
|
86
89
|
function removeEmptyObjects(ctx) {
|
|
87
90
|
return Effect.sync(() => {
|
|
88
|
-
ctx.packageJsonFiles.forEach(
|
|
91
|
+
ctx.packageJsonFiles.forEach(file => {
|
|
89
92
|
const contents = file.jsonFile.contents;
|
|
90
|
-
Object.keys(contents).forEach(
|
|
93
|
+
Object.keys(contents).forEach(key => {
|
|
91
94
|
const value = contents[key];
|
|
92
|
-
if (isObject(value) &&
|
|
95
|
+
if (isObject(value) &&
|
|
96
|
+
value &&
|
|
97
|
+
Object.values(value).every(isUndefined)) {
|
|
93
98
|
delete contents[key];
|
|
94
99
|
}
|
|
95
100
|
});
|
|
@@ -10,38 +10,7 @@ program.description(chalk `
|
|
|
10
10
|
Ensure that multiple packages requiring the same dependency define the same
|
|
11
11
|
version, so that every package requires eg. {yellow react@16.4.2}, instead of a
|
|
12
12
|
combination of {yellow react@16.4.2}, {yellow react@0.15.9}, and {yellow react@16.0.0}.`.replace(/^\n/, ''));
|
|
13
|
-
program.on('--help', () => {
|
|
14
|
-
console.log(chalk `
|
|
15
|
-
Resolving Packages:
|
|
16
|
-
1. If {yellow --source} globs are provided, use those.
|
|
17
|
-
2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
18
|
-
3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
19
|
-
4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
20
|
-
5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
21
|
-
|
|
22
|
-
Examples:
|
|
23
|
-
{dim # uses defaults for resolving packages}
|
|
24
|
-
syncpack fix-mismatches
|
|
25
|
-
{dim # uses packages defined by --source when provided}
|
|
26
|
-
syncpack fix-mismatches --source {yellow "apps/*/package.json"}
|
|
27
|
-
{dim # multiple globs can be provided like this}
|
|
28
|
-
syncpack fix-mismatches --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
|
|
29
|
-
{dim # uses dependencies regular expression defined by --filter when provided}
|
|
30
|
-
syncpack fix-mismatches --filter {yellow "typescript|tslint"}
|
|
31
|
-
{dim # only inspect "devDependencies"}
|
|
32
|
-
syncpack fix-mismatches --types dev
|
|
33
|
-
{dim # only inspect "devDependencies" and "peerDependencies"}
|
|
34
|
-
syncpack fix-mismatches --types dev,peer
|
|
35
|
-
{dim # indent package.json with 4 spaces instead of 2}
|
|
36
|
-
syncpack fix-mismatches --indent {yellow " "}
|
|
37
|
-
|
|
38
|
-
Reference:
|
|
39
|
-
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
40
|
-
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
41
|
-
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
42
|
-
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
43
|
-
`);
|
|
44
|
-
});
|
|
13
|
+
program.on('--help', () => { });
|
|
45
14
|
showHelpOnError(program);
|
|
46
15
|
program
|
|
47
16
|
.option(...option.source)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import type { CliConfig } from '../config/types.js';
|
|
3
3
|
import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
4
4
|
import type { Ctx } from '../get-context/index.js';
|
|
5
5
|
import type { Io } from '../io/index.js';
|
|
@@ -8,6 +8,6 @@ interface Input {
|
|
|
8
8
|
cli: Partial<CliConfig>;
|
|
9
9
|
errorHandlers?: ErrorHandlers;
|
|
10
10
|
}
|
|
11
|
-
export declare function format({ io, cli, errorHandlers }: Input): Effect.Effect<unknown, never, never>;
|
|
11
|
+
export declare function format({ io, cli, errorHandlers, }: Input): Effect.Effect<unknown, never, never>;
|
|
12
12
|
export declare function pipeline(ctx: Ctx): Effect.Effect<Ctx>;
|
|
13
13
|
export {};
|
|
@@ -10,10 +10,11 @@ import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.j
|
|
|
10
10
|
import { getContext } from '../get-context/index.js';
|
|
11
11
|
import { exitIfInvalid } from '../io/exit-if-invalid.js';
|
|
12
12
|
import { IoTag } from '../io/index.js';
|
|
13
|
+
import { toFormattedJson } from '../io/to-formatted-json.js';
|
|
13
14
|
import { writeIfChanged } from '../io/write-if-changed.js';
|
|
14
15
|
import { withLogger } from '../lib/with-logger.js';
|
|
15
|
-
export function format({ io, cli, errorHandlers = defaultErrorHandlers }) {
|
|
16
|
-
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(pipeline), Effect.flatMap(
|
|
16
|
+
export function format({ io, cli, errorHandlers = defaultErrorHandlers, }) {
|
|
17
|
+
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(pipeline), Effect.flatMap(ctx => pipe(writeIfChanged(ctx), Effect.catchTags({
|
|
17
18
|
WriteFileError: flow(errorHandlers.WriteFileError, Effect.map(() => {
|
|
18
19
|
ctx.isInvalid = true;
|
|
19
20
|
return ctx;
|
|
@@ -28,7 +29,7 @@ export function pipeline(ctx) {
|
|
|
28
29
|
const sortPackages = config.rcFile.sortPackages !== false;
|
|
29
30
|
const formatBugs = config.rcFile.formatBugs !== false;
|
|
30
31
|
const formatRepository = config.rcFile.formatRepository !== false;
|
|
31
|
-
packageJsonFiles.forEach(
|
|
32
|
+
packageJsonFiles.forEach(file => {
|
|
32
33
|
const { contents } = file.jsonFile;
|
|
33
34
|
const chain = contents;
|
|
34
35
|
if (formatBugs) {
|
|
@@ -50,7 +51,7 @@ export function pipeline(ctx) {
|
|
|
50
51
|
visitExports(sortExports, contents.exports);
|
|
51
52
|
}
|
|
52
53
|
if (sortAz.length > 0) {
|
|
53
|
-
sortAz.forEach(
|
|
54
|
+
sortAz.forEach(key => sortAlphabetically(contents[key]));
|
|
54
55
|
}
|
|
55
56
|
if (sortPackages) {
|
|
56
57
|
const sortedKeys = Object.keys(contents).sort();
|
|
@@ -61,6 +62,7 @@ export function pipeline(ctx) {
|
|
|
61
62
|
const sortedKeys = new Set([...sortFirst, ...otherKeys]);
|
|
62
63
|
sortObject(sortedKeys, contents);
|
|
63
64
|
}
|
|
65
|
+
file.nextJson = toFormattedJson(ctx, file);
|
|
64
66
|
});
|
|
65
67
|
return Effect.succeed(ctx);
|
|
66
68
|
}
|
|
@@ -69,7 +71,7 @@ function visitExports(sortExports, value) {
|
|
|
69
71
|
const otherKeys = Object.keys(value);
|
|
70
72
|
const sortedKeys = new Set([...sortExports, ...otherKeys]);
|
|
71
73
|
sortObject(sortedKeys, value);
|
|
72
|
-
Object.values(value).forEach(
|
|
74
|
+
Object.values(value).forEach(nextValue => visitExports(sortExports, nextValue));
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
function sortObject(sortedKeys, obj) {
|
|
@@ -80,10 +82,11 @@ function sortObject(sortedKeys, obj) {
|
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
function sortAlphabetically(value) {
|
|
85
|
+
const localeComparison = (a, b) => a.localeCompare(b);
|
|
83
86
|
if (isArray(value)) {
|
|
84
|
-
value.sort();
|
|
87
|
+
value.sort(localeComparison);
|
|
85
88
|
}
|
|
86
89
|
else if (isObject(value)) {
|
|
87
|
-
sortObject(Object.keys(value).sort(), value);
|
|
90
|
+
sortObject(Object.keys(value).sort(localeComparison), value);
|
|
88
91
|
}
|
|
89
92
|
}
|
package/dist/bin-format/index.js
CHANGED
|
@@ -11,32 +11,7 @@ program.description(chalk `
|
|
|
11
11
|
appear in a predictable order and nested fields are ordered alphabetically.
|
|
12
12
|
Shorthand properties are used where available, such as the {yellow repository} and
|
|
13
13
|
{yellow bugs} fields.`.replace(/^\n/, ''));
|
|
14
|
-
program.on('--help', () => {
|
|
15
|
-
console.log(chalk `
|
|
16
|
-
Examples:
|
|
17
|
-
{dim # uses defaults for resolving packages}
|
|
18
|
-
syncpack format
|
|
19
|
-
{dim # uses packages defined by --source when provided}
|
|
20
|
-
syncpack format --source {yellow "apps/*/package.json"}
|
|
21
|
-
{dim # multiple globs can be provided like this}
|
|
22
|
-
syncpack format --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
|
|
23
|
-
{dim # indent package.json with 4 spaces instead of 2}
|
|
24
|
-
syncpack format --indent {yellow " "}
|
|
25
|
-
|
|
26
|
-
Resolving Packages:
|
|
27
|
-
1. If {yellow --source} globs are provided, use those.
|
|
28
|
-
2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
29
|
-
3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
30
|
-
4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
31
|
-
5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
32
|
-
|
|
33
|
-
Reference:
|
|
34
|
-
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
35
|
-
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
36
|
-
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
37
|
-
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
38
|
-
`);
|
|
39
|
-
});
|
|
14
|
+
program.on('--help', () => { });
|
|
40
15
|
showHelpOnError(program);
|
|
41
16
|
program
|
|
42
17
|
.option(...option.source)
|
package/dist/bin-lint/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import chalk from 'chalk-template';
|
|
3
2
|
import { program } from 'commander';
|
|
4
3
|
import { Effect } from 'effect';
|
|
5
4
|
import { io } from '../io/index.js';
|
|
@@ -7,27 +6,7 @@ import { showHelpOnError } from '../lib/show-help-on-error.js';
|
|
|
7
6
|
import { option } from '../option.js';
|
|
8
7
|
import { lint } from './lint.js';
|
|
9
8
|
program.description(' lint all versions and ranges');
|
|
10
|
-
program.on('--help', () => {
|
|
11
|
-
console.log(chalk `
|
|
12
|
-
Examples:
|
|
13
|
-
{dim # uses config file for resolving packages}
|
|
14
|
-
syncpack lint
|
|
15
|
-
{dim # uses config file defined by --config when provided}
|
|
16
|
-
syncpack lint --config {yellow ./config/.syncpackrc}
|
|
17
|
-
|
|
18
|
-
Resolving Packages:
|
|
19
|
-
1. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
20
|
-
2. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
21
|
-
3. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
22
|
-
4. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
23
|
-
|
|
24
|
-
Reference:
|
|
25
|
-
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
26
|
-
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
27
|
-
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
28
|
-
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
29
|
-
`);
|
|
30
|
-
});
|
|
9
|
+
program.on('--help', () => { });
|
|
31
10
|
showHelpOnError(program);
|
|
32
11
|
program.option(...option.config).parse(process.argv);
|
|
33
12
|
Effect.runPromise(lint({
|
package/dist/bin-lint/lint.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import type { CliConfig } from '../config/types.js';
|
|
3
3
|
import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
4
4
|
import type { Io } from '../io/index.js';
|
|
5
5
|
interface Input {
|
package/dist/bin-lint/lint.js
CHANGED
|
@@ -9,12 +9,32 @@ import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.j
|
|
|
9
9
|
import { getContext } from '../get-context/index.js';
|
|
10
10
|
import { exitIfInvalid } from '../io/exit-if-invalid.js';
|
|
11
11
|
import { IoTag } from '../io/index.js';
|
|
12
|
-
import {
|
|
12
|
+
import { toFormattedJson } from '../io/to-formatted-json.js';
|
|
13
13
|
import { withLogger } from '../lib/with-logger.js';
|
|
14
14
|
export function lint({ io, cli, errorHandlers = defaultErrorHandlers }) {
|
|
15
15
|
return pipe(getContext({ io, cli, errorHandlers }),
|
|
16
|
+
// Formatting
|
|
17
|
+
Effect.flatMap(ctx => Effect.gen(function* ($) {
|
|
18
|
+
if (ctx.config.rcFile.lintFormatting !== false) {
|
|
19
|
+
yield* $(Effect.logInfo(chalk `{yellow Formatting}`));
|
|
20
|
+
yield* $(format(ctx));
|
|
21
|
+
for (const file of ctx.packageJsonFiles) {
|
|
22
|
+
const shortPath = file.jsonFile.shortPath;
|
|
23
|
+
const formattedJson = toFormattedJson(ctx, file);
|
|
24
|
+
const isFormatted = file.jsonFile.json === formattedJson;
|
|
25
|
+
if (isFormatted) {
|
|
26
|
+
yield* $(Effect.logInfo(chalk `{green ${ICON.tick}} ${shortPath}`));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
ctx.isInvalid = true;
|
|
30
|
+
yield* $(Effect.logInfo(chalk `{red ${ICON.cross}} ${shortPath}`));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return ctx;
|
|
35
|
+
})),
|
|
16
36
|
// Versions
|
|
17
|
-
Effect.flatMap(
|
|
37
|
+
Effect.flatMap(ctx => Effect.gen(function* ($) {
|
|
18
38
|
if (ctx.config.rcFile.lintVersions !== false) {
|
|
19
39
|
yield* $(Effect.logInfo(chalk `{yellow Versions}`));
|
|
20
40
|
yield* $(listMismatches(ctx, io, errorHandlers));
|
|
@@ -22,31 +42,11 @@ export function lint({ io, cli, errorHandlers = defaultErrorHandlers }) {
|
|
|
22
42
|
return ctx;
|
|
23
43
|
})),
|
|
24
44
|
// Semver Ranges
|
|
25
|
-
Effect.flatMap(
|
|
45
|
+
Effect.flatMap(ctx => Effect.gen(function* ($) {
|
|
26
46
|
if (ctx.config.rcFile.lintSemverRanges !== false) {
|
|
27
47
|
yield* $(Effect.logInfo(chalk `{yellow Semver Ranges}`));
|
|
28
48
|
yield* $(lintSemverRanges(ctx, io, errorHandlers));
|
|
29
49
|
}
|
|
30
50
|
return ctx;
|
|
31
|
-
})),
|
|
32
|
-
// Formatting
|
|
33
|
-
Effect.flatMap((ctx) => Effect.gen(function* ($) {
|
|
34
|
-
if (ctx.config.rcFile.lintFormatting !== false) {
|
|
35
|
-
yield* $(Effect.logInfo(chalk `{yellow Formatting}`));
|
|
36
|
-
yield* $(format(ctx));
|
|
37
|
-
for (const file of ctx.packageJsonFiles) {
|
|
38
|
-
const nextJson = toJson(ctx, file);
|
|
39
|
-
const hasChanged = file.jsonFile.json !== nextJson;
|
|
40
|
-
const shortPath = file.jsonFile.shortPath;
|
|
41
|
-
if (hasChanged) {
|
|
42
|
-
ctx.isInvalid = true;
|
|
43
|
-
yield* $(Effect.logInfo(chalk `{red ${ICON.cross}} ${shortPath}`));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
yield* $(Effect.logInfo(chalk `{green ${ICON.tick}} ${shortPath}`));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return ctx;
|
|
51
51
|
})), Effect.flatMap(exitIfInvalid), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
|
|
52
52
|
}
|
|
@@ -9,42 +9,7 @@ import { lintSemverRanges } from './lint-semver-ranges.js';
|
|
|
9
9
|
program.description(chalk `
|
|
10
10
|
Check dependency versions within {yellow dependencies}, {yellow devDependencies},
|
|
11
11
|
{yellow peerDependencies}, {yellow overrides}, and {yellow resolutions} follow a consistent format.`.replace(/^\n/, ''));
|
|
12
|
-
program.on('--help', () => {
|
|
13
|
-
console.log(chalk `
|
|
14
|
-
Examples:
|
|
15
|
-
{dim # uses defaults for resolving packages}
|
|
16
|
-
syncpack lint-semver-ranges
|
|
17
|
-
{dim # uses packages defined by --source when provided}
|
|
18
|
-
syncpack lint-semver-ranges --source {yellow "apps/*/package.json"}
|
|
19
|
-
{dim # multiple globs can be provided like this}
|
|
20
|
-
syncpack lint-semver-ranges --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
|
|
21
|
-
{dim # uses dependencies regular expression defined by --filter when provided}
|
|
22
|
-
syncpack lint-semver-ranges --filter {yellow "typescript|tslint"}
|
|
23
|
-
|
|
24
|
-
Supported Ranges:
|
|
25
|
-
< {dim <1.4.2}
|
|
26
|
-
<= {dim <=1.4.2}
|
|
27
|
-
"" {dim 1.4.2}
|
|
28
|
-
~ {dim ~1.4.2}
|
|
29
|
-
^ {dim ^1.4.2}
|
|
30
|
-
>= {dim >=1.4.2}
|
|
31
|
-
> {dim >1.4.2}
|
|
32
|
-
* {dim *}
|
|
33
|
-
|
|
34
|
-
Resolving Packages:
|
|
35
|
-
1. If {yellow --source} globs are provided, use those.
|
|
36
|
-
2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
37
|
-
3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
38
|
-
4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
39
|
-
5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
40
|
-
|
|
41
|
-
Reference:
|
|
42
|
-
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
43
|
-
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
44
|
-
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
45
|
-
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
46
|
-
`);
|
|
47
|
-
});
|
|
12
|
+
program.on('--help', () => { });
|
|
48
13
|
showHelpOnError(program);
|
|
49
14
|
program
|
|
50
15
|
.option(...option.source)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import type { CliConfig } from '../config/types.js';
|
|
3
3
|
import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
4
4
|
import type { Ctx } from '../get-context/index.js';
|
|
5
5
|
import type { Io } from '../io/index.js';
|
|
@@ -8,7 +8,7 @@ interface Input {
|
|
|
8
8
|
cli: Partial<CliConfig>;
|
|
9
9
|
errorHandlers?: ErrorHandlers;
|
|
10
10
|
}
|
|
11
|
-
export declare function lintSemverRanges({ io, cli, errorHandlers }: Input): Effect.Effect<unknown, never, never>;
|
|
11
|
+
export declare function lintSemverRanges({ io, cli, errorHandlers, }: Input): Effect.Effect<unknown, never, never>;
|
|
12
12
|
/** Exported to be reused by `syncpack lint` */
|
|
13
13
|
export declare function pipeline(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<Ctx>;
|
|
14
14
|
export declare function logSemverGroupsDisabledWarning(): Effect.Effect<void, never, never>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { EOL } from 'node:os';
|
|
1
2
|
import chalk from 'chalk-template';
|
|
2
3
|
import { Context, Effect, pipe } from 'effect';
|
|
3
|
-
import { EOL } from 'os';
|
|
4
4
|
import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
|
|
5
5
|
import { CliConfigTag } from '../config/tag.js';
|
|
6
6
|
import { ICON } from '../constants.js';
|
|
@@ -12,8 +12,8 @@ import { IoTag } from '../io/index.js';
|
|
|
12
12
|
import { getSemverGroupHeader } from '../lib/get-group-header.js';
|
|
13
13
|
import { padStart } from '../lib/pad-start.js';
|
|
14
14
|
import { withLogger } from '../lib/with-logger.js';
|
|
15
|
-
export function lintSemverRanges({ io, cli, errorHandlers = defaultErrorHandlers }) {
|
|
16
|
-
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(
|
|
15
|
+
export function lintSemverRanges({ io, cli, errorHandlers = defaultErrorHandlers, }) {
|
|
16
|
+
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(ctx => pipeline(ctx, io, errorHandlers)), Effect.flatMap(exitIfInvalid), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
|
|
17
17
|
}
|
|
18
18
|
/** Exported to be reused by `syncpack lint` */
|
|
19
19
|
export function pipeline(ctx, io, errorHandlers) {
|
|
@@ -49,8 +49,9 @@ export function pipeline(ctx, io, errorHandlers) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
if (validCount > 0)
|
|
52
|
+
if (validCount > 0) {
|
|
53
53
|
yield* $(logValidSize(validCount));
|
|
54
|
+
}
|
|
54
55
|
index++;
|
|
55
56
|
}
|
|
56
57
|
return ctx;
|
package/dist/bin-list/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import chalk from 'chalk-template';
|
|
3
2
|
import { program } from 'commander';
|
|
4
3
|
import { Effect } from 'effect';
|
|
5
4
|
import { io } from '../io/index.js';
|
|
@@ -7,36 +6,7 @@ import { showHelpOnError } from '../lib/show-help-on-error.js';
|
|
|
7
6
|
import { option } from '../option.js';
|
|
8
7
|
import { list } from './list.js';
|
|
9
8
|
program.description(' List all dependencies required by your packages.');
|
|
10
|
-
program.on('--help', () => {
|
|
11
|
-
console.log(chalk `
|
|
12
|
-
Examples:
|
|
13
|
-
{dim # uses defaults for resolving packages}
|
|
14
|
-
syncpack list
|
|
15
|
-
{dim # uses packages defined by --source when provided}
|
|
16
|
-
syncpack list --source {yellow "apps/*/package.json"}
|
|
17
|
-
{dim # multiple globs can be provided like this}
|
|
18
|
-
syncpack list --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
|
|
19
|
-
{dim # uses dependencies regular expression defined by --filter when provided}
|
|
20
|
-
syncpack list --filter {yellow "typescript|tslint"}
|
|
21
|
-
{dim # only inspect "devDependencies"}
|
|
22
|
-
syncpack list --types dev
|
|
23
|
-
{dim # only inspect "devDependencies" and "peerDependencies"}
|
|
24
|
-
syncpack list --types dev,peer
|
|
25
|
-
|
|
26
|
-
Resolving Packages:
|
|
27
|
-
1. If {yellow --source} globs are provided, use those.
|
|
28
|
-
2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
29
|
-
3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
30
|
-
4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
31
|
-
5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
32
|
-
|
|
33
|
-
Reference:
|
|
34
|
-
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
35
|
-
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
36
|
-
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
37
|
-
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
38
|
-
`);
|
|
39
|
-
});
|
|
9
|
+
program.on('--help', () => { });
|
|
40
10
|
showHelpOnError(program);
|
|
41
11
|
program
|
|
42
12
|
.option(...option.source)
|
package/dist/bin-list/list.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import type { CliConfig } from '../config/types.js';
|
|
3
3
|
import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
4
4
|
import type { Ctx } from '../get-context/index.js';
|
|
5
5
|
import type { Io } from '../io/index.js';
|
package/dist/bin-list/list.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { EOL } from 'node:os';
|
|
1
2
|
import chalk from 'chalk-template';
|
|
2
3
|
import { Context, Effect, pipe } from 'effect';
|
|
3
|
-
import { EOL } from 'os';
|
|
4
4
|
import { CliConfigTag } from '../config/tag.js';
|
|
5
5
|
import { ICON } from '../constants.js';
|
|
6
6
|
import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
@@ -12,7 +12,7 @@ import { getVersionGroupHeader } from '../lib/get-group-header.js';
|
|
|
12
12
|
import { padStart } from '../lib/pad-start.js';
|
|
13
13
|
import { withLogger } from '../lib/with-logger.js';
|
|
14
14
|
export function list({ io, cli, errorHandlers = defaultErrorHandlers }) {
|
|
15
|
-
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(
|
|
15
|
+
return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(ctx => pipeline(ctx, io, errorHandlers)), Effect.flatMap(exitIfInvalid), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
|
|
16
16
|
}
|
|
17
17
|
export function pipeline(ctx, io, errorHandlers) {
|
|
18
18
|
return Effect.gen(function* ($) {
|
|
@@ -21,9 +21,12 @@ export function pipeline(ctx, io, errorHandlers) {
|
|
|
21
21
|
for (const group of versionGroups) {
|
|
22
22
|
yield* $(Effect.logInfo(getVersionGroupHeader({ group, index })));
|
|
23
23
|
yield* $(onGroupTag[group._tag](group));
|
|
24
|
-
if (group._tag === 'Banned' ||
|
|
25
|
-
|
|
24
|
+
if (group._tag === 'Banned' ||
|
|
25
|
+
group._tag === 'FilteredOut' ||
|
|
26
|
+
group._tag === 'Ignored') {
|
|
27
|
+
if (group._tag === 'Banned') {
|
|
26
28
|
ctx.isInvalid = true;
|
|
29
|
+
}
|
|
27
30
|
index++;
|
|
28
31
|
continue;
|
|
29
32
|
}
|
|
@@ -31,8 +34,9 @@ export function pipeline(ctx, io, errorHandlers) {
|
|
|
31
34
|
const matches = new Set();
|
|
32
35
|
const mismatches = new Set();
|
|
33
36
|
for (const report of groupReport.reports) {
|
|
34
|
-
if (report.isInvalid)
|
|
37
|
+
if (report.isInvalid) {
|
|
35
38
|
ctx.isInvalid = true;
|
|
39
|
+
}
|
|
36
40
|
switch (report._tagGroup) {
|
|
37
41
|
case 'Valid': {
|
|
38
42
|
const actual = report.specifier.raw;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import chalk from 'chalk-template';
|
|
3
2
|
import { program } from 'commander';
|
|
4
3
|
import { Effect } from 'effect';
|
|
5
4
|
import { io } from '../io/index.js';
|
|
@@ -9,36 +8,7 @@ import { listMismatches } from './list-mismatches.js';
|
|
|
9
8
|
program.description(`
|
|
10
9
|
List dependencies which are required by multiple packages, where the version
|
|
11
10
|
is not the same across every package.`.replace(/^\n/, ''));
|
|
12
|
-
program.on('--help', () => {
|
|
13
|
-
console.log(chalk `
|
|
14
|
-
Examples:
|
|
15
|
-
{dim # uses defaults for resolving packages}
|
|
16
|
-
syncpack list-mismatches
|
|
17
|
-
{dim # uses packages defined by --source when provided}
|
|
18
|
-
syncpack list-mismatches --source {yellow "apps/*/package.json"}
|
|
19
|
-
{dim # multiple globs can be provided like this}
|
|
20
|
-
syncpack list-mismatches --source {yellow "apps/*/package.json"} --source {yellow "core/*/package.json"}
|
|
21
|
-
{dim # uses dependencies regular expression defined by --filter when provided}
|
|
22
|
-
syncpack list-mismatches --filter {yellow "typescript|tslint"}
|
|
23
|
-
{dim # only inspect "devDependencies"}
|
|
24
|
-
syncpack list-mismatches --types dev
|
|
25
|
-
{dim # only inspect "devDependencies" and "peerDependencies"}
|
|
26
|
-
syncpack list-mismatches --types dev,peer
|
|
27
|
-
|
|
28
|
-
Resolving Packages:
|
|
29
|
-
1. If {yellow --source} globs are provided, use those.
|
|
30
|
-
2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.
|
|
31
|
-
3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.
|
|
32
|
-
4. If using Lerna, read {yellow packages} from {yellow lerna.json}.
|
|
33
|
-
5. Default to {yellow "package.json"} and {yellow "packages/*/package.json"}.
|
|
34
|
-
|
|
35
|
-
Reference:
|
|
36
|
-
globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}
|
|
37
|
-
lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}
|
|
38
|
-
Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}
|
|
39
|
-
Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}
|
|
40
|
-
`);
|
|
41
|
-
});
|
|
11
|
+
program.on('--help', () => { });
|
|
42
12
|
showHelpOnError(program);
|
|
43
13
|
program
|
|
44
14
|
.option(...option.source)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import type { CliConfig } from '../config/types.js';
|
|
3
3
|
import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
|
|
4
4
|
import type { Ctx } from '../get-context/index.js';
|
|
5
5
|
import type { Io } from '../io/index.js';
|
|
@@ -8,7 +8,7 @@ interface Input {
|
|
|
8
8
|
cli: Partial<CliConfig>;
|
|
9
9
|
errorHandlers?: ErrorHandlers;
|
|
10
10
|
}
|
|
11
|
-
export declare function listMismatches({ io, cli, errorHandlers }: Input): Effect.Effect<unknown, never, never>;
|
|
11
|
+
export declare function listMismatches({ io, cli, errorHandlers, }: Input): Effect.Effect<unknown, never, never>;
|
|
12
12
|
/** Exported to be reused by `syncpack lint` */
|
|
13
13
|
export declare function pipeline(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<Ctx>;
|
|
14
14
|
export declare const logMissingLocalVersion: (report: any) => Effect.Effect<void>;
|