syncpack 5.7.11 → 6.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 +261 -103
- package/dist/bin-fix-mismatches/fix-mismatches.d.ts +3 -0
- package/dist/bin-fix-mismatches/fix-mismatches.js +58 -0
- package/dist/bin-fix-mismatches/get-highest-version.d.ts +1 -0
- package/dist/{commands/lib → bin-fix-mismatches}/get-highest-version.js +16 -19
- package/dist/bin-fix-mismatches/get-workspace-version.d.ts +6 -0
- package/dist/bin-fix-mismatches/get-workspace-version.js +17 -0
- package/dist/{bin-fix-mismatches.d.ts → bin-fix-mismatches/index.d.ts} +0 -0
- package/dist/bin-fix-mismatches/index.js +66 -0
- package/dist/bin-format/format.d.ts +3 -0
- package/dist/bin-format/format.js +44 -0
- package/dist/{bin-format.d.ts → bin-format/index.d.ts} +0 -0
- package/dist/bin-format/index.js +56 -0
- package/dist/{bin-list-mismatches.d.ts → bin-lint-semver-ranges/index.d.ts} +0 -0
- package/dist/bin-lint-semver-ranges/index.js +66 -0
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -0
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +52 -0
- package/dist/bin-lint-semver-ranges/list-semver-group-mismatches.d.ts +2 -0
- package/dist/bin-lint-semver-ranges/list-semver-group-mismatches.js +12 -0
- package/dist/{bin-set-semver-ranges.d.ts → bin-list/index.d.ts} +0 -0
- package/dist/bin-list/index.js +64 -0
- package/dist/bin-list/list-version-groups.d.ts +3 -0
- package/dist/bin-list/list-version-groups.js +40 -0
- package/dist/bin-list/list.d.ts +9 -0
- package/dist/bin-list/list.js +46 -0
- package/dist/{bin-list.d.ts → bin-list-mismatches/index.d.ts} +0 -0
- package/dist/bin-list-mismatches/index.js +64 -0
- package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -0
- package/dist/bin-list-mismatches/list-mismatches.js +44 -0
- package/dist/bin-set-semver-ranges/index.d.ts +2 -0
- package/dist/bin-set-semver-ranges/index.js +68 -0
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +3 -0
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +37 -0
- package/dist/bin.js +21 -7
- package/dist/constants.d.ts +53 -32
- package/dist/constants.js +23 -19
- package/dist/lib/collect.d.ts +1 -1
- package/dist/lib/collect.js +2 -2
- package/dist/lib/disk.d.ts +10 -0
- package/dist/lib/disk.js +32 -0
- package/dist/lib/get-input/get-config.d.ts +9 -0
- package/dist/lib/get-input/get-config.js +112 -0
- package/dist/lib/get-input/get-instances.d.ts +21 -0
- package/dist/lib/get-input/get-instances.js +133 -0
- package/dist/lib/get-input/get-wrappers/get-file-paths.d.ts +15 -0
- package/dist/lib/get-input/get-wrappers/get-file-paths.js +48 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/get-lerna-patterns.d.ts +3 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/get-lerna-patterns.js +36 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/get-pnpm-patterns.d.ts +3 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/get-pnpm-patterns.js +41 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/get-yarn-patterns.d.ts +3 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/get-yarn-patterns.js +42 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/index.d.ts +13 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/index.js +72 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/props.d.ts +7 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/props.js +39 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/read-json-safe.d.ts +4 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/read-json-safe.js +37 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/read-yaml-safe.d.ts +3 -0
- package/dist/lib/get-input/get-wrappers/get-patterns/read-yaml-safe.js +30 -0
- package/dist/lib/get-input/get-wrappers/index.d.ts +34 -0
- package/dist/lib/get-input/get-wrappers/index.js +36 -0
- package/dist/lib/get-input/get-wrappers/readonly.d.ts +4 -0
- package/dist/lib/get-input/get-wrappers/readonly.js +10 -0
- package/dist/lib/get-input/get-wrappers/tap.d.ts +5 -0
- package/dist/lib/get-input/get-wrappers/tap.js +39 -0
- package/dist/lib/get-input/get-wrappers/try-catch.d.ts +5 -0
- package/dist/lib/get-input/get-wrappers/try-catch.js +13 -0
- package/dist/lib/get-input/index.d.ts +18 -0
- package/dist/lib/get-input/index.js +33 -0
- package/dist/lib/group-by.d.ts +1 -0
- package/dist/lib/group-by.js +11 -0
- package/dist/lib/is-semver.d.ts +4 -0
- package/dist/lib/is-semver.js +26 -0
- package/dist/lib/matches-filter.d.ts +3 -0
- package/dist/lib/matches-filter.js +10 -0
- package/dist/lib/set-semver-range.d.ts +2 -0
- package/dist/lib/set-semver-range.js +19 -0
- package/dist/lib/sort-by-name.d.ts +5 -0
- package/dist/{commands/lib/installations → lib}/sort-by-name.js +2 -2
- package/dist/lib/write-if-changed.d.ts +10 -0
- package/dist/lib/write-if-changed.js +23 -0
- package/dist/option.d.ts +12 -0
- package/dist/option.js +42 -0
- package/package.json +41 -39
- package/CHANGELOG.md +0 -396
- package/dist/bin-fix-mismatches.js +0 -56
- package/dist/bin-format.js +0 -48
- package/dist/bin-list-mismatches.js +0 -54
- package/dist/bin-list.js +0 -54
- package/dist/bin-set-semver-ranges.js +0 -58
- package/dist/commands/fix-mismatches.d.ts +0 -6
- package/dist/commands/fix-mismatches.js +0 -58
- package/dist/commands/format.d.ts +0 -6
- package/dist/commands/format.js +0 -49
- package/dist/commands/lib/get-dependency-types.d.ts +0 -8
- package/dist/commands/lib/get-dependency-types.js +0 -14
- package/dist/commands/lib/get-highest-version.d.ts +0 -1
- package/dist/commands/lib/get-wrappers.d.ts +0 -42
- package/dist/commands/lib/get-wrappers.js +0 -46
- package/dist/commands/lib/installations/get-dependencies.d.ts +0 -19
- package/dist/commands/lib/installations/get-dependencies.js +0 -121
- package/dist/commands/lib/installations/get-grouped-mismatched-dependencies.d.ts +0 -4
- package/dist/commands/lib/installations/get-grouped-mismatched-dependencies.js +0 -133
- package/dist/commands/lib/installations/get-installations-of.d.ts +0 -4
- package/dist/commands/lib/installations/get-installations-of.js +0 -105
- package/dist/commands/lib/installations/get-mismatched-dependencies.d.ts +0 -4
- package/dist/commands/lib/installations/get-mismatched-dependencies.js +0 -131
- package/dist/commands/lib/installations/sort-by-name.d.ts +0 -2
- package/dist/commands/lib/is-semver.d.ts +0 -4
- package/dist/commands/lib/is-semver.js +0 -23
- package/dist/commands/lib/log.d.ts +0 -2
- package/dist/commands/lib/log.js +0 -31
- package/dist/commands/lib/matches-filter.d.ts +0 -4
- package/dist/commands/lib/matches-filter.js +0 -8
- package/dist/commands/lib/write-if-changed.d.ts +0 -2
- package/dist/commands/lib/write-if-changed.js +0 -26
- package/dist/commands/list-mismatches.d.ts +0 -7
- package/dist/commands/list-mismatches.js +0 -39
- package/dist/commands/list.d.ts +0 -6
- package/dist/commands/list.js +0 -42
- package/dist/commands/set-semver-ranges.d.ts +0 -7
- package/dist/commands/set-semver-ranges.js +0 -76
- package/dist/lib/get-config.d.ts +0 -2
- package/dist/lib/get-config.js +0 -40
package/README.md
CHANGED
|
@@ -1,49 +1,43 @@
|
|
|
1
1
|
# syncpack
|
|
2
2
|
|
|
3
|
-
> Manage multiple package.json files, such as in Lerna Monorepos and Yarn/Pnpm
|
|
3
|
+
> Manage multiple package.json files, such as in Lerna Monorepos and Yarn/Pnpm
|
|
4
|
+
> Workspaces
|
|
4
5
|
|
|
5
6
|
[](https://www.npmjs.com/package/syncpack)
|
|
6
7
|
[](https://www.npmjs.com/package/syncpack)
|
|
7
|
-
[](https://github.com/JamieMason/syncpack/actions)
|
|
8
9
|
[](https://codeclimate.com/github/JamieMason/syncpack/maintainability)
|
|
9
10
|
|
|
10
|
-
## Table of Contents
|
|
11
|
-
|
|
12
|
-
- [🌩 Installation](#-installation)
|
|
13
|
-
- [📝 Commands](#-commands)
|
|
14
|
-
- [fix-mismatches](#fix-mismatches)
|
|
15
|
-
- [format](#format)
|
|
16
|
-
- [list](#list)
|
|
17
|
-
- [list-mismatches](#list-mismatches)
|
|
18
|
-
- [set-semver-ranges](#set-semver-ranges)
|
|
19
|
-
- [🛠 Configuration File](#-configuration-file)
|
|
20
|
-
- [🕵🏾♀️ Resolving Packages](#️-resolving-packages)
|
|
21
|
-
- [🙋🏿♀️ Getting Help](#️-getting-help)
|
|
22
|
-
- [👀 Other Projects](#-other-projects)
|
|
23
|
-
|
|
24
11
|
## 🌩 Installation
|
|
25
12
|
|
|
26
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npm install --global syncpack
|
|
15
|
+
```
|
|
27
16
|
|
|
28
17
|
## 📝 Commands
|
|
29
18
|
|
|
30
19
|
### fix-mismatches
|
|
31
20
|
|
|
32
|
-
Ensure that multiple packages requiring the same dependency define the same
|
|
33
|
-
|
|
21
|
+
Ensure that multiple packages requiring the same dependency define the same
|
|
22
|
+
version, so that every package requires eg. `react@16.4.2`, instead of a
|
|
23
|
+
combination of `react@16.4.2`, `react@0.15.9`, and `react@16.0.0`.
|
|
34
24
|
|
|
35
25
|
See [`versionGroups`](#versiongroups) if you have advanced requirements.
|
|
36
26
|
|
|
37
27
|
<details>
|
|
38
28
|
<summary>Options</summary>
|
|
39
29
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
```
|
|
31
|
+
-s, --source [pattern] glob pattern for package.json files to read from (default: [])
|
|
32
|
+
-p, --prod include dependencies
|
|
33
|
+
-d, --dev include devDependencies
|
|
34
|
+
-P, --peer include peerDependencies
|
|
35
|
+
-R, --resolutions include resolutions (yarn)
|
|
36
|
+
-o, --overrides include overrides (pnpm)
|
|
37
|
+
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
38
|
+
-i, --indent [value] override indentation. defaults to " "
|
|
39
|
+
-h, --help display help for command
|
|
40
|
+
```
|
|
47
41
|
|
|
48
42
|
</details>
|
|
49
43
|
|
|
@@ -71,16 +65,19 @@ syncpack fix-mismatches --indent " "
|
|
|
71
65
|
|
|
72
66
|
### format
|
|
73
67
|
|
|
74
|
-
Organise package.json files according to a conventional format, where fields
|
|
75
|
-
|
|
68
|
+
Organise package.json files according to a conventional format, where fields
|
|
69
|
+
appear in a predictable order and nested fields are ordered alphabetically.
|
|
70
|
+
Shorthand properties are used where available, such as the `"repository"` and
|
|
76
71
|
`"bugs"` fields.
|
|
77
72
|
|
|
78
73
|
<details>
|
|
79
74
|
<summary>Options</summary>
|
|
80
75
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
```
|
|
77
|
+
-s, --source [pattern] glob pattern for package.json files to read from
|
|
78
|
+
-i, --indent [value] override indentation. defaults to " "
|
|
79
|
+
-h, --help output usage information
|
|
80
|
+
```
|
|
84
81
|
|
|
85
82
|
</details>
|
|
86
83
|
|
|
@@ -100,6 +97,52 @@ syncpack format --indent " "
|
|
|
100
97
|
|
|
101
98
|
</details>
|
|
102
99
|
|
|
100
|
+
### lint-semver-ranges
|
|
101
|
+
|
|
102
|
+
Check whether dependency versions used within "dependencies", "devDependencies",
|
|
103
|
+
and "peerDependencies" follow a consistent format.
|
|
104
|
+
|
|
105
|
+
See [`semverGroups`](#semvergroups) if you have advanced requirements.
|
|
106
|
+
|
|
107
|
+
<details>
|
|
108
|
+
<summary>Options</summary>
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
-s, --source [pattern] glob pattern for package.json files to read from (default: [])
|
|
112
|
+
-p, --prod include dependencies
|
|
113
|
+
-d, --dev include devDependencies
|
|
114
|
+
-P, --peer include peerDependencies
|
|
115
|
+
-R, --resolutions include resolutions (yarn)
|
|
116
|
+
-o, --overrides include overrides (pnpm)
|
|
117
|
+
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
118
|
+
-r, --semver-range <range> see supported ranges below. defaults to ""
|
|
119
|
+
-h, --help display help for command
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
</details>
|
|
123
|
+
|
|
124
|
+
<details>
|
|
125
|
+
<summary>Examples</summary>
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# uses defaults for resolving packages
|
|
129
|
+
syncpack lint-semver-ranges
|
|
130
|
+
# uses packages defined by --source when provided
|
|
131
|
+
syncpack lint-semver-ranges --source "apps/*/package.json"
|
|
132
|
+
# multiple globs can be provided like this
|
|
133
|
+
syncpack lint-semver-ranges --source "apps/*/package.json" --source "core/*/package.json"
|
|
134
|
+
# uses dependencies regular expression defined by --filter when provided
|
|
135
|
+
syncpack lint-semver-ranges --filter "typescript|tslint"
|
|
136
|
+
# use ~ range instead of default ""
|
|
137
|
+
syncpack lint-semver-ranges --semver-range ~
|
|
138
|
+
# use ~ range in "devDependencies"
|
|
139
|
+
syncpack lint-semver-ranges --dev --semver-range ~
|
|
140
|
+
# use ~ range in "devDependencies" and "peerDependencies"
|
|
141
|
+
syncpack lint-semver-ranges --dev --peer --semver-range ~
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
</details>
|
|
145
|
+
|
|
103
146
|
### list
|
|
104
147
|
|
|
105
148
|
List all dependencies required by your packages.
|
|
@@ -107,12 +150,16 @@ List all dependencies required by your packages.
|
|
|
107
150
|
<details>
|
|
108
151
|
<summary>Options</summary>
|
|
109
152
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
153
|
+
```
|
|
154
|
+
-s, --source [pattern] glob pattern for package.json files to read from (default: [])
|
|
155
|
+
-p, --prod include dependencies
|
|
156
|
+
-d, --dev include devDependencies
|
|
157
|
+
-P, --peer include peerDependencies
|
|
158
|
+
-R, --resolutions include resolutions (yarn)
|
|
159
|
+
-o, --overrides include overrides (pnpm)
|
|
160
|
+
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
161
|
+
-h, --help display help for command
|
|
162
|
+
```
|
|
116
163
|
|
|
117
164
|
</details>
|
|
118
165
|
|
|
@@ -138,19 +185,24 @@ syncpack list --dev --peer
|
|
|
138
185
|
|
|
139
186
|
### list-mismatches
|
|
140
187
|
|
|
141
|
-
List dependencies which are required by multiple packages, where the version is
|
|
188
|
+
List dependencies which are required by multiple packages, where the version is
|
|
189
|
+
not the same across every package.
|
|
142
190
|
|
|
143
191
|
See [`versionGroups`](#versiongroups) if you have advanced requirements.
|
|
144
192
|
|
|
145
193
|
<details>
|
|
146
194
|
<summary>Options</summary>
|
|
147
195
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
196
|
+
```
|
|
197
|
+
-s, --source [pattern] glob pattern for package.json files to read from (default: [])
|
|
198
|
+
-p, --prod include dependencies
|
|
199
|
+
-d, --dev include devDependencies
|
|
200
|
+
-P, --peer include peerDependencies
|
|
201
|
+
-R, --resolutions include resolutions (yarn)
|
|
202
|
+
-o, --overrides include overrides (pnpm)
|
|
203
|
+
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
204
|
+
-h, --help display help for command
|
|
205
|
+
```
|
|
154
206
|
|
|
155
207
|
</details>
|
|
156
208
|
|
|
@@ -176,20 +228,26 @@ syncpack list-mismatches --dev --peer
|
|
|
176
228
|
|
|
177
229
|
### set-semver-ranges
|
|
178
230
|
|
|
179
|
-
Ensure dependency versions used within `"dependencies"`, `"devDependencies"`,
|
|
180
|
-
consistent format.
|
|
231
|
+
Ensure dependency versions used within `"dependencies"`, `"devDependencies"`,
|
|
232
|
+
and `"peerDependencies"` follow a consistent format.
|
|
233
|
+
|
|
234
|
+
See [`semverGroups`](#semvergroups) if you have advanced requirements.
|
|
181
235
|
|
|
182
236
|
<details>
|
|
183
237
|
<summary>Options</summary>
|
|
184
238
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
239
|
+
```
|
|
240
|
+
-s, --source [pattern] glob pattern for package.json files to read from (default: [])
|
|
241
|
+
-p, --prod include dependencies
|
|
242
|
+
-d, --dev include devDependencies
|
|
243
|
+
-P, --peer include peerDependencies
|
|
244
|
+
-R, --resolutions include resolutions (yarn)
|
|
245
|
+
-o, --overrides include overrides (pnpm)
|
|
246
|
+
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
247
|
+
-i, --indent [value] override indentation. defaults to " "
|
|
248
|
+
-r, --semver-range <range> see supported ranges below. defaults to ""
|
|
249
|
+
-h, --help display help for command
|
|
250
|
+
```
|
|
193
251
|
|
|
194
252
|
</details>
|
|
195
253
|
|
|
@@ -219,12 +277,15 @@ syncpack set-semver-ranges --indent " "
|
|
|
219
277
|
|
|
220
278
|
## 🛠 Configuration File
|
|
221
279
|
|
|
222
|
-
Creating a configuration file is optional, syncpack will search up the directory
|
|
280
|
+
Creating a configuration file is optional, syncpack will search up the directory
|
|
281
|
+
tree in the following places:
|
|
223
282
|
|
|
224
283
|
- a `syncpack` property in `package.json`
|
|
225
284
|
- a `.syncpackrc` file in JSON or YAML format
|
|
226
|
-
- a `.syncpackrc.json`, `.syncpackrc.yaml`, `.syncpackrc.yml`, `.syncpackrc.js`,
|
|
227
|
-
|
|
285
|
+
- a `.syncpackrc.json`, `.syncpackrc.yaml`, `.syncpackrc.yml`, `.syncpackrc.js`,
|
|
286
|
+
or `.syncpackrc.cjs` file
|
|
287
|
+
- a `syncpack.config.js` or `syncpack.config.cjs` CommonJS module exporting an
|
|
288
|
+
object
|
|
228
289
|
|
|
229
290
|
### Default Configuration
|
|
230
291
|
|
|
@@ -233,34 +294,51 @@ Creating a configuration file is optional, syncpack will search up the directory
|
|
|
233
294
|
"dev": true,
|
|
234
295
|
"filter": ".",
|
|
235
296
|
"indent": " ",
|
|
297
|
+
"overrides": true,
|
|
236
298
|
"peer": true,
|
|
237
299
|
"prod": true,
|
|
300
|
+
"resolutions": true,
|
|
301
|
+
"semverGroups": [],
|
|
238
302
|
"semverRange": "",
|
|
239
|
-
"sortAz": [
|
|
303
|
+
"sortAz": [
|
|
304
|
+
"contributors",
|
|
305
|
+
"dependencies",
|
|
306
|
+
"devDependencies",
|
|
307
|
+
"keywords",
|
|
308
|
+
"peerDependencies",
|
|
309
|
+
"scripts"
|
|
310
|
+
],
|
|
240
311
|
"sortFirst": ["name", "description", "version", "author"],
|
|
241
312
|
"source": ["package.json", "packages/*/package.json"],
|
|
242
313
|
"versionGroups": []
|
|
243
314
|
}
|
|
244
315
|
```
|
|
245
316
|
|
|
246
|
-
### `dev`, `peer`, and `
|
|
317
|
+
### `dev`, `peer`, `prod`, `resolutions`, and `overrides`
|
|
247
318
|
|
|
248
|
-
Whether to search within `devDependencies`, `peerDependencies`,
|
|
249
|
-
|
|
250
|
-
|
|
319
|
+
Whether to search within `devDependencies`, `peerDependencies`, `dependencies`,
|
|
320
|
+
`resolutions` (Yarn), and `overrides` (Pnpm) respectively.
|
|
321
|
+
|
|
322
|
+
All of these locations are searched by default but they can be disabled
|
|
323
|
+
individually in your config file. If any are set via the command line options
|
|
324
|
+
`--dev`, `--peer`, `--prod`, `--resolutions`, or `overrides` then only the
|
|
325
|
+
options you provide will be searched.
|
|
251
326
|
|
|
252
327
|
### `filter`
|
|
253
328
|
|
|
254
|
-
A string which will be passed to `new RegExp()` to match against package names
|
|
329
|
+
A string which will be passed to `new RegExp()` to match against package names
|
|
330
|
+
that should be included.
|
|
255
331
|
|
|
256
332
|
### `indent`
|
|
257
333
|
|
|
258
|
-
The character(s) to be used to indent your package.json files when writing to
|
|
334
|
+
The character(s) to be used to indent your package.json files when writing to
|
|
335
|
+
disk.
|
|
259
336
|
|
|
260
337
|
### `semverRange`
|
|
261
338
|
|
|
262
|
-
Defaulted to `""` to ensure that exact dependency versions are used instead of
|
|
263
|
-
in your config file or via the
|
|
339
|
+
Defaulted to `""` to ensure that exact dependency versions are used instead of
|
|
340
|
+
loose ranges, but this can be overridden in your config file or via the
|
|
341
|
+
`--semver-range` command line option.
|
|
264
342
|
|
|
265
343
|
#### Supported Ranges
|
|
266
344
|
|
|
@@ -277,31 +355,91 @@ in your config file or via the `--semver-range` command line option.
|
|
|
277
355
|
|
|
278
356
|
### `sortAz`
|
|
279
357
|
|
|
280
|
-
When using the `format` command, determines which fields within package.json
|
|
281
|
-
|
|
358
|
+
When using the `format` command, determines which fields within package.json
|
|
359
|
+
files should be sorted alphabetically. When the value is an Object, its keys are
|
|
360
|
+
sorted alphabetically. When the value is an Array, its values are sorted
|
|
282
361
|
alphabetically. There is no equivalent CLI Option for this configuration.
|
|
283
362
|
|
|
284
363
|
### `sortFirst`
|
|
285
364
|
|
|
286
|
-
When using the `format` command, determines which fields within package.json
|
|
287
|
-
order. There is no equivalent CLI
|
|
365
|
+
When using the `format` command, determines which fields within package.json
|
|
366
|
+
files should appear at the top, and in what order. There is no equivalent CLI
|
|
367
|
+
Option for this configuration.
|
|
288
368
|
|
|
289
369
|
### `source`
|
|
290
370
|
|
|
291
|
-
Defaults to `["package.json", "packages/*/package.json"]` to match most Projects
|
|
292
|
-
this can be overridden in your config file
|
|
293
|
-
|
|
371
|
+
Defaults to `["package.json", "packages/*/package.json"]` to match most Projects
|
|
372
|
+
using Lerna or Yarn Workspaces, but this can be overridden in your config file
|
|
373
|
+
or via multiple `--source` command line options. Supports any patterns supported
|
|
374
|
+
by [glob](https://github.com/isaacs/node-glob).
|
|
375
|
+
|
|
376
|
+
### `semverGroups`
|
|
377
|
+
|
|
378
|
+
Allow some packages to have different semver range rules to the rest of your
|
|
379
|
+
monorepo. Each dependency can only belong to one semver group, the first rule
|
|
380
|
+
which matches a given dependency and package will apply.
|
|
381
|
+
|
|
382
|
+
#### Example use cases
|
|
383
|
+
|
|
384
|
+
1: Every dependency of `@myrepo/library` should have a semver range of `~`,
|
|
385
|
+
regardless of what the rest of the monorepo uses:
|
|
386
|
+
|
|
387
|
+
```json
|
|
388
|
+
{
|
|
389
|
+
"semverGroups": [
|
|
390
|
+
{
|
|
391
|
+
"range": "~",
|
|
392
|
+
"dependencies": ["**"],
|
|
393
|
+
"packages": ["@myrepo/library"]
|
|
394
|
+
}
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
2: Every dependency of `@myrepo/library` whose name matches `@alpha/**` should
|
|
400
|
+
have a semver range of `~`, regardless of what the rest of that package or the
|
|
401
|
+
rest of the monorepo uses:
|
|
402
|
+
|
|
403
|
+
```json
|
|
404
|
+
{
|
|
405
|
+
"semverGroups": [
|
|
406
|
+
{
|
|
407
|
+
"range": "~",
|
|
408
|
+
"dependencies": ["@alpha/**"],
|
|
409
|
+
"packages": ["@myrepo/library"]
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
3: Every dependency in the monorepo whose name matches `@alpha/**` should have a
|
|
416
|
+
semver range of `~`, regardless of what the rest of the monorepo uses:
|
|
417
|
+
|
|
418
|
+
```json
|
|
419
|
+
{
|
|
420
|
+
"semverGroups": [
|
|
421
|
+
{
|
|
422
|
+
"range": "~",
|
|
423
|
+
"dependencies": ["@alpha/**"],
|
|
424
|
+
"packages": ["**"]
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
}
|
|
428
|
+
```
|
|
294
429
|
|
|
295
430
|
### `versionGroups`
|
|
296
431
|
|
|
297
|
-
If some packages in your Monorepo relate to "alpha" (or legacy) versions of your
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
versions
|
|
432
|
+
If some packages in your Monorepo relate to "alpha" (or legacy) versions of your
|
|
433
|
+
software, you will need to manage dependencies differently within those
|
|
434
|
+
packages. Your alpha packages might use latest or unstable versions of some 3rd
|
|
435
|
+
party dependencies, while the rest of the repo might need to remain on older
|
|
436
|
+
versions. You don't want mismatches within your alpha packages, or within the
|
|
437
|
+
other packages in your monorepo – but you do want those groups to use different
|
|
438
|
+
versions to each other and not have `syncpack fix-mismatches` make them all the
|
|
439
|
+
same.
|
|
302
440
|
|
|
303
|
-
In the following example, 2 packages in our monorepo are using different
|
|
304
|
-
of the project.
|
|
441
|
+
In the following example, 2 packages in our monorepo are using different
|
|
442
|
+
versions of `react` and `react-dom` to the rest of the project.
|
|
305
443
|
|
|
306
444
|
```json
|
|
307
445
|
{
|
|
@@ -314,45 +452,65 @@ of the project.
|
|
|
314
452
|
}
|
|
315
453
|
```
|
|
316
454
|
|
|
455
|
+
> ℹ️ The `dependencies` and `packages` fields are processed using
|
|
456
|
+
> [minimatch](https://github.com/isaacs/minimatch), so the above example can
|
|
457
|
+
> also be written as `"packages": ["@alpha/**"]`.
|
|
458
|
+
|
|
317
459
|
`syncpack` will make ensure that:
|
|
318
460
|
|
|
319
|
-
- The versions of `react` and `react-dom` are the same within `@alpha/server`
|
|
320
|
-
|
|
321
|
-
- The versions of `react` and `react-dom`
|
|
322
|
-
|
|
323
|
-
- The versions of
|
|
324
|
-
|
|
461
|
+
- The versions of `react` and `react-dom` are the same within `@alpha/server`
|
|
462
|
+
and `@alpha/ui`.
|
|
463
|
+
- The versions of `react` and `react-dom` are the same across every package
|
|
464
|
+
except `@alpha/server` and `@alpha/ui`.
|
|
465
|
+
- The versions of `react` and `react-dom` within `@alpha/server` and `@alpha/ui`
|
|
466
|
+
can be different to the other packages in the monorepo.
|
|
467
|
+
- The versions of every other dependency in the monorepo (eg `lodash`) are the
|
|
468
|
+
same across every package including `@alpha/server` and `@alpha/ui`.
|
|
469
|
+
|
|
470
|
+
Each dependency can only belong to one version group, the first rule which
|
|
471
|
+
matches a given dependency and package will apply.
|
|
325
472
|
|
|
326
473
|
## 🕵🏾♀️ Resolving Packages
|
|
327
474
|
|
|
328
475
|
package.json files are resolved in this order of precendence:
|
|
329
476
|
|
|
330
|
-
1. If `--source`
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
477
|
+
1. If `--source`
|
|
478
|
+
[glob patterns](https://github.com/isaacs/node-glob#glob-primer) are
|
|
479
|
+
provided, use those.
|
|
480
|
+
2. If using [Yarn Workspaces](https://yarnpkg.com/lang/en/docs/workspaces/),
|
|
481
|
+
read `workspaces` from `./package.json`.
|
|
482
|
+
3. If using [Lerna](https://lerna.js.org/), read `packages` from
|
|
483
|
+
`./lerna.json`.
|
|
484
|
+
4. If using [Pnpm](https://pnpm.js.org/), read `packages` from
|
|
485
|
+
`./pnpm-workspace.yaml`.
|
|
334
486
|
5. Default to `'package.json'` and `'packages/*/package.json'`.
|
|
335
487
|
|
|
336
488
|
## 🙋🏿♀️ Getting Help
|
|
337
489
|
|
|
338
|
-
Get help with issues by creating a [Bug Report] or discuss ideas by opening a
|
|
490
|
+
Get help with issues by creating a [Bug Report] or discuss ideas by opening a
|
|
491
|
+
[Feature Request].
|
|
339
492
|
|
|
340
|
-
[bug report]:
|
|
341
|
-
|
|
493
|
+
[bug report]:
|
|
494
|
+
https://github.com/JamieMason/syncpack/issues/new?template=bug_report.md
|
|
495
|
+
[feature request]:
|
|
496
|
+
https://github.com/JamieMason/syncpack/issues/new?template=feature_request.md
|
|
342
497
|
|
|
343
498
|
## 👀 Other Projects
|
|
344
499
|
|
|
345
500
|
If you find my Open Source projects useful, please share them ❤️
|
|
346
501
|
|
|
347
|
-
- [**eslint-formatter-git-log**](https://github.com/JamieMason/eslint-formatter-git-log)<br>ESLint
|
|
348
|
-
Git Author, Date, and Hash
|
|
349
|
-
- [**eslint-plugin-move-files**](https://github.com/JamieMason/eslint-plugin-move-files)<br>Move
|
|
350
|
-
keeping imports up to date
|
|
502
|
+
- [**eslint-formatter-git-log**](https://github.com/JamieMason/eslint-formatter-git-log)<br>ESLint
|
|
503
|
+
Formatter featuring Git Author, Date, and Hash
|
|
504
|
+
- [**eslint-plugin-move-files**](https://github.com/JamieMason/eslint-plugin-move-files)<br>Move
|
|
505
|
+
and rename files while keeping imports up to date
|
|
351
506
|
- [**eslint-plugin-prefer-arrow-functions**](https://github.com/JamieMason/eslint-plugin-prefer-arrow-functions)<br>Convert
|
|
352
507
|
functions to arrow functions
|
|
353
|
-
- [**ImageOptim-CLI**](https://github.com/JamieMason/ImageOptim-CLI)<br>Automates
|
|
354
|
-
for Mac to make batch optimisation of
|
|
355
|
-
|
|
356
|
-
- [**
|
|
357
|
-
|
|
358
|
-
- [**
|
|
508
|
+
- [**ImageOptim-CLI**](https://github.com/JamieMason/ImageOptim-CLI)<br>Automates
|
|
509
|
+
ImageOptim, ImageAlpha, and JPEGmini for Mac to make batch optimisation of
|
|
510
|
+
images part of your automated build process.
|
|
511
|
+
- [**Jasmine-Matchers**](https://github.com/JamieMason/Jasmine-Matchers)<br>Write
|
|
512
|
+
Beautiful Specs with Custom Matchers
|
|
513
|
+
- [**karma-benchmark**](https://github.com/JamieMason/karma-benchmark)<br>Run
|
|
514
|
+
Benchmark.js over multiple Browsers, with CI compatible output
|
|
515
|
+
- [**self-help**](https://github.com/JamieMason/self-help#readme)<br>Interactive
|
|
516
|
+
Q&A Guides for Web and the Command Line
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
exports.__esModule = true;
|
|
10
|
+
exports.fixMismatches = void 0;
|
|
11
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
12
|
+
var list_version_groups_1 = require("../bin-list/list-version-groups");
|
|
13
|
+
var matches_filter_1 = require("../lib/matches-filter");
|
|
14
|
+
var write_if_changed_1 = require("../lib/write-if-changed");
|
|
15
|
+
var get_highest_version_1 = require("./get-highest-version");
|
|
16
|
+
var get_workspace_version_1 = require("./get-workspace-version");
|
|
17
|
+
function fixMismatches(input, disk) {
|
|
18
|
+
/**
|
|
19
|
+
* Reverse the list so the default/ungrouped version group is rendered first
|
|
20
|
+
* (appears at the top). The actual version groups which the user configured
|
|
21
|
+
* will then start from index 1.
|
|
22
|
+
*/
|
|
23
|
+
input.instances.versionGroups.reverse().forEach(function (versionGroup, i) {
|
|
24
|
+
var isVersionGroup = i > 0;
|
|
25
|
+
var filtered = versionGroup.instances.filter((0, matches_filter_1.matchesFilter)(input));
|
|
26
|
+
var groups = (0, list_version_groups_1.listVersionGroups)(filtered);
|
|
27
|
+
if (isVersionGroup) {
|
|
28
|
+
console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim = Version Group ", " ", "}"], ["{dim = Version Group ", " ", "}"])), i, '='.repeat(63)));
|
|
29
|
+
}
|
|
30
|
+
groups.forEach(function (_a) {
|
|
31
|
+
var hasMismatches = _a.hasMismatches, instances = _a.instances, name = _a.name;
|
|
32
|
+
if (hasMismatches) {
|
|
33
|
+
var nextVersion_1 = (0, get_workspace_version_1.getWorkspaceVersion)(name, input.wrappers) ||
|
|
34
|
+
(0, get_highest_version_1.getHighestVersion)(instances.map(function (_a) {
|
|
35
|
+
var version = _a.version;
|
|
36
|
+
return version;
|
|
37
|
+
}));
|
|
38
|
+
instances.forEach(function (_a) {
|
|
39
|
+
var dependencyType = _a.dependencyType, version = _a.version, wrapper = _a.wrapper;
|
|
40
|
+
var root = wrapper.contents;
|
|
41
|
+
if (version !== nextVersion_1) {
|
|
42
|
+
root[dependencyType][name] = nextVersion_1;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
input.wrappers.forEach(function (wrapper) {
|
|
49
|
+
(0, write_if_changed_1.writeIfChanged)(disk, {
|
|
50
|
+
contents: wrapper.contents,
|
|
51
|
+
filePath: wrapper.filePath,
|
|
52
|
+
indent: input.indent,
|
|
53
|
+
json: wrapper.json
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.fixMismatches = fixMismatches;
|
|
58
|
+
var templateObject_1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getHighestVersion(versions: string[]): string | null;
|
|
@@ -2,10 +2,12 @@
|
|
|
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("
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var constants_1 = require("../constants");
|
|
6
|
+
var is_semver_1 = require("../lib/is-semver");
|
|
7
|
+
function getRange(version) {
|
|
8
|
+
return version.slice(0, version.search(/[0-9]/));
|
|
9
|
+
}
|
|
10
|
+
function getRangeScore(version) {
|
|
9
11
|
if (version === null)
|
|
10
12
|
return 0;
|
|
11
13
|
if (version === constants_1.RANGE_ANY)
|
|
@@ -28,27 +30,22 @@ var getRangeScore = function (version) {
|
|
|
28
30
|
if (range === constants_1.RANGE_LT)
|
|
29
31
|
return 0;
|
|
30
32
|
return 0;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
+
}
|
|
34
|
+
function getHighestVersion(versions) {
|
|
33
35
|
return versions.reduce(function (rawHighest, raw) {
|
|
34
|
-
var version = semver_1.valid(semver_1.coerce(raw));
|
|
35
|
-
var highest = semver_1.valid(semver_1.coerce(rawHighest));
|
|
36
|
-
if (raw === '*' || rawHighest === '*')
|
|
36
|
+
var version = (0, semver_1.valid)((0, semver_1.coerce)(raw));
|
|
37
|
+
var highest = (0, semver_1.valid)((0, semver_1.coerce)(rawHighest));
|
|
38
|
+
if (raw === '*' || rawHighest === '*')
|
|
37
39
|
return '*';
|
|
38
|
-
|
|
39
|
-
if (!is_semver_1.isSemver(raw) || version === null) {
|
|
40
|
+
if (!(0, is_semver_1.isSemver)(raw) || version === null)
|
|
40
41
|
return rawHighest;
|
|
41
|
-
|
|
42
|
-
if (highest === null) {
|
|
42
|
+
if (highest === null)
|
|
43
43
|
return raw;
|
|
44
|
-
|
|
45
|
-
if (semver_1.gt(version, highest)) {
|
|
44
|
+
if ((0, semver_1.gt)(version, highest))
|
|
46
45
|
return raw;
|
|
47
|
-
|
|
48
|
-
if (semver_1.eq(version, highest) && getRangeScore(raw) > getRangeScore(rawHighest)) {
|
|
46
|
+
if ((0, semver_1.eq)(version, highest) && getRangeScore(raw) > getRangeScore(rawHighest))
|
|
49
47
|
return raw;
|
|
50
|
-
}
|
|
51
48
|
return rawHighest;
|
|
52
49
|
}, null);
|
|
53
|
-
}
|
|
50
|
+
}
|
|
54
51
|
exports.getHighestVersion = getHighestVersion;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SourceWrapper } from '../lib/get-input/get-wrappers';
|
|
2
|
+
/**
|
|
3
|
+
* If the dependency `name` is a package developed locally in this monorepo, we
|
|
4
|
+
* should use its version as the source of truth.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getWorkspaceVersion(name: string, wrappers: SourceWrapper[]): string;
|