syncpack 8.3.8 → 8.4.10

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 (31) hide show
  1. package/README.md +36 -9
  2. package/dist/bin-fix-mismatches/fix-mismatches.js +2 -2
  3. package/dist/bin-fix-mismatches/get-expected-version/get-pinned-version.d.ts +2 -2
  4. package/dist/bin-fix-mismatches/get-expected-version/index.d.ts +2 -2
  5. package/dist/bin-fix-mismatches/get-expected-version/index.js +18 -12
  6. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +3 -1
  7. package/dist/bin-list/list-version-groups.d.ts +3 -2
  8. package/dist/bin-list/list-version-groups.js +4 -2
  9. package/dist/bin-list/list.js +7 -9
  10. package/dist/bin-list-mismatches/list-mismatches.js +1 -4
  11. package/dist/bin-set-semver-ranges/set-semver-ranges.js +16 -14
  12. package/dist/constants.d.ts +1 -116
  13. package/dist/lib/disk.d.ts +1 -1
  14. package/dist/lib/get-input/get-config.d.ts +1 -1
  15. package/dist/lib/get-input/get-config.js +1 -1
  16. package/dist/lib/get-input/get-instances.d.ts +11 -3
  17. package/dist/lib/get-input/get-wrappers/get-file-paths.d.ts +1 -1
  18. package/dist/lib/get-input/get-wrappers/get-patterns/index.d.ts +1 -1
  19. package/dist/lib/get-input/get-wrappers/index.d.ts +1 -1
  20. package/dist/lib/get-input/index.d.ts +1 -1
  21. package/dist/lib/is-semver.d.ts +1 -1
  22. package/dist/lib/is-semver.js +2 -1
  23. package/dist/lib/set-semver-range.d.ts +1 -1
  24. package/dist/lib/set-semver-range.js +3 -2
  25. package/dist/types/index.d.ts +77 -0
  26. package/dist/types/index.js +2 -0
  27. package/dist/types/semver-group.d.ts +30 -0
  28. package/dist/types/semver-group.js +2 -0
  29. package/dist/types/version-group.d.ts +35 -0
  30. package/dist/types/version-group.js +2 -0
  31. package/package.json +1 -1
package/README.md CHANGED
@@ -362,6 +362,13 @@ or `--workspace` then only the options you provide will be searched.
362
362
  A string which will be passed to `new RegExp()` to match against package names
363
363
  that should be included.
364
364
 
365
+ > ⚠️ `filter` was originally intended as a convenience to be used from the
366
+ > command line to filter the output of `syncpack list`, **it is not recommended
367
+ > to add this to your config file to manage your project more generally**.
368
+ >
369
+ > Instead use [`versionGroups`](#versiongroups) and/or
370
+ > [`semverGroups`](#semvergroups).
371
+
365
372
  ### `indent`
366
373
 
367
374
  The character(s) to be used to indent your package.json files when writing to
@@ -520,6 +527,22 @@ Remove dependencies which you've decided should never be allowed.
520
527
  }
521
528
  ```
522
529
 
530
+ #### `versionGroup.isIgnored`
531
+
532
+ Have syncpack ignore these dependencies completely.
533
+
534
+ ```json
535
+ {
536
+ "versionGroups": [
537
+ {
538
+ "dependencies": ["**"],
539
+ "isIgnored": true,
540
+ "packages": ["oops-moment", "workaround"]
541
+ }
542
+ ]
543
+ }
544
+ ```
545
+
523
546
  #### `versionGroup.pinVersion`
524
547
 
525
548
  Pin the version of all dependencies in this group to match this specific version
@@ -600,7 +623,7 @@ and peer dependencies can be broader.
600
623
  {
601
624
  "range": "",
602
625
  "dependencyTypes": [
603
- "prod",
626
+ "dependencies",
604
627
  "resolutions",
605
628
  "overrides",
606
629
  "pnpmOverrides",
@@ -611,13 +634,13 @@ and peer dependencies can be broader.
611
634
  },
612
635
  {
613
636
  "range": "~",
614
- "dependencyTypes": ["dev"],
637
+ "dependencyTypes": ["devDependencies"],
615
638
  "dependencies": ["**"],
616
639
  "packages": ["**"]
617
640
  },
618
641
  {
619
642
  "range": "^",
620
- "dependencyTypes": ["peer"],
643
+ "dependencyTypes": ["peerDependencies"],
621
644
  "dependencies": ["**"],
622
645
  "packages": ["**"]
623
646
  }
@@ -631,15 +654,20 @@ Which of the [Supported Ranges](#supported-ranges) this group should use.
631
654
 
632
655
  #### `semverGroup.dependencies`
633
656
 
634
- Works the same as [`semverGroup.dependencies`](#semvergroupdependencies).
657
+ Works the same as [`versionGroup.dependencies`](#versiongroupdependencies).
658
+
659
+ #### `semverGroup.isIgnored`
660
+
661
+ Works the same as [`versionGroup.isIgnored`](#versiongroupisignored).
635
662
 
636
663
  #### `semverGroup.packages`
637
664
 
638
- Works the same as [`semverGroup.packages`](#semvergrouppackages).
665
+ Works the same as [`versionGroup.packages`](#versiongrouppackages).
639
666
 
640
667
  #### `semverGroup.dependencyTypes`
641
668
 
642
- Works the same as [`semverGroup.dependencyTypes`](#semvergroupdependencytypes).
669
+ Works the same as
670
+ [`versionGroup.dependencyTypes`](#versiongroupdependencytypes).
643
671
 
644
672
  ## 🕵🏾‍♀️ Resolving Packages
645
673
 
@@ -656,7 +684,8 @@ package.json files are resolved in this order of precendence:
656
684
  `./pnpm-workspace.yaml`.
657
685
  5. Default to `'package.json'` and `'packages/*/package.json'`.
658
686
 
659
- > 👋 Always add quotes around your `--source` patterns [[more info](https://github.com/JamieMason/syncpack/issues/66#issuecomment-1146011769)].
687
+ > 👋 Always add quotes around your `--source` patterns
688
+ > [[more info](https://github.com/JamieMason/syncpack/issues/66#issuecomment-1146011769)].
660
689
 
661
690
  ## 🙋🏿‍♀️ Getting Help
662
691
 
@@ -674,8 +703,6 @@ If you find my Open Source projects useful, please share them ❤️
674
703
 
675
704
  - [**eslint-formatter-git-log**](https://github.com/JamieMason/eslint-formatter-git-log)<br>ESLint
676
705
  Formatter featuring Git Author, Date, and Hash
677
- - [**eslint-plugin-move-files**](https://github.com/JamieMason/eslint-plugin-move-files)<br>Move
678
- and rename files while keeping imports up to date
679
706
  - [**eslint-plugin-prefer-arrow-functions**](https://github.com/JamieMason/eslint-plugin-prefer-arrow-functions)<br>Convert
680
707
  functions to arrow functions
681
708
  - [**ImageOptim-CLI**](https://github.com/JamieMason/ImageOptim-CLI)<br>Automates
@@ -26,8 +26,8 @@ function fixMismatches(input, disk) {
26
26
  console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim = Version Group ", " ", "}"], ["{dim = Version Group ", " ", "}"])), i, '='.repeat(63)));
27
27
  }
28
28
  groups.forEach(function (_a) {
29
- var hasMismatches = _a.hasMismatches, instances = _a.instances, name = _a.name;
30
- if (hasMismatches) {
29
+ var hasMismatches = _a.hasMismatches, instances = _a.instances, isIgnored = _a.isIgnored, name = _a.name;
30
+ if (hasMismatches && !isIgnored) {
31
31
  var nextVersion_1 = (0, get_expected_version_1.getExpectedVersion)(name, versionGroup, input);
32
32
  instances.forEach(function (_a) {
33
33
  var dependencyType = _a.dependencyType, version = _a.version, wrapper = _a.wrapper;
@@ -1,2 +1,2 @@
1
- import type { IndexedVersionGroup } from '../../lib/get-input/get-instances';
2
- export declare function getPinnedVersion(versionGroup: Pick<IndexedVersionGroup, 'pinVersion'>): string;
1
+ import type { PinnedVersionGroup } from '../../types/version-group';
2
+ export declare function getPinnedVersion(versionGroup: Pick<PinnedVersionGroup, 'pinVersion'>): string;
@@ -1,3 +1,3 @@
1
1
  import type { ProgramInput } from '../../lib/get-input';
2
- import type { IndexedVersionGroup } from '../../lib/get-input/get-instances';
3
- export declare function getExpectedVersion(name: string, versionGroup: Pick<IndexedVersionGroup, 'isBanned' | 'instances' | 'pinVersion'>, input: Pick<ProgramInput, 'workspace' | 'wrappers'>): string | undefined;
2
+ import type { IndexedBannedVersionGroup, IndexedPinnedVersionGroup, IndexedVersionGroup } from '../../lib/get-input/get-instances';
3
+ export declare function getExpectedVersion(name: string, versionGroup: Pick<IndexedBannedVersionGroup, 'isBanned' | 'instances'> | Pick<IndexedPinnedVersionGroup, 'instances' | 'pinVersion'> | Pick<IndexedVersionGroup, 'instances'>, input: Pick<ProgramInput, 'workspace' | 'wrappers'>): string | undefined;
@@ -5,17 +5,23 @@ 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 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
- }));
8
+ if ('isBanned' in versionGroup && versionGroup.isBanned === true) {
9
+ // remove this dependency
10
+ return undefined;
11
+ }
12
+ if ('pinVersion' in versionGroup && versionGroup.pinVersion) {
13
+ return (0, get_pinned_version_1.getPinnedVersion)(versionGroup);
14
+ }
15
+ if (input.workspace === true) {
16
+ var workspaceVersion = (0, get_workspace_version_1.getWorkspaceVersion)(name, input.wrappers);
17
+ if (workspaceVersion)
18
+ return workspaceVersion;
19
+ }
20
+ return (0, get_highest_version_1.getHighestVersion)(versionGroup.instances
21
+ .filter(function (instance) { return instance.name === name; })
22
+ .map(function (_a) {
23
+ var version = _a.version;
24
+ return version;
25
+ }));
20
26
  }
21
27
  exports.getExpectedVersion = getExpectedVersion;
@@ -19,9 +19,11 @@ function lintSemverRanges(input, disk) {
19
19
  * will then start from index 1.
20
20
  */
21
21
  input.instances.semverGroups.reverse().forEach(function (semverGroup, i) {
22
+ if (!('range' in semverGroup && semverGroup.range))
23
+ return;
22
24
  var isSemverGroup = i > 0;
23
25
  var mismatches = (0, list_semver_group_mismatches_1.listSemverGroupMismatches)(semverGroup);
24
- if (isSemverGroup) {
26
+ if (isSemverGroup && mismatches.length > 0) {
25
27
  console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim = Semver Group ", " ", "}"], ["{dim = Semver Group ", " ", "}"])), i, '='.repeat(63)));
26
28
  }
27
29
  mismatches.forEach(function (_a) {
@@ -1,9 +1,10 @@
1
- import type { IndexedVersionGroup, Instance } from '../lib/get-input/get-instances';
1
+ import type { AnyIndexedVersionGroup, Instance } from '../lib/get-input/get-instances';
2
2
  export interface ListItem {
3
3
  hasMismatches: boolean;
4
4
  instances: Instance[];
5
5
  isBanned: boolean;
6
+ isIgnored: boolean;
6
7
  name: string;
7
8
  uniques: string[];
8
9
  }
9
- export declare function listVersionGroups(versionGroup: IndexedVersionGroup): ListItem[];
10
+ export declare function listVersionGroups(versionGroup: AnyIndexedVersionGroup): ListItem[];
@@ -25,14 +25,15 @@ function listVersionGroups(versionGroup) {
25
25
  var instancesByName = (0, group_by_1.groupBy)('name', instances.sort(sort_by_name_1.sortByName));
26
26
  return Object.entries(instancesByName).map(function (_a) {
27
27
  var _b = __read(_a, 2), name = _b[0], instances = _b[1];
28
- var pinnedVersion = versionGroup.pinVersion;
28
+ var pinnedVersion = 'pinVersion' in versionGroup ? versionGroup.pinVersion : '';
29
29
  var hasPinnedVersion = (0, expect_more_1.isNonEmptyString)(pinnedVersion);
30
30
  var versions = instances.map(function (_a) {
31
31
  var version = _a.version;
32
32
  return version;
33
33
  });
34
34
  var uniques = Array.from(new Set(versions));
35
- var isBanned = versionGroup.isBanned === true;
35
+ var isBanned = 'isBanned' in versionGroup && versionGroup.isBanned === true;
36
+ var isIgnored = 'isIgnored' in versionGroup && versionGroup.isIgnored === true;
36
37
  var hasMismatches = isBanned ||
37
38
  versions.some(function (version, i) {
38
39
  return (hasPinnedVersion && version !== pinnedVersion) ||
@@ -42,6 +43,7 @@ function listVersionGroups(versionGroup) {
42
43
  hasMismatches: hasMismatches,
43
44
  instances: instances,
44
45
  isBanned: isBanned,
46
+ isIgnored: isIgnored,
45
47
  name: name,
46
48
  uniques: uniques
47
49
  };
@@ -26,23 +26,21 @@ function list(input, disk) {
26
26
  console.log((0, chalk_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{dim = Version Group ", " ", "}"], ["{dim = Version Group ", " ", "}"])), i, '='.repeat(63)));
27
27
  }
28
28
  groups.forEach(function (_a) {
29
- var hasMismatches = _a.hasMismatches, isBanned = _a.isBanned, name = _a.name, uniques = _a.uniques;
29
+ var hasMismatches = _a.hasMismatches, isBanned = _a.isBanned, isIgnored = _a.isIgnored, name = _a.name, uniques = _a.uniques;
30
30
  var versionList = uniques.sort();
31
31
  var expected = (0, get_expected_version_1.getExpectedVersion)(name, versionGroup, input);
32
32
  console.log(isBanned
33
- ? (0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{red ", " ", "} {dim.red is defined in this version group as banned from use}"], ["{red ", " ", "} {dim.red is defined in this version group as banned from use}"])), constants_1.ICON.cross, name) : hasMismatches
34
- ? (0, chalk_1["default"])(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{red ", " ", "} ", ""], ["{red ", " ", "} ", ""])), constants_1.ICON.cross, name, versionList
33
+ ? (0, chalk_1["default"])(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{red ", " ", "} {dim.red is defined in this version group as banned from use}"], ["{red ", " ", "} {dim.red is defined in this version group as banned from use}"])), constants_1.ICON.cross, name) : isIgnored
34
+ ? (0, chalk_1["default"])(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{dim ", " ", "} is ignored in this version group"], ["{dim ", " ", "} is ignored in this version group"])), constants_1.ICON.skip, name) : hasMismatches
35
+ ? (0, chalk_1["default"])(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{red ", " ", "} ", ""], ["{red ", " ", "} ", ""])), constants_1.ICON.cross, name, versionList
35
36
  .map(function (version) {
36
37
  return version === expected
37
38
  ? chalk_1["default"].green(version)
38
39
  : chalk_1["default"].red(version);
39
40
  })
40
- .join(chalk_1["default"].dim(', '))) : (0, chalk_1["default"])(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{dim -} {white ", "} {dim ", "}"], ["{dim -} {white ", "} {dim ", "}"])), name, versionList));
41
+ .join(chalk_1["default"].dim(', '))) : (0, chalk_1["default"])(templateObject_5 || (templateObject_5 = __makeTemplateObject(["{dim -} {white ", "} {dim ", "}"], ["{dim -} {white ", "} {dim ", "}"])), name, versionList));
41
42
  });
42
- if (groups.some(function (_a) {
43
- var hasMismatches = _a.hasMismatches;
44
- return hasMismatches;
45
- })) {
43
+ if (groups.some(function (group) { return !group.isIgnored && group.hasMismatches; })) {
46
44
  isInvalid = true;
47
45
  }
48
46
  });
@@ -51,4 +49,4 @@ function list(input, disk) {
51
49
  }
52
50
  }
53
51
  exports.list = list;
54
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
52
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -33,10 +33,7 @@ function listMismatches(input, disk) {
33
33
  */
34
34
  input.instances.versionGroups.reverse().forEach(function (versionGroup, i) {
35
35
  var isVersionGroup = i > 0;
36
- var groups = (0, list_version_groups_1.listVersionGroups)(versionGroup).filter(function (_a) {
37
- var hasMismatches = _a.hasMismatches;
38
- return hasMismatches;
39
- });
36
+ var groups = (0, list_version_groups_1.listVersionGroups)(versionGroup).filter(function (group) { return !group.isIgnored && group.hasMismatches; });
40
37
  if (groups.length > 0) {
41
38
  isInvalid = true;
42
39
  if (isVersionGroup) {
@@ -6,20 +6,22 @@ var set_semver_range_1 = require("../lib/set-semver-range");
6
6
  var write_if_changed_1 = require("../lib/write-if-changed");
7
7
  var setSemverRanges = function (input, disk) {
8
8
  input.instances.semverGroups.reverse().forEach(function (semverGroup) {
9
- var mismatches = (0, list_semver_group_mismatches_1.listSemverGroupMismatches)(semverGroup);
10
- mismatches.forEach(function (_a) {
11
- var dependencyType = _a.dependencyType, name = _a.name, version = _a.version, wrapper = _a.wrapper;
12
- if (dependencyType === 'workspace')
13
- return;
14
- var root = wrapper.contents;
15
- var nextVersion = (0, set_semver_range_1.setSemverRange)(semverGroup.range, version);
16
- if (dependencyType === 'pnpmOverrides') {
17
- root.pnpm.overrides[name] = nextVersion;
18
- }
19
- else {
20
- root[dependencyType][name] = nextVersion;
21
- }
22
- });
9
+ if ('range' in semverGroup && semverGroup.range) {
10
+ var mismatches = (0, list_semver_group_mismatches_1.listSemverGroupMismatches)(semverGroup);
11
+ mismatches.forEach(function (_a) {
12
+ var dependencyType = _a.dependencyType, name = _a.name, version = _a.version, wrapper = _a.wrapper;
13
+ if (dependencyType === 'workspace')
14
+ return;
15
+ var root = wrapper.contents;
16
+ var nextVersion = (0, set_semver_range_1.setSemverRange)(semverGroup.range, version);
17
+ if (dependencyType === 'pnpmOverrides') {
18
+ root.pnpm.overrides[name] = nextVersion;
19
+ }
20
+ else {
21
+ root[dependencyType][name] = nextVersion;
22
+ }
23
+ });
24
+ }
23
25
  });
24
26
  input.wrappers.forEach(function (wrapper) {
25
27
  (0, write_if_changed_1.writeIfChanged)(disk, {
@@ -1,119 +1,4 @@
1
- export declare type DependencyType = 'dependencies' | 'devDependencies' | 'overrides' | 'peerDependencies' | 'pnpmOverrides' | 'resolutions' | 'workspace';
2
- export declare type DependencyOption = Pick<SyncpackConfig, 'dev' | 'workspace' | 'overrides' | 'peer' | 'prod' | 'resolutions'>;
3
- export declare type ValidRange = typeof RANGE_ANY | typeof RANGE_EXACT | typeof RANGE_GT | typeof RANGE_GTE | typeof RANGE_LOOSE | typeof RANGE_LT | typeof RANGE_LTE | typeof RANGE_MINOR | typeof RANGE_PATCH;
4
- export interface SemverGroup {
5
- /**
6
- * the names of packages in your monorepo which belong to this group, taken
7
- * from the "name" field in package.json, not the package directory name
8
- */
9
- packages: string[];
10
- /**
11
- * the names of the dependencies (eg. "lodash") which belong to this group
12
- */
13
- dependencies: string[];
14
- /**
15
- * the semver range which dependencies in this group should use
16
- */
17
- range: ValidRange;
18
- /**
19
- * optionally only apply this group to dependencies of the provided types
20
- */
21
- dependencyTypes?: DependencyType[];
22
- }
23
- export interface VersionGroup {
24
- /**
25
- * the names of packages in your monorepo which belong to this group, taken
26
- * from the "name" field in package.json, not the package directory name
27
- */
28
- packages: string[];
29
- /**
30
- * the names of the dependencies (eg. "lodash") which belong to this group
31
- */
32
- dependencies: string[];
33
- /**
34
- * optionally force all dependencies in this group to be removed
35
- */
36
- isBanned?: true;
37
- /**
38
- * optionally force all dependencies in this group to have this version
39
- */
40
- pinVersion?: string;
41
- /**
42
- * optionally only apply this group to dependencies of the provided types
43
- */
44
- dependencyTypes?: DependencyType[];
45
- }
46
- export interface SyncpackConfig {
47
- /**
48
- * which dependency properties to search within
49
- */
50
- dependencyTypes: DependencyType[];
51
- /**
52
- * whether to search within devDependencies
53
- */
54
- dev: boolean;
55
- /**
56
- * a string which will be passed to `new RegExp()` to match against package
57
- * names that should be included
58
- */
59
- filter: string;
60
- /**
61
- * the character(s) to be used to indent your package.json files when writing
62
- * to disk
63
- */
64
- indent: string;
65
- /**
66
- * whether to search within npm overrides
67
- */
68
- overrides: boolean;
69
- /**
70
- * whether to search within peerDependencies
71
- */
72
- peer: boolean;
73
- /**
74
- * whether to search within pnpm overrides
75
- */
76
- pnpmOverrides: boolean;
77
- /**
78
- * whether to search within dependencies
79
- */
80
- prod: boolean;
81
- /**
82
- * whether to search within yarn resolutions
83
- */
84
- resolutions: boolean;
85
- /**
86
- *
87
- */
88
- semverGroups: SemverGroup[];
89
- /**
90
- * defaults to `""` to ensure that exact dependency versions are used instead
91
- * of loose ranges
92
- */
93
- semverRange: ValidRange;
94
- /**
95
- * which fields within package.json files should be sorted alphabetically
96
- */
97
- sortAz: string[];
98
- /**
99
- * which fields within package.json files should appear at the top, and in
100
- * what order
101
- */
102
- sortFirst: string[];
103
- /**
104
- * glob patterns for package.json file locations
105
- */
106
- source: string[];
107
- /**
108
- *
109
- */
110
- versionGroups: VersionGroup[];
111
- /**
112
- * whether to include the versions of the `--source` packages developed in
113
- * your workspace/monorepo as part of the search for versions to sync
114
- */
115
- workspace: boolean;
116
- }
1
+ import type { DependencyType, SyncpackConfig, ValidRange } from './types';
117
2
  export declare const ALL_PATTERNS: string[];
118
3
  export declare const DEPENDENCY_TYPES: DependencyType[];
119
4
  export declare const CWD: string;
@@ -1,4 +1,4 @@
1
- import type { SyncpackConfig } from '../constants';
1
+ import type { SyncpackConfig } from '../types';
2
2
  export declare type Disk = typeof disk;
3
3
  export declare const disk: {
4
4
  readonly process: {
@@ -1,4 +1,4 @@
1
- import type { SyncpackConfig } from '../../constants';
1
+ import type { SyncpackConfig } from '../../types';
2
2
  import type { Disk } from '../disk';
3
3
  /**
4
4
  * Take all configuration from the command line and config file, combine it, and
@@ -120,7 +120,7 @@ var getConfig = function (disk, program) {
120
120
  return (0, expect_more_1.isObject)(value) &&
121
121
  (0, expect_more_1.isArrayOfStrings)(value.packages) &&
122
122
  (0, expect_more_1.isArrayOfStrings)(value.dependencies) &&
123
- (0, expect_more_1.isString)(value.range);
123
+ (value.isIgnored === true || (0, expect_more_1.isString)(value.range));
124
124
  }));
125
125
  }
126
126
  function isArrayOfVersionGroups(value) {
@@ -1,4 +1,6 @@
1
- import type { DependencyType, SemverGroup, SyncpackConfig, VersionGroup } from '../../constants';
1
+ import type { DependencyType, SyncpackConfig } from '../../types';
2
+ import type { AnySemverGroup, IgnoredSemverGroup, SemverGroup } from '../../types/semver-group';
3
+ import type { AnyVersionGroup, BannedVersionGroup, IgnoredVersionGroup, PinnedVersionGroup, VersionGroup } from '../../types/version-group';
2
4
  import type { SourceWrapper } from './get-wrappers';
3
5
  export interface Instance {
4
6
  dependencyType: DependencyType;
@@ -11,11 +13,17 @@ export interface InstanceIndex {
11
13
  instancesByName: InstancesByName;
12
14
  }
13
15
  export declare type InstancesByName = Record<string, Instance[]>;
16
+ export declare type IndexedIgnoredSemverGroup = IgnoredSemverGroup & InstanceIndex;
14
17
  export declare type IndexedSemverGroup = SemverGroup & InstanceIndex;
18
+ export declare type AnyIndexedSemverGroup = AnySemverGroup & InstanceIndex;
15
19
  export declare type IndexedVersionGroup = VersionGroup & InstanceIndex;
20
+ export declare type IndexedBannedVersionGroup = BannedVersionGroup & InstanceIndex;
21
+ export declare type IndexedIgnoredVersionGroup = IgnoredVersionGroup & InstanceIndex;
22
+ export declare type IndexedPinnedVersionGroup = PinnedVersionGroup & InstanceIndex;
23
+ export declare type AnyIndexedVersionGroup = AnyVersionGroup & InstanceIndex;
16
24
  export interface Instances {
17
25
  all: Instance[];
18
- semverGroups: IndexedSemverGroup[];
19
- versionGroups: IndexedVersionGroup[];
26
+ semverGroups: AnyIndexedSemverGroup[];
27
+ versionGroups: AnyIndexedVersionGroup[];
20
28
  }
21
29
  export declare function getInstances(options: SyncpackConfig, wrappers: SourceWrapper[]): Instances;
@@ -1,6 +1,6 @@
1
1
  import * as E from 'fp-ts/lib/Either';
2
2
  import * as O from 'fp-ts/lib/Option';
3
- import type { SyncpackConfig } from '../../../constants';
3
+ import type { SyncpackConfig } from '../../../types';
4
4
  import type { Disk } from '../../../lib/disk';
5
5
  /**
6
6
  * Using --source options and/or config files on disk from npm/pnpm/yarn/lerna,
@@ -1,5 +1,5 @@
1
1
  import * as O from 'fp-ts/lib/Option';
2
- import type { SyncpackConfig } from '../../../../constants';
2
+ import type { SyncpackConfig } from '../../../../types';
3
3
  import type { Disk } from '../../../../lib/disk';
4
4
  /**
5
5
  * Find every glob pattern which should be used to find package.json files for
@@ -1,4 +1,4 @@
1
- import type { SyncpackConfig } from '../../../constants';
1
+ import type { SyncpackConfig } from '../../../types';
2
2
  import type { Disk } from '../../../lib/disk';
3
3
  export interface Source {
4
4
  bugs?: {
@@ -1,4 +1,4 @@
1
- import type { SyncpackConfig } from '../../constants';
1
+ import type { SyncpackConfig } from '../../types';
2
2
  import type { Disk } from '../../lib/disk';
3
3
  import type { Instances } from './get-instances';
4
4
  import type { SourceWrapper } from './get-wrappers';
@@ -1,4 +1,4 @@
1
- import type { ValidRange } from '../constants';
1
+ import type { ValidRange } from '../types';
2
2
  export declare function isValidSemverRange(value: unknown): value is ValidRange;
3
3
  export declare function isSemver(version: unknown): boolean;
4
4
  export declare function isLooseSemver(version: unknown): boolean;
@@ -4,7 +4,8 @@ exports.isLooseSemver = exports.isSemver = exports.isValidSemverRange = void 0;
4
4
  var expect_more_1 = require("expect-more");
5
5
  var constants_1 = require("../constants");
6
6
  function isValidSemverRange(value) {
7
- return (value === constants_1.RANGE_EXACT ||
7
+ return (value === constants_1.RANGE_ANY ||
8
+ value === constants_1.RANGE_EXACT ||
8
9
  value === constants_1.RANGE_GT ||
9
10
  value === constants_1.RANGE_GTE ||
10
11
  value === constants_1.RANGE_LOOSE ||
@@ -1,2 +1,2 @@
1
- import type { ValidRange } from '../constants';
1
+ import type { ValidRange } from '../types';
2
2
  export declare function setSemverRange(semverRange: ValidRange, version: string): string;
@@ -4,9 +4,10 @@ exports.setSemverRange = void 0;
4
4
  var constants_1 = require("../constants");
5
5
  var is_semver_1 = require("./is-semver");
6
6
  function setSemverRange(semverRange, version) {
7
- if (!(0, is_semver_1.isSemver)(version) || !(0, is_semver_1.isValidSemverRange)(semverRange)) {
7
+ if (!(0, is_semver_1.isSemver)(version) || !(0, is_semver_1.isValidSemverRange)(semverRange))
8
8
  return version;
9
- }
9
+ if (semverRange === '*')
10
+ return semverRange;
10
11
  var nextVersion = (0, is_semver_1.isLooseSemver)(version)
11
12
  ? version.replace(/\.x/g, '.0')
12
13
  : version;
@@ -0,0 +1,77 @@
1
+ import type { RANGE_ANY, RANGE_EXACT, RANGE_GT, RANGE_GTE, RANGE_LOOSE, RANGE_LT, RANGE_LTE, RANGE_MINOR, RANGE_PATCH } from '../constants';
2
+ import type { AnySemverGroup } from './semver-group';
3
+ import type { AnyVersionGroup } from './version-group';
4
+ export declare type DependencyType = 'dependencies' | 'devDependencies' | 'overrides' | 'peerDependencies' | 'pnpmOverrides' | 'resolutions' | 'workspace';
5
+ export declare type DependencyOption = Pick<SyncpackConfig, 'dev' | 'workspace' | 'overrides' | 'peer' | 'prod' | 'resolutions'>;
6
+ export declare type ValidRange = typeof RANGE_ANY | typeof RANGE_EXACT | typeof RANGE_GT | typeof RANGE_GTE | typeof RANGE_LOOSE | typeof RANGE_LT | typeof RANGE_LTE | typeof RANGE_MINOR | typeof RANGE_PATCH;
7
+ export interface SyncpackConfig {
8
+ /**
9
+ * which dependency properties to search within
10
+ */
11
+ dependencyTypes: DependencyType[];
12
+ /**
13
+ * whether to search within devDependencies
14
+ */
15
+ dev: boolean;
16
+ /**
17
+ * a string which will be passed to `new RegExp()` to match against package
18
+ * names that should be included
19
+ */
20
+ filter: string;
21
+ /**
22
+ * the character(s) to be used to indent your package.json files when writing
23
+ * to disk
24
+ */
25
+ indent: string;
26
+ /**
27
+ * whether to search within npm overrides
28
+ */
29
+ overrides: boolean;
30
+ /**
31
+ * whether to search within peerDependencies
32
+ */
33
+ peer: boolean;
34
+ /**
35
+ * whether to search within pnpm overrides
36
+ */
37
+ pnpmOverrides: boolean;
38
+ /**
39
+ * whether to search within dependencies
40
+ */
41
+ prod: boolean;
42
+ /**
43
+ * whether to search within yarn resolutions
44
+ */
45
+ resolutions: boolean;
46
+ /**
47
+ *
48
+ */
49
+ semverGroups: AnySemverGroup[];
50
+ /**
51
+ * defaults to `""` to ensure that exact dependency versions are used instead
52
+ * of loose ranges
53
+ */
54
+ semverRange: ValidRange;
55
+ /**
56
+ * which fields within package.json files should be sorted alphabetically
57
+ */
58
+ sortAz: string[];
59
+ /**
60
+ * which fields within package.json files should appear at the top, and in
61
+ * what order
62
+ */
63
+ sortFirst: string[];
64
+ /**
65
+ * glob patterns for package.json file locations
66
+ */
67
+ source: string[];
68
+ /**
69
+ *
70
+ */
71
+ versionGroups: AnyVersionGroup[];
72
+ /**
73
+ * whether to include the versions of the `--source` packages developed in
74
+ * your workspace/monorepo as part of the search for versions to sync
75
+ */
76
+ workspace: boolean;
77
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ exports.__esModule = true;
@@ -0,0 +1,30 @@
1
+ import type { ValidRange, DependencyType } from '.';
2
+ export declare type AnySemverGroup = IgnoredSemverGroup | SemverGroup;
3
+ export interface IgnoredSemverGroup extends Base {
4
+ /**
5
+ * optionally force syncpack to ignore all dependencies in this group
6
+ */
7
+ isIgnored: true;
8
+ }
9
+ export interface SemverGroup extends Base {
10
+ /**
11
+ * the semver range which dependencies in this group should use
12
+ */
13
+ range: ValidRange;
14
+ }
15
+ interface Base {
16
+ /**
17
+ * the names of packages in your monorepo which belong to this group, taken
18
+ * from the "name" field in package.json, not the package directory name
19
+ */
20
+ packages: string[];
21
+ /**
22
+ * the names of the dependencies (eg. "lodash") which belong to this group
23
+ */
24
+ dependencies: string[];
25
+ /**
26
+ * optionally only apply this group to dependencies of the provided types
27
+ */
28
+ dependencyTypes?: DependencyType[];
29
+ }
30
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ exports.__esModule = true;
@@ -0,0 +1,35 @@
1
+ import type { DependencyType } from '.';
2
+ export declare type AnyVersionGroup = VersionGroup | BannedVersionGroup | IgnoredVersionGroup | PinnedVersionGroup;
3
+ export interface VersionGroup {
4
+ /**
5
+ * the names of packages in your monorepo which belong to this group, taken
6
+ * from the "name" field in package.json, not the package directory name
7
+ */
8
+ packages: string[];
9
+ /**
10
+ * the names of the dependencies (eg. "lodash") which belong to this group
11
+ */
12
+ dependencies: string[];
13
+ /**
14
+ * optionally only apply this group to dependencies of the provided types
15
+ */
16
+ dependencyTypes?: DependencyType[];
17
+ }
18
+ export interface BannedVersionGroup extends VersionGroup {
19
+ /**
20
+ * optionally force all dependencies in this group to be removed
21
+ */
22
+ isBanned: true;
23
+ }
24
+ export interface IgnoredVersionGroup extends VersionGroup {
25
+ /**
26
+ * optionally force syncpack to ignore all dependencies in this group
27
+ */
28
+ isIgnored?: true;
29
+ }
30
+ export interface PinnedVersionGroup extends VersionGroup {
31
+ /**
32
+ * optionally force all dependencies in this group to have this version
33
+ */
34
+ pinVersion?: string;
35
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ exports.__esModule = true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "syncpack",
3
3
  "description": "Manage multiple package.json files, such as in Lerna Monorepos and Yarn/Pnpm Workspaces",
4
- "version": "8.3.8",
4
+ "version": "8.4.10",
5
5
  "author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",
6
6
  "bin": {
7
7
  "syncpack": "dist/bin.js",