syncpack 5.8.15 → 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 +211 -91
- 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-lint-semver-ranges.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-list.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-mismatches.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.d.ts → bin-set-semver-ranges/index.d.ts} +0 -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 +19 -6
- 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/{commands/lib → lib}/is-semver.js +11 -11
- package/dist/lib/matches-filter.d.ts +3 -0
- package/dist/{commands/lib → lib}/matches-filter.js +4 -4
- 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 +34 -37
- package/CHANGELOG.md +0 -429
- package/dist/bin-fix-mismatches.js +0 -57
- package/dist/bin-format.js +0 -49
- package/dist/bin-lint-semver-ranges.js +0 -57
- package/dist/bin-list-mismatches.js +0 -55
- package/dist/bin-list.js +0 -55
- package/dist/bin-set-semver-ranges.js +0 -59
- 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 -47
- package/dist/commands/lib/get-wrappers.js +0 -53
- 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-installations.d.ts +0 -6
- package/dist/commands/lib/installations/get-installations.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/log.d.ts +0 -2
- package/dist/commands/lib/log.js +0 -32
- package/dist/commands/lib/matches-filter.d.ts +0 -5
- package/dist/commands/lib/set-semver-range.d.ts +0 -4
- package/dist/commands/lib/set-semver-range.js +0 -20
- package/dist/commands/lib/write-if-changed.d.ts +0 -2
- package/dist/commands/lib/write-if-changed.js +0 -27
- package/dist/commands/lint-semver-ranges.d.ts +0 -9
- package/dist/commands/lint-semver-ranges.js +0 -65
- 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 -6
- package/dist/commands/set-semver-ranges.js +0 -49
- package/dist/lib/get-config.d.ts +0 -2
- package/dist/lib/get-config.js +0 -43
package/README.md
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
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
11
|
## 🌩 Installation
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npm install --global syncpack
|
|
15
|
+
```
|
|
13
16
|
|
|
14
17
|
## 📝 Commands
|
|
15
18
|
|
|
16
19
|
### fix-mismatches
|
|
17
20
|
|
|
18
|
-
Ensure that multiple packages requiring the same dependency define the same
|
|
19
|
-
|
|
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`.
|
|
20
24
|
|
|
21
25
|
See [`versionGroups`](#versiongroups) if you have advanced requirements.
|
|
22
26
|
|
|
@@ -24,13 +28,15 @@ See [`versionGroups`](#versiongroups) if you have advanced requirements.
|
|
|
24
28
|
<summary>Options</summary>
|
|
25
29
|
|
|
26
30
|
```
|
|
27
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
31
|
+
-s, --source [pattern] glob pattern for package.json files to read from (default: [])
|
|
28
32
|
-p, --prod include dependencies
|
|
29
33
|
-d, --dev include devDependencies
|
|
30
34
|
-P, --peer include peerDependencies
|
|
31
|
-
-
|
|
35
|
+
-R, --resolutions include resolutions (yarn)
|
|
36
|
+
-o, --overrides include overrides (pnpm)
|
|
37
|
+
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
32
38
|
-i, --indent [value] override indentation. defaults to " "
|
|
33
|
-
-h, --help
|
|
39
|
+
-h, --help display help for command
|
|
34
40
|
```
|
|
35
41
|
|
|
36
42
|
</details>
|
|
@@ -59,8 +65,9 @@ syncpack fix-mismatches --indent " "
|
|
|
59
65
|
|
|
60
66
|
### format
|
|
61
67
|
|
|
62
|
-
Organise package.json files according to a conventional format, where fields
|
|
63
|
-
|
|
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
|
|
64
71
|
`"bugs"` fields.
|
|
65
72
|
|
|
66
73
|
<details>
|
|
@@ -92,8 +99,10 @@ syncpack format --indent " "
|
|
|
92
99
|
|
|
93
100
|
### lint-semver-ranges
|
|
94
101
|
|
|
95
|
-
Check whether dependency versions used within "dependencies", "devDependencies",
|
|
96
|
-
consistent format.
|
|
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.
|
|
97
106
|
|
|
98
107
|
<details>
|
|
99
108
|
<summary>Options</summary>
|
|
@@ -103,7 +112,9 @@ consistent format.
|
|
|
103
112
|
-p, --prod include dependencies
|
|
104
113
|
-d, --dev include devDependencies
|
|
105
114
|
-P, --peer include peerDependencies
|
|
106
|
-
-
|
|
115
|
+
-R, --resolutions include resolutions (yarn)
|
|
116
|
+
-o, --overrides include overrides (pnpm)
|
|
117
|
+
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
107
118
|
-r, --semver-range <range> see supported ranges below. defaults to ""
|
|
108
119
|
-h, --help display help for command
|
|
109
120
|
```
|
|
@@ -132,22 +143,22 @@ syncpack lint-semver-ranges --dev --peer --semver-range ~
|
|
|
132
143
|
|
|
133
144
|
</details>
|
|
134
145
|
|
|
135
|
-
### list
|
|
136
|
-
|
|
137
|
-
List dependencies which are required by multiple packages, where the version is not the same across every package.
|
|
146
|
+
### list
|
|
138
147
|
|
|
139
|
-
|
|
148
|
+
List all dependencies required by your packages.
|
|
140
149
|
|
|
141
150
|
<details>
|
|
142
151
|
<summary>Options</summary>
|
|
143
152
|
|
|
144
153
|
```
|
|
145
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
154
|
+
-s, --source [pattern] glob pattern for package.json files to read from (default: [])
|
|
146
155
|
-p, --prod include dependencies
|
|
147
156
|
-d, --dev include devDependencies
|
|
148
157
|
-P, --peer include peerDependencies
|
|
149
|
-
-
|
|
150
|
-
-
|
|
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
|
|
151
162
|
```
|
|
152
163
|
|
|
153
164
|
</details>
|
|
@@ -157,35 +168,40 @@ See [`versionGroups`](#versiongroups) if you have advanced requirements.
|
|
|
157
168
|
|
|
158
169
|
```bash
|
|
159
170
|
# uses defaults for resolving packages
|
|
160
|
-
syncpack list
|
|
171
|
+
syncpack list
|
|
161
172
|
# uses packages defined by --source when provided
|
|
162
|
-
syncpack list
|
|
173
|
+
syncpack list --source "apps/*/package.json"
|
|
163
174
|
# multiple globs can be provided like this
|
|
164
|
-
syncpack list
|
|
175
|
+
syncpack list --source "apps/*/package.json" --source "core/*/package.json"
|
|
165
176
|
# uses dependencies regular expression defined by --filter when provided
|
|
166
|
-
syncpack list
|
|
177
|
+
syncpack list --filter "typescript|tslint"
|
|
167
178
|
# only inspect "devDependencies"
|
|
168
|
-
syncpack list
|
|
179
|
+
syncpack list --dev
|
|
169
180
|
# only inspect "devDependencies" and "peerDependencies"
|
|
170
|
-
syncpack list
|
|
181
|
+
syncpack list --dev --peer
|
|
171
182
|
```
|
|
172
183
|
|
|
173
184
|
</details>
|
|
174
185
|
|
|
175
|
-
### list
|
|
186
|
+
### list-mismatches
|
|
176
187
|
|
|
177
|
-
List
|
|
188
|
+
List dependencies which are required by multiple packages, where the version is
|
|
189
|
+
not the same across every package.
|
|
190
|
+
|
|
191
|
+
See [`versionGroups`](#versiongroups) if you have advanced requirements.
|
|
178
192
|
|
|
179
193
|
<details>
|
|
180
194
|
<summary>Options</summary>
|
|
181
195
|
|
|
182
196
|
```
|
|
183
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
197
|
+
-s, --source [pattern] glob pattern for package.json files to read from (default: [])
|
|
184
198
|
-p, --prod include dependencies
|
|
185
199
|
-d, --dev include devDependencies
|
|
186
200
|
-P, --peer include peerDependencies
|
|
187
|
-
-
|
|
188
|
-
-
|
|
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
|
|
189
205
|
```
|
|
190
206
|
|
|
191
207
|
</details>
|
|
@@ -195,38 +211,42 @@ List all dependencies required by your packages.
|
|
|
195
211
|
|
|
196
212
|
```bash
|
|
197
213
|
# uses defaults for resolving packages
|
|
198
|
-
syncpack list
|
|
214
|
+
syncpack list-mismatches
|
|
199
215
|
# uses packages defined by --source when provided
|
|
200
|
-
syncpack list --source "apps/*/package.json"
|
|
216
|
+
syncpack list-mismatches --source "apps/*/package.json"
|
|
201
217
|
# multiple globs can be provided like this
|
|
202
|
-
syncpack list --source "apps/*/package.json" --source "core/*/package.json"
|
|
218
|
+
syncpack list-mismatches --source "apps/*/package.json" --source "core/*/package.json"
|
|
203
219
|
# uses dependencies regular expression defined by --filter when provided
|
|
204
|
-
syncpack list --filter "typescript|tslint"
|
|
220
|
+
syncpack list-mismatches --filter "typescript|tslint"
|
|
205
221
|
# only inspect "devDependencies"
|
|
206
|
-
syncpack list --dev
|
|
222
|
+
syncpack list-mismatches --dev
|
|
207
223
|
# only inspect "devDependencies" and "peerDependencies"
|
|
208
|
-
syncpack list --dev --peer
|
|
224
|
+
syncpack list-mismatches --dev --peer
|
|
209
225
|
```
|
|
210
226
|
|
|
211
227
|
</details>
|
|
212
228
|
|
|
213
229
|
### set-semver-ranges
|
|
214
230
|
|
|
215
|
-
Ensure dependency versions used within `"dependencies"`, `"devDependencies"`,
|
|
216
|
-
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.
|
|
217
235
|
|
|
218
236
|
<details>
|
|
219
237
|
<summary>Options</summary>
|
|
220
238
|
|
|
221
239
|
```
|
|
222
|
-
-s, --source [pattern] glob pattern for package.json files to read from
|
|
240
|
+
-s, --source [pattern] glob pattern for package.json files to read from (default: [])
|
|
223
241
|
-p, --prod include dependencies
|
|
224
242
|
-d, --dev include devDependencies
|
|
225
243
|
-P, --peer include peerDependencies
|
|
226
|
-
-
|
|
244
|
+
-R, --resolutions include resolutions (yarn)
|
|
245
|
+
-o, --overrides include overrides (pnpm)
|
|
246
|
+
-f, --filter [pattern] only include dependencies whose name matches this regex
|
|
227
247
|
-i, --indent [value] override indentation. defaults to " "
|
|
228
248
|
-r, --semver-range <range> see supported ranges below. defaults to ""
|
|
229
|
-
-h, --help
|
|
249
|
+
-h, --help display help for command
|
|
230
250
|
```
|
|
231
251
|
|
|
232
252
|
</details>
|
|
@@ -257,12 +277,15 @@ syncpack set-semver-ranges --indent " "
|
|
|
257
277
|
|
|
258
278
|
## 🛠 Configuration File
|
|
259
279
|
|
|
260
|
-
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:
|
|
261
282
|
|
|
262
283
|
- a `syncpack` property in `package.json`
|
|
263
284
|
- a `.syncpackrc` file in JSON or YAML format
|
|
264
|
-
- a `.syncpackrc.json`, `.syncpackrc.yaml`, `.syncpackrc.yml`, `.syncpackrc.js`,
|
|
265
|
-
|
|
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
|
|
266
289
|
|
|
267
290
|
### Default Configuration
|
|
268
291
|
|
|
@@ -271,34 +294,51 @@ Creating a configuration file is optional, syncpack will search up the directory
|
|
|
271
294
|
"dev": true,
|
|
272
295
|
"filter": ".",
|
|
273
296
|
"indent": " ",
|
|
297
|
+
"overrides": true,
|
|
274
298
|
"peer": true,
|
|
275
299
|
"prod": true,
|
|
300
|
+
"resolutions": true,
|
|
301
|
+
"semverGroups": [],
|
|
276
302
|
"semverRange": "",
|
|
277
|
-
"sortAz": [
|
|
303
|
+
"sortAz": [
|
|
304
|
+
"contributors",
|
|
305
|
+
"dependencies",
|
|
306
|
+
"devDependencies",
|
|
307
|
+
"keywords",
|
|
308
|
+
"peerDependencies",
|
|
309
|
+
"scripts"
|
|
310
|
+
],
|
|
278
311
|
"sortFirst": ["name", "description", "version", "author"],
|
|
279
312
|
"source": ["package.json", "packages/*/package.json"],
|
|
280
313
|
"versionGroups": []
|
|
281
314
|
}
|
|
282
315
|
```
|
|
283
316
|
|
|
284
|
-
### `dev`, `peer`, and `
|
|
317
|
+
### `dev`, `peer`, `prod`, `resolutions`, and `overrides`
|
|
318
|
+
|
|
319
|
+
Whether to search within `devDependencies`, `peerDependencies`, `dependencies`,
|
|
320
|
+
`resolutions` (Yarn), and `overrides` (Pnpm) respectively.
|
|
285
321
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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.
|
|
289
326
|
|
|
290
327
|
### `filter`
|
|
291
328
|
|
|
292
|
-
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.
|
|
293
331
|
|
|
294
332
|
### `indent`
|
|
295
333
|
|
|
296
|
-
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.
|
|
297
336
|
|
|
298
337
|
### `semverRange`
|
|
299
338
|
|
|
300
|
-
Defaulted to `""` to ensure that exact dependency versions are used instead of
|
|
301
|
-
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.
|
|
302
342
|
|
|
303
343
|
#### Supported Ranges
|
|
304
344
|
|
|
@@ -315,31 +355,91 @@ in your config file or via the `--semver-range` command line option.
|
|
|
315
355
|
|
|
316
356
|
### `sortAz`
|
|
317
357
|
|
|
318
|
-
When using the `format` command, determines which fields within package.json
|
|
319
|
-
|
|
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
|
|
320
361
|
alphabetically. There is no equivalent CLI Option for this configuration.
|
|
321
362
|
|
|
322
363
|
### `sortFirst`
|
|
323
364
|
|
|
324
|
-
When using the `format` command, determines which fields within package.json
|
|
325
|
-
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.
|
|
326
368
|
|
|
327
369
|
### `source`
|
|
328
370
|
|
|
329
|
-
Defaults to `["package.json", "packages/*/package.json"]` to match most Projects
|
|
330
|
-
this can be overridden in your config file
|
|
331
|
-
|
|
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
|
+
```
|
|
332
429
|
|
|
333
430
|
### `versionGroups`
|
|
334
431
|
|
|
335
|
-
If some packages in your Monorepo relate to "alpha" (or legacy) versions of your
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
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.
|
|
340
440
|
|
|
341
|
-
In the following example, 2 packages in our monorepo are using different
|
|
342
|
-
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.
|
|
343
443
|
|
|
344
444
|
```json
|
|
345
445
|
{
|
|
@@ -352,45 +452,65 @@ of the project.
|
|
|
352
452
|
}
|
|
353
453
|
```
|
|
354
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
|
+
|
|
355
459
|
`syncpack` will make ensure that:
|
|
356
460
|
|
|
357
|
-
- The versions of `react` and `react-dom` are the same within `@alpha/server`
|
|
358
|
-
|
|
359
|
-
- The versions of `react` and `react-dom`
|
|
360
|
-
|
|
361
|
-
- The versions of
|
|
362
|
-
|
|
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.
|
|
363
472
|
|
|
364
473
|
## 🕵🏾♀️ Resolving Packages
|
|
365
474
|
|
|
366
475
|
package.json files are resolved in this order of precendence:
|
|
367
476
|
|
|
368
|
-
1. If `--source`
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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`.
|
|
372
486
|
5. Default to `'package.json'` and `'packages/*/package.json'`.
|
|
373
487
|
|
|
374
488
|
## 🙋🏿♀️ Getting Help
|
|
375
489
|
|
|
376
|
-
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].
|
|
377
492
|
|
|
378
|
-
[bug report]:
|
|
379
|
-
|
|
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
|
|
380
497
|
|
|
381
498
|
## 👀 Other Projects
|
|
382
499
|
|
|
383
500
|
If you find my Open Source projects useful, please share them ❤️
|
|
384
501
|
|
|
385
|
-
- [**eslint-formatter-git-log**](https://github.com/JamieMason/eslint-formatter-git-log)<br>ESLint
|
|
386
|
-
Git Author, Date, and Hash
|
|
387
|
-
- [**eslint-plugin-move-files**](https://github.com/JamieMason/eslint-plugin-move-files)<br>Move
|
|
388
|
-
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
|
|
389
506
|
- [**eslint-plugin-prefer-arrow-functions**](https://github.com/JamieMason/eslint-plugin-prefer-arrow-functions)<br>Convert
|
|
390
507
|
functions to arrow functions
|
|
391
|
-
- [**ImageOptim-CLI**](https://github.com/JamieMason/ImageOptim-CLI)<br>Automates
|
|
392
|
-
for Mac to make batch optimisation of
|
|
393
|
-
|
|
394
|
-
- [**
|
|
395
|
-
|
|
396
|
-
- [**
|
|
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;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.getWorkspaceVersion = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* If the dependency `name` is a package developed locally in this monorepo, we
|
|
6
|
+
* should use its version as the source of truth.
|
|
7
|
+
*/
|
|
8
|
+
function getWorkspaceVersion(name, wrappers) {
|
|
9
|
+
var wrapper = wrappers.find(function (_a) {
|
|
10
|
+
var contents = _a.contents;
|
|
11
|
+
return contents.name === name;
|
|
12
|
+
});
|
|
13
|
+
if (!wrapper)
|
|
14
|
+
return '';
|
|
15
|
+
return wrapper.contents.version || '';
|
|
16
|
+
}
|
|
17
|
+
exports.getWorkspaceVersion = getWorkspaceVersion;
|
|
File without changes
|