syncpack 8.5.14 → 9.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.
Files changed (150) hide show
  1. package/README.md +194 -108
  2. package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +2 -2
  3. package/dist/bin-fix-mismatches/fix-mismatches-cli.js +1 -1
  4. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -2
  5. package/dist/bin-fix-mismatches/fix-mismatches.js +35 -8
  6. package/dist/bin-fix-mismatches/index.js +9 -18
  7. package/dist/bin-format/format-cli.d.ts +2 -2
  8. package/dist/bin-format/format-cli.js +1 -1
  9. package/dist/bin-format/format.d.ts +2 -2
  10. package/dist/bin-format/index.js +2 -0
  11. package/dist/bin-lint-semver-ranges/index.js +10 -19
  12. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.d.ts +2 -2
  13. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +1 -1
  14. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -2
  15. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +13 -14
  16. package/dist/bin-list/index.js +9 -18
  17. package/dist/bin-list/list-cli.d.ts +2 -2
  18. package/dist/bin-list/list-cli.js +1 -1
  19. package/dist/bin-list/list.d.ts +2 -2
  20. package/dist/bin-list/list.js +2 -2
  21. package/dist/bin-list-mismatches/index.js +9 -18
  22. package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +2 -2
  23. package/dist/bin-list-mismatches/list-mismatches-cli.js +1 -1
  24. package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -2
  25. package/dist/bin-list-mismatches/list-mismatches.js +6 -6
  26. package/dist/bin-set-semver-ranges/index.js +10 -19
  27. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +2 -2
  28. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +1 -1
  29. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -2
  30. package/dist/constants.d.ts +11 -7
  31. package/dist/constants.js +11 -22
  32. package/dist/get-context/$R.d.ts +13 -0
  33. package/dist/get-context/$R.js +56 -0
  34. package/dist/{lib/get-context → get-context}/get-all-instances.d.ts +0 -0
  35. package/dist/{lib/get-context → get-context}/get-all-instances.js +1 -1
  36. package/dist/get-context/get-config/get-core-types.d.ts +36 -0
  37. package/dist/get-context/get-config/get-core-types.js +68 -0
  38. package/dist/get-context/get-config/get-custom-types.d.ts +4 -0
  39. package/dist/get-context/get-config/get-custom-types.js +28 -0
  40. package/dist/get-context/get-config/get-enabled-types.d.ts +4 -0
  41. package/dist/get-context/get-config/get-enabled-types.js +19 -0
  42. package/dist/get-context/get-config/index.d.ts +7 -0
  43. package/dist/get-context/get-config/index.js +115 -0
  44. package/dist/get-context/get-config/path-strategy/index.d.ts +8 -0
  45. package/dist/get-context/get-config/path-strategy/index.js +18 -0
  46. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.d.ts +4 -0
  47. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.js +11 -0
  48. package/dist/get-context/get-config/path-strategy/name-and-version-props.d.ts +2 -0
  49. package/dist/get-context/get-config/path-strategy/name-and-version-props.js +66 -0
  50. package/dist/get-context/get-config/path-strategy/name-and-version-string.d.ts +2 -0
  51. package/dist/get-context/get-config/path-strategy/name-and-version-string.js +60 -0
  52. package/dist/get-context/get-config/path-strategy/types.d.ts +15 -0
  53. package/dist/{lib/get-context/get-config/config.js → get-context/get-config/path-strategy/types.js} +0 -0
  54. package/dist/get-context/get-config/path-strategy/version-string.d.ts +2 -0
  55. package/dist/get-context/get-config/path-strategy/version-string.js +60 -0
  56. package/dist/get-context/get-config/path-strategy/versions-by-name.d.ts +2 -0
  57. package/dist/get-context/get-config/path-strategy/versions-by-name.js +39 -0
  58. package/dist/get-context/get-config/schema/base-group.d.ts +6 -0
  59. package/dist/get-context/get-config/schema/base-group.js +9 -0
  60. package/dist/get-context/get-config/schema/index.d.ts +1276 -0
  61. package/dist/get-context/get-config/schema/index.js +104 -0
  62. package/dist/get-context/get-config/schema/paths.d.ts +89 -0
  63. package/dist/get-context/get-config/schema/paths.js +33 -0
  64. package/dist/get-context/get-config/schema/semver-group.d.ts +101 -0
  65. package/dist/get-context/get-config/schema/semver-group.js +50 -0
  66. package/dist/get-context/get-config/schema/semver-range.d.ts +2 -0
  67. package/dist/get-context/get-config/schema/semver-range.js +16 -0
  68. package/dist/get-context/get-config/schema/version-group.d.ts +151 -0
  69. package/dist/get-context/get-config/schema/version-group.js +31 -0
  70. package/dist/get-context/get-groups/get-semver-groups.d.ts +4 -0
  71. package/dist/{lib/get-context → get-context}/get-groups/get-semver-groups.js +2 -1
  72. package/dist/get-context/get-groups/get-version-groups.d.ts +4 -0
  73. package/dist/{lib/get-context → get-context}/get-groups/get-version-groups.js +2 -1
  74. package/dist/{lib/get-context → get-context}/get-groups/semver-group/index.d.ts +10 -11
  75. package/dist/get-context/get-groups/semver-group/index.js +56 -0
  76. package/dist/{lib/get-context → get-context}/get-groups/version-group/index.d.ts +5 -6
  77. package/dist/{lib/get-context → get-context}/get-groups/version-group/index.js +0 -0
  78. package/dist/{lib/get-context → get-context}/get-groups/version-group/instance-group/get-highest-version.d.ts +0 -0
  79. package/dist/{lib/get-context → get-context}/get-groups/version-group/instance-group/get-highest-version.js +2 -2
  80. package/dist/{lib/get-context → get-context}/get-groups/version-group/instance-group/index.d.ts +3 -1
  81. package/dist/{lib/get-context → get-context}/get-groups/version-group/instance-group/index.js +10 -9
  82. package/dist/get-context/get-package-json-files/get-file-paths.d.ts +14 -0
  83. package/dist/get-context/get-package-json-files/get-file-paths.js +40 -0
  84. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +4 -0
  85. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +19 -0
  86. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +4 -0
  87. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +23 -0
  88. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +4 -0
  89. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +20 -0
  90. package/dist/get-context/get-package-json-files/get-patterns/index.d.ts +11 -0
  91. package/dist/get-context/get-package-json-files/get-patterns/index.js +70 -0
  92. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.d.ts +1 -0
  93. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.js +10 -0
  94. package/dist/get-context/get-package-json-files/get-patterns/props.d.ts +6 -0
  95. package/dist/get-context/get-package-json-files/get-patterns/props.js +48 -0
  96. package/dist/{lib/get-context → get-context}/get-package-json-files/get-patterns/read-json-safe.d.ts +4 -3
  97. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.js +20 -0
  98. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.d.ts +4 -0
  99. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +11 -0
  100. package/dist/get-context/get-package-json-files/index.d.ts +5 -0
  101. package/dist/get-context/get-package-json-files/index.js +16 -0
  102. package/dist/{lib/get-context → get-context}/get-package-json-files/package-json-file/index.d.ts +7 -6
  103. package/dist/{lib/get-context → get-context}/get-package-json-files/package-json-file/index.js +28 -38
  104. package/dist/{lib/get-context → get-context}/get-package-json-files/package-json-file/instance.d.ts +6 -6
  105. package/dist/get-context/get-package-json-files/package-json-file/instance.js +62 -0
  106. package/dist/{lib/get-context → get-context}/index.d.ts +4 -5
  107. package/dist/{lib/get-context → get-context}/index.js +1 -1
  108. package/dist/lib/disk.d.ts +11 -11
  109. package/dist/lib/error.d.ts +12 -0
  110. package/dist/lib/error.js +43 -0
  111. package/dist/lib/exit-if-invalid.d.ts +2 -2
  112. package/dist/lib/is-semver.d.ts +2 -2
  113. package/dist/lib/set-semver-range.d.ts +2 -2
  114. package/dist/lib/show-help-on-error.d.ts +2 -0
  115. package/dist/lib/show-help-on-error.js +16 -0
  116. package/dist/lib/write-if-changed.d.ts +2 -2
  117. package/dist/option.d.ts +4 -10
  118. package/dist/option.js +6 -16
  119. package/dist/types.d.ts +88 -0
  120. package/dist/{lib/get-context/get-config/internal-config.js → types.js} +0 -0
  121. package/package.json +4 -3
  122. package/dist/lib/get-context/get-config/config.d.ts +0 -151
  123. package/dist/lib/get-context/get-config/index.d.ts +0 -8
  124. package/dist/lib/get-context/get-config/index.js +0 -160
  125. package/dist/lib/get-context/get-config/internal-config.d.ts +0 -24
  126. package/dist/lib/get-context/get-groups/get-semver-groups.d.ts +0 -4
  127. package/dist/lib/get-context/get-groups/get-version-groups.d.ts +0 -4
  128. package/dist/lib/get-context/get-groups/semver-group/index.js +0 -33
  129. package/dist/lib/get-context/get-package-json-files/get-file-paths.d.ts +0 -12
  130. package/dist/lib/get-context/get-package-json-files/get-file-paths.js +0 -55
  131. package/dist/lib/get-context/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +0 -3
  132. package/dist/lib/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +0 -40
  133. package/dist/lib/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +0 -3
  134. package/dist/lib/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +0 -45
  135. package/dist/lib/get-context/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +0 -3
  136. package/dist/lib/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +0 -46
  137. package/dist/lib/get-context/get-package-json-files/get-patterns/index.d.ts +0 -10
  138. package/dist/lib/get-context/get-package-json-files/get-patterns/index.js +0 -79
  139. package/dist/lib/get-context/get-package-json-files/get-patterns/props.d.ts +0 -7
  140. package/dist/lib/get-context/get-package-json-files/get-patterns/props.js +0 -43
  141. package/dist/lib/get-context/get-package-json-files/get-patterns/read-json-safe.js +0 -41
  142. package/dist/lib/get-context/get-package-json-files/get-patterns/read-yaml-safe.d.ts +0 -3
  143. package/dist/lib/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +0 -34
  144. package/dist/lib/get-context/get-package-json-files/index.d.ts +0 -5
  145. package/dist/lib/get-context/get-package-json-files/index.js +0 -40
  146. package/dist/lib/get-context/get-package-json-files/package-json-file/instance.js +0 -46
  147. package/dist/lib/get-context/get-package-json-files/tap.d.ts +0 -15
  148. package/dist/lib/get-context/get-package-json-files/tap.js +0 -56
  149. package/dist/lib/get-context/get-package-json-files/try-catch.d.ts +0 -5
  150. package/dist/lib/get-context/get-package-json-files/try-catch.js +0 -13
