syncpack 6.2.1 → 7.2.1

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.
Files changed (42) hide show
  1. package/README.md +122 -58
  2. package/dist/bin-fix-mismatches/fix-mismatches.js +13 -0
  3. package/dist/bin-fix-mismatches/get-expected-version/index.d.ts +1 -1
  4. package/dist/bin-fix-mismatches/get-expected-version/index.js +12 -8
  5. package/dist/bin-fix-mismatches/index.js +9 -5
  6. package/dist/bin-format/index.js +5 -5
  7. package/dist/bin-lint-semver-ranges/index.js +16 -12
  8. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -1
  9. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +2 -2
  10. package/dist/bin-list/index.js +10 -6
  11. package/dist/bin-list/list-version-groups.d.ts +2 -2
  12. package/dist/bin-list/list-version-groups.js +9 -5
  13. package/dist/bin-list/list.d.ts +2 -1
  14. package/dist/bin-list/list.js +7 -6
  15. package/dist/bin-list-mismatches/index.js +10 -6
  16. package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -1
  17. package/dist/bin-list-mismatches/list-mismatches.js +15 -6
  18. package/dist/bin-set-semver-ranges/index.js +16 -12
  19. package/dist/constants.d.ts +11 -2
  20. package/dist/constants.js +2 -0
  21. package/dist/lib/disk.d.ts +4 -1
  22. package/dist/lib/disk.js +25 -6
  23. package/dist/lib/get-input/get-config.d.ts +4 -1
  24. package/dist/lib/get-input/get-config.js +8 -2
  25. package/dist/lib/get-input/get-instances.js +42 -26
  26. package/dist/lib/get-input/get-wrappers/get-file-paths.js +5 -1
  27. package/dist/lib/get-input/get-wrappers/get-patterns/get-lerna-patterns.js +5 -1
  28. package/dist/lib/get-input/get-wrappers/get-patterns/get-pnpm-patterns.js +5 -1
  29. package/dist/lib/get-input/get-wrappers/get-patterns/get-yarn-patterns.js +5 -1
  30. package/dist/lib/get-input/get-wrappers/get-patterns/index.js +5 -1
  31. package/dist/lib/get-input/get-wrappers/get-patterns/props.js +5 -1
  32. package/dist/lib/get-input/get-wrappers/get-patterns/read-json-safe.js +5 -1
  33. package/dist/lib/get-input/get-wrappers/get-patterns/read-yaml-safe.js +5 -1
  34. package/dist/lib/get-input/get-wrappers/index.js +6 -2
  35. package/dist/lib/get-input/get-wrappers/tap.js +7 -8
  36. package/dist/lib/get-input/index.d.ts +4 -2
  37. package/dist/lib/get-input/index.js +2 -3
  38. package/dist/lib/log.d.ts +1 -0
  39. package/dist/lib/log.js +13 -0
  40. package/dist/option.d.ts +2 -0
  41. package/dist/option.js +4 -2
  42. package/package.json +17 -17
