syncpack 9.8.6 → 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 +22 -19
- package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +2 -2
- package/dist/bin-fix-mismatches/fix-mismatches-cli.js +3 -1
- package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -2
- package/dist/bin-fix-mismatches/fix-mismatches.js +42 -24
- package/dist/bin-format/format-cli.d.ts +2 -2
- package/dist/bin-format/format-cli.js +2 -1
- package/dist/bin-format/format.d.ts +2 -2
- package/dist/bin-format/format.js +4 -1
- 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-lint-semver-ranges/lint-semver-ranges-cli.d.ts +2 -2
- package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +2 -1
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -2
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +29 -25
- package/dist/bin-list/list-cli.d.ts +2 -2
- package/dist/bin-list/list-cli.js +2 -1
- package/dist/bin-list/list.d.ts +2 -2
- package/dist/bin-list/list.js +58 -54
- package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +2 -2
- package/dist/bin-list-mismatches/list-mismatches-cli.js +2 -1
- package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -2
- package/dist/bin-list-mismatches/list-mismatches.js +72 -106
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +2 -2
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +2 -1
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -2
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +17 -3
- package/dist/bin.js +3 -0
- package/dist/config/get-custom-types.d.ts +9 -0
- package/dist/config/get-custom-types.js +49 -0
- package/dist/config/get-enabled-types.d.ts +3 -0
- package/dist/config/get-enabled-types.js +48 -0
- package/dist/config/get-filter.d.ts +2 -0
- package/dist/config/get-filter.js +13 -0
- package/dist/config/get-indent.d.ts +2 -0
- package/dist/config/get-indent.js +12 -0
- package/dist/config/get-semver-range.d.ts +3 -0
- package/dist/config/get-semver-range.js +12 -0
- package/dist/config/get-sort-az.d.ts +2 -0
- package/dist/config/get-sort-az.js +18 -0
- package/dist/config/get-sort-first.d.ts +2 -0
- package/dist/config/get-sort-first.js +10 -0
- package/dist/config/get-source.d.ts +2 -0
- package/dist/config/get-source.js +13 -0
- package/dist/config/types.d.ts +106 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/get-context/index.d.ts +8 -16
- package/dist/get-context/index.js +7 -33
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.d.ts +3 -3
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.js +4 -4
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-lerna-patterns.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-lerna-patterns.js +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-pnpm-patterns.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-pnpm-patterns.js +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-yarn-patterns.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-yarn-patterns.js +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.d.ts +3 -3
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.js +4 -3
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-json-safe.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-yaml-safe.d.ts +1 -1
- package/dist/{get-context/get-package-json-files → get-package-json-files}/index.d.ts +3 -3
- package/dist/{get-context/get-package-json-files → get-package-json-files}/index.js +1 -1
- package/dist/{get-context/get-package-json-files/package-json-file → get-package-json-files}/instance.d.ts +6 -8
- package/dist/get-package-json-files/instance.js +23 -0
- package/dist/{get-context/get-package-json-files/package-json-file/index.d.ts → get-package-json-files/package-json-file.d.ts} +7 -9
- package/dist/get-package-json-files/package-json-file.js +45 -0
- package/dist/get-semver-groups/catch-all.d.ts +4 -0
- package/dist/get-semver-groups/catch-all.js +11 -0
- package/dist/get-semver-groups/filtered-out.d.ts +13 -0
- package/dist/get-semver-groups/filtered-out.js +29 -0
- package/dist/get-semver-groups/ignored.d.ts +11 -0
- package/dist/get-semver-groups/ignored.js +22 -0
- package/dist/get-semver-groups/index.d.ts +32 -0
- package/dist/get-semver-groups/index.js +90 -0
- package/dist/get-semver-groups/with-range.d.ts +11 -0
- package/dist/get-semver-groups/with-range.js +55 -0
- package/dist/get-version-groups/banned.d.ts +11 -0
- package/dist/get-version-groups/banned.js +24 -0
- package/dist/get-version-groups/catch-all.d.ts +4 -0
- package/dist/get-version-groups/catch-all.js +11 -0
- package/dist/get-version-groups/filtered-out.d.ts +13 -0
- package/dist/get-version-groups/filtered-out.js +31 -0
- package/dist/get-version-groups/ignored.d.ts +11 -0
- package/dist/get-version-groups/ignored.js +24 -0
- package/dist/get-version-groups/index.d.ts +57 -0
- package/dist/get-version-groups/index.js +119 -0
- package/dist/get-version-groups/lib/delete.d.ts +2 -0
- package/dist/get-version-groups/lib/delete.js +4 -0
- package/dist/get-version-groups/lib/get-highest-version.js +13 -0
- package/dist/get-version-groups/lib/get-lowest-version.js +13 -0
- package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.js +3 -2
- package/dist/get-version-groups/lib/get-unique-versions.d.ts +2 -0
- package/dist/get-version-groups/lib/get-unique-versions.js +8 -0
- package/dist/get-version-groups/lib/group-by.d.ts +1 -0
- package/dist/get-version-groups/lib/group-by.js +11 -0
- package/dist/get-version-groups/lib/sort.d.ts +1 -0
- package/dist/get-version-groups/lib/sort.js +44 -0
- package/dist/get-version-groups/pinned.d.ts +11 -0
- package/dist/get-version-groups/pinned.js +43 -0
- package/dist/get-version-groups/snapped-to.d.ts +11 -0
- package/dist/get-version-groups/snapped-to.js +52 -0
- package/dist/get-version-groups/standard.d.ts +11 -0
- package/dist/get-version-groups/standard.js +95 -0
- package/dist/index.d.ts +2 -0
- package/dist/{get-context → lib}/$R.d.ts +2 -2
- package/dist/{get-context → lib}/$R.js +3 -4
- package/dist/lib/disk.d.ts +3 -2
- package/dist/lib/exit-if-invalid.d.ts +2 -2
- package/dist/lib/is-semver.d.ts +5 -3
- package/dist/lib/is-semver.js +17 -3
- package/dist/lib/log.d.ts +4 -8
- package/dist/lib/log.js +3 -29
- package/dist/lib/set-semver-range.d.ts +2 -2
- package/dist/lib/write-if-changed.d.ts +2 -2
- package/dist/lib/write-if-changed.js +6 -25
- package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.d.ts +1 -1
- package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.js +1 -2
- package/dist/strategy/name-and-version-props.d.ts +12 -0
- package/dist/strategy/name-and-version-props.js +50 -0
- package/dist/strategy/named-version-string.d.ts +11 -0
- package/dist/{get-context/get-config/path-strategy/name-and-version-string.js → strategy/named-version-string.js} +26 -22
- package/dist/strategy/unnamed-version-string.d.ts +11 -0
- package/dist/strategy/unnamed-version-string.js +48 -0
- package/dist/strategy/versions-by-name.d.ts +11 -0
- package/dist/strategy/versions-by-name.js +29 -0
- package/package.json +8 -4
- package/dist/get-context/get-config/get-core-types.d.ts +0 -36
- package/dist/get-context/get-config/get-core-types.js +0 -38
- package/dist/get-context/get-config/get-custom-types.d.ts +0 -4
- package/dist/get-context/get-config/get-custom-types.js +0 -16
- package/dist/get-context/get-config/get-enabled-types.d.ts +0 -4
- package/dist/get-context/get-config/get-enabled-types.js +0 -17
- package/dist/get-context/get-config/index.d.ts +0 -8
- package/dist/get-context/get-config/index.js +0 -98
- package/dist/get-context/get-config/path-strategy/index.d.ts +0 -8
- package/dist/get-context/get-config/path-strategy/index.js +0 -18
- package/dist/get-context/get-config/path-strategy/name-and-version-props.d.ts +0 -2
- package/dist/get-context/get-config/path-strategy/name-and-version-props.js +0 -44
- package/dist/get-context/get-config/path-strategy/name-and-version-string.d.ts +0 -2
- package/dist/get-context/get-config/path-strategy/types.d.ts +0 -14
- package/dist/get-context/get-config/path-strategy/version-string.d.ts +0 -2
- package/dist/get-context/get-config/path-strategy/version-string.js +0 -49
- package/dist/get-context/get-config/path-strategy/versions-by-name.d.ts +0 -2
- package/dist/get-context/get-config/path-strategy/versions-by-name.js +0 -21
- package/dist/get-context/get-config/schema/base-group.d.ts +0 -7
- package/dist/get-context/get-config/schema/base-group.js +0 -10
- package/dist/get-context/get-config/schema/index.d.ts +0 -1540
- package/dist/get-context/get-config/schema/index.js +0 -81
- package/dist/get-context/get-config/schema/lib/non-empty-string.d.ts +0 -2
- package/dist/get-context/get-config/schema/lib/non-empty-string.js +0 -5
- package/dist/get-context/get-config/schema/paths.d.ts +0 -89
- package/dist/get-context/get-config/schema/paths.js +0 -33
- package/dist/get-context/get-config/schema/semver-group.d.ts +0 -119
- package/dist/get-context/get-config/schema/semver-group.js +0 -43
- package/dist/get-context/get-config/schema/semver-range.d.ts +0 -2
- package/dist/get-context/get-config/schema/semver-range.js +0 -16
- package/dist/get-context/get-config/schema/version-group.d.ts +0 -230
- package/dist/get-context/get-config/schema/version-group.js +0 -36
- package/dist/get-context/get-groups/base-group.d.ts +0 -22
- package/dist/get-context/get-groups/base-group.js +0 -39
- package/dist/get-context/get-groups/index.d.ts +0 -11
- package/dist/get-context/get-groups/index.js +0 -53
- package/dist/get-context/get-groups/semver-group.d.ts +0 -15
- package/dist/get-context/get-groups/semver-group.js +0 -46
- package/dist/get-context/get-groups/version-group/index.d.ts +0 -15
- package/dist/get-context/get-groups/version-group/index.js +0 -40
- package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +0 -42
- package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.js +0 -44
- package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +0 -34
- package/dist/get-context/get-groups/version-group/instance-group/index.js +0 -103
- package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +0 -4
- package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +0 -38
- package/dist/get-context/get-package-json-files/package-json-file/index.js +0 -65
- package/dist/get-context/get-package-json-files/package-json-file/instance.js +0 -46
- package/dist/lib/error.d.ts +0 -12
- package/dist/lib/error.js +0 -25
- package/dist/types.d.ts +0 -90
- /package/dist/{get-context/get-config/path-strategy → config}/types.js +0 -0
- /package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-json-safe.js +0 -0
- /package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-yaml-safe.js +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.d.ts +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.js +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups/lib}/get-highest-version.d.ts +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups/lib}/get-lowest-version.d.ts +0 -0
- /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.d.ts +0 -0
- /package/dist/{types.js → index.js} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSource = void 0;
|
|
4
|
+
const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function getSource({ cli, rcFile }) {
|
|
7
|
+
return (0, is_array_of_strings_1.isArrayOfStrings)(cli.source)
|
|
8
|
+
? cli.source
|
|
9
|
+
: (0, is_array_of_strings_1.isArrayOfStrings)(rcFile.source)
|
|
10
|
+
? rcFile.source
|
|
11
|
+
: [...constants_1.DEFAULT_CONFIG.source];
|
|
12
|
+
}
|
|
13
|
+
exports.getSource = getSource;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Union } from 'ts-toolbelt';
|
|
2
|
+
/**
|
|
3
|
+
* Aliases for semver range formats supported by syncpack
|
|
4
|
+
*
|
|
5
|
+
* Defaults to `""` to ensure that exact dependency versions are used
|
|
6
|
+
* instead of loose ranges, but this can be overridden in your config file
|
|
7
|
+
* or via the `--semver-range` command line option.
|
|
8
|
+
*
|
|
9
|
+
* | Supported Range | Example |
|
|
10
|
+
* | --------------- | --------: |
|
|
11
|
+
* | `"<"` | `<1.4.2` |
|
|
12
|
+
* | `"<="` | `<=1.4.2` |
|
|
13
|
+
* | `""` | `1.4.2` |
|
|
14
|
+
* | `"~"` | `~1.4.2` |
|
|
15
|
+
* | `"^"` | `^1.4.2` |
|
|
16
|
+
* | `">="` | `>=1.4.2` |
|
|
17
|
+
* | `">"` | `>1.4.2` |
|
|
18
|
+
* | `"*"` | `*` |
|
|
19
|
+
*
|
|
20
|
+
* @default ""
|
|
21
|
+
*/
|
|
22
|
+
export type SemverRange = '' | '*' | '>' | '>=' | '.x' | '<' | '<=' | '^' | '~';
|
|
23
|
+
export interface GroupConfig {
|
|
24
|
+
dependencies: string[];
|
|
25
|
+
dependencyTypes?: string[];
|
|
26
|
+
label?: string;
|
|
27
|
+
packages: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare namespace SemverGroupConfig {
|
|
30
|
+
interface Ignored extends GroupConfig {
|
|
31
|
+
isIgnored: true;
|
|
32
|
+
}
|
|
33
|
+
interface WithRange extends GroupConfig {
|
|
34
|
+
range: SemverRange;
|
|
35
|
+
}
|
|
36
|
+
type Any = Union.Strict<Ignored | WithRange>;
|
|
37
|
+
}
|
|
38
|
+
export declare namespace VersionGroupConfig {
|
|
39
|
+
interface Banned extends GroupConfig {
|
|
40
|
+
isBanned: true;
|
|
41
|
+
}
|
|
42
|
+
interface Ignored extends GroupConfig {
|
|
43
|
+
isIgnored: true;
|
|
44
|
+
}
|
|
45
|
+
interface Pinned extends GroupConfig {
|
|
46
|
+
pinVersion: string;
|
|
47
|
+
}
|
|
48
|
+
interface SnappedTo extends GroupConfig {
|
|
49
|
+
snapTo: string[];
|
|
50
|
+
}
|
|
51
|
+
interface Standard extends GroupConfig {
|
|
52
|
+
preferVersion?: 'highestSemver' | 'lowestSemver';
|
|
53
|
+
}
|
|
54
|
+
type Any = Union.Strict<Standard | Banned | Ignored | Pinned | SnappedTo>;
|
|
55
|
+
}
|
|
56
|
+
declare namespace CustomTypeConfig {
|
|
57
|
+
interface NameAndVersionProps {
|
|
58
|
+
namePath: string;
|
|
59
|
+
path: string;
|
|
60
|
+
strategy: 'name~version';
|
|
61
|
+
}
|
|
62
|
+
interface NamedVersionString {
|
|
63
|
+
path: string;
|
|
64
|
+
strategy: 'name@version';
|
|
65
|
+
}
|
|
66
|
+
interface UnnamedVersionString {
|
|
67
|
+
path: string;
|
|
68
|
+
strategy: 'version';
|
|
69
|
+
}
|
|
70
|
+
interface VersionsByName {
|
|
71
|
+
path: string;
|
|
72
|
+
strategy: 'versionsByName';
|
|
73
|
+
}
|
|
74
|
+
type Any = Union.Strict<NameAndVersionProps | NamedVersionString | UnnamedVersionString | VersionsByName>;
|
|
75
|
+
}
|
|
76
|
+
export interface CliConfig {
|
|
77
|
+
configPath?: string;
|
|
78
|
+
filter: string;
|
|
79
|
+
indent: string;
|
|
80
|
+
semverRange: SemverRange;
|
|
81
|
+
source: string[];
|
|
82
|
+
types: string;
|
|
83
|
+
}
|
|
84
|
+
export interface RcConfig {
|
|
85
|
+
/** @see https://jamiemason.github.io/syncpack/config/custom-types */
|
|
86
|
+
customTypes: Record<string, CustomTypeConfig.Any>;
|
|
87
|
+
/** @see https://jamiemason.github.io/syncpack/config/dependency-types */
|
|
88
|
+
dependencyTypes: string[];
|
|
89
|
+
/** @see https://jamiemason.github.io/syncpack/config/filter */
|
|
90
|
+
filter: string;
|
|
91
|
+
/** @see https://jamiemason.github.io/syncpack/config/indent */
|
|
92
|
+
indent: string;
|
|
93
|
+
/** @see https://jamiemason.github.io/syncpack/config/semver-groups */
|
|
94
|
+
semverGroups: SemverGroupConfig.Any[];
|
|
95
|
+
/** @see https://jamiemason.github.io/syncpack/config/semver-range */
|
|
96
|
+
semverRange: SemverRange;
|
|
97
|
+
/** @see https://jamiemason.github.io/syncpack/config/sort-az */
|
|
98
|
+
sortAz: string[];
|
|
99
|
+
/** @see https://jamiemason.github.io/syncpack/config/sort-first */
|
|
100
|
+
sortFirst: string[];
|
|
101
|
+
/** @see https://jamiemason.github.io/syncpack/config/source */
|
|
102
|
+
source: string[];
|
|
103
|
+
/** @see https://jamiemason.github.io/syncpack/config/version-groups */
|
|
104
|
+
versionGroups: VersionGroupConfig.Any[];
|
|
105
|
+
}
|
|
106
|
+
export {};
|
package/dist/constants.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare const RANGE: {
|
|
|
21
21
|
readonly LTE: "<=";
|
|
22
22
|
readonly MINOR: "^";
|
|
23
23
|
readonly PATCH: "~";
|
|
24
|
+
readonly WORKSPACE: "workspace:";
|
|
24
25
|
};
|
|
25
26
|
export declare const DEFAULT_CONFIG: {
|
|
26
27
|
readonly dependencyTypes: readonly ["dev", "overrides", "peer", "pnpmOverrides", "prod", "resolutions", "workspace"];
|
package/dist/constants.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
+
import type { O } from 'ts-toolbelt';
|
|
2
|
+
import type { CliConfig, RcConfig } from '../config/types';
|
|
3
|
+
import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
|
|
1
4
|
import type { Disk } from '../lib/disk';
|
|
2
|
-
import type { Syncpack } from '../types';
|
|
3
|
-
import type { SemverGroup } from './get-groups/semver-group';
|
|
4
|
-
import type { VersionGroup } from './get-groups/version-group';
|
|
5
|
-
import type { PackageJsonFile } from './get-package-json-files/package-json-file';
|
|
6
5
|
export interface Context {
|
|
7
|
-
config:
|
|
6
|
+
config: {
|
|
7
|
+
cli: Partial<CliConfig>;
|
|
8
|
+
rcFile: O.Partial<RcConfig, 'deep'>;
|
|
9
|
+
};
|
|
8
10
|
disk: Disk;
|
|
9
11
|
isInvalid: boolean;
|
|
10
12
|
packageJsonFiles: PackageJsonFile[];
|
|
11
|
-
semverGroups: SemverGroup[];
|
|
12
|
-
versionGroups: VersionGroup[];
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
* Every command in syncpack should accept the return value of this function as
|
|
16
|
-
* its input.
|
|
17
|
-
*
|
|
18
|
-
* The aim here is to move all disk activity to a single place, so
|
|
19
|
-
* that the majority of syncpack and its tests don't have to deal with the file
|
|
20
|
-
* system and can focus solely on transformation logic.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getContext(program: Partial<Syncpack.Config.Cli>, disk?: Disk): Context;
|
|
14
|
+
export declare function getContext(cli: Partial<CliConfig>, disk: Disk): Context;
|
|
@@ -1,43 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getContext = void 0;
|
|
4
|
-
const pipe_1 = require("tightrope/fn/pipe");
|
|
5
|
-
const and_then_1 = require("tightrope/result/and-then");
|
|
6
|
-
const map_1 = require("tightrope/result/map");
|
|
7
4
|
const unwrap_1 = require("tightrope/result/unwrap");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
* Every command in syncpack should accept the return value of this function as
|
|
15
|
-
* its input.
|
|
16
|
-
*
|
|
17
|
-
* The aim here is to move all disk activity to a single place, so
|
|
18
|
-
* that the majority of syncpack and its tests don't have to deal with the file
|
|
19
|
-
* system and can focus solely on transformation logic.
|
|
20
|
-
*/
|
|
21
|
-
function getContext(program, disk = disk_1.disk) {
|
|
22
|
-
return (0, pipe_1.pipe)(
|
|
23
|
-
// merge CLI options, .syncpackrc contents, and default config
|
|
24
|
-
(0, get_config_1.getConfig)(disk, program), (0, and_then_1.andThen)((config) => (0, pipe_1.pipe)(
|
|
25
|
-
// get the package.json file which match the globs in config
|
|
26
|
-
(0, get_package_json_files_1.getPackageJsonFiles)(disk, config), (0, and_then_1.andThen)((packageJsonFiles) => (0, pipe_1.pipe)(
|
|
27
|
-
// allocate dependencies into semver and version groups
|
|
28
|
-
(0, get_groups_1.getGroups)(config, packageJsonFiles),
|
|
29
|
-
// combine everything into the final config
|
|
30
|
-
(0, map_1.map)(({ semverGroups, versionGroups }) => ({
|
|
5
|
+
const get_package_json_files_1 = require("../get-package-json-files");
|
|
6
|
+
function getContext(cli, disk) {
|
|
7
|
+
const rcFile = disk.readConfigFileSync(cli.configPath);
|
|
8
|
+
const config = { cli, rcFile };
|
|
9
|
+
const packageJsonFiles = (0, unwrap_1.unwrap)((0, get_package_json_files_1.getPackageJsonFiles)(disk, config));
|
|
10
|
+
return {
|
|
31
11
|
config,
|
|
32
12
|
disk,
|
|
33
13
|
isInvalid: false,
|
|
34
14
|
packageJsonFiles,
|
|
35
|
-
|
|
36
|
-
versionGroups,
|
|
37
|
-
})))))),
|
|
38
|
-
// if anything errored at any stage, log it when in verbose mode
|
|
39
|
-
_R_1.$R.tapErrVerbose,
|
|
40
|
-
// throw if anything errored, can't do anything without this data
|
|
41
|
-
unwrap_1.unwrap);
|
|
15
|
+
};
|
|
42
16
|
}
|
|
43
17
|
exports.getContext = getContext;
|
package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.d.ts
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Result } from 'tightrope/result';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { Context } from '../get-context';
|
|
3
|
+
import type { Disk } from '../lib/disk';
|
|
4
4
|
type SafeFilePaths = Result<string[]>;
|
|
5
5
|
/**
|
|
6
6
|
* Using --source options and/or config files on disk from npm/pnpm/yarn/lerna,
|
|
@@ -9,5 +9,5 @@ type SafeFilePaths = Result<string[]>;
|
|
|
9
9
|
*
|
|
10
10
|
* @returns Array of absolute file paths to package.json files
|
|
11
11
|
*/
|
|
12
|
-
export declare function getFilePaths(disk: Disk,
|
|
12
|
+
export declare function getFilePaths(disk: Disk, config: Context['config']): SafeFilePaths;
|
|
13
13
|
export {};
|
package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.js
RENAMED
|
@@ -10,8 +10,8 @@ const filter_1 = require("tightrope/result/filter");
|
|
|
10
10
|
const from_try_1 = require("tightrope/result/from-try");
|
|
11
11
|
const map_1 = require("tightrope/result/map");
|
|
12
12
|
const map_err_1 = require("tightrope/result/map-err");
|
|
13
|
-
const _R_1 = require("
|
|
14
|
-
const print_strings_1 = require("
|
|
13
|
+
const _R_1 = require("../lib/$R");
|
|
14
|
+
const print_strings_1 = require("../lib/print-strings");
|
|
15
15
|
const get_patterns_1 = require("./get-patterns");
|
|
16
16
|
/**
|
|
17
17
|
* Using --source options and/or config files on disk from npm/pnpm/yarn/lerna,
|
|
@@ -20,8 +20,8 @@ const get_patterns_1 = require("./get-patterns");
|
|
|
20
20
|
*
|
|
21
21
|
* @returns Array of absolute file paths to package.json files
|
|
22
22
|
*/
|
|
23
|
-
function getFilePaths(disk,
|
|
24
|
-
return (0, pipe_1.pipe)(
|
|
23
|
+
function getFilePaths(disk, config) {
|
|
24
|
+
return (0, pipe_1.pipe)(config, (0, get_patterns_1.getPatterns)(disk), (0, and_then_1.andThen)(function resolvePatterns(patterns) {
|
|
25
25
|
return (0, pipe_1.pipe)(patterns, _R_1.$R.onlyOk(function resolvePattern(pattern) {
|
|
26
26
|
return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => disk.globSync(pattern)), (0, filter_1.filter)(is_array_of_strings_1.isArrayOfStrings, `"glob" did not match "${pattern}"`), (0, map_1.map)(flat_1.flat), (0, map_1.map)(uniq_1.uniq), _R_1.$R.tapErrVerbose);
|
|
27
27
|
}), (0, map_1.map)(flat_1.flat), (0, map_1.map)(uniq_1.uniq), (0, map_err_1.mapErr)(() => new Error(`No files matched ${(0, print_strings_1.printStrings)(patterns)}`)));
|
|
@@ -7,7 +7,7 @@ const pipe_1 = require("tightrope/fn/pipe");
|
|
|
7
7
|
const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
|
|
8
8
|
const and_then_1 = require("tightrope/result/and-then");
|
|
9
9
|
const filter_1 = require("tightrope/result/filter");
|
|
10
|
-
const constants_1 = require("
|
|
10
|
+
const constants_1 = require("../../constants");
|
|
11
11
|
const read_json_safe_1 = require("./read-json-safe");
|
|
12
12
|
function getLernaPatterns(disk) {
|
|
13
13
|
return function getLernaPatterns() {
|
|
@@ -7,7 +7,7 @@ const pipe_1 = require("tightrope/fn/pipe");
|
|
|
7
7
|
const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
|
|
8
8
|
const and_then_1 = require("tightrope/result/and-then");
|
|
9
9
|
const filter_1 = require("tightrope/result/filter");
|
|
10
|
-
const constants_1 = require("
|
|
10
|
+
const constants_1 = require("../../constants");
|
|
11
11
|
const read_yaml_safe_1 = require("./read-yaml-safe");
|
|
12
12
|
function getPnpmPatterns(disk) {
|
|
13
13
|
return function getPnpmPatterns() {
|
|
@@ -8,7 +8,7 @@ const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
|
|
|
8
8
|
const and_then_1 = require("tightrope/result/and-then");
|
|
9
9
|
const filter_1 = require("tightrope/result/filter");
|
|
10
10
|
const or_else_1 = require("tightrope/result/or-else");
|
|
11
|
-
const constants_1 = require("
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
12
|
const read_json_safe_1 = require("./read-json-safe");
|
|
13
13
|
function getYarnPatterns(disk) {
|
|
14
14
|
return function getYarnPatterns() {
|
package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.d.ts
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Result } from 'tightrope/result';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { Context } from '../../get-context';
|
|
3
|
+
import type { Disk } from '../../lib/disk';
|
|
4
4
|
/**
|
|
5
5
|
* Find every glob pattern which should be used to find package.json files for
|
|
6
6
|
* this monorepo.
|
|
7
7
|
*
|
|
8
8
|
* @returns `['./package.json', './packages/* /package.json']`
|
|
9
9
|
*/
|
|
10
|
-
export declare function getPatterns(disk: Disk): (
|
|
10
|
+
export declare function getPatterns(disk: Disk): (config: Context['config']) => Result<string[]>;
|
package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.js
RENAMED
|
@@ -7,7 +7,8 @@ const result_1 = require("tightrope/result");
|
|
|
7
7
|
const from_guard_1 = require("tightrope/result/from-guard");
|
|
8
8
|
const map_1 = require("tightrope/result/map");
|
|
9
9
|
const or_else_1 = require("tightrope/result/or-else");
|
|
10
|
-
const
|
|
10
|
+
const get_source_1 = require("../../config/get-source");
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
11
12
|
const get_lerna_patterns_1 = require("./get-lerna-patterns");
|
|
12
13
|
const get_pnpm_patterns_1 = require("./get-pnpm-patterns");
|
|
13
14
|
const get_yarn_patterns_1 = require("./get-yarn-patterns");
|
|
@@ -18,10 +19,10 @@ const get_yarn_patterns_1 = require("./get-yarn-patterns");
|
|
|
18
19
|
* @returns `['./package.json', './packages/* /package.json']`
|
|
19
20
|
*/
|
|
20
21
|
function getPatterns(disk) {
|
|
21
|
-
return function getPatterns(
|
|
22
|
+
return function getPatterns(config) {
|
|
22
23
|
return (0, pipe_1.pipe)(getCliPatterns(), (0, or_else_1.orElse)((0, get_yarn_patterns_1.getYarnPatterns)(disk)), (0, or_else_1.orElse)((0, get_pnpm_patterns_1.getPnpmPatterns)(disk)), (0, or_else_1.orElse)((0, get_lerna_patterns_1.getLernaPatterns)(disk)), (0, map_1.map)(addRootDir), (0, map_1.map)(limitToPackageJson), (0, or_else_1.orElse)(() => new result_1.Ok(constants_1.DEFAULT_SOURCES)));
|
|
23
24
|
function getCliPatterns() {
|
|
24
|
-
return (0, from_guard_1.fromGuard)(is_array_of_strings_1.isArrayOfStrings, new Error('No --source options provided'),
|
|
25
|
+
return (0, from_guard_1.fromGuard)(is_array_of_strings_1.isArrayOfStrings, new Error('No --source options provided'), (0, get_source_1.getSource)(config));
|
|
25
26
|
}
|
|
26
27
|
function addRootDir(patterns) {
|
|
27
28
|
return ['package.json', ...patterns];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Result } from 'tightrope/result';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { Context } from '../get-context';
|
|
3
|
+
import type { Disk } from '../lib/disk';
|
|
4
4
|
import { PackageJsonFile } from './package-json-file';
|
|
5
5
|
/** Create an API for every package.json file needed. */
|
|
6
|
-
export declare function getPackageJsonFiles(disk: Disk, config:
|
|
6
|
+
export declare function getPackageJsonFiles(disk: Disk, config: Context['config']): Result<PackageJsonFile[]>;
|
|
@@ -7,7 +7,7 @@ const result_1 = require("tightrope/result");
|
|
|
7
7
|
const and_then_1 = require("tightrope/result/and-then");
|
|
8
8
|
const map_1 = require("tightrope/result/map");
|
|
9
9
|
const or_1 = require("tightrope/result/or");
|
|
10
|
-
const _R_1 = require("
|
|
10
|
+
const _R_1 = require("../lib/$R");
|
|
11
11
|
const get_file_paths_1 = require("./get-file-paths");
|
|
12
12
|
const read_json_safe_1 = require("./get-patterns/read-json-safe");
|
|
13
13
|
const package_json_file_1 = require("./package-json-file");
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { Strategy } from '../config/get-custom-types';
|
|
2
|
+
import type { Delete } from '../get-version-groups/lib/delete';
|
|
3
|
+
import type { PackageJsonFile } from './package-json-file';
|
|
4
4
|
export declare class Instance {
|
|
5
5
|
/** the name of this dependency */
|
|
6
6
|
name: string;
|
|
7
7
|
/** The package this dependency is installed in this specific time */
|
|
8
8
|
packageJsonFile: PackageJsonFile;
|
|
9
|
-
/** where this dependency is installed */
|
|
10
|
-
|
|
9
|
+
/** locates where in the file this dependency is installed */
|
|
10
|
+
strategy: Strategy.Any;
|
|
11
11
|
/** The .name property of the package.json file of this instance */
|
|
12
12
|
pkgName: string;
|
|
13
13
|
/** the version of this dependency */
|
|
14
14
|
version: string;
|
|
15
|
-
constructor(
|
|
16
|
-
/** Is this instance the package.json file of this package developed in this repo? */
|
|
17
|
-
isWorkspace(): boolean;
|
|
15
|
+
constructor(strategy: Strategy.Any, name: string, packageJsonFile: PackageJsonFile, version: string);
|
|
18
16
|
/**
|
|
19
17
|
* In the case of banned dependencies, their version is set to `undefined`,
|
|
20
18
|
* which causes them to be removed by `JSON.stringify`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Instance = void 0;
|
|
4
|
+
const pipe_1 = require("tightrope/fn/pipe");
|
|
5
|
+
const _R_1 = require("../lib/$R");
|
|
6
|
+
class Instance {
|
|
7
|
+
constructor(strategy, name, packageJsonFile, version) {
|
|
8
|
+
this.strategy = strategy;
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.packageJsonFile = packageJsonFile;
|
|
11
|
+
this.pkgName = packageJsonFile.contents.name || 'PACKAGE_JSON_HAS_NO_NAME';
|
|
12
|
+
this.version = version;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* In the case of banned dependencies, their version is set to `undefined`,
|
|
16
|
+
* which causes them to be removed by `JSON.stringify`.
|
|
17
|
+
*/
|
|
18
|
+
setVersion(version) {
|
|
19
|
+
const file = this.packageJsonFile;
|
|
20
|
+
(0, pipe_1.pipe)(this.strategy.write(file, [this.name, version]), _R_1.$R.tapErrVerbose);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Instance = Instance;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { Strategy } from '../config/get-custom-types';
|
|
2
|
+
import type { Context } from '../get-context';
|
|
3
|
+
import type { Disk } from '../lib/disk';
|
|
4
|
+
import type { JsonFile } from './get-patterns/read-json-safe';
|
|
4
5
|
import { Instance } from './instance';
|
|
5
6
|
export interface PackageJson {
|
|
6
7
|
bugs?: {
|
|
@@ -27,7 +28,6 @@ export interface PackageJson {
|
|
|
27
28
|
workspaces?: Record<string, string[]> | string[];
|
|
28
29
|
[otherProps: string]: Record<string, string | string[] | Record<string, string | string[]>> | string | string[] | undefined;
|
|
29
30
|
}
|
|
30
|
-
type Entry = [string, string];
|
|
31
31
|
export declare class PackageJsonFile {
|
|
32
32
|
/** parsed JSON contents of the file */
|
|
33
33
|
contents: PackageJson;
|
|
@@ -38,14 +38,12 @@ export declare class PackageJsonFile {
|
|
|
38
38
|
/** raw file contents of the file */
|
|
39
39
|
readonly json: string;
|
|
40
40
|
/** resolved configuration */
|
|
41
|
-
readonly config:
|
|
41
|
+
readonly config: Context['config'];
|
|
42
42
|
/** relative path on disk to this file */
|
|
43
43
|
readonly shortPath: string;
|
|
44
|
-
constructor(jsonFile: JsonFile<PackageJson>, config:
|
|
44
|
+
constructor(jsonFile: JsonFile<PackageJson>, config: Context['config'], disk: Disk);
|
|
45
45
|
hasChanged(): boolean;
|
|
46
46
|
write(): void;
|
|
47
47
|
getSource(): string;
|
|
48
|
-
getInstances(): Instance[];
|
|
49
|
-
getPathEntries(pathDef: Syncpack.PathDefinition, file: PackageJsonFile): Entry[];
|
|
48
|
+
getInstances(enabledTypes: Strategy.Any[]): Instance[];
|
|
50
49
|
}
|
|
51
|
-
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PackageJsonFile = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const pipe_1 = require("tightrope/fn/pipe");
|
|
6
|
+
const map_1 = require("tightrope/result/map");
|
|
7
|
+
const get_indent_1 = require("../config/get-indent");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const log_1 = require("../lib/log");
|
|
10
|
+
const newlines_1 = require("../lib/newlines");
|
|
11
|
+
const instance_1 = require("./instance");
|
|
12
|
+
class PackageJsonFile {
|
|
13
|
+
constructor(jsonFile, config, disk) {
|
|
14
|
+
this.config = config;
|
|
15
|
+
this.contents = jsonFile.contents;
|
|
16
|
+
this.disk = disk;
|
|
17
|
+
this.filePath = jsonFile.filePath;
|
|
18
|
+
this.json = jsonFile.json;
|
|
19
|
+
this.shortPath = (0, path_1.relative)(constants_1.CWD, jsonFile.filePath);
|
|
20
|
+
}
|
|
21
|
+
hasChanged() {
|
|
22
|
+
return this.json !== this.getSource();
|
|
23
|
+
}
|
|
24
|
+
write() {
|
|
25
|
+
this.disk.writeFileSync(this.filePath, this.getSource());
|
|
26
|
+
}
|
|
27
|
+
getSource() {
|
|
28
|
+
const contents = this.contents;
|
|
29
|
+
const indent = (0, get_indent_1.getIndent)(this.config);
|
|
30
|
+
const EOL = newlines_1.newlines.detect(this.json);
|
|
31
|
+
const source = `${JSON.stringify(contents, null, indent)}${EOL}`;
|
|
32
|
+
return newlines_1.newlines.fix(source, EOL);
|
|
33
|
+
}
|
|
34
|
+
getInstances(enabledTypes) {
|
|
35
|
+
const instances = [];
|
|
36
|
+
enabledTypes.forEach((strategy) => {
|
|
37
|
+
(0, pipe_1.pipe)(strategy.read(this), (0, map_1.map)((entries) => entries.forEach(([name, version]) => {
|
|
38
|
+
(0, log_1.verbose)(`add ${name}@${version} to ${strategy.name}:${strategy._tag} ${this.shortPath}`);
|
|
39
|
+
instances.push(new instance_1.Instance(strategy, name, this, version));
|
|
40
|
+
})));
|
|
41
|
+
});
|
|
42
|
+
return instances;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.PackageJsonFile = PackageJsonFile;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CatchAllSemverGroup = void 0;
|
|
4
|
+
const with_range_1 = require("./with-range");
|
|
5
|
+
class CatchAllSemverGroup extends with_range_1.WithRangeSemverGroup {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this._tag = 'CatchAll';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.CatchAllSemverGroup = CatchAllSemverGroup;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SemverGroupReport } from '.';
|
|
2
|
+
import type { GroupConfig } from '../config/types';
|
|
3
|
+
import type { Context } from '../get-context';
|
|
4
|
+
import type { Instance } from '../get-package-json-files/instance';
|
|
5
|
+
export declare class FilteredOutSemverGroup {
|
|
6
|
+
_tag: string;
|
|
7
|
+
config: GroupConfig;
|
|
8
|
+
filter: string;
|
|
9
|
+
instances: Instance[];
|
|
10
|
+
constructor(ctx: Context);
|
|
11
|
+
canAdd(instance: Instance): boolean;
|
|
12
|
+
inspect(): SemverGroupReport[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilteredOutSemverGroup = void 0;
|
|
4
|
+
const get_filter_1 = require("../config/get-filter");
|
|
5
|
+
class FilteredOutSemverGroup {
|
|
6
|
+
constructor(ctx) {
|
|
7
|
+
this._tag = 'FilteredOut';
|
|
8
|
+
this.config = {
|
|
9
|
+
dependencies: ['**'],
|
|
10
|
+
dependencyTypes: [],
|
|
11
|
+
label: 'Filtered out',
|
|
12
|
+
packages: ['**'],
|
|
13
|
+
};
|
|
14
|
+
this.filter = (0, get_filter_1.getFilter)(ctx.config);
|
|
15
|
+
this.instances = [];
|
|
16
|
+
}
|
|
17
|
+
canAdd(instance) {
|
|
18
|
+
return instance.name.search(new RegExp(this.filter)) === -1;
|
|
19
|
+
}
|
|
20
|
+
inspect() {
|
|
21
|
+
return this.instances.map((instance) => ({
|
|
22
|
+
status: 'FILTERED_OUT',
|
|
23
|
+
instance,
|
|
24
|
+
isValid: true,
|
|
25
|
+
name: instance.name,
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.FilteredOutSemverGroup = FilteredOutSemverGroup;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SemverGroupReport } from '.';
|
|
2
|
+
import type { SemverGroupConfig } from '../config/types';
|
|
3
|
+
import type { Instance } from '../get-package-json-files/instance';
|
|
4
|
+
export declare class IgnoredSemverGroup {
|
|
5
|
+
_tag: string;
|
|
6
|
+
config: SemverGroupConfig.Ignored;
|
|
7
|
+
instances: Instance[];
|
|
8
|
+
constructor(config: SemverGroupConfig.Ignored);
|
|
9
|
+
canAdd(_: Instance): boolean;
|
|
10
|
+
inspect(): SemverGroupReport[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IgnoredSemverGroup = void 0;
|
|
4
|
+
class IgnoredSemverGroup {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this._tag = 'Ignored';
|
|
7
|
+
this.config = config;
|
|
8
|
+
this.instances = [];
|
|
9
|
+
}
|
|
10
|
+
canAdd(_) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
inspect() {
|
|
14
|
+
return this.instances.map((instance) => ({
|
|
15
|
+
status: 'IGNORED',
|
|
16
|
+
instance,
|
|
17
|
+
isValid: true,
|
|
18
|
+
name: instance.name,
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.IgnoredSemverGroup = IgnoredSemverGroup;
|