syncpack 9.0.0 → 9.1.2
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 +24 -764
- package/dist/bin-fix-mismatches/fix-mismatches.js +16 -39
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +2 -5
- package/dist/bin-list/list.js +33 -17
- package/dist/bin-list-mismatches/list-mismatches.js +59 -30
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +1 -1
- package/dist/get-context/get-groups/base-group.d.ts +19 -0
- package/dist/get-context/get-groups/base-group.js +40 -0
- package/dist/get-context/get-groups/index.d.ts +8 -0
- package/dist/get-context/get-groups/index.js +47 -0
- package/dist/get-context/get-groups/semver-group.d.ts +16 -0
- package/dist/get-context/get-groups/semver-group.js +89 -0
- package/dist/get-context/get-groups/version-group/index.d.ts +9 -26
- package/dist/get-context/get-groups/version-group/index.js +67 -15
- package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +10 -20
- package/dist/get-context/get-groups/version-group/instance-group/index.js +49 -53
- package/dist/get-context/get-package-json-files/get-file-paths.js +2 -1
- package/dist/get-context/get-package-json-files/package-json-file/index.js +3 -2
- package/dist/get-context/get-package-json-files/package-json-file/instance.d.ts +2 -5
- package/dist/get-context/get-package-json-files/package-json-file/instance.js +3 -19
- package/dist/get-context/index.js +2 -4
- package/dist/lib/print-strings.d.ts +1 -0
- package/dist/lib/print-strings.js +7 -0
- package/dist/option.d.ts +1 -1
- package/dist/option.js +1 -0
- package/package.json +3 -1
- package/dist/get-context/get-groups/get-semver-groups.d.ts +0 -4
- package/dist/get-context/get-groups/get-semver-groups.js +0 -46
- package/dist/get-context/get-groups/get-version-groups.d.ts +0 -4
- package/dist/get-context/get-groups/get-version-groups.js +0 -72
- package/dist/get-context/get-groups/semver-group/index.d.ts +0 -29
- package/dist/get-context/get-groups/semver-group/index.js +0 -56
package/README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
# syncpack
|
|
2
2
|
|
|
3
|
-
>
|
|
4
|
-
> Workspaces
|
|
5
|
-
|
|
6
|
-
[](https://www.npmjs.com/package/syncpack)
|
|
7
|
-
[](https://www.npmjs.com/package/syncpack)
|
|
8
|
-
[](https://github.com/JamieMason/syncpack/actions)
|
|
9
|
-
[](https://codeclimate.com/github/JamieMason/syncpack/maintainability)
|
|
3
|
+
> Consistent dependency versions in large JavaScript Monorepos.
|
|
10
4
|
|
|
11
5
|
## Installation
|
|
12
6
|
|
|
@@ -14,789 +8,55 @@
|
|
|
14
8
|
npm install --save-dev syncpack
|
|
15
9
|
```
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
> [`customTypes`](#customtypes) feature, but they are very simple to make.
|
|
22
|
-
>
|
|
23
|
-
> ### GitHub Action
|
|
24
|
-
>
|
|
25
|
-
> As of May 2022 there is now a
|
|
26
|
-
> [Syncpack GitHub Action](https://github.com/marketplace/actions/syncpack-synchronise-monorepo-dependency-versions).
|
|
27
|
-
> It is new and less stable than syncpack itself, but please give it a try and
|
|
28
|
-
> [give your feedback](https://github.com/JamieMason/syncpack-github-action/issues/new).
|
|
11
|
+
## Documentation
|
|
12
|
+
|
|
13
|
+
Full information can be found in the documentation at
|
|
14
|
+
https://jamiemason.github.io/syncpack/.
|
|
29
15
|
|
|
30
16
|
## Commands
|
|
31
17
|
|
|
32
|
-
### fix-mismatches
|
|
18
|
+
### [fix-mismatches](https://jamiemason.github.io/syncpack/fix-mismatches)
|
|
33
19
|
|
|
34
20
|
Ensure that multiple packages requiring the same dependency define the same
|
|
35
21
|
version, so that every package requires eg. `react@16.4.2`, instead of a
|
|
36
22
|
combination of `react@16.4.2`, `react@0.15.9`, and `react@16.0.0`.
|
|
37
23
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<details>
|
|
41
|
-
<summary>Options</summary>
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
45
|
-
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
46
|
-
-t, --types <names> only include dependencies matching these types (eg. types=dev,prod,myCustomType)
|
|
47
|
-
-c, --config <path> path to a syncpack config file
|
|
48
|
-
-i, --indent [value] override indentation. defaults to " "
|
|
49
|
-
-h, --help display help for command
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
</details>
|
|
53
|
-
|
|
54
|
-
<details>
|
|
55
|
-
<summary>Examples</summary>
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
# uses defaults for resolving packages
|
|
59
|
-
syncpack fix-mismatches
|
|
60
|
-
# uses packages defined by --source when provided
|
|
61
|
-
syncpack fix-mismatches --source "apps/*/package.json"
|
|
62
|
-
# multiple globs can be provided like this
|
|
63
|
-
syncpack fix-mismatches --source "apps/*/package.json" --source "core/*/package.json"
|
|
64
|
-
# uses dependencies regular expression defined by --filter when provided
|
|
65
|
-
syncpack fix-mismatches --filter "typescript|tslint"
|
|
66
|
-
# only inspect "devDependencies"
|
|
67
|
-
syncpack fix-mismatches --types dev
|
|
68
|
-
# only inspect "devDependencies" and "peerDependencies"
|
|
69
|
-
syncpack fix-mismatches --types dev,peer
|
|
70
|
-
# indent package.json with 4 spaces instead of 2
|
|
71
|
-
syncpack fix-mismatches --indent " "
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
</details>
|
|
75
|
-
|
|
76
|
-
### format
|
|
24
|
+
### [format](https://jamiemason.github.io/syncpack/format)
|
|
77
25
|
|
|
78
26
|
Organise package.json files according to a conventional format, where fields
|
|
79
27
|
appear in a predictable order and nested fields are ordered alphabetically.
|
|
80
28
|
Shorthand properties are used where available, such as the `"repository"` and
|
|
81
29
|
`"bugs"` fields.
|
|
82
30
|
|
|
83
|
-
|
|
84
|
-
<summary>Options</summary>
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
88
|
-
-c, --config <path> path to a syncpack config file
|
|
89
|
-
-i, --indent [value] override indentation. defaults to " "
|
|
90
|
-
-h, --help display help for command
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
</details>
|
|
94
|
-
|
|
95
|
-
<details>
|
|
96
|
-
<summary>Examples</summary>
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
# uses defaults for resolving packages
|
|
100
|
-
syncpack format
|
|
101
|
-
# uses packages defined by --source when provided
|
|
102
|
-
syncpack format --source "apps/*/package.json"
|
|
103
|
-
# multiple globs can be provided like this
|
|
104
|
-
syncpack format --source "apps/*/package.json" --source "core/*/package.json"
|
|
105
|
-
# indent package.json with 4 spaces instead of 2
|
|
106
|
-
syncpack format --indent " "
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
</details>
|
|
110
|
-
|
|
111
|
-
### lint-semver-ranges
|
|
31
|
+
### [lint-semver-ranges](https://jamiemason.github.io/syncpack/lint-semver-ranges)
|
|
112
32
|
|
|
113
33
|
Check whether dependency versions used within "dependencies", "devDependencies",
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
See [`semverGroups`](#semvergroups) if you have advanced requirements.
|
|
34
|
+
etc follow a consistent format.
|
|
117
35
|
|
|
118
|
-
|
|
119
|
-
<summary>Options</summary>
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
123
|
-
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
124
|
-
-r, --semver-range <range> see supported ranges below. defaults to ""
|
|
125
|
-
-c, --config <path> path to a syncpack config file
|
|
126
|
-
-t, --types <names> only include dependencies matching these types (eg. types=dev,prod,myCustomType)
|
|
127
|
-
-h, --help display help for command
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
</details>
|
|
131
|
-
|
|
132
|
-
<details>
|
|
133
|
-
<summary>Examples</summary>
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
# uses defaults for resolving packages
|
|
137
|
-
syncpack lint-semver-ranges
|
|
138
|
-
# uses packages defined by --source when provided
|
|
139
|
-
syncpack lint-semver-ranges --source "apps/*/package.json"
|
|
140
|
-
# multiple globs can be provided like this
|
|
141
|
-
syncpack lint-semver-ranges --source "apps/*/package.json" --source "core/*/package.json"
|
|
142
|
-
# uses dependencies regular expression defined by --filter when provided
|
|
143
|
-
syncpack lint-semver-ranges --filter "typescript|tslint"
|
|
144
|
-
# use ~ range instead of default ""
|
|
145
|
-
syncpack lint-semver-ranges --semver-range ~
|
|
146
|
-
# use ~ range in "devDependencies"
|
|
147
|
-
syncpack lint-semver-ranges --types dev --semver-range ~
|
|
148
|
-
# use ~ range in "devDependencies" and "peerDependencies"
|
|
149
|
-
syncpack lint-semver-ranges --types dev,peer semver-range ~
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
</details>
|
|
153
|
-
|
|
154
|
-
### list
|
|
36
|
+
### [list](https://jamiemason.github.io/syncpack/list)
|
|
155
37
|
|
|
156
38
|
List all dependencies required by your packages.
|
|
157
39
|
|
|
158
|
-
|
|
159
|
-
<summary>Options</summary>
|
|
160
|
-
|
|
161
|
-
```
|
|
162
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
163
|
-
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
164
|
-
-c, --config <path> path to a syncpack config file
|
|
165
|
-
-t, --types <names> only include dependencies matching these types (eg. types=dev,prod,myCustomType)
|
|
166
|
-
-h, --help display help for command
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
</details>
|
|
170
|
-
|
|
171
|
-
<details>
|
|
172
|
-
<summary>Examples</summary>
|
|
173
|
-
|
|
174
|
-
```bash
|
|
175
|
-
# uses defaults for resolving packages
|
|
176
|
-
syncpack list
|
|
177
|
-
# uses packages defined by --source when provided
|
|
178
|
-
syncpack list --source "apps/*/package.json"
|
|
179
|
-
# multiple globs can be provided like this
|
|
180
|
-
syncpack list --source "apps/*/package.json" --source "core/*/package.json"
|
|
181
|
-
# uses dependencies regular expression defined by --filter when provided
|
|
182
|
-
syncpack list --filter "typescript|tslint"
|
|
183
|
-
# only inspect "devDependencies"
|
|
184
|
-
syncpack list --types dev
|
|
185
|
-
# only inspect "devDependencies" and "peerDependencies"
|
|
186
|
-
syncpack list --types dev,peer
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
</details>
|
|
190
|
-
|
|
191
|
-
### list-mismatches
|
|
40
|
+
### [list-mismatches](https://jamiemason.github.io/syncpack/list-mismatches)
|
|
192
41
|
|
|
193
42
|
List dependencies which are required by multiple packages, where the version is
|
|
194
43
|
not the same across every package.
|
|
195
44
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
<details>
|
|
199
|
-
<summary>Options</summary>
|
|
200
|
-
|
|
201
|
-
```
|
|
202
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
203
|
-
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
204
|
-
-c, --config <path> path to a syncpack config file
|
|
205
|
-
-t, --types <names> only include dependencies matching these types (eg. types=dev,prod,myCustomType)
|
|
206
|
-
-h, --help display help for command
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
</details>
|
|
210
|
-
|
|
211
|
-
<details>
|
|
212
|
-
<summary>Examples</summary>
|
|
213
|
-
|
|
214
|
-
```bash
|
|
215
|
-
# uses defaults for resolving packages
|
|
216
|
-
syncpack list-mismatches
|
|
217
|
-
# uses packages defined by --source when provided
|
|
218
|
-
syncpack list-mismatches --source "apps/*/package.json"
|
|
219
|
-
# multiple globs can be provided like this
|
|
220
|
-
syncpack list-mismatches --source "apps/*/package.json" --source "core/*/package.json"
|
|
221
|
-
# uses dependencies regular expression defined by --filter when provided
|
|
222
|
-
syncpack list-mismatches --filter "typescript|tslint"
|
|
223
|
-
# only inspect "devDependencies"
|
|
224
|
-
syncpack list-mismatches --types dev
|
|
225
|
-
# only inspect "devDependencies" and "peerDependencies"
|
|
226
|
-
syncpack list-mismatches --types dev,peer
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
</details>
|
|
230
|
-
|
|
231
|
-
### set-semver-ranges
|
|
232
|
-
|
|
233
|
-
Ensure dependency versions used within `"dependencies"`, `"devDependencies"`,
|
|
234
|
-
and `"peerDependencies"` follow a consistent format.
|
|
235
|
-
|
|
236
|
-
See [`semverGroups`](#semvergroups) if you have advanced requirements.
|
|
237
|
-
|
|
238
|
-
<details>
|
|
239
|
-
<summary>Options</summary>
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
243
|
-
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
244
|
-
-c, --config <path> path to a syncpack config file
|
|
245
|
-
-r, --semver-range <range> see supported ranges below. defaults to ""
|
|
246
|
-
-t, --types <names> only include dependencies matching these types (eg. types=dev,prod,myCustomType)
|
|
247
|
-
-i, --indent [value] override indentation. defaults to " "
|
|
248
|
-
-h, --help display help for command
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
</details>
|
|
252
|
-
|
|
253
|
-
<details>
|
|
254
|
-
<summary>Examples</summary>
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
# uses defaults for resolving packages
|
|
258
|
-
syncpack set-semver-ranges
|
|
259
|
-
# uses packages defined by --source when provided
|
|
260
|
-
syncpack set-semver-ranges --source "apps/*/package.json"
|
|
261
|
-
# multiple globs can be provided like this
|
|
262
|
-
syncpack set-semver-ranges --source "apps/*/package.json" --source "core/*/package.json"
|
|
263
|
-
# uses dependencies regular expression defined by --filter when provided
|
|
264
|
-
syncpack set-semver-ranges --filter "typescript|tslint"
|
|
265
|
-
# use ~ range instead of default ""
|
|
266
|
-
syncpack set-semver-ranges --semver-range ~
|
|
267
|
-
# set ~ range in "devDependencies"
|
|
268
|
-
syncpack set-semver-ranges --types dev --semver-range ~
|
|
269
|
-
# set ~ range in "devDependencies" and "peerDependencies"
|
|
270
|
-
syncpack set-semver-ranges --types dev,peer --semver-range ~
|
|
271
|
-
# indent package.json with 4 spaces instead of 2
|
|
272
|
-
syncpack set-semver-ranges --indent " "
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
</details>
|
|
276
|
-
|
|
277
|
-
## Configuration File
|
|
278
|
-
|
|
279
|
-
Creating a configuration file is optional, syncpack will search up the directory
|
|
280
|
-
tree in the following places:
|
|
281
|
-
|
|
282
|
-
- a `syncpack` property in `package.json`
|
|
283
|
-
- a `.syncpackrc` file in JSON or YAML format
|
|
284
|
-
- a `.syncpackrc.json`, `.syncpackrc.yaml`, `.syncpackrc.yml`, `.syncpackrc.js`,
|
|
285
|
-
or `.syncpackrc.cjs` file
|
|
286
|
-
- a `syncpack.config.js` or `syncpack.config.cjs` CommonJS module exporting an
|
|
287
|
-
object
|
|
288
|
-
- a `config.syncpack` property in `package.json`
|
|
289
|
-
|
|
290
|
-
If you want to specify a path to a configuration file, overriding the discovered
|
|
291
|
-
configuration file (if present), you can use the `--config` option.
|
|
292
|
-
|
|
293
|
-
### Default Configuration
|
|
294
|
-
|
|
295
|
-
```json
|
|
296
|
-
{
|
|
297
|
-
"dependencyTypes": [
|
|
298
|
-
"dev",
|
|
299
|
-
"overrides",
|
|
300
|
-
"peer",
|
|
301
|
-
"pnpmOverrides",
|
|
302
|
-
"prod",
|
|
303
|
-
"resolutions",
|
|
304
|
-
"workspace"
|
|
305
|
-
],
|
|
306
|
-
"filter": ".",
|
|
307
|
-
"indent": " ",
|
|
308
|
-
"semverGroups": [],
|
|
309
|
-
"semverRange": "",
|
|
310
|
-
"sortAz": [
|
|
311
|
-
"contributors",
|
|
312
|
-
"dependencies",
|
|
313
|
-
"devDependencies",
|
|
314
|
-
"keywords",
|
|
315
|
-
"peerDependencies",
|
|
316
|
-
"resolutions",
|
|
317
|
-
"scripts"
|
|
318
|
-
],
|
|
319
|
-
"sortFirst": ["name", "description", "version", "author"],
|
|
320
|
-
"source": [],
|
|
321
|
-
"versionGroups": []
|
|
322
|
-
}
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
### Configuration Options
|
|
326
|
-
|
|
327
|
-
#### `--type` / `dependencyTypes`
|
|
328
|
-
|
|
329
|
-
All of the properties in the table below are searched by default, but can be
|
|
330
|
-
disabled via the `dependencyTypes` property of your config file or the `--types`
|
|
331
|
-
option on the command line.
|
|
332
|
-
|
|
333
|
-
- If `dependencyTypes` is unset or is an empty array, nothing is disabled.
|
|
334
|
-
- If `dependencyTypes` is set, only those listed will be enabled.
|
|
335
|
-
- If `--types` is set, it takes precedence and only its values will be used.
|
|
336
|
-
|
|
337
|
-
In this example, only dependencies found in `dependencies` and `devDependencies`
|
|
338
|
-
will be inspected by syncpack.
|
|
339
|
-
|
|
340
|
-
```json
|
|
341
|
-
{
|
|
342
|
-
"dependencyTypes": ["dev", "prod"]
|
|
343
|
-
}
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
| Value | Property in package.json |
|
|
347
|
-
| --------------- | ------------------------ |
|
|
348
|
-
| `dev` | `.devDependencies` |
|
|
349
|
-
| `overrides` | `.overrides` |
|
|
350
|
-
| `peer` | `.peerDependencies` |
|
|
351
|
-
| `pnpmOverrides` | `.pnpm.overrides` |
|
|
352
|
-
| `prod` | `.dependencies` |
|
|
353
|
-
| `resolutions` | `.resolutions` |
|
|
354
|
-
| `workspace` | `.version` |
|
|
355
|
-
|
|
356
|
-
This list can be extended with your own `customTypes`, so you can find and fix
|
|
357
|
-
versions found in other parts of your package.json files.
|
|
358
|
-
|
|
359
|
-
##### The `workspace` type
|
|
360
|
-
|
|
361
|
-
This option synchronises the versions of your dependencies with the `version`
|
|
362
|
-
properties of the package.json files developed in your own local
|
|
363
|
-
workspace/project, when they relate to eachother.
|
|
364
|
-
|
|
365
|
-
Take this example, `@your-repo/fetch` is developed in your repo:
|
|
366
|
-
|
|
367
|
-
```jsonc
|
|
368
|
-
{
|
|
369
|
-
"name": "@your-repo/fetch",
|
|
370
|
-
"version": "1.0.2"
|
|
371
|
-
// ...rest of the file
|
|
372
|
-
}
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
and another package developed in your repo depends on it:
|
|
376
|
-
|
|
377
|
-
```jsonc
|
|
378
|
-
{
|
|
379
|
-
"name": "@your-repo/ui",
|
|
380
|
-
// ...other stuff
|
|
381
|
-
"dependencies": {
|
|
382
|
-
"@your-repo/fetch": "0.9.4"
|
|
383
|
-
}
|
|
384
|
-
// ...rest of the file
|
|
385
|
-
}
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
When `workspace` is enabled, syncpack will fix `@your-repo/ui` so it depends on
|
|
389
|
-
version `1.0.2` of `@your-repo/fetch`.
|
|
390
|
-
|
|
391
|
-
#### `indent`
|
|
392
|
-
|
|
393
|
-
The character(s) to be used to indent your package.json files when writing to
|
|
394
|
-
disk.
|
|
395
|
-
|
|
396
|
-
#### `semverRange`
|
|
397
|
-
|
|
398
|
-
Defaulted to `""` to ensure that exact dependency versions are used instead of
|
|
399
|
-
loose ranges, but this can be overridden in your config file or via the
|
|
400
|
-
`--semver-range` command line option.
|
|
401
|
-
|
|
402
|
-
##### Supported Ranges
|
|
403
|
-
|
|
404
|
-
```
|
|
405
|
-
< <1.4.2
|
|
406
|
-
<= <=1.4.2
|
|
407
|
-
"" 1.4.2
|
|
408
|
-
~ ~1.4.2
|
|
409
|
-
^ ^1.4.2
|
|
410
|
-
>= >=1.4.2
|
|
411
|
-
> >1.4.2
|
|
412
|
-
* *
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
#### `sortAz`
|
|
416
|
-
|
|
417
|
-
When using the `format` command, determines which fields within package.json
|
|
418
|
-
files should be sorted alphabetically. When the value is an Object, its keys are
|
|
419
|
-
sorted alphabetically. When the value is an Array, its values are sorted
|
|
420
|
-
alphabetically. There is no equivalent CLI Option for this configuration.
|
|
421
|
-
|
|
422
|
-
#### `sortFirst`
|
|
423
|
-
|
|
424
|
-
When using the `format` command, determines which fields within package.json
|
|
425
|
-
files should appear at the top, and in what order. There is no equivalent CLI
|
|
426
|
-
Option for this configuration.
|
|
427
|
-
|
|
428
|
-
#### `source`
|
|
429
|
-
|
|
430
|
-
Defaults to `["package.json", "packages/*/package.json"]` to match most Projects
|
|
431
|
-
using Lerna or Yarn Workspaces, but this can be overridden in your config file
|
|
432
|
-
or via multiple `--source` command line options. Supports any patterns supported
|
|
433
|
-
by [glob](https://github.com/isaacs/node-glob).
|
|
434
|
-
|
|
435
|
-
#### `customTypes`
|
|
436
|
-
|
|
437
|
-
Extend syncpack to find and fix versions in your packages which are not
|
|
438
|
-
available by default. Custom types behave like any other dependency, so can be
|
|
439
|
-
included in [versionGroups](#versiongroups) or [semverGroups](#semvergroups)
|
|
440
|
-
etc.
|
|
441
|
-
|
|
442
|
-
The example below adds support for synchronising versions found in:
|
|
443
|
-
|
|
444
|
-
1. The
|
|
445
|
-
[`engines`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#engines)
|
|
446
|
-
object.
|
|
447
|
-
1. The [`packageManager`](https://nodejs.org/api/packages.html#packagemanager)
|
|
448
|
-
string.
|
|
449
|
-
|
|
450
|
-
```json
|
|
451
|
-
{
|
|
452
|
-
"customTypes": {
|
|
453
|
-
"engines": {
|
|
454
|
-
"path": "engines",
|
|
455
|
-
"strategy": "versionsByName"
|
|
456
|
-
},
|
|
457
|
-
"packageManager": {
|
|
458
|
-
"path": "packageManager",
|
|
459
|
-
"strategy": "name@version"
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
##### `customTypes[name]`
|
|
466
|
-
|
|
467
|
-
The key of each custom type is its name, this can be used in the following
|
|
468
|
-
places to toggle when it is enabled:
|
|
469
|
-
|
|
470
|
-
1. [`--type` / `dependencyTypes`](#--type--dependencytypes).
|
|
471
|
-
1. [`versionGroup.dependencyTypes`](#versiongroupdependencytypes)
|
|
472
|
-
1. [`semverGroup.dependencyTypes`](#semvergroupdependencytypes)
|
|
473
|
-
|
|
474
|
-
##### `customTypes[name].path`
|
|
475
|
-
|
|
476
|
-
Where the version can be found in each package.json file, such as `engines`,
|
|
477
|
-
`packageManager` or `some.nested.property`.
|
|
478
|
-
|
|
479
|
-
##### `customTypes[name].strategy`
|
|
480
|
-
|
|
481
|
-
A strategy defines how syncpack needs to read and write dependency names and
|
|
482
|
-
versions, there are 3 to choose from:
|
|
483
|
-
|
|
484
|
-
| Name | Example |
|
|
485
|
-
| ---------------- | -------------------------------------- |
|
|
486
|
-
| `name@version` | `pnpm@7.27.0` |
|
|
487
|
-
| `version` | `12.4.2` |
|
|
488
|
-
| `versionsByName` | `{"pnpm":"7.27.0", "semver": "7.3.8"}` |
|
|
489
|
-
|
|
490
|
-
#### `versionGroups`
|
|
491
|
-
|
|
492
|
-
The most common use case for version groups is when some of the packages in your
|
|
493
|
-
Monorepo are considered alpha (or legacy). Since those packages are much further
|
|
494
|
-
ahead (or behind) the other packages, the dependencies within those packages
|
|
495
|
-
need to be managed differently to the rest of the Monorepo.
|
|
496
|
-
|
|
497
|
-
Your alpha packages might use unstable versions of some dependencies, while the
|
|
498
|
-
rest of the repo might need to remain on stable versions.
|
|
499
|
-
|
|
500
|
-
You don't want mismatches within your alpha packages, you don't want mismatches
|
|
501
|
-
within the other packages, but you _do_ want those groups to use different
|
|
502
|
-
versions _to each other_ and not have `syncpack` make them all the same.
|
|
503
|
-
|
|
504
|
-
In the following example, 2 of our packages are using different versions of
|
|
505
|
-
`react` and `react-dom` to the rest of the project.
|
|
506
|
-
|
|
507
|
-
```json
|
|
508
|
-
{
|
|
509
|
-
"versionGroups": [
|
|
510
|
-
{
|
|
511
|
-
"dependencies": ["react", "react-dom"],
|
|
512
|
-
"packages": ["@alpha/server", "@alpha/ui"]
|
|
513
|
-
}
|
|
514
|
-
]
|
|
515
|
-
}
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
> 👋 The `dependencies` and `packages` fields are processed using
|
|
519
|
-
> [minimatch](https://github.com/isaacs/minimatch), so the above example can
|
|
520
|
-
> also be written as `"packages": ["@alpha/**"]`.
|
|
521
|
-
|
|
522
|
-
`syncpack` will make ensure that:
|
|
523
|
-
|
|
524
|
-
- The versions of `react` and `react-dom` are the same within `@alpha/server`
|
|
525
|
-
and `@alpha/ui`.
|
|
526
|
-
- The versions of `react` and `react-dom` are the same across every package
|
|
527
|
-
except `@alpha/server` and `@alpha/ui`.
|
|
528
|
-
- The versions of `react` and `react-dom` within `@alpha/server` and `@alpha/ui`
|
|
529
|
-
can be different to the other packages in the monorepo.
|
|
530
|
-
- The versions of every other dependency in the monorepo (eg `lodash`) are the
|
|
531
|
-
same across every package including `@alpha/server` and `@alpha/ui`.
|
|
532
|
-
|
|
533
|
-
Each dependency can only belong to one version group, the first rule which
|
|
534
|
-
matches a given dependency and package will apply.
|
|
535
|
-
|
|
536
|
-
You can be quite granular with these rules, so the partitioning doesn't _have_
|
|
537
|
-
to apply to an entire package:
|
|
538
|
-
|
|
539
|
-
- A specific dependency in a specific package.
|
|
540
|
-
- A specific dependency in some specific packages only.
|
|
541
|
-
- Any dependency who name matches a pattern such as `@aws-sdk/**`.
|
|
542
|
-
|
|
543
|
-
See [`semverGroups`](#semverGroups) for more examples, they work the same way.
|
|
544
|
-
|
|
545
|
-
##### `versionGroup.dependencies`
|
|
546
|
-
|
|
547
|
-
Required. An array of minimatch glob patterns which should match the key of
|
|
548
|
-
dependencies defined in your package.json files.
|
|
549
|
-
|
|
550
|
-
| Pattern | Matches |
|
|
551
|
-
| ------------------------ | ---------------------------------------- |
|
|
552
|
-
| `["**"]` | Any dependency |
|
|
553
|
-
| `["@aws-sdk/**"]` | Any dependency with the scope `@aws-sdk` |
|
|
554
|
-
| `["react", "react-dom"]` | Specific dependencies by name |
|
|
555
|
-
|
|
556
|
-
##### `versionGroup.packages`
|
|
557
|
-
|
|
558
|
-
Required. An array of minimatch glob patterns which should match the `name`
|
|
559
|
-
property of packages developed within your monorepo.
|
|
560
|
-
|
|
561
|
-
| Pattern | Matches |
|
|
562
|
-
| ---------------------------- | ------------------------------------- |
|
|
563
|
-
| `["**"]` | Any package |
|
|
564
|
-
| `["@my-repo/**"]` | Any package with the scope `@my-repo` |
|
|
565
|
-
| `["my-server", "my-client"]` | Specific packages by name |
|
|
566
|
-
|
|
567
|
-
##### `versionGroup.dependencyTypes`
|
|
568
|
-
|
|
569
|
-
Optional. If set, will result in only the dependency types included in that
|
|
570
|
-
array being considered a match for this version group.
|
|
571
|
-
|
|
572
|
-
In this example we define that all dependencies within `peerDependencies` in the
|
|
573
|
-
repo must match, regardless of what versions of the same dependencies might be
|
|
574
|
-
used in `dependencies` or `devDependencies`.
|
|
575
|
-
|
|
576
|
-
```json
|
|
577
|
-
{
|
|
578
|
-
"versionGroups": [
|
|
579
|
-
{
|
|
580
|
-
"dependencies": ["**"],
|
|
581
|
-
"dependencyTypes": ["peerDependencies"],
|
|
582
|
-
"packages": ["**"]
|
|
583
|
-
}
|
|
584
|
-
]
|
|
585
|
-
}
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
##### `versionGroup.isBanned`
|
|
589
|
-
|
|
590
|
-
Remove dependencies which you've decided should never be allowed.
|
|
591
|
-
|
|
592
|
-
```json
|
|
593
|
-
{
|
|
594
|
-
"versionGroups": [
|
|
595
|
-
{
|
|
596
|
-
"dependencies": ["never-gonna"],
|
|
597
|
-
"isBanned": true,
|
|
598
|
-
"packages": ["**"]
|
|
599
|
-
}
|
|
600
|
-
]
|
|
601
|
-
}
|
|
602
|
-
```
|
|
603
|
-
|
|
604
|
-
##### `versionGroup.isIgnored`
|
|
605
|
-
|
|
606
|
-
Have syncpack ignore these dependencies completely.
|
|
607
|
-
|
|
608
|
-
```json
|
|
609
|
-
{
|
|
610
|
-
"versionGroups": [
|
|
611
|
-
{
|
|
612
|
-
"dependencies": ["**"],
|
|
613
|
-
"isIgnored": true,
|
|
614
|
-
"packages": ["oops-moment", "workaround"]
|
|
615
|
-
}
|
|
616
|
-
]
|
|
617
|
-
}
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
##### `versionGroup.pinVersion`
|
|
621
|
-
|
|
622
|
-
Pin the version of all dependencies in this group to match this specific version
|
|
623
|
-
you've defined.
|
|
624
|
-
|
|
625
|
-
```json
|
|
626
|
-
{
|
|
627
|
-
"versionGroups": [
|
|
628
|
-
{
|
|
629
|
-
"dependencies": ["@aws-sdk/**"],
|
|
630
|
-
"packages": ["**"],
|
|
631
|
-
"pinVersion": "3.55.0"
|
|
632
|
-
}
|
|
633
|
-
]
|
|
634
|
-
}
|
|
635
|
-
```
|
|
636
|
-
|
|
637
|
-
#### `semverGroups`
|
|
638
|
-
|
|
639
|
-
Allow some packages to have different semver range rules to the rest of your
|
|
640
|
-
monorepo. Each dependency can only belong to one semver group, the first rule
|
|
641
|
-
which matches a given dependency and package will apply.
|
|
642
|
-
|
|
643
|
-
##### Example use cases
|
|
644
|
-
|
|
645
|
-
1: Every dependency of `@myrepo/library` should have a semver range of `~`,
|
|
646
|
-
regardless of what the rest of the monorepo uses:
|
|
647
|
-
|
|
648
|
-
```json
|
|
649
|
-
{
|
|
650
|
-
"semverGroups": [
|
|
651
|
-
{
|
|
652
|
-
"range": "~",
|
|
653
|
-
"dependencies": ["**"],
|
|
654
|
-
"packages": ["@myrepo/library"]
|
|
655
|
-
}
|
|
656
|
-
]
|
|
657
|
-
}
|
|
658
|
-
```
|
|
659
|
-
|
|
660
|
-
2: Every dependency of `@myrepo/library` whose name matches `@alpha/**` should
|
|
661
|
-
have a semver range of `^`, regardless of what the rest of that package or the
|
|
662
|
-
rest of the monorepo uses:
|
|
663
|
-
|
|
664
|
-
```json
|
|
665
|
-
{
|
|
666
|
-
"semverGroups": [
|
|
667
|
-
{
|
|
668
|
-
"range": "^",
|
|
669
|
-
"dependencies": ["@alpha/**"],
|
|
670
|
-
"packages": ["@myrepo/library"]
|
|
671
|
-
}
|
|
672
|
-
]
|
|
673
|
-
}
|
|
674
|
-
```
|
|
675
|
-
|
|
676
|
-
3: Every dependency in the monorepo whose name matches `@alpha/**` should have a
|
|
677
|
-
semver range of `~`, regardless of what the rest of the monorepo uses:
|
|
678
|
-
|
|
679
|
-
```json
|
|
680
|
-
{
|
|
681
|
-
"semverGroups": [
|
|
682
|
-
{
|
|
683
|
-
"range": "~",
|
|
684
|
-
"dependencies": ["@alpha/**"],
|
|
685
|
-
"packages": ["**"]
|
|
686
|
-
}
|
|
687
|
-
]
|
|
688
|
-
}
|
|
689
|
-
```
|
|
690
|
-
|
|
691
|
-
3: Production dependencies should have fixed version numbers, but development
|
|
692
|
-
and peer dependencies can be broader.
|
|
693
|
-
|
|
694
|
-
```json
|
|
695
|
-
{
|
|
696
|
-
"semverGroups": [
|
|
697
|
-
{
|
|
698
|
-
"range": "",
|
|
699
|
-
"dependencyTypes": [
|
|
700
|
-
"dependencies",
|
|
701
|
-
"resolutions",
|
|
702
|
-
"overrides",
|
|
703
|
-
"pnpmOverrides",
|
|
704
|
-
"workspace"
|
|
705
|
-
],
|
|
706
|
-
"dependencies": ["**"],
|
|
707
|
-
"packages": ["**"]
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
"range": "~",
|
|
711
|
-
"dependencyTypes": ["devDependencies"],
|
|
712
|
-
"dependencies": ["**"],
|
|
713
|
-
"packages": ["**"]
|
|
714
|
-
},
|
|
715
|
-
{
|
|
716
|
-
"range": "^",
|
|
717
|
-
"dependencyTypes": ["peerDependencies"],
|
|
718
|
-
"dependencies": ["**"],
|
|
719
|
-
"packages": ["**"]
|
|
720
|
-
}
|
|
721
|
-
]
|
|
722
|
-
}
|
|
723
|
-
```
|
|
724
|
-
|
|
725
|
-
##### `semverGroup.range`
|
|
726
|
-
|
|
727
|
-
Which of the [Supported Ranges](#supported-ranges) this group should use.
|
|
728
|
-
|
|
729
|
-
##### `semverGroup.dependencies`
|
|
730
|
-
|
|
731
|
-
Works the same as [`versionGroup.dependencies`](#versiongroupdependencies).
|
|
732
|
-
|
|
733
|
-
##### `semverGroup.isIgnored`
|
|
734
|
-
|
|
735
|
-
Works the same as [`versionGroup.isIgnored`](#versiongroupisignored).
|
|
736
|
-
|
|
737
|
-
##### `semverGroup.packages`
|
|
738
|
-
|
|
739
|
-
Works the same as [`versionGroup.packages`](#versiongrouppackages).
|
|
740
|
-
|
|
741
|
-
##### `semverGroup.dependencyTypes`
|
|
742
|
-
|
|
743
|
-
Works the same as
|
|
744
|
-
[`versionGroup.dependencyTypes`](#versiongroupdependencytypes).
|
|
745
|
-
|
|
746
|
-
#### `filter`
|
|
747
|
-
|
|
748
|
-
A string which will be passed to `new RegExp()` to match against package names
|
|
749
|
-
that should be included.
|
|
750
|
-
|
|
751
|
-
> ⚠️ `filter` was originally intended as a convenience to be used from the
|
|
752
|
-
> command line to filter the output of `syncpack list`, **it is not recommended
|
|
753
|
-
> to add this to your config file to manage your project more generally**.
|
|
754
|
-
>
|
|
755
|
-
> Instead use [`versionGroups`](#versiongroups) and/or
|
|
756
|
-
> [`semverGroups`](#semvergroups).
|
|
757
|
-
|
|
758
|
-
## Resolving Packages
|
|
759
|
-
|
|
760
|
-
package.json files are resolved in this order of precendence:
|
|
761
|
-
|
|
762
|
-
1. If `--source`
|
|
763
|
-
[glob patterns](https://github.com/isaacs/node-glob#glob-primer) are
|
|
764
|
-
provided, use those.
|
|
765
|
-
2. If using [Yarn Workspaces](https://yarnpkg.com/lang/en/docs/workspaces/),
|
|
766
|
-
read `workspaces` from `./package.json`.
|
|
767
|
-
3. If using [Lerna](https://lerna.js.org/), read `packages` from
|
|
768
|
-
`./lerna.json`.
|
|
769
|
-
4. If using [Pnpm](https://pnpm.js.org/), read `packages` from
|
|
770
|
-
`./pnpm-workspace.yaml`.
|
|
771
|
-
5. Default to `'package.json'` and `'packages/*/package.json'`.
|
|
772
|
-
|
|
773
|
-
> 👋 Always add quotes around your `--source` patterns
|
|
774
|
-
> [[more info](https://github.com/JamieMason/syncpack/issues/66#issuecomment-1146011769)].
|
|
775
|
-
|
|
776
|
-
## Getting Help
|
|
45
|
+
### [set-semver-ranges](https://jamiemason.github.io/syncpack/set-semver-ranges)
|
|
777
46
|
|
|
778
|
-
|
|
779
|
-
|
|
47
|
+
Ensure dependency versions used within `"dependencies"`, `"devDependencies"` etc
|
|
48
|
+
follow a consistent format.
|
|
780
49
|
|
|
781
|
-
|
|
782
|
-
https://github.com/JamieMason/syncpack/issues/new?template=bug_report.md
|
|
783
|
-
[feature request]:
|
|
784
|
-
https://github.com/JamieMason/syncpack/issues/new?template=feature_request.md
|
|
50
|
+
## Breaking Changes
|
|
785
51
|
|
|
786
|
-
|
|
52
|
+
Version [9.0.0](https://github.com/JamieMason/syncpack/releases/tag/9.0.0)
|
|
53
|
+
required some breaking API changes to add support for a new
|
|
54
|
+
[`customTypes`](https://jamiemason.github.io/syncpack/config/custom-types)
|
|
55
|
+
feature, but they are very simple to make.
|
|
787
56
|
|
|
788
|
-
|
|
57
|
+
## Badges
|
|
789
58
|
|
|
790
|
-
- [
|
|
791
|
-
|
|
792
|
-
- [
|
|
793
|
-
|
|
794
|
-
- [**ImageOptim-CLI**](https://github.com/JamieMason/ImageOptim-CLI)<br>Automates
|
|
795
|
-
ImageOptim, ImageAlpha, and JPEGmini for Mac to make batch optimisation of
|
|
796
|
-
images part of your automated build process.
|
|
797
|
-
- [**Jasmine-Matchers**](https://github.com/JamieMason/Jasmine-Matchers)<br>Write
|
|
798
|
-
Beautiful Specs with Custom Matchers
|
|
799
|
-
- [**karma-benchmark**](https://github.com/JamieMason/karma-benchmark)<br>Run
|
|
800
|
-
Benchmark.js over multiple Browsers, with CI compatible output
|
|
801
|
-
- [**self-help**](https://github.com/JamieMason/self-help#readme)<br>Interactive
|
|
802
|
-
Q&A Guides for Web and the Command Line
|
|
59
|
+
- [](https://www.npmjs.com/package/syncpack)
|
|
60
|
+
- [](https://www.npmjs.com/package/syncpack)
|
|
61
|
+
- [](https://github.com/JamieMason/syncpack/actions)
|
|
62
|
+
- [](https://codeclimate.com/github/JamieMason/syncpack/maintainability)
|