package/README.md CHANGED
@@ -28,14 +28,16 @@ See [`versionGroups`](#versiongroups) if you have advanced requirements.
28
28
  <summary>Options</summary>
29
29
 
30
30
  ```
31
- -s, --source [pattern] glob pattern for package.json files to read from (default: [])
31
+ -s, --source [pattern] glob pattern for package.json files to read from
32
+ -f, --filter [pattern] only include dependencies whose name matches this regex
32
33
  -p, --prod include dependencies
33
34
  -d, --dev include devDependencies
34
35
  -P, --peer include peerDependencies
35
36
  -R, --resolutions include resolutions (yarn)
36
37
  -o, --overrides include overrides (pnpm)
37
- -f, --filter [pattern] only include dependencies whose name matches this regex
38
+ -w, --workspace include locally developed package versions
38
39
  -i, --indent [value] override indentation. defaults to " "
40
+ -c, --config <path> path to a syncpack config file
39
41
  -h, --help display help for command
40
42
  ```
41
43
 
@@ -76,7 +78,8 @@ Shorthand properties are used where available, such as the `"repository"` and
76
78
  ```
77
79
  -s, --source [pattern] glob pattern for package.json files to read from
78
80
  -i, --indent [value] override indentation. defaults to " "
79
- -h, --help output usage information
81
+ -c, --config <path> path to a syncpack config file
82
+ -h, --help display help for command
80
83
  ```
81
84
 
82
85
  </details>
@@ -108,7 +111,7 @@ See [`semverGroups`](#semvergroups) if you have advanced requirements.
108
111
  <summary>Options</summary>
109
112
 
110
113
  ```
111
- -s, --source [pattern] glob pattern for package.json files to read from (default: [])
114
+ -s, --source [pattern] glob pattern for package.json files to read from
112
115
  -p, --prod include dependencies
113
116
  -d, --dev include devDependencies
114
117
  -P, --peer include peerDependencies
@@ -116,6 +119,8 @@ See [`semverGroups`](#semvergroups) if you have advanced requirements.
116
119
  -o, --overrides include overrides (pnpm)
117
120
  -f, --filter [pattern] only include dependencies whose name matches this regex
118
121
  -r, --semver-range <range> see supported ranges below. defaults to ""
122
+ -c, --config <path> path to a syncpack config file
123
+ -w, --workspace include locally developed package versions
119
124
  -h, --help display help for command
120
125
  ```
121
126
 
@@ -151,13 +156,15 @@ List all dependencies required by your packages.
151
156
  <summary>Options</summary>
152
157
 
153
158
  ```
154
- -s, --source [pattern] glob pattern for package.json files to read from (default: [])
159
+ -s, --source [pattern] glob pattern for package.json files to read from
155
160
  -p, --prod include dependencies
156
161
  -d, --dev include devDependencies
157
162
  -P, --peer include peerDependencies
158
163
  -R, --resolutions include resolutions (yarn)
159
164
  -o, --overrides include overrides (pnpm)
160
165
  -f, --filter [pattern] only include dependencies whose name matches this regex
166
+ -c, --config <path> path to a syncpack config file
167
+ -w, --workspace include locally developed package versions
161
168
  -h, --help display help for command
162
169
  ```
163
170
 
@@ -194,13 +201,15 @@ See [`versionGroups`](#versiongroups) if you have advanced requirements.
194
201
  <summary>Options</summary>
195
202
 
196
203
  ```
197
- -s, --source [pattern] glob pattern for package.json files to read from (default: [])
204
+ -s, --source [pattern] glob pattern for package.json files to read from
198
205
  -p, --prod include dependencies
199
206
  -d, --dev include devDependencies
200
207
  -P, --peer include peerDependencies
201
208
  -R, --resolutions include resolutions (yarn)
202
209
  -o, --overrides include overrides (pnpm)
203
210
  -f, --filter [pattern] only include dependencies whose name matches this regex
211
+ -c, --config <path> path to a syncpack config file
212
+ -w, --workspace include locally developed package versions
204
213
  -h, --help display help for command
205
214
  ```
206
215
 
@@ -237,15 +246,18 @@ See [`semverGroups`](#semvergroups) if you have advanced requirements.
237
246
  <summary>Options</summary>
238
247
 
239
248
  ```
240
- -s, --source [pattern] glob pattern for package.json files to read from (default: [])
249
+ -s, --source [pattern] glob pattern for package.json files to read from
250
+ -r, --semver-range <range> see supported ranges below. defaults to ""
251
+ -f, --filter [pattern] only include dependencies whose name matches this regex
241
252
  -p, --prod include dependencies
242
253
  -d, --dev include devDependencies
243
254
  -P, --peer include peerDependencies
244
255
  -R, --resolutions include resolutions (yarn)
245
256
  -o, --overrides include overrides (pnpm)
246
- -f, --filter [pattern] only include dependencies whose name matches this regex
257
+ -w, --workspace include locally developed package versions
247
258
  -i, --indent [value] override indentation. defaults to " "
248
259
  -r, --semver-range <range> see supported ranges below. defaults to ""
260
+ -c, --config <path> path to a syncpack config file
249
261
  -h, --help display help for command
250
262
  ```
251
263
 
@@ -287,6 +299,9 @@ tree in the following places:
287
299
  - a `syncpack.config.js` or `syncpack.config.cjs` CommonJS module exporting an
288
300
  object
289
301
 
302
+ If you want to specify a path to a configuration file, overriding the discovered
303
+ configuration file (if present), you can use the `--config` option.
304
+
290
305
  ### Default Configuration
291
306
 
292
307
  ```json
@@ -298,6 +313,7 @@ tree in the following places:
298
313
  "peer": true,
299
314
  "prod": true,
300
315
  "resolutions": true,
316
+ "workspace": true,
301
317
  "semverGroups": [],
302
318
  "semverRange": "",
303
319
  "sortAz": [
@@ -306,23 +322,26 @@ tree in the following places:
306
322
  "devDependencies",
307
323
  "keywords",
308
324
  "peerDependencies",
325
+ "resolutions",
309
326
  "scripts"
310
327
  ],
311
328
  "sortFirst": ["name", "description", "version", "author"],
312
- "source": ["package.json", "packages/*/package.json"],
329
+ "source": [],
313
330
  "versionGroups": []
314
331
  }
315
332
  ```
316
333
 
317
- ### `dev`, `peer`, `prod`, `resolutions`, and `overrides`
334
+ ### `dev`, `peer`, `prod`, `resolutions`, `overrides`, and `workspace`
318
335
 
319
336
  Whether to search within `devDependencies`, `peerDependencies`, `dependencies`,
320
- `resolutions` (Yarn), and `overrides` (Pnpm) respectively.
337
+ `resolutions` (Yarn), `overrides` (Pnpm), and the `version` property of the
338
+ package.json files of your own packages developed within your `workspace`
339
+ respectively.
321
340
 
322
341
  All of these locations are searched by default but they can be disabled
323
342
  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.
343
+ `--dev`, `--peer`, `--prod`, `--resolutions`, `--overrides`, or `--workspace`
344
+ then only the options you provide will be searched.
326
345
 
327
346
  ### `filter`
328
347
 
@@ -373,6 +392,94 @@ using Lerna or Yarn Workspaces, but this can be overridden in your config file
373
392
  or via multiple `--source` command line options. Supports any patterns supported
374
393
  by [glob](https://github.com/isaacs/node-glob).
375
394
 
395
+ ### `versionGroups`
396
+
397
+ The most common use case for version groups is when some of the packages in your
398
+ Monorepo are considered alpha (or legacy). Since those packages are much further
399
+ ahead (or behind) the other packages, the dependencies within those packages
400
+ need to be managed differently to the rest of the Monorepo.
401
+
402
+ Your alpha packages might use unstable versions of some dependencies, while the
403
+ rest of the repo might need to remain on stable versions.
404
+
405
+ You don't want mismatches within your alpha packages, you don't want mismatches
406
+ within the other packages, but you _do_ want those groups to use different
407
+ versions _to each other_ and not have `syncpack` make them all the same.
408
+
409
+ In the following example, 2 of our packages are using different versions of
410
+ `react` and `react-dom` to the rest of the project.
411
+
412
+ ```json
413
+ {
414
+ "versionGroups": [
415
+ {
416
+ "dependencies": ["react", "react-dom"],
417
+ "packages": ["@alpha/server", "@alpha/ui"]
418
+ }
419
+ ]
420
+ }
421
+ ```
422
+
423
+ > 👋 The `dependencies` and `packages` fields are processed using
424
+ > [minimatch](https://github.com/isaacs/minimatch), so the above example can
425
+ > also be written as `"packages": ["@alpha/**"]`.
426
+
427
+ `syncpack` will make ensure that:
428
+
429
+ - The versions of `react` and `react-dom` are the same within `@alpha/server`
430
+ and `@alpha/ui`.
431
+ - The versions of `react` and `react-dom` are the same across every package
432
+ except `@alpha/server` and `@alpha/ui`.
433
+ - The versions of `react` and `react-dom` within `@alpha/server` and `@alpha/ui`
434
+ can be different to the other packages in the monorepo.
435
+ - The versions of every other dependency in the monorepo (eg `lodash`) are the
436
+ same across every package including `@alpha/server` and `@alpha/ui`.
437
+
438
+ Each dependency can only belong to one version group, the first rule which
439
+ matches a given dependency and package will apply.
440
+
441
+ You can be quite granular with these rules, so the partitioning doesn't _have_
442
+ to apply to an entire package:
443
+
444
+ - A specific dependency in a specific package.
445
+ - A specific dependency in some specific packages only.
446
+ - Any dependency who name matches a pattern such as `@aws-sdk/**`.
447
+
448
+ See [`semverGroups`](#semverGroups) for more examples, they work the same way.
449
+
450
+ #### `versionGroup.isBanned`
451
+
452
+ Remove dependencies which you've decided should never be allowed.
453
+
454
+ ```json
455
+ {
456
+ "versionGroups": [
457
+ {
458
+ "isBanned": true,
459
+ "dependencies": ["never-gonna"],
460
+ "packages": ["**"]
461
+ }
462
+ ]
463
+ }
464
+ ```
465
+
466
+ #### `versionGroup.pinVersion`
467
+
468
+ Pin the version of all dependencies in this group to match this specific version
469
+ you've defined.
470
+
471
+ ```json
472
+ {
473
+ "versionGroups": [
474
+ {
475
+ "pinVersion": "3.55.0",
476
+ "dependencies": ["@aws-sdk/**"],
477
+ "packages": ["**"]
478
+ }
479
+ ]
480
+ }
481
+ ```
482
+
376
483
  ### `semverGroups`
377
484
 
378
485
  Allow some packages to have different semver range rules to the rest of your
@@ -397,14 +504,14 @@ regardless of what the rest of the monorepo uses:
397
504
  ```
398
505
 
399
506
  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
507
+ have a semver range of `^`, regardless of what the rest of that package or the
401
508
  rest of the monorepo uses:
402
509
 
403
510
  ```json
404
511
  {
405
512
  "semverGroups": [
406
513
  {
407
- "range": "~",
514
+ "range": "^",
408
515
  "dependencies": ["@alpha/**"],
409
516
  "packages": ["@myrepo/library"]
410
517
  }
@@ -427,49 +534,6 @@ semver range of `~`, regardless of what the rest of the monorepo uses:
427
534
  }
428
535
  ```
429
536
 
430
- ### `versionGroups`
431
-
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.
440
-
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.
443
-
444
- ```json
445
- {
446
- "versionGroups": [
447
- {
448
- "dependencies": ["react", "react-dom"],
449
- "packages": ["@alpha/server", "@alpha/ui"]
450
- }
451
- ]
452
- }
453
- ```
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
-
459
- `syncpack` will make ensure that:
460
-
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.
472
-
473
537
  ## 🕵🏾‍♀️ Resolving Packages
474
538
 
475
539
  package.json files are resolved in this order of precendence:
@@ -9,6 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  exports.__esModule = true;
10
10
  exports.fixMismatches = void 0;
11
11
  var chalk_1 = __importDefault(require("chalk"));
12
+ var expect_more_1 = require("expect-more");
12
13
  var list_version_groups_1 = require("../bin-list/list-version-groups");
13
14
  var write_if_changed_1 = require("../lib/write-if-changed");
14
15
  var get_expected_version_1 = require("./get-expected-version");
@@ -39,6 +40,7 @@ function fixMismatches(input, disk) {
39
40
  });
40
41
  });
41
42
  input.wrappers.forEach(function (wrapper) {
43
+ removeEmptyIndexes(wrapper);
42
44
  (0, write_if_changed_1.writeIfChanged)(disk, {
43
45
  contents: wrapper.contents,
44
46
  filePath: wrapper.filePath,
@@ -46,6 +48,17 @@ function fixMismatches(input, disk) {
46
48
  json: wrapper.json
47
49
  });
48
50
  });
51
+ /**
52
+ * Remove eg `{"dependencies": {}, "devDependencies": {}}`
53
+ */
54
+ function removeEmptyIndexes(wrapper) {
55
+ input.dependencyTypes.forEach(function (dependencyType) {
56
+ var deps = wrapper.contents[dependencyType];
57
+ if (deps && Object.values(deps).every(expect_more_1.isUndefined)) {
58
+ delete wrapper.contents[dependencyType];
59
+ }
60
+ });
61
+ }
49
62
  }
50
63
  exports.fixMismatches = fixMismatches;
51
64
  var templateObject_1;
@@ -1,3 +1,3 @@
1
1
  import type { ProgramInput } from '../../lib/get-input';
2
2
  import type { IndexedVersionGroup } from '../../lib/get-input/get-instances';
3
- export declare function getExpectedVersion(name: string, versionGroup: Pick<IndexedVersionGroup, 'instances' | 'pinVersion'>, input: Pick<ProgramInput, 'wrappers'>): string;
3
+ export declare function getExpectedVersion(name: string, versionGroup: Pick<IndexedVersionGroup, 'isBanned' | 'instances' | 'pinVersion'>, input: Pick<ProgramInput, 'workspace' | 'wrappers'>): string | undefined;
@@ -5,13 +5,17 @@ var get_highest_version_1 = require("./get-highest-version");
5
5
  var get_pinned_version_1 = require("./get-pinned-version");
6
6
  var get_workspace_version_1 = require("./get-workspace-version");
7
7
  function getExpectedVersion(name, versionGroup, input) {
8
- return ((0, get_pinned_version_1.getPinnedVersion)(versionGroup) ||
9
- (0, get_workspace_version_1.getWorkspaceVersion)(name, input.wrappers) ||
10
- (0, get_highest_version_1.getHighestVersion)(versionGroup.instances
11
- .filter(function (instance) { return instance.name === name; })
12
- .map(function (_a) {
13
- var version = _a.version;
14
- return version;
15
- })));
8
+ return versionGroup.isBanned === true
9
+ ? // remove this dependency
10
+ undefined
11
+ : (0, get_pinned_version_1.getPinnedVersion)(versionGroup) ||
12
+ (input.workspace === true &&
13
+ (0, get_workspace_version_1.getWorkspaceVersion)(name, input.wrappers)) ||
14
+ (0, get_highest_version_1.getHighestVersion)(versionGroup.instances
15
+ .filter(function (instance) { return instance.name === name; })
16
+ .map(function (_a) {
17
+ var version = _a.version;
18
+ return version;
19
+ }));
16
20
  }
17
21
  exports.getExpectedVersion = getExpectedVersion;
@@ -32,28 +32,31 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
32
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
- var _a, _b, _c, _d, _e, _f, _g;
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
36
36
  exports.__esModule = true;
37
37
  var chalk_1 = __importDefault(require("chalk"));
38
38
  var commander_1 = require("commander");
39
- var option_1 = require("../option");
40
39
  var disk_1 = require("../lib/disk");
41
40
  var get_input_1 = require("../lib/get-input");
41
+ var option_1 = require("../option");
42
42
  var fix_mismatches_1 = require("./fix-mismatches");
43
43
  commander_1.program.description((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Ensure that multiple packages requiring the same dependency define the same\n version, so that every package requires eg. {yellow react@16.4.2}, instead of a\n combination of {yellow react@16.4.2}, {yellow react@0.15.9}, and {yellow react@16.0.0}."], ["\n Ensure that multiple packages requiring the same dependency define the same\n version, so that every package requires eg. {yellow react@16.4.2}, instead of a\n combination of {yellow react@16.4.2}, {yellow react@0.15.9}, and {yellow react@16.0.0}."]))).replace(/^\n/, ''));
44
44
  commander_1.program.on('--help', function () {
45
45
  console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack fix-mismatches\n {dim # uses packages defined by --source when provided}\n syncpack fix-mismatches --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack fix-mismatches --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack fix-mismatches --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack fix-mismatches --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack fix-mismatches --dev --peer\n {dim # indent package.json with 4 spaces instead of 2}\n syncpack fix-mismatches --indent {yellow \" \"}\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"], ["\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack fix-mismatches\n {dim # uses packages defined by --source when provided}\n syncpack fix-mismatches --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack fix-mismatches --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack fix-mismatches --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack fix-mismatches --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack fix-mismatches --dev --peer\n {dim # indent package.json with 4 spaces instead of 2}\n syncpack fix-mismatches --indent {yellow \" \"}\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"]))));
46
46
  });
47
- (_a = (_b = (_c = (_d = (_e = (_f = (_g = commander_1.program
47
+ (_a = (_b = (_c = (_d = (_e = (_f = (_g = (_h = (_j = commander_1.program
48
48
  .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
49
+ .option.apply(_j, __spreadArray([], __read(option_1.option.filter), false)))
50
+ .option.apply(_h, __spreadArray([], __read(option_1.option.config), false)))
49
51
  .option.apply(_g, __spreadArray([], __read(option_1.option.prod), false)))
50
52
  .option.apply(_f, __spreadArray([], __read(option_1.option.dev), false)))
51
53
  .option.apply(_e, __spreadArray([], __read(option_1.option.peer), false)))
52
54
  .option.apply(_d, __spreadArray([], __read(option_1.option.resolutions), false)))
53
55
  .option.apply(_c, __spreadArray([], __read(option_1.option.overrides), false)))
54
- .option.apply(_b, __spreadArray([], __read(option_1.option.filter), false)))
56
+ .option.apply(_b, __spreadArray([], __read(option_1.option.workspace), false)))
55
57
  .option.apply(_a, __spreadArray([], __read(option_1.option.indent), false)).parse(process.argv);
56
58
  (0, fix_mismatches_1.fixMismatches)((0, get_input_1.getInput)(disk_1.disk, {
59
+ configPath: commander_1.program.opts().config,
57
60
  dev: commander_1.program.opts().dev,
58
61
  filter: commander_1.program.opts().filter,
59
62
  indent: commander_1.program.opts().indent,
@@ -61,6 +64,7 @@ commander_1.program.on('--help', function () {
61
64
  peer: commander_1.program.opts().peer,
62
65
  prod: commander_1.program.opts().prod,
63
66
  resolutions: commander_1.program.opts().resolutions,
64
- source: commander_1.program.opts().source
67
+ source: commander_1.program.opts().source,
68
+ workspace: commander_1.program.opts().workspace
65
69
  }), disk_1.disk);
66
70
  var templateObject_1, templateObject_2;
@@ -32,25 +32,25 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
32
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
- var _a;
35
+ var _a, _b;
36
36
  exports.__esModule = true;
37
37
  var chalk_1 = __importDefault(require("chalk"));
38
38
  var commander_1 = require("commander");
39
- var option_1 = require("../option");
40
39
  var disk_1 = require("../lib/disk");
41
40
  var get_input_1 = require("../lib/get-input");
41
+ var option_1 = require("../option");
42
42
  var format_1 = require("./format");
43
43
  commander_1.program.description((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Organise package.json files according to a conventional format, where fields\n appear in a predictable order and nested fields are ordered alphabetically.\n Shorthand properties are used where available, such as the {yellow repository} and\n {yellow bugs} fields."], ["\n Organise package.json files according to a conventional format, where fields\n appear in a predictable order and nested fields are ordered alphabetically.\n Shorthand properties are used where available, such as the {yellow repository} and\n {yellow bugs} fields."]))).replace(/^\n/, ''));
44
44
  commander_1.program.on('--help', function () {
45
45
  console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack format\n {dim # uses packages defined by --source when provided}\n syncpack format --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack format --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # indent package.json with 4 spaces instead of 2}\n syncpack format --indent {yellow \" \"}\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"], ["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack format\n {dim # uses packages defined by --source when provided}\n syncpack format --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack format --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # indent package.json with 4 spaces instead of 2}\n syncpack format --indent {yellow \" \"}\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"]))));
46
46
  });
47
- (_a = commander_1.program
47
+ (_a = (_b = commander_1.program
48
48
  .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
49
+ .option.apply(_b, __spreadArray([], __read(option_1.option.config), false)))
49
50
  .option.apply(_a, __spreadArray([], __read(option_1.option.indent), false)).parse(process.argv);
50
51
  (0, format_1.format)((0, get_input_1.getInput)(disk_1.disk, {
52
+ configPath: commander_1.program.opts().config,
51
53
  indent: commander_1.program.opts().indent,
52
- overrides: commander_1.program.opts().overrides,
53
- resolutions: commander_1.program.opts().resolutions,
54
54
  source: commander_1.program.opts().source
55
55
  }), disk_1.disk);
56
56
  var templateObject_1, templateObject_2;
@@ -32,28 +32,31 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
32
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
- var _a, _b, _c, _d, _e, _f, _g;
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
36
36
  exports.__esModule = true;
37
37
  var chalk_1 = __importDefault(require("chalk"));
38
38
  var commander_1 = require("commander");
39
- var option_1 = require("../option");
40
39
  var disk_1 = require("../lib/disk");
41
40
  var get_input_1 = require("../lib/get-input");
41
+ var option_1 = require("../option");
42
42
  var lint_semver_ranges_1 = require("./lint-semver-ranges");
43
43
  commander_1.program.description((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Check dependency versions within {yellow dependencies}, {yellow devDependencies},\n {yellow peerDependencies}, {yellow overrides}, and {yellow resolutions} follow a consistent format."], ["\n Check dependency versions within {yellow dependencies}, {yellow devDependencies},\n {yellow peerDependencies}, {yellow overrides}, and {yellow resolutions} follow a consistent format."]))).replace(/^\n/, ''));
44
44
  commander_1.program.on('--help', function () {
45
45
  console.log((0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack lint-semver-ranges\n {dim # uses packages defined by --source when provided}\n syncpack lint-semver-ranges --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack lint-semver-ranges --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack lint-semver-ranges --filter {yellow \"typescript|tslint\"}\n {dim # use ~ range instead of default \"\"}\n syncpack lint-semver-ranges --semver-range ~\n {dim # use ~ range in \"devDependencies\"}\n syncpack lint-semver-ranges --dev --semver-range ~\n {dim # use ~ range in \"devDependencies\" and \"peerDependencies\"}\n syncpack lint-semver-ranges --dev --peer --semver-range ~\n\nSupported Ranges:\n < {dim <1.4.2}\n <= {dim <=1.4.2}\n \"\" {dim 1.4.2}\n ~ {dim ~1.4.2}\n ^ {dim ^1.4.2}\n >= {dim >=1.4.2}\n > {dim >1.4.2}\n * {dim *}\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"], ["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack lint-semver-ranges\n {dim # uses packages defined by --source when provided}\n syncpack lint-semver-ranges --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack lint-semver-ranges --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack lint-semver-ranges --filter {yellow \"typescript|tslint\"}\n {dim # use ~ range instead of default \"\"}\n syncpack lint-semver-ranges --semver-range ~\n {dim # use ~ range in \"devDependencies\"}\n syncpack lint-semver-ranges --dev --semver-range ~\n {dim # use ~ range in \"devDependencies\" and \"peerDependencies\"}\n syncpack lint-semver-ranges --dev --peer --semver-range ~\n\nSupported Ranges:\n < {dim <1.4.2}\n <= {dim <=1.4.2}\n \"\" {dim 1.4.2}\n ~ {dim ~1.4.2}\n ^ {dim ^1.4.2}\n >= {dim >=1.4.2}\n > {dim >1.4.2}\n * {dim *}\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"]))));
46
46
  });
47
- (_a = (_b = (_c = (_d = (_e = (_f = (_g = commander_1.program
47
+ (_a = (_b = (_c = (_d = (_e = (_f = (_g = (_h = (_j = commander_1.program
48
48
  .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
49
- .option.apply(_g, __spreadArray([], __read(option_1.option.prod), false)))
50
- .option.apply(_f, __spreadArray([], __read(option_1.option.dev), false)))
51
- .option.apply(_e, __spreadArray([], __read(option_1.option.peer), false)))
52
- .option.apply(_d, __spreadArray([], __read(option_1.option.resolutions), false)))
53
- .option.apply(_c, __spreadArray([], __read(option_1.option.overrides), false)))
54
- .option.apply(_b, __spreadArray([], __read(option_1.option.filter), false)))
55
- .option.apply(_a, __spreadArray([], __read(option_1.option.semverRange), false)).parse(process.argv);
49
+ .option.apply(_j, __spreadArray([], __read(option_1.option.filter), false)))
50
+ .option.apply(_h, __spreadArray([], __read(option_1.option.semverRange), false)))
51
+ .option.apply(_g, __spreadArray([], __read(option_1.option.config), false)))
52
+ .option.apply(_f, __spreadArray([], __read(option_1.option.prod), false)))
53
+ .option.apply(_e, __spreadArray([], __read(option_1.option.dev), false)))
54
+ .option.apply(_d, __spreadArray([], __read(option_1.option.peer), false)))
55
+ .option.apply(_c, __spreadArray([], __read(option_1.option.resolutions), false)))
56
+ .option.apply(_b, __spreadArray([], __read(option_1.option.overrides), false)))
57
+ .option.apply(_a, __spreadArray([], __read(option_1.option.workspace), false)).parse(process.argv);
56
58
  (0, lint_semver_ranges_1.lintSemverRanges)((0, get_input_1.getInput)(disk_1.disk, {
59
+ configPath: commander_1.program.opts().config,
57
60
  dev: commander_1.program.opts().dev,
58
61
  filter: commander_1.program.opts().filter,
59
62
  overrides: commander_1.program.opts().overrides,
@@ -61,6 +64,7 @@ commander_1.program.on('--help', function () {
61
64
  prod: commander_1.program.opts().prod,
62
65
  resolutions: commander_1.program.opts().resolutions,
63
66
  semverRange: commander_1.program.opts().semverRange,
64
- source: commander_1.program.opts().source
65
- }));
67
+ source: commander_1.program.opts().source,
68
+ workspace: commander_1.program.opts().workspace
69
+ }), disk_1.disk);
66
70
  var templateObject_1, templateObject_2;
@@ -1,2 +1,3 @@
1
+ import type { Disk } from '../lib/disk';
1
2
  import type { ProgramInput } from '../lib/get-input';
2
- export declare function lintSemverRanges(input: ProgramInput): void;
3
+ export declare function lintSemverRanges(input: ProgramInput, disk: Disk): void;
@@ -11,7 +11,7 @@ exports.lintSemverRanges = void 0;
11
11
  var chalk_1 = __importDefault(require("chalk"));
12
12
  var set_semver_range_1 = require("../lib/set-semver-range");
13
13
  var list_semver_group_mismatches_1 = require("./list-semver-group-mismatches");
14
- function lintSemverRanges(input) {
14
+ function lintSemverRanges(input, disk) {
15
15
  var isInvalid = false;
16
16
  /**
17
17
  * Reverse the list so the default/ungrouped semver group is rendered first
@@ -33,7 +33,7 @@ function lintSemverRanges(input) {
33
33
  }
34
34
  });
35
35
  if (isInvalid) {
36
- process.exit(1);
36
+ disk.process.exit(1);
37
37
  }
38
38
  }
39
39
  exports.lintSemverRanges = lintSemverRanges;
@@ -32,33 +32,37 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
32
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
- var _a, _b, _c, _d, _e, _f;
35
+ var _a, _b, _c, _d, _e, _f, _g, _h;
36
36
  exports.__esModule = true;
37
37
  var chalk_1 = __importDefault(require("chalk"));
38
38
  var commander_1 = require("commander");
39
- var option_1 = require("../option");
40
39
  var disk_1 = require("../lib/disk");
41
40
  var get_input_1 = require("../lib/get-input");
41
+ var option_1 = require("../option");
42
42
  var list_1 = require("./list");
43
43
  commander_1.program.description(' List all dependencies required by your packages.');
44
44
  commander_1.program.on('--help', function () {
45
45
  console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack list\n {dim # uses packages defined by --source when provided}\n syncpack list --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack list --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack list --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack list --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list --dev --peer\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"], ["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack list\n {dim # uses packages defined by --source when provided}\n syncpack list --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack list --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack list --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack list --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list --dev --peer\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"]))));
46
46
  });
47
- (_a = (_b = (_c = (_d = (_e = (_f = commander_1.program
47
+ (_a = (_b = (_c = (_d = (_e = (_f = (_g = (_h = commander_1.program
48
48
  .option.apply(commander_1.program, __spreadArray([], __read(option_1.option.source), false)))
49
+ .option.apply(_h, __spreadArray([], __read(option_1.option.filter), false)))
50
+ .option.apply(_g, __spreadArray([], __read(option_1.option.config), false)))
49
51
  .option.apply(_f, __spreadArray([], __read(option_1.option.prod), false)))
50
52
  .option.apply(_e, __spreadArray([], __read(option_1.option.dev), false)))
51
53
  .option.apply(_d, __spreadArray([], __read(option_1.option.peer), false)))
52
54
  .option.apply(_c, __spreadArray([], __read(option_1.option.resolutions), false)))
53
55
  .option.apply(_b, __spreadArray([], __read(option_1.option.overrides), false)))
54
- .option.apply(_a, __spreadArray([], __read(option_1.option.filter), false)).parse(process.argv);
56
+ .option.apply(_a, __spreadArray([], __read(option_1.option.workspace), false)).parse(process.argv);
55
57
  (0, list_1.list)((0, get_input_1.getInput)(disk_1.disk, {
58
+ configPath: commander_1.program.opts().config,
56
59
  dev: commander_1.program.opts().dev,
57
60
  filter: commander_1.program.opts().filter,
58
61
  overrides: commander_1.program.opts().overrides,
59
62
  peer: commander_1.program.opts().peer,
60
63
  prod: commander_1.program.opts().prod,
61
64
  resolutions: commander_1.program.opts().resolutions,
62
- source: commander_1.program.opts().source
63
- }));
65
+ source: commander_1.program.opts().source,
66
+ workspace: commander_1.program.opts().workspace
67
+ }), disk_1.disk);
64
68
  var templateObject_1;
@@ -1,9 +1,9 @@
1
1
  import type { IndexedVersionGroup, Instance } from '../lib/get-input/get-instances';
2
- interface ListItem {
2
+ export interface ListItem {
3
3
  hasMismatches: boolean;
4
4
  instances: Instance[];
5
+ isBanned: boolean;
5
6
  name: string;
6
7
  uniques: string[];
7
8
  }
8
9
  export declare function listVersionGroups(versionGroup: IndexedVersionGroup): ListItem[];
9
- export {};
@@ -21,7 +21,8 @@ var expect_more_1 = require("expect-more");
21
21
  var group_by_1 = require("../lib/group-by");
22
22
  var sort_by_name_1 = require("../lib/sort-by-name");
23
23
  function listVersionGroups(versionGroup) {
24
- var instancesByName = (0, group_by_1.groupBy)('name', versionGroup.instances.sort(sort_by_name_1.sortByName));
24
+ var instances = versionGroup.instances;
25
+ var instancesByName = (0, group_by_1.groupBy)('name', instances.sort(sort_by_name_1.sortByName));
25
26
  return Object.entries(instancesByName).map(function (_a) {
26
27
  var _b = __read(_a, 2), name = _b[0], instances = _b[1];
27
28
  var pinnedVersion = versionGroup.pinVersion;
@@ -31,13 +32,16 @@ function listVersionGroups(versionGroup) {
31
32
  return version;
32
33
  });
33
34
  var uniques = Array.from(new Set(versions));
34
- var hasMismatches = versions.some(function (version, i) {
35
- return (hasPinnedVersion && version !== pinnedVersion) ||
36
- (i > 0 && version !== versions[i - 1]);
37
- });
35
+ var isBanned = versionGroup.isBanned === true;
36
+ var hasMismatches = isBanned ||
37
+ versions.some(function (version, i) {
38
+ return (hasPinnedVersion && version !== pinnedVersion) ||
39
+ (i > 0 && version !== versions[i - 1]);
40
+ });
38
41
  return {
39
42
  hasMismatches: hasMismatches,
40
43
  instances: instances,
44
+ isBanned: isBanned,
41
45
  name: name,
42
46
  uniques: uniques
43
47
  };