@@ -1,151 +0,0 @@
1
- import type { ALL_DEPENDENCY_TYPES, RANGE } from '../../../constants';
2
- /** Aliases for locations within package.json files where versions can be found */
3
- export type DependencyType = (typeof ALL_DEPENDENCY_TYPES)[number];
4
- /** Aliases for semver range formats supported by syncpack */
5
- export type ValidRange = (typeof RANGE)[keyof typeof RANGE];
6
- export declare namespace Config {
7
- export namespace SemverGroup {
8
- /** All valid forms of Semver Group */
9
- export type Any = Ignored | WithRange;
10
- export interface Ignored extends Base {
11
- /** Optionally force syncpack to ignore all dependencies in this group */
12
- isIgnored: true;
13
- }
14
- export interface WithRange extends Base {
15
- /** The semver range which dependencies in this group should use */
16
- range: ValidRange;
17
- }
18
- interface Base {
19
- /**
20
- * The names of packages in your monorepo which belong to this group, taken
21
- * from the "name" field in package.json, not the package directory name
22
- */
23
- packages: string[];
24
- /** Dependency names (eg. "lodash") which belong to this group */
25
- dependencies: string[];
26
- /** Optionally limit this group to dependencies of the provided types */
27
- dependencyTypes?: DependencyType[];
28
- }
29
- export {};
30
- }
31
- export namespace VersionGroup {
32
- /** All valid forms of Version Group */
33
- type Any = Standard | Banned | Ignored | Pinned;
34
- interface Standard {
35
- /**
36
- * The names of packages in your monorepo which belong to this group, taken
37
- * from the "name" field in package.json, not the package directory name
38
- */
39
- packages: string[];
40
- /** Dependency names (eg. "lodash") which belong to this group */
41
- dependencies: string[];
42
- /** Optionally limit this group to dependencies of the provided types */
43
- dependencyTypes?: DependencyType[];
44
- }
45
- interface Banned extends Standard {
46
- /** Optionally force all dependencies in this group to be removed */
47
- isBanned: true;
48
- }
49
- interface Ignored extends Standard {
50
- /** Optionally force syncpack to ignore all dependencies in this group */
51
- isIgnored?: true;
52
- }
53
- interface Pinned extends Standard {
54
- /** Optionally force all dependencies in this group to have this version */
55
- pinVersion?: string;
56
- }
57
- }
58
- /** All valid config which can only be provided via .syncpackrc */
59
- interface RcFileOnly {
60
- /**
61
- * When using the `format` command, determines which fields within
62
- * package.json files should be sorted alphabetically. When the value is an
63
- * Object, its keys are sorted alphabetically. When the value is an Array, its
64
- * values are sorted alphabetically. There is no equivalent CLI Option for
65
- * this configuration.
66
- */
67
- sortAz: string[];
68
- /**
69
- * When using the `format` command, determines which fields within package.json
70
- * files should appear at the top, and in what order. There is no equivalent
71
- * CLI Option for this configuration.
72
- */
73
- sortFirst: string[];
74
- /** */
75
- versionGroups: VersionGroup.Any[];
76
- /** */
77
- semverGroups: SemverGroup.Any[];
78
- }
79
- /** All valid config which can only be provided via the CLI */
80
- interface CliOnly {
81
- /** Absolute or relative path to a .syncpackrc */
82
- configPath: string;
83
- }
84
- /** All valid config which can be provided via the CLI or .syncpackrc */
85
- export interface CliAndRcFile {
86
- /** Whether to search within `devDependencies` */
87
- dev: boolean;
88
- /** Whether to search within npm `overrides` */
89
- overrides: boolean;
90
- /** Whether to search within `peerDependencies` */
91
- peer: boolean;
92
- /** Whether to search within `pnpm.overrides` */
93
- pnpmOverrides: boolean;
94
- /** Whether to search within `dependencies` */
95
- prod: boolean;
96
- /** Whether to search within yarn `resolutions` */
97
- resolutions: boolean;
98
- /**
99
- * Whether to include the versions of the `--source` packages developed in
100
- * your workspace/monorepo as part of the search for versions to sync
101
- */
102
- workspace: boolean;
103
- /**
104
- * A string which will be passed to `new RegExp()` to match against package
105
- * names that should be included.
106
- *
107
- * > ⚠️ `filter` was originally intended as a convenience to be used from the
108
- * > command line to filter the output of `syncpack list`, it is not recommended
109
- * > to add this to your config file to manage your project more generally.
110
- * >
111
- * > Instead use `versionGroups` and/or `semverGroups`.
112
- *
113
- */
114
- filter: string;
115
- /**
116
- * The character(s) to be used to indent your package.json files when writing
117
- * to disk
118
- */
119
- indent: string;
120
- /**
121
- * Defaulted to `""` to ensure that exact dependency versions are used instead
122
- * of loose ranges, but this can be overridden in your config file or via the
123
- * `--semver-range` command line option.
124
- *
125
- * | Supported Range | Example |
126
- * | --------------- | --------: |
127
- * | `"<"` | `<1.4.2` |
128
- * | `"<="` | `<=1.4.2` |
129
- * | `""` | `1.4.2` |
130
- * | `"~"` | `~1.4.2` |
131
- * | `"^"` | `^1.4.2` |
132
- * | `">="` | `>=1.4.2` |
133
- * | `">"` | `>1.4.2` |
134
- * | `"*"` | `*` |
135
- */
136
- semverRange: ValidRange;
137
- /**
138
- * Defaults to `["package.json", "packages/\*\/package.json"]` to match most
139
- * Projects using Lerna or Yarn Workspaces, but this can be overridden in your
140
- * config file or via multiple `--source` command line options.
141
- *
142
- * Supports any patterns supported by https://github.com/isaacs/node-glob
143
- */
144
- source: string[];
145
- }
146
- /** All valid config in .syncpackrc */
147
- export type RcFile = RcFileOnly & CliAndRcFile;
148
- /** All valid config recognised by Syncpack */
149
- export type All = CliOnly & RcFile;
150
- export {};
151
- }
@@ -1,8 +0,0 @@
1
- import type { Disk } from '../../disk';
2
- import type { Config } from './config';
3
- import type { InternalConfig } from './internal-config';
4
- /**
5
- * Take all configuration from the command line and config file, combine it, and
6
- * set defaults for anything which hasn't been defined.
7
- */
8
- export declare const getConfig: (disk: Disk, program: Partial<Config.All>) => InternalConfig;
@@ -1,160 +0,0 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
- if (ar || !(i in from)) {
21
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
- ar[i] = from[i];
23
- }
24
- }
25
- return to.concat(ar || Array.prototype.slice.call(from));
26
- };
27
- exports.__esModule = true;
28
- exports.getConfig = void 0;
29
- var expect_more_1 = require("expect-more");
30
- var constants_1 = require("../../../constants");
31
- var is_semver_1 = require("../../is-semver");
32
- var log_1 = require("../../log");
33
- /**
34
- * Take all configuration from the command line and config file, combine it, and
35
- * set defaults for anything which hasn't been defined.
36
- */
37
- var getConfig = function (disk, program) {
38
- (0, log_1.verbose)('cli arguments:', program);
39
- var rcFile = disk.readConfigFileSync(program.configPath);
40
- var hasTypeOverride = (0, expect_more_1.isBoolean)(program.dev) ||
41
- (0, expect_more_1.isBoolean)(program.overrides) ||
42
- (0, expect_more_1.isBoolean)(program.peer) ||
43
- (0, expect_more_1.isBoolean)(program.pnpmOverrides) ||
44
- (0, expect_more_1.isBoolean)(program.prod) ||
45
- (0, expect_more_1.isBoolean)(program.resolutions) ||
46
- (0, expect_more_1.isBoolean)(program.workspace);
47
- var dev = hasTypeOverride
48
- ? Boolean(program.dev)
49
- : getOption('dev', expect_more_1.isBoolean);
50
- var overrides = hasTypeOverride
51
- ? Boolean(program.overrides)
52
- : getOption('overrides', expect_more_1.isBoolean);
53
- var peer = hasTypeOverride
54
- ? Boolean(program.peer)
55
- : getOption('peer', expect_more_1.isBoolean);
56
- var pnpmOverrides = hasTypeOverride
57
- ? Boolean(program.pnpmOverrides)
58
- : getOption('pnpmOverrides', expect_more_1.isBoolean);
59
- var prod = hasTypeOverride
60
- ? Boolean(program.prod)
61
- : getOption('prod', expect_more_1.isBoolean);
62
- var resolutions = hasTypeOverride
63
- ? Boolean(program.resolutions)
64
- : getOption('resolutions', expect_more_1.isBoolean);
65
- var workspace = hasTypeOverride
66
- ? Boolean(program.workspace)
67
- : getOption('workspace', expect_more_1.isBoolean);
68
- var dependencyTypes = dev ||
69
- overrides ||
70
- peer ||
71
- pnpmOverrides ||
72
- prod ||
73
- resolutions ||
74
- workspace
75
- ? constants_1.ALL_DEPENDENCY_TYPES.filter(function (type) {
76
- return (type === 'devDependencies' && dev) ||
77
- (type === 'overrides' && overrides) ||
78
- (type === 'peerDependencies' && peer) ||
79
- (type === 'pnpmOverrides' && pnpmOverrides) ||
80
- (type === 'dependencies' && prod) ||
81
- (type === 'resolutions' && resolutions) ||
82
- (type === 'workspace' && workspace);
83
- })
84
- : __spreadArray([], __read(constants_1.ALL_DEPENDENCY_TYPES), false);
85
- var filter = getOption('filter', expect_more_1.isNonEmptyString);
86
- var indent = getOption('indent', expect_more_1.isNonEmptyString);
87
- var semverRange = getOption('semverRange', is_semver_1.isValidSemverRange);
88
- var sortAz = getOption('sortAz', expect_more_1.isArrayOfStrings);
89
- var sortFirst = getOption('sortFirst', expect_more_1.isArrayOfStrings);
90
- var source = getOption('source', expect_more_1.isArrayOfStrings);
91
- /**
92
- * Every instance must belong to a semver group, even if that semver group is
93
- * this one which represents a default, no special treatment group.
94
- */
95
- var defaultSemverGroup = {
96
- range: semverRange,
97
- dependencies: ['**'],
98
- packages: ['**']
99
- };
100
- var semverGroups = getOption('semverGroups', isArrayOfSemverGroups).concat(defaultSemverGroup);
101
- /**
102
- * Every instance must belong to a semver group, even if that semver group is
103
- * this one which represents a default, no special treatment group.
104
- */
105
- var defaultVersionGroup = {
106
- packages: ['**'],
107
- dependencies: ['**']
108
- };
109
- var versionGroups = getOption('versionGroups', isArrayOfVersionGroups).concat(defaultVersionGroup);
110
- var finalConfig = {
111
- dev: dev,
112
- filter: filter,
113
- indent: indent,
114
- workspace: workspace,
115
- overrides: overrides,
116
- peer: peer,
117
- pnpmOverrides: pnpmOverrides,
118
- prod: prod,
119
- resolutions: resolutions,
120
- semverGroups: semverGroups,
121
- semverRange: semverRange,
122
- sortAz: sortAz,
123
- sortFirst: sortFirst,
124
- source: source,
125
- versionGroups: versionGroups,
126
- // The following are internal additions not exposed in public config
127
- defaultSemverGroup: defaultSemverGroup,
128
- defaultVersionGroup: defaultVersionGroup,
129
- dependencyTypes: dependencyTypes
130
- };
131
- (0, log_1.verbose)('final config:', finalConfig);
132
- return finalConfig;
133
- function getOption(name, isValid) {
134
- var cliOption = program[name];
135
- if (isValid(cliOption))
136
- return cliOption;
137
- var configOption = rcFile[name];
138
- if (isValid(configOption))
139
- return configOption;
140
- return constants_1.DEFAULT_CONFIG[name];
141
- }
142
- function isArrayOfSemverGroups(value) {
143
- return ((0, expect_more_1.isArray)(value) &&
144
- value.every(function (value) {
145
- return (0, expect_more_1.isObject)(value) &&
146
- (0, expect_more_1.isArrayOfStrings)(value.packages) &&
147
- (0, expect_more_1.isArrayOfStrings)(value.dependencies) &&
148
- (value.isIgnored === true || (0, expect_more_1.isString)(value.range));
149
- }));
150
- }
151
- function isArrayOfVersionGroups(value) {
152
- return ((0, expect_more_1.isArray)(value) &&
153
- value.every(function (value) {
154
- return (0, expect_more_1.isObject)(value) &&
155
- (0, expect_more_1.isArrayOfStrings)(value.packages) &&
156
- (0, expect_more_1.isArrayOfStrings)(value.dependencies);
157
- }));
158
- }
159
- };
160
- exports.getConfig = getConfig;
@@ -1,24 +0,0 @@
1
- import type { Config, DependencyType } from './config';
2
- export interface InternalConfig extends Config.RcFile {
3
- /**
4
- * The standard/catch-all semver group.
5
- *
6
- * + When no semver groups are defined, this will be the only group.
7
- * + Otherwise this group will appear last, to be used when none of the user's
8
- * groups found a match.
9
- */
10
- defaultSemverGroup: Config.SemverGroup.WithRange;
11
- /**
12
- * The standard/catch-all version group.
13
- *
14
- * + When no version groups are defined, this will be the only group.
15
- * + Otherwise this group will appear last, to be used when none of the user's
16
- * groups found a match.
17
- */
18
- defaultVersionGroup: Config.VersionGroup.Standard;
19
- /**
20
- * Aliases for locations of versions within package.json files, it is looped
21
- * over by each command to operate on each are as defined by the user.
22
- */
23
- dependencyTypes: DependencyType[];
24
- }
@@ -1,4 +0,0 @@
1
- import type { InternalConfig } from '../get-config/internal-config';
2
- import type { Instance } from '../get-package-json-files/package-json-file/instance';
3
- import { SemverGroup } from './semver-group';
4
- export declare function getSemverGroups(input: InternalConfig, instances: Instance[]): SemverGroup[];
@@ -1,4 +0,0 @@
1
- import type { InternalConfig } from '../get-config/internal-config';
2
- import type { Instance } from '../get-package-json-files/package-json-file/instance';
3
- import { VersionGroup } from './version-group';
4
- export declare function getVersionGroups(input: InternalConfig, instances: Instance[]): VersionGroup[];
@@ -1,33 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.SemverGroup = void 0;
4
- var SemverGroup = /** @class */ (function () {
5
- function SemverGroup(input, semverGroup) {
6
- this.dependencies = semverGroup.dependencies;
7
- this.input = input;
8
- this.instances = [];
9
- this.instancesByName = {};
10
- this.isDefault = semverGroup === input.defaultSemverGroup;
11
- this.isIgnored = semverGroup.isIgnored === true;
12
- this.packages = semverGroup.packages;
13
- this.range = semverGroup.range;
14
- }
15
- /** Syncpack must report or fix this group's mismatches */
16
- SemverGroup.prototype.isInvalid = function () {
17
- return !this.isIgnored && this.hasInvalidInstances();
18
- };
19
- /** 1+ `Instance` has a version which does not follow the rules */
20
- SemverGroup.prototype.hasInvalidInstances = function () {
21
- return this.getInvalidInstances().length > 0;
22
- };
23
- /** Get every `Instance` with a version which does not follow the rules */
24
- SemverGroup.prototype.getInvalidInstances = function () {
25
- var _this = this;
26
- return this.instances.filter(function (instance) {
27
- return instance.dependencyType !== 'workspace' &&
28
- !instance.hasRange(_this.range);
29
- });
30
- };
31
- return SemverGroup;
32
- }());
33
- exports.SemverGroup = SemverGroup;
@@ -1,12 +0,0 @@
1
- import * as E from 'fp-ts/lib/Either';
2
- import * as O from 'fp-ts/lib/Option';
3
- import type { Disk } from '../../disk';
4
- import type { Config } from '../get-config/config';
5
- /**
6
- * Using --source options and/or config files on disk from npm/pnpm/yarn/lerna,
7
- * return an array of absolute paths to every package.json file the user is
8
- * working with.
9
- *
10
- * @returns Array of absolute file paths to package.json files
11
- */
12
- export declare function getFilePaths(disk: Disk, program: Config.RcFile): E.Either<Error, O.Option<string[]>>;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- exports.__esModule = true;
26
- exports.getFilePaths = void 0;
27
- var expect_more_1 = require("expect-more");
28
- var A = __importStar(require("fp-ts/lib/Array"));
29
- var E = __importStar(require("fp-ts/lib/Either"));
30
- var function_1 = require("fp-ts/lib/function");
31
- var O = __importStar(require("fp-ts/lib/Option"));
32
- var S = __importStar(require("fp-ts/lib/string"));
33
- var get_patterns_1 = require("./get-patterns");
34
- var tap_1 = require("./tap");
35
- var try_catch_1 = require("./try-catch");
36
- /**
37
- * Using --source options and/or config files on disk from npm/pnpm/yarn/lerna,
38
- * return an array of absolute paths to every package.json file the user is
39
- * working with.
40
- *
41
- * @returns Array of absolute file paths to package.json files
42
- */
43
- function getFilePaths(disk, program) {
44
- return (0, function_1.pipe)(program, (0, get_patterns_1.getPatterns)(disk), O.getOrElse(function () { return []; }), E.traverseArray(resolvePattern), E.map(removeReadonlyType), E.map((0, function_1.flow)(A.flatten, A.uniq(S.Eq))), E.map(O.fromPredicate(expect_more_1.isArrayOfStrings)), E.map((0, tap_1.tapOption)('package.json files found')));
45
- function resolvePattern(pattern) {
46
- return (0, function_1.pipe)(E.tryCatch(function () { return disk.globSync(pattern); }, (0, try_catch_1.getErrorOrElse)("npm package \"glob\" threw on pattern \"".concat(pattern, "\""))), E.map((0, function_1.flow)(O.fromPredicate(expect_more_1.isArrayOfStrings), (0, tap_1.tapOption)("files found matching pattern \"".concat(pattern, "\"")), O.getOrElse(function () { return []; }))));
47
- }
48
- }
49
- exports.getFilePaths = getFilePaths;
50
- /**
51
- * Remove unwanted readonly type added by TaskEither.traverseArray
52
- */
53
- function removeReadonlyType(value) {
54
- return value;
55
- }
@@ -1,3 +0,0 @@
1
- import * as O from 'fp-ts/lib/Option';
2
- import type { Disk } from '../../../disk';
3
- export declare function getLernaPatterns(disk: Disk): () => O.Option<string[]>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- exports.__esModule = true;
26
- exports.getLernaPatterns = void 0;
27
- var expect_more_1 = require("expect-more");
28
- var E = __importStar(require("fp-ts/lib/Either"));
29
- var function_1 = require("fp-ts/lib/function");
30
- var O = __importStar(require("fp-ts/lib/Option"));
31
- var path_1 = require("path");
32
- var constants_1 = require("../../../../constants");
33
- var props_1 = require("./props");
34
- var read_json_safe_1 = require("./read-json-safe");
35
- function getLernaPatterns(disk) {
36
- return function () {
37
- return (0, function_1.pipe)((0, read_json_safe_1.readJsonSafe)(disk)((0, path_1.join)(constants_1.CWD, 'lerna.json')), E.map((0, function_1.flow)((0, props_1.props)('contents.packages'), O.filter(expect_more_1.isArrayOfStrings))), E.match(function () { return O.none; }, function (value) { return value; }));
38
- };
39
- }
40
- exports.getLernaPatterns = getLernaPatterns;
@@ -1,3 +0,0 @@
1
- import * as O from 'fp-ts/lib/Option';
2
- import type { Disk } from '../../../disk';
3
- export declare function getPnpmPatterns(disk: Disk): () => O.Option<string[]>;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- exports.__esModule = true;
26
- exports.getPnpmPatterns = void 0;
27
- var expect_more_1 = require("expect-more");
28
- var E = __importStar(require("fp-ts/lib/Either"));
29
- var function_1 = require("fp-ts/lib/function");
30
- var O = __importStar(require("fp-ts/lib/Option"));
31
- var path_1 = require("path");
32
- var constants_1 = require("../../../../constants");
33
- var props_1 = require("./props");
34
- var read_yaml_safe_1 = require("./read-yaml-safe");
35
- function getPnpmPatterns(disk) {
36
- return function () {
37
- return (0, function_1.pipe)(
38
- // packages:
39
- // - "packages/**"
40
- // - "components/**"
41
- // - "!**/test/**"
42
- (0, read_yaml_safe_1.readYamlSafe)(disk)((0, path_1.join)(constants_1.CWD, 'pnpm-workspace.yaml')), E.map((0, function_1.flow)((0, props_1.props)('packages'), O.filter(expect_more_1.isArrayOfStrings))), E.match(function () { return O.none; }, function (value) { return value; }));
43
- };
44
- }
45
- exports.getPnpmPatterns = getPnpmPatterns;
@@ -1,3 +0,0 @@
1
- import * as O from 'fp-ts/lib/Option';
2
- import type { Disk } from '../../../disk';
3
- export declare function getYarnPatterns(disk: Disk): () => O.Option<string[]>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- exports.__esModule = true;
26
- exports.getYarnPatterns = void 0;
27
- var expect_more_1 = require("expect-more");
28
- var E = __importStar(require("fp-ts/lib/Either"));
29
- var function_1 = require("fp-ts/lib/function");
30
- var O = __importStar(require("fp-ts/lib/Option"));
31
- var path_1 = require("path");
32
- var constants_1 = require("../../../../constants");
33
- var props_1 = require("./props");
34
- var read_json_safe_1 = require("./read-json-safe");
35
- function getYarnPatterns(disk) {
36
- return function () {
37
- return (0, function_1.pipe)((0, read_json_safe_1.readJsonSafe)(disk)((0, path_1.join)(constants_1.CWD, 'package.json')), E.map(function (file) { return (0, function_1.pipe)(findPackages(file.contents)); }), O.fromEither, O.flatten);
38
- };
39
- function findPackages(yarn) {
40
- return (0, function_1.pipe)(getArrayOfStrings('workspaces', yarn), O.fold(function () { return getArrayOfStrings('workspaces.packages', yarn); }, O.some));
41
- }
42
- function getArrayOfStrings(paths, yarn) {
43
- return (0, function_1.pipe)(yarn, (0, props_1.props)(paths), O.filter(expect_more_1.isArrayOfStrings));
44
- }
45
- }
46
- exports.getYarnPatterns = getYarnPatterns;
@@ -1,10 +0,0 @@
1
- import * as O from 'fp-ts/lib/Option';
2
- import type { Disk } from '../../../disk';
3
- import type { Config } from '../../get-config/config';
4
- /**
5
- * Find every glob pattern which should be used to find package.json files for
6
- * this monorepo.
7
- *
8
- * @returns `['./package.json', './packages/* /package.json']`
9
- */
10
- export declare function getPatterns(disk: Disk): (program: Config.RcFile) => O.Option<string[]>;