syncpack 8.4.11 → 8.5.14
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 -1
- package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +3 -0
- package/dist/bin-fix-mismatches/fix-mismatches-cli.js +10 -0
- package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -3
- package/dist/bin-fix-mismatches/fix-mismatches.js +19 -58
- package/dist/bin-fix-mismatches/index.js +3 -4
- package/dist/bin-format/format-cli.d.ts +3 -0
- package/dist/bin-format/format-cli.js +10 -0
- package/dist/bin-format/format.d.ts +2 -3
- package/dist/bin-format/format.js +10 -11
- package/dist/bin-format/index.js +3 -4
- package/dist/bin-lint-semver-ranges/index.js +3 -4
- package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.d.ts +3 -0
- package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +10 -0
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -3
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +73 -27
- package/dist/bin-list/index.js +3 -4
- package/dist/bin-list/list-cli.d.ts +3 -0
- package/dist/bin-list/list-cli.js +10 -0
- package/dist/bin-list/list.d.ts +2 -3
- package/dist/bin-list/list.js +60 -35
- package/dist/bin-list-mismatches/index.js +3 -4
- package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +3 -0
- package/dist/bin-list-mismatches/list-mismatches-cli.js +10 -0
- package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -3
- package/dist/bin-list-mismatches/list-mismatches.js +75 -73
- package/dist/bin-set-semver-ranges/index.js +3 -4
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +3 -0
- package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +10 -0
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -3
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +5 -29
- package/dist/constants.d.ts +27 -21
- package/dist/constants.js +28 -32
- package/dist/lib/disk.d.ts +3 -3
- package/dist/lib/disk.js +0 -1
- package/dist/lib/exit-if-invalid.d.ts +2 -0
- package/dist/lib/exit-if-invalid.js +10 -0
- package/dist/lib/get-context/get-all-instances.d.ts +3 -0
- package/dist/lib/get-context/get-all-instances.js +8 -0
- package/dist/lib/get-context/get-config/config.d.ts +151 -0
- package/dist/{types/index.js → lib/get-context/get-config/config.js} +0 -0
- package/dist/lib/get-context/get-config/index.d.ts +8 -0
- package/dist/lib/{get-input/get-config.js → get-context/get-config/index.js} +35 -10
- package/dist/lib/get-context/get-config/internal-config.d.ts +24 -0
- package/dist/{types/semver-group.js → lib/get-context/get-config/internal-config.js} +0 -0
- package/dist/lib/get-context/get-groups/get-semver-groups.d.ts +4 -0
- package/dist/lib/get-context/get-groups/get-semver-groups.js +45 -0
- package/dist/lib/get-context/get-groups/get-version-groups.d.ts +4 -0
- package/dist/lib/get-context/get-groups/get-version-groups.js +71 -0
- package/dist/lib/get-context/get-groups/semver-group/index.d.ts +30 -0
- package/dist/lib/get-context/get-groups/semver-group/index.js +33 -0
- package/dist/lib/get-context/get-groups/version-group/index.d.ts +30 -0
- package/dist/lib/get-context/get-groups/version-group/index.js +23 -0
- package/dist/{bin-fix-mismatches/get-expected-version → lib/get-context/get-groups/version-group/instance-group}/get-highest-version.d.ts +0 -0
- package/dist/{bin-fix-mismatches/get-expected-version → lib/get-context/get-groups/version-group/instance-group}/get-highest-version.js +10 -10
- package/dist/lib/get-context/get-groups/version-group/instance-group/index.d.ts +32 -0
- package/dist/lib/get-context/get-groups/version-group/instance-group/index.js +79 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-file-paths.d.ts +3 -3
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-file-paths.js +7 -2
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-lerna-patterns.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-lerna-patterns.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-pnpm-patterns.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-pnpm-patterns.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-yarn-patterns.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/get-yarn-patterns.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/index.d.ts +3 -3
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/index.js +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/props.d.ts +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/props.js +0 -0
- package/dist/lib/get-context/get-package-json-files/get-patterns/read-json-safe.d.ts +11 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/read-json-safe.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/read-yaml-safe.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/get-patterns/read-yaml-safe.js +0 -0
- package/dist/lib/get-context/get-package-json-files/index.d.ts +5 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/index.js +8 -8
- package/dist/lib/get-context/get-package-json-files/package-json-file/index.d.ts +50 -0
- package/dist/lib/get-context/get-package-json-files/package-json-file/index.js +95 -0
- package/dist/lib/get-context/get-package-json-files/package-json-file/instance.d.ts +25 -0
- package/dist/lib/get-context/get-package-json-files/package-json-file/instance.js +46 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/tap.d.ts +1 -1
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/tap.js +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/try-catch.d.ts +0 -0
- package/dist/lib/{get-input/get-wrappers → get-context/get-package-json-files}/try-catch.js +0 -0
- package/dist/lib/get-context/index.d.ts +22 -0
- package/dist/lib/get-context/index.js +38 -0
- package/dist/lib/is-semver.d.ts +1 -1
- package/dist/lib/is-semver.js +9 -9
- package/dist/lib/log.d.ts +6 -0
- package/dist/lib/log.js +40 -1
- package/dist/lib/newlines.d.ts +6 -0
- package/dist/lib/newlines.js +24 -0
- package/dist/lib/set-semver-range.d.ts +1 -1
- package/dist/lib/set-semver-range.js +1 -1
- package/dist/lib/write-if-changed.d.ts +2 -0
- package/dist/lib/write-if-changed.js +40 -0
- package/dist/option.d.ts +2 -1
- package/dist/option.js +4 -2
- package/package.json +21 -21
- package/dist/bin-fix-mismatches/get-expected-version/get-pinned-version.d.ts +0 -2
- package/dist/bin-fix-mismatches/get-expected-version/get-pinned-version.js +0 -7
- package/dist/bin-fix-mismatches/get-expected-version/get-workspace-version.d.ts +0 -6
- package/dist/bin-fix-mismatches/get-expected-version/get-workspace-version.js +0 -17
- package/dist/bin-fix-mismatches/get-expected-version/index.d.ts +0 -3
- package/dist/bin-fix-mismatches/get-expected-version/index.js +0 -27
- package/dist/bin-lint-semver-ranges/list-semver-group-mismatches.d.ts +0 -2
- package/dist/bin-lint-semver-ranges/list-semver-group-mismatches.js +0 -12
- package/dist/bin-list/list-version-groups.d.ts +0 -10
- package/dist/bin-list/list-version-groups.js +0 -52
- package/dist/lib/collect.d.ts +0 -1
- package/dist/lib/collect.js +0 -7
- package/dist/lib/get-input/get-config.d.ts +0 -12
- package/dist/lib/get-input/get-instances.d.ts +0 -29
- package/dist/lib/get-input/get-instances.js +0 -172
- package/dist/lib/get-input/get-wrappers/get-patterns/read-json-safe.d.ts +0 -4
- package/dist/lib/get-input/get-wrappers/index.d.ts +0 -38
- package/dist/lib/get-input/get-wrappers/readonly.d.ts +0 -4
- package/dist/lib/get-input/get-wrappers/readonly.js +0 -10
- package/dist/lib/get-input/index.d.ts +0 -20
- package/dist/lib/get-input/index.js +0 -32
- package/dist/lib/group-by.d.ts +0 -1
- package/dist/lib/group-by.js +0 -11
- package/dist/lib/write-if-changed/index.d.ts +0 -10
- package/dist/lib/write-if-changed/index.js +0 -25
- package/dist/lib/write-if-changed/set-newlines.d.ts +0 -4
- package/dist/lib/write-if-changed/set-newlines.js +0 -24
- package/dist/types/index.d.ts +0 -77
- package/dist/types/semver-group.d.ts +0 -30
- package/dist/types/version-group.d.ts +0 -35
- package/dist/types/version-group.js +0 -2
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { ALL_DEPENDENCY_TYPES, RANGE } from '../../../constants';
|
|
2
|
+
/** Aliases for locations within package.json files where versions can be found */
|
|
3
|
+
export type DependencyType = (typeof ALL_DEPENDENCY_TYPES)[number];
|
|
4
|
+
/** Aliases for semver range formats supported by syncpack */
|
|
5
|
+
export type ValidRange = (typeof RANGE)[keyof typeof RANGE];
|
|
6
|
+
export declare namespace Config {
|
|
7
|
+
export namespace SemverGroup {
|
|
8
|
+
/** All valid forms of Semver Group */
|
|
9
|
+
export type Any = Ignored | WithRange;
|
|
10
|
+
export interface Ignored extends Base {
|
|
11
|
+
/** Optionally force syncpack to ignore all dependencies in this group */
|
|
12
|
+
isIgnored: true;
|
|
13
|
+
}
|
|
14
|
+
export interface WithRange extends Base {
|
|
15
|
+
/** The semver range which dependencies in this group should use */
|
|
16
|
+
range: ValidRange;
|
|
17
|
+
}
|
|
18
|
+
interface Base {
|
|
19
|
+
/**
|
|
20
|
+
* The names of packages in your monorepo which belong to this group, taken
|
|
21
|
+
* from the "name" field in package.json, not the package directory name
|
|
22
|
+
*/
|
|
23
|
+
packages: string[];
|
|
24
|
+
/** Dependency names (eg. "lodash") which belong to this group */
|
|
25
|
+
dependencies: string[];
|
|
26
|
+
/** Optionally limit this group to dependencies of the provided types */
|
|
27
|
+
dependencyTypes?: DependencyType[];
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
}
|
|
31
|
+
export namespace VersionGroup {
|
|
32
|
+
/** All valid forms of Version Group */
|
|
33
|
+
type Any = Standard | Banned | Ignored | Pinned;
|
|
34
|
+
interface Standard {
|
|
35
|
+
/**
|
|
36
|
+
* The names of packages in your monorepo which belong to this group, taken
|
|
37
|
+
* from the "name" field in package.json, not the package directory name
|
|
38
|
+
*/
|
|
39
|
+
packages: string[];
|
|
40
|
+
/** Dependency names (eg. "lodash") which belong to this group */
|
|
41
|
+
dependencies: string[];
|
|
42
|
+
/** Optionally limit this group to dependencies of the provided types */
|
|
43
|
+
dependencyTypes?: DependencyType[];
|
|
44
|
+
}
|
|
45
|
+
interface Banned extends Standard {
|
|
46
|
+
/** Optionally force all dependencies in this group to be removed */
|
|
47
|
+
isBanned: true;
|
|
48
|
+
}
|
|
49
|
+
interface Ignored extends Standard {
|
|
50
|
+
/** Optionally force syncpack to ignore all dependencies in this group */
|
|
51
|
+
isIgnored?: true;
|
|
52
|
+
}
|
|
53
|
+
interface Pinned extends Standard {
|
|
54
|
+
/** Optionally force all dependencies in this group to have this version */
|
|
55
|
+
pinVersion?: string;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** All valid config which can only be provided via .syncpackrc */
|
|
59
|
+
interface RcFileOnly {
|
|
60
|
+
/**
|
|
61
|
+
* When using the `format` command, determines which fields within
|
|
62
|
+
* package.json files should be sorted alphabetically. When the value is an
|
|
63
|
+
* Object, its keys are sorted alphabetically. When the value is an Array, its
|
|
64
|
+
* values are sorted alphabetically. There is no equivalent CLI Option for
|
|
65
|
+
* this configuration.
|
|
66
|
+
*/
|
|
67
|
+
sortAz: string[];
|
|
68
|
+
/**
|
|
69
|
+
* When using the `format` command, determines which fields within package.json
|
|
70
|
+
* files should appear at the top, and in what order. There is no equivalent
|
|
71
|
+
* CLI Option for this configuration.
|
|
72
|
+
*/
|
|
73
|
+
sortFirst: string[];
|
|
74
|
+
/** */
|
|
75
|
+
versionGroups: VersionGroup.Any[];
|
|
76
|
+
/** */
|
|
77
|
+
semverGroups: SemverGroup.Any[];
|
|
78
|
+
}
|
|
79
|
+
/** All valid config which can only be provided via the CLI */
|
|
80
|
+
interface CliOnly {
|
|
81
|
+
/** Absolute or relative path to a .syncpackrc */
|
|
82
|
+
configPath: string;
|
|
83
|
+
}
|
|
84
|
+
/** All valid config which can be provided via the CLI or .syncpackrc */
|
|
85
|
+
export interface CliAndRcFile {
|
|
86
|
+
/** Whether to search within `devDependencies` */
|
|
87
|
+
dev: boolean;
|
|
88
|
+
/** Whether to search within npm `overrides` */
|
|
89
|
+
overrides: boolean;
|
|
90
|
+
/** Whether to search within `peerDependencies` */
|
|
91
|
+
peer: boolean;
|
|
92
|
+
/** Whether to search within `pnpm.overrides` */
|
|
93
|
+
pnpmOverrides: boolean;
|
|
94
|
+
/** Whether to search within `dependencies` */
|
|
95
|
+
prod: boolean;
|
|
96
|
+
/** Whether to search within yarn `resolutions` */
|
|
97
|
+
resolutions: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether to include the versions of the `--source` packages developed in
|
|
100
|
+
* your workspace/monorepo as part of the search for versions to sync
|
|
101
|
+
*/
|
|
102
|
+
workspace: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* A string which will be passed to `new RegExp()` to match against package
|
|
105
|
+
* names that should be included.
|
|
106
|
+
*
|
|
107
|
+
* > ⚠️ `filter` was originally intended as a convenience to be used from the
|
|
108
|
+
* > command line to filter the output of `syncpack list`, it is not recommended
|
|
109
|
+
* > to add this to your config file to manage your project more generally.
|
|
110
|
+
* >
|
|
111
|
+
* > Instead use `versionGroups` and/or `semverGroups`.
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
filter: string;
|
|
115
|
+
/**
|
|
116
|
+
* The character(s) to be used to indent your package.json files when writing
|
|
117
|
+
* to disk
|
|
118
|
+
*/
|
|
119
|
+
indent: string;
|
|
120
|
+
/**
|
|
121
|
+
* Defaulted to `""` to ensure that exact dependency versions are used instead
|
|
122
|
+
* of loose ranges, but this can be overridden in your config file or via the
|
|
123
|
+
* `--semver-range` command line option.
|
|
124
|
+
*
|
|
125
|
+
* | Supported Range | Example |
|
|
126
|
+
* | --------------- | --------: |
|
|
127
|
+
* | `"<"` | `<1.4.2` |
|
|
128
|
+
* | `"<="` | `<=1.4.2` |
|
|
129
|
+
* | `""` | `1.4.2` |
|
|
130
|
+
* | `"~"` | `~1.4.2` |
|
|
131
|
+
* | `"^"` | `^1.4.2` |
|
|
132
|
+
* | `">="` | `>=1.4.2` |
|
|
133
|
+
* | `">"` | `>1.4.2` |
|
|
134
|
+
* | `"*"` | `*` |
|
|
135
|
+
*/
|
|
136
|
+
semverRange: ValidRange;
|
|
137
|
+
/**
|
|
138
|
+
* Defaults to `["package.json", "packages/\*\/package.json"]` to match most
|
|
139
|
+
* Projects using Lerna or Yarn Workspaces, but this can be overridden in your
|
|
140
|
+
* config file or via multiple `--source` command line options.
|
|
141
|
+
*
|
|
142
|
+
* Supports any patterns supported by https://github.com/isaacs/node-glob
|
|
143
|
+
*/
|
|
144
|
+
source: string[];
|
|
145
|
+
}
|
|
146
|
+
/** All valid config in .syncpackrc */
|
|
147
|
+
export type RcFile = RcFileOnly & CliAndRcFile;
|
|
148
|
+
/** All valid config recognised by Syncpack */
|
|
149
|
+
export type All = CliOnly & RcFile;
|
|
150
|
+
export {};
|
|
151
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Disk } from '../../disk';
|
|
2
|
+
import type { Config } from './config';
|
|
3
|
+
import type { InternalConfig } from './internal-config';
|
|
4
|
+
/**
|
|
5
|
+
* Take all configuration from the command line and config file, combine it, and
|
|
6
|
+
* set defaults for anything which hasn't been defined.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getConfig: (disk: Disk, program: Partial<Config.All>) => InternalConfig;
|
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
2
27
|
exports.__esModule = true;
|
|
3
28
|
exports.getConfig = void 0;
|
|
4
29
|
var expect_more_1 = require("expect-more");
|
|
5
|
-
var constants_1 = require("
|
|
6
|
-
var is_semver_1 = require("../../
|
|
7
|
-
var log_1 = require("
|
|
30
|
+
var constants_1 = require("../../../constants");
|
|
31
|
+
var is_semver_1 = require("../../is-semver");
|
|
32
|
+
var log_1 = require("../../log");
|
|
8
33
|
/**
|
|
9
34
|
* Take all configuration from the command line and config file, combine it, and
|
|
10
35
|
* set defaults for anything which hasn't been defined.
|
|
11
|
-
*
|
|
12
|
-
* @param rcFile Optional configuration file contents
|
|
13
|
-
* @param program Optional command line options
|
|
14
36
|
*/
|
|
15
37
|
var getConfig = function (disk, program) {
|
|
16
38
|
(0, log_1.verbose)('cli arguments:', program);
|
|
@@ -50,7 +72,7 @@ var getConfig = function (disk, program) {
|
|
|
50
72
|
prod ||
|
|
51
73
|
resolutions ||
|
|
52
74
|
workspace
|
|
53
|
-
? constants_1.
|
|
75
|
+
? constants_1.ALL_DEPENDENCY_TYPES.filter(function (type) {
|
|
54
76
|
return (type === 'devDependencies' && dev) ||
|
|
55
77
|
(type === 'overrides' && overrides) ||
|
|
56
78
|
(type === 'peerDependencies' && peer) ||
|
|
@@ -59,7 +81,7 @@ var getConfig = function (disk, program) {
|
|
|
59
81
|
(type === 'resolutions' && resolutions) ||
|
|
60
82
|
(type === 'workspace' && workspace);
|
|
61
83
|
})
|
|
62
|
-
: constants_1.
|
|
84
|
+
: __spreadArray([], __read(constants_1.ALL_DEPENDENCY_TYPES), false);
|
|
63
85
|
var filter = getOption('filter', expect_more_1.isNonEmptyString);
|
|
64
86
|
var indent = getOption('indent', expect_more_1.isNonEmptyString);
|
|
65
87
|
var semverRange = getOption('semverRange', is_semver_1.isValidSemverRange);
|
|
@@ -86,7 +108,6 @@ var getConfig = function (disk, program) {
|
|
|
86
108
|
};
|
|
87
109
|
var versionGroups = getOption('versionGroups', isArrayOfVersionGroups).concat(defaultVersionGroup);
|
|
88
110
|
var finalConfig = {
|
|
89
|
-
dependencyTypes: dependencyTypes,
|
|
90
111
|
dev: dev,
|
|
91
112
|
filter: filter,
|
|
92
113
|
indent: indent,
|
|
@@ -101,7 +122,11 @@ var getConfig = function (disk, program) {
|
|
|
101
122
|
sortAz: sortAz,
|
|
102
123
|
sortFirst: sortFirst,
|
|
103
124
|
source: source,
|
|
104
|
-
versionGroups: versionGroups
|
|
125
|
+
versionGroups: versionGroups,
|
|
126
|
+
// The following are internal additions not exposed in public config
|
|
127
|
+
defaultSemverGroup: defaultSemverGroup,
|
|
128
|
+
defaultVersionGroup: defaultVersionGroup,
|
|
129
|
+
dependencyTypes: dependencyTypes
|
|
105
130
|
};
|
|
106
131
|
(0, log_1.verbose)('final config:', finalConfig);
|
|
107
132
|
return finalConfig;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Config, DependencyType } from './config';
|
|
2
|
+
export interface InternalConfig extends Config.RcFile {
|
|
3
|
+
/**
|
|
4
|
+
* The standard/catch-all semver group.
|
|
5
|
+
*
|
|
6
|
+
* + When no semver groups are defined, this will be the only group.
|
|
7
|
+
* + Otherwise this group will appear last, to be used when none of the user's
|
|
8
|
+
* groups found a match.
|
|
9
|
+
*/
|
|
10
|
+
defaultSemverGroup: Config.SemverGroup.WithRange;
|
|
11
|
+
/**
|
|
12
|
+
* The standard/catch-all version group.
|
|
13
|
+
*
|
|
14
|
+
* + When no version groups are defined, this will be the only group.
|
|
15
|
+
* + Otherwise this group will appear last, to be used when none of the user's
|
|
16
|
+
* groups found a match.
|
|
17
|
+
*/
|
|
18
|
+
defaultVersionGroup: Config.VersionGroup.Standard;
|
|
19
|
+
/**
|
|
20
|
+
* Aliases for locations of versions within package.json files, it is looped
|
|
21
|
+
* over by each command to operate on each are as defined by the user.
|
|
22
|
+
*/
|
|
23
|
+
dependencyTypes: DependencyType[];
|
|
24
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InternalConfig } from '../get-config/internal-config';
|
|
2
|
+
import type { Instance } from '../get-package-json-files/package-json-file/instance';
|
|
3
|
+
import { SemverGroup } from './semver-group';
|
|
4
|
+
export declare function getSemverGroups(input: InternalConfig, instances: Instance[]): SemverGroup[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
13
|
+
exports.__esModule = true;
|
|
14
|
+
exports.getSemverGroups = void 0;
|
|
15
|
+
var semver_group_1 = require("./semver-group");
|
|
16
|
+
function getSemverGroups(input, instances) {
|
|
17
|
+
var semverGroups = input.semverGroups.map(function (semverGroup) { return new semver_group_1.SemverGroup(input, semverGroup); });
|
|
18
|
+
instances.forEach(function (instance) {
|
|
19
|
+
var e_1, _a;
|
|
20
|
+
var name = instance.name, pkgName = instance.pkgName;
|
|
21
|
+
try {
|
|
22
|
+
for (var semverGroups_1 = __values(semverGroups), semverGroups_1_1 = semverGroups_1.next(); !semverGroups_1_1.done; semverGroups_1_1 = semverGroups_1.next()) {
|
|
23
|
+
var semverGroup = semverGroups_1_1.value;
|
|
24
|
+
if (instance.matchesGroup(semverGroup)) {
|
|
25
|
+
if (!semverGroup.instancesByName[name]) {
|
|
26
|
+
semverGroup.instancesByName[name] = [];
|
|
27
|
+
}
|
|
28
|
+
semverGroup.instancesByName[name].push(instance);
|
|
29
|
+
semverGroup.instances.push(instance);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
35
|
+
finally {
|
|
36
|
+
try {
|
|
37
|
+
if (semverGroups_1_1 && !semverGroups_1_1.done && (_a = semverGroups_1["return"])) _a.call(semverGroups_1);
|
|
38
|
+
}
|
|
39
|
+
finally { if (e_1) throw e_1.error; }
|
|
40
|
+
}
|
|
41
|
+
throw new Error("".concat(name, " in ").concat(pkgName, " did not match any semverGroups"));
|
|
42
|
+
});
|
|
43
|
+
return semverGroups;
|
|
44
|
+
}
|
|
45
|
+
exports.getSemverGroups = getSemverGroups;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InternalConfig } from '../get-config/internal-config';
|
|
2
|
+
import type { Instance } from '../get-package-json-files/package-json-file/instance';
|
|
3
|
+
import { VersionGroup } from './version-group';
|
|
4
|
+
export declare function getVersionGroups(input: InternalConfig, instances: Instance[]): VersionGroup[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
exports.__esModule = true;
|
|
30
|
+
exports.getVersionGroups = void 0;
|
|
31
|
+
var version_group_1 = require("./version-group");
|
|
32
|
+
var instance_group_1 = require("./version-group/instance-group");
|
|
33
|
+
function getVersionGroups(input, instances) {
|
|
34
|
+
var versionGroups = input.versionGroups.map(function (versionGroup) { return new version_group_1.VersionGroup(input, versionGroup); });
|
|
35
|
+
instances.forEach(function (instance) {
|
|
36
|
+
var e_1, _a;
|
|
37
|
+
var name = instance.name, pkgName = instance.pkgName;
|
|
38
|
+
try {
|
|
39
|
+
for (var versionGroups_1 = __values(versionGroups), versionGroups_1_1 = versionGroups_1.next(); !versionGroups_1_1.done; versionGroups_1_1 = versionGroups_1.next()) {
|
|
40
|
+
var versionGroup = versionGroups_1_1.value;
|
|
41
|
+
if (instance.matchesGroup(versionGroup)) {
|
|
42
|
+
if (!versionGroup.instancesByName[name]) {
|
|
43
|
+
versionGroup.instancesByName[name] = [];
|
|
44
|
+
}
|
|
45
|
+
versionGroup.instancesByName[name].push(instance);
|
|
46
|
+
versionGroup.instances.push(instance);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
52
|
+
finally {
|
|
53
|
+
try {
|
|
54
|
+
if (versionGroups_1_1 && !versionGroups_1_1.done && (_a = versionGroups_1["return"])) _a.call(versionGroups_1);
|
|
55
|
+
}
|
|
56
|
+
finally { if (e_1) throw e_1.error; }
|
|
57
|
+
}
|
|
58
|
+
throw new Error("".concat(name, " in ").concat(pkgName, " did not match any versionGroups"));
|
|
59
|
+
});
|
|
60
|
+
versionGroups.forEach(function (versionGroup) {
|
|
61
|
+
versionGroup.instanceGroups = getInstanceGroups(versionGroup);
|
|
62
|
+
});
|
|
63
|
+
return versionGroups;
|
|
64
|
+
}
|
|
65
|
+
exports.getVersionGroups = getVersionGroups;
|
|
66
|
+
function getInstanceGroups(versionGroup) {
|
|
67
|
+
return Object.entries(versionGroup.instancesByName).map(function (_a) {
|
|
68
|
+
var _b = __read(_a, 2), name = _b[0], instances = _b[1];
|
|
69
|
+
return new instance_group_1.InstanceGroup(versionGroup, name, instances);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Config, DependencyType, ValidRange } from '../../get-config/config';
|
|
2
|
+
import type { InternalConfig } from '../../get-config/internal-config';
|
|
3
|
+
import type { Instance } from '../../get-package-json-files/package-json-file/instance';
|
|
4
|
+
export declare class SemverGroup {
|
|
5
|
+
/** */
|
|
6
|
+
dependencies: string[];
|
|
7
|
+
/** Optionally limit this group to dependencies of the provided types */
|
|
8
|
+
dependencyTypes?: DependencyType[];
|
|
9
|
+
/** */
|
|
10
|
+
input: InternalConfig;
|
|
11
|
+
/** */
|
|
12
|
+
instances: Instance[];
|
|
13
|
+
/** */
|
|
14
|
+
instancesByName: Record<string, Instance[]>;
|
|
15
|
+
/** */
|
|
16
|
+
isDefault: boolean;
|
|
17
|
+
/** Optionally force syncpack to ignore all dependencies in this group */
|
|
18
|
+
isIgnored: boolean;
|
|
19
|
+
/** */
|
|
20
|
+
packages: string[];
|
|
21
|
+
/** The semver range which dependencies in this group should use */
|
|
22
|
+
range: ValidRange;
|
|
23
|
+
constructor(input: InternalConfig, semverGroup: Config.SemverGroup.Any);
|
|
24
|
+
/** Syncpack must report or fix this group's mismatches */
|
|
25
|
+
isInvalid(): boolean;
|
|
26
|
+
/** 1+ `Instance` has a version which does not follow the rules */
|
|
27
|
+
hasInvalidInstances(): boolean;
|
|
28
|
+
/** Get every `Instance` with a version which does not follow the rules */
|
|
29
|
+
getInvalidInstances(): Instance[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.SemverGroup = void 0;
|
|
4
|
+
var SemverGroup = /** @class */ (function () {
|
|
5
|
+
function SemverGroup(input, semverGroup) {
|
|
6
|
+
this.dependencies = semverGroup.dependencies;
|
|
7
|
+
this.input = input;
|
|
8
|
+
this.instances = [];
|
|
9
|
+
this.instancesByName = {};
|
|
10
|
+
this.isDefault = semverGroup === input.defaultSemverGroup;
|
|
11
|
+
this.isIgnored = semverGroup.isIgnored === true;
|
|
12
|
+
this.packages = semverGroup.packages;
|
|
13
|
+
this.range = semverGroup.range;
|
|
14
|
+
}
|
|
15
|
+
/** Syncpack must report or fix this group's mismatches */
|
|
16
|
+
SemverGroup.prototype.isInvalid = function () {
|
|
17
|
+
return !this.isIgnored && this.hasInvalidInstances();
|
|
18
|
+
};
|
|
19
|
+
/** 1+ `Instance` has a version which does not follow the rules */
|
|
20
|
+
SemverGroup.prototype.hasInvalidInstances = function () {
|
|
21
|
+
return this.getInvalidInstances().length > 0;
|
|
22
|
+
};
|
|
23
|
+
/** Get every `Instance` with a version which does not follow the rules */
|
|
24
|
+
SemverGroup.prototype.getInvalidInstances = function () {
|
|
25
|
+
var _this = this;
|
|
26
|
+
return this.instances.filter(function (instance) {
|
|
27
|
+
return instance.dependencyType !== 'workspace' &&
|
|
28
|
+
!instance.hasRange(_this.range);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
return SemverGroup;
|
|
32
|
+
}());
|
|
33
|
+
exports.SemverGroup = SemverGroup;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Config, DependencyType } from '../../get-config/config';
|
|
2
|
+
import type { InternalConfig } from '../../get-config/internal-config';
|
|
3
|
+
import type { Instance } from '../../get-package-json-files/package-json-file/instance';
|
|
4
|
+
import type { InstanceGroup } from './instance-group';
|
|
5
|
+
export declare class VersionGroup {
|
|
6
|
+
/** */
|
|
7
|
+
dependencies: string[];
|
|
8
|
+
/** Optionally limit this group to dependencies of the provided types */
|
|
9
|
+
dependencyTypes?: DependencyType[];
|
|
10
|
+
/** */
|
|
11
|
+
input: InternalConfig;
|
|
12
|
+
/** */
|
|
13
|
+
instanceGroups: InstanceGroup[];
|
|
14
|
+
/** */
|
|
15
|
+
instances: Instance[];
|
|
16
|
+
/** */
|
|
17
|
+
instancesByName: Record<string, Instance[]>;
|
|
18
|
+
/** */
|
|
19
|
+
isBanned: boolean;
|
|
20
|
+
/** */
|
|
21
|
+
isDefault: boolean;
|
|
22
|
+
/** */
|
|
23
|
+
isIgnored: boolean;
|
|
24
|
+
/** */
|
|
25
|
+
packages: string[];
|
|
26
|
+
/** Optionally force all dependencies in this group to have this version */
|
|
27
|
+
pinVersion?: string;
|
|
28
|
+
constructor(input: InternalConfig, versionGroup: Config.VersionGroup.Any);
|
|
29
|
+
getInvalidInstanceGroups(): InstanceGroup[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.VersionGroup = void 0;
|
|
4
|
+
var VersionGroup = /** @class */ (function () {
|
|
5
|
+
function VersionGroup(input, versionGroup) {
|
|
6
|
+
this.dependencies = versionGroup.dependencies;
|
|
7
|
+
this.dependencyTypes = versionGroup.dependencyTypes;
|
|
8
|
+
this.input = input;
|
|
9
|
+
this.instanceGroups = [];
|
|
10
|
+
this.instances = [];
|
|
11
|
+
this.instancesByName = {};
|
|
12
|
+
this.isBanned = versionGroup.isBanned === true;
|
|
13
|
+
this.isDefault = versionGroup === input.defaultVersionGroup;
|
|
14
|
+
this.isIgnored = versionGroup.isIgnored === true;
|
|
15
|
+
this.packages = versionGroup.packages;
|
|
16
|
+
this.pinVersion = versionGroup.pinVersion;
|
|
17
|
+
}
|
|
18
|
+
VersionGroup.prototype.getInvalidInstanceGroups = function () {
|
|
19
|
+
return this.instanceGroups.filter(function (group) { return group.isInvalid; });
|
|
20
|
+
};
|
|
21
|
+
return VersionGroup;
|
|
22
|
+
}());
|
|
23
|
+
exports.VersionGroup = VersionGroup;
|
|
File without changes
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.getHighestVersion = void 0;
|
|
4
4
|
var semver_1 = require("semver");
|
|
5
|
-
var constants_1 = require("
|
|
6
|
-
var is_semver_1 = require("
|
|
5
|
+
var constants_1 = require("../../../../../constants");
|
|
6
|
+
var is_semver_1 = require("../../../../is-semver");
|
|
7
7
|
function getHighestVersion(versions) {
|
|
8
8
|
return versions.reduce(function (rawHighest, raw) {
|
|
9
9
|
var version = (0, semver_1.valid)((0, semver_1.coerce)(raw)) || '';
|
|
@@ -25,24 +25,24 @@ exports.getHighestVersion = getHighestVersion;
|
|
|
25
25
|
function getRangeScore(version) {
|
|
26
26
|
if (version === '')
|
|
27
27
|
return 0;
|
|
28
|
-
if (version === constants_1.
|
|
28
|
+
if (version === constants_1.RANGE.ANY)
|
|
29
29
|
return 8;
|
|
30
30
|
var range = getRange(version);
|
|
31
|
-
if (range === constants_1.
|
|
31
|
+
if (range === constants_1.RANGE.GT)
|
|
32
32
|
return 7;
|
|
33
|
-
if (range === constants_1.
|
|
33
|
+
if (range === constants_1.RANGE.GTE)
|
|
34
34
|
return 6;
|
|
35
|
-
if (range === constants_1.
|
|
35
|
+
if (range === constants_1.RANGE.MINOR)
|
|
36
36
|
return 5;
|
|
37
37
|
if (version.indexOf('.x') !== -1)
|
|
38
38
|
return 4;
|
|
39
|
-
if (range === constants_1.
|
|
39
|
+
if (range === constants_1.RANGE.PATCH)
|
|
40
40
|
return 3;
|
|
41
|
-
if (range === constants_1.
|
|
41
|
+
if (range === constants_1.RANGE.EXACT)
|
|
42
42
|
return 2;
|
|
43
|
-
if (range === constants_1.
|
|
43
|
+
if (range === constants_1.RANGE.LTE)
|
|
44
44
|
return 1;
|
|
45
|
-
if (range === constants_1.
|
|
45
|
+
if (range === constants_1.RANGE.LT)
|
|
46
46
|
return 0;
|
|
47
47
|
return 0;
|
|
48
48
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { VersionGroup } from '..';
|
|
2
|
+
import type { Instance } from '../../../get-package-json-files/package-json-file/instance';
|
|
3
|
+
/** Every `Instance` of eg `"lodash"` for a given `VersionGroup` */
|
|
4
|
+
export declare class InstanceGroup {
|
|
5
|
+
/** 1+ `Instance` has a version which does not follow the rules */
|
|
6
|
+
hasMismatches: boolean;
|
|
7
|
+
/** Every package/dependencyType location where this dependency was found */
|
|
8
|
+
instances: Instance[];
|
|
9
|
+
/** Syncpack must report or fix this groups mismatches */
|
|
10
|
+
isInvalid: boolean;
|
|
11
|
+
/** 1+ `Instance` has a version not matching `VersionGroup.pinVersion` */
|
|
12
|
+
isUnpinned: boolean;
|
|
13
|
+
/** @example `"lodash"` */
|
|
14
|
+
name: string;
|
|
15
|
+
/** All `Instance` versions, with duplicates removed */
|
|
16
|
+
uniques: string[];
|
|
17
|
+
/** The `VersionGroup` which this `InstanceGroup` belongs to */
|
|
18
|
+
versionGroup: VersionGroup;
|
|
19
|
+
constructor(versionGroup: VersionGroup, name: string, instances: Instance[]);
|
|
20
|
+
getExpectedVersion(): string | undefined;
|
|
21
|
+
getPinnedVersion(): string;
|
|
22
|
+
/**
|
|
23
|
+
* If this dependency is a package developed locally, we should use its
|
|
24
|
+
* version as the source of truth.
|
|
25
|
+
*/
|
|
26
|
+
getWorkspaceVersion(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Find instance of this dependency which is a package developed locally in
|
|
29
|
+
* this monorepo.
|
|
30
|
+
*/
|
|
31
|
+
getWorkspaceInstance(): Instance | undefined;
|
|
32
|
+
}
|