syncpack 13.0.1 → 14.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +0 -3
  2. package/index.js +48 -0
  3. package/package.json +16 -73
  4. package/schema.json +917 -0
  5. package/syncpack.d.ts +122 -0
  6. package/LICENSE +0 -20
  7. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +0 -16
  8. package/dist/bin-fix-mismatches/fix-mismatches.js +0 -115
  9. package/dist/bin-fix-mismatches/index.d.ts +0 -2
  10. package/dist/bin-fix-mismatches/index.js +0 -33
  11. package/dist/bin-format/format.d.ts +0 -13
  12. package/dist/bin-format/format.js +0 -92
  13. package/dist/bin-format/index.d.ts +0 -2
  14. package/dist/bin-format/index.js +0 -28
  15. package/dist/bin-lint/index.d.ts +0 -2
  16. package/dist/bin-lint/index.js +0 -17
  17. package/dist/bin-lint/lint.d.ts +0 -11
  18. package/dist/bin-lint/lint.js +0 -52
  19. package/dist/bin-lint-semver-ranges/index.d.ts +0 -2
  20. package/dist/bin-lint-semver-ranges/index.js +0 -30
  21. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +0 -16
  22. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +0 -92
  23. package/dist/bin-list/index.d.ts +0 -2
  24. package/dist/bin-list/index.js +0 -27
  25. package/dist/bin-list/list.d.ts +0 -14
  26. package/dist/bin-list/list.js +0 -151
  27. package/dist/bin-list-mismatches/index.d.ts +0 -2
  28. package/dist/bin-list-mismatches/index.js +0 -29
  29. package/dist/bin-list-mismatches/list-mismatches.d.ts +0 -18
  30. package/dist/bin-list-mismatches/list-mismatches.js +0 -224
  31. package/dist/bin-prompt/index.d.ts +0 -2
  32. package/dist/bin-prompt/index.js +0 -29
  33. package/dist/bin-prompt/prompt.d.ts +0 -11
  34. package/dist/bin-prompt/prompt.js +0 -95
  35. package/dist/bin-set-semver-ranges/index.d.ts +0 -2
  36. package/dist/bin-set-semver-ranges/index.js +0 -32
  37. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +0 -11
  38. package/dist/bin-set-semver-ranges/set-semver-ranges.js +0 -61
  39. package/dist/bin-update/effects.d.ts +0 -52
  40. package/dist/bin-update/effects.js +0 -282
  41. package/dist/bin-update/index.d.ts +0 -2
  42. package/dist/bin-update/index.js +0 -24
  43. package/dist/bin-update/update.d.ts +0 -6
  44. package/dist/bin-update/update.js +0 -59
  45. package/dist/bin.d.ts +0 -2
  46. package/dist/bin.js +0 -37
  47. package/dist/config/get-custom-types.d.ts +0 -19
  48. package/dist/config/get-custom-types.js +0 -57
  49. package/dist/config/get-enabled-types.d.ts +0 -17
  50. package/dist/config/get-enabled-types.js +0 -109
  51. package/dist/config/get-filter.d.ts +0 -2
  52. package/dist/config/get-filter.js +0 -10
  53. package/dist/config/get-indent.d.ts +0 -2
  54. package/dist/config/get-indent.js +0 -9
  55. package/dist/config/get-sort-az.d.ts +0 -2
  56. package/dist/config/get-sort-az.js +0 -8
  57. package/dist/config/get-sort-exports.d.ts +0 -2
  58. package/dist/config/get-sort-exports.js +0 -9
  59. package/dist/config/get-sort-first.d.ts +0 -2
  60. package/dist/config/get-sort-first.js +0 -8
  61. package/dist/config/get-source.d.ts +0 -2
  62. package/dist/config/get-source.js +0 -8
  63. package/dist/config/tag.d.ts +0 -3
  64. package/dist/config/tag.js +0 -2
  65. package/dist/config/types.d.ts +0 -134
  66. package/dist/config/types.js +0 -1
  67. package/dist/constants.d.ts +0 -106
  68. package/dist/constants.js +0 -103
  69. package/dist/error-handlers/default-error-handlers.d.ts +0 -25
  70. package/dist/error-handlers/default-error-handlers.js +0 -80
  71. package/dist/get-context/index.d.ts +0 -23
  72. package/dist/get-context/index.js +0 -18
  73. package/dist/get-context/lib/key-by.d.ts +0 -6
  74. package/dist/get-context/lib/key-by.js +0 -12
  75. package/dist/get-instances/index.d.ts +0 -14
  76. package/dist/get-instances/index.js +0 -42
  77. package/dist/get-instances/instance.d.ts +0 -26
  78. package/dist/get-instances/instance.js +0 -35
  79. package/dist/get-package-json-files/get-file-paths.d.ts +0 -21
  80. package/dist/get-package-json-files/get-file-paths.js +0 -22
  81. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +0 -3
  82. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +0 -12
  83. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +0 -3
  84. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +0 -14
  85. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +0 -3
  86. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +0 -16
  87. package/dist/get-package-json-files/get-patterns/index.d.ts +0 -8
  88. package/dist/get-package-json-files/get-patterns/index.js +0 -23
  89. package/dist/get-package-json-files/index.d.ts +0 -10
  90. package/dist/get-package-json-files/index.js +0 -8
  91. package/dist/get-package-json-files/package-json-file.d.ts +0 -54
  92. package/dist/get-package-json-files/package-json-file.js +0 -44
  93. package/dist/guards/can-add-to-group.d.ts +0 -5
  94. package/dist/guards/can-add-to-group.js +0 -58
  95. package/dist/guards/is-semver.d.ts +0 -2
  96. package/dist/guards/is-semver.js +0 -15
  97. package/dist/guards/is-valid-semver-range.d.ts +0 -3
  98. package/dist/guards/is-valid-semver-range.js +0 -14
  99. package/dist/index.d.ts +0 -2
  100. package/dist/index.js +0 -1
  101. package/dist/io/ask-for-choice.d.ts +0 -14
  102. package/dist/io/ask-for-choice.js +0 -17
  103. package/dist/io/ask-for-input.d.ts +0 -13
  104. package/dist/io/ask-for-input.js +0 -14
  105. package/dist/io/exit-if-invalid.d.ts +0 -4
  106. package/dist/io/exit-if-invalid.js +0 -9
  107. package/dist/io/glob-sync.d.ts +0 -11
  108. package/dist/io/glob-sync.js +0 -14
  109. package/dist/io/index.d.ts +0 -27
  110. package/dist/io/index.js +0 -26
  111. package/dist/io/read-config-file.d.ts +0 -7
  112. package/dist/io/read-config-file.js +0 -24
  113. package/dist/io/read-file-sync.d.ts +0 -12
  114. package/dist/io/read-file-sync.js +0 -9
  115. package/dist/io/read-json-file-sync.d.ts +0 -31
  116. package/dist/io/read-json-file-sync.js +0 -23
  117. package/dist/io/read-yaml-file-sync.d.ts +0 -12
  118. package/dist/io/read-yaml-file-sync.js +0 -9
  119. package/dist/io/to-formatted-json.d.ts +0 -9
  120. package/dist/io/to-formatted-json.js +0 -32
  121. package/dist/io/write-file-sync.d.ts +0 -12
  122. package/dist/io/write-file-sync.js +0 -10
  123. package/dist/io/write-if-changed.d.ts +0 -5
  124. package/dist/io/write-if-changed.js +0 -9
  125. package/dist/lib/format-repository-url.d.ts +0 -1
  126. package/dist/lib/format-repository-url.js +0 -40
  127. package/dist/lib/get-group-header.d.ts +0 -10
  128. package/dist/lib/get-group-header.js +0 -25
  129. package/dist/lib/get.d.ts +0 -11
  130. package/dist/lib/get.js +0 -44
  131. package/dist/lib/pad-start.d.ts +0 -1
  132. package/dist/lib/pad-start.js +0 -3
  133. package/dist/lib/ring-buffer.d.ts +0 -10
  134. package/dist/lib/ring-buffer.js +0 -20
  135. package/dist/lib/set-semver-range.d.ts +0 -3
  136. package/dist/lib/set-semver-range.js +0 -24
  137. package/dist/lib/show-help-on-error.d.ts +0 -2
  138. package/dist/lib/show-help-on-error.js +0 -32
  139. package/dist/lib/sort-by-name.d.ts +0 -5
  140. package/dist/lib/sort-by-name.js +0 -9
  141. package/dist/lib/with-logger.d.ts +0 -2
  142. package/dist/lib/with-logger.js +0 -28
  143. package/dist/option.d.ts +0 -10
  144. package/dist/option.js +0 -30
  145. package/dist/report.d.ts +0 -131
  146. package/dist/report.js +0 -129
  147. package/dist/schema.json +0 -614
  148. package/dist/semver-group/create-semver-groups.d.ts +0 -4
  149. package/dist/semver-group/create-semver-groups.js +0 -83
  150. package/dist/semver-group/disabled.d.ts +0 -26
  151. package/dist/semver-group/disabled.js +0 -28
  152. package/dist/semver-group/filtered-out.d.ts +0 -27
  153. package/dist/semver-group/filtered-out.js +0 -34
  154. package/dist/semver-group/ignored.d.ts +0 -22
  155. package/dist/semver-group/ignored.js +0 -24
  156. package/dist/semver-group/index.d.ts +0 -20
  157. package/dist/semver-group/index.js +0 -7
  158. package/dist/semver-group/with-range.d.ts +0 -22
  159. package/dist/semver-group/with-range.js +0 -45
  160. package/dist/specifier/alias.d.ts +0 -17
  161. package/dist/specifier/alias.js +0 -21
  162. package/dist/specifier/base.d.ts +0 -41
  163. package/dist/specifier/base.js +0 -54
  164. package/dist/specifier/delete.d.ts +0 -17
  165. package/dist/specifier/delete.js +0 -16
  166. package/dist/specifier/exact.d.ts +0 -20
  167. package/dist/specifier/exact.js +0 -21
  168. package/dist/specifier/file.d.ts +0 -8
  169. package/dist/specifier/file.js +0 -7
  170. package/dist/specifier/hosted-git.d.ts +0 -15
  171. package/dist/specifier/hosted-git.js +0 -24
  172. package/dist/specifier/index.d.ts +0 -28
  173. package/dist/specifier/index.js +0 -75
  174. package/dist/specifier/latest.d.ts +0 -19
  175. package/dist/specifier/latest.js +0 -20
  176. package/dist/specifier/lib/non-semver-error.d.ts +0 -11
  177. package/dist/specifier/lib/non-semver-error.js +0 -6
  178. package/dist/specifier/lib/parse-specifier.d.ts +0 -14
  179. package/dist/specifier/lib/parse-specifier.js +0 -18
  180. package/dist/specifier/lib/specific-registry-result.d.ts +0 -9
  181. package/dist/specifier/lib/specific-registry-result.js +0 -1
  182. package/dist/specifier/range.d.ts +0 -19
  183. package/dist/specifier/range.js +0 -20
  184. package/dist/specifier/tag.d.ts +0 -11
  185. package/dist/specifier/tag.js +0 -10
  186. package/dist/specifier/unsupported.d.ts +0 -7
  187. package/dist/specifier/unsupported.js +0 -7
  188. package/dist/specifier/url.d.ts +0 -8
  189. package/dist/specifier/url.js +0 -7
  190. package/dist/specifier/workspace-protocol.d.ts +0 -19
  191. package/dist/specifier/workspace-protocol.js +0 -35
  192. package/dist/strategy/lib/get-non-empty-string-prop.d.ts +0 -3
  193. package/dist/strategy/lib/get-non-empty-string-prop.js +0 -7
  194. package/dist/strategy/name-and-version-props.d.ts +0 -12
  195. package/dist/strategy/name-and-version-props.js +0 -60
  196. package/dist/strategy/named-version-string.d.ts +0 -11
  197. package/dist/strategy/named-version-string.js +0 -52
  198. package/dist/strategy/unnamed-version-string.d.ts +0 -11
  199. package/dist/strategy/unnamed-version-string.js +0 -45
  200. package/dist/strategy/versions-by-name.d.ts +0 -11
  201. package/dist/strategy/versions-by-name.js +0 -27
  202. package/dist/version-group/banned.d.ts +0 -17
  203. package/dist/version-group/banned.js +0 -26
  204. package/dist/version-group/create-version-groups.d.ts +0 -4
  205. package/dist/version-group/create-version-groups.js +0 -118
  206. package/dist/version-group/filtered-out.d.ts +0 -19
  207. package/dist/version-group/filtered-out.js +0 -30
  208. package/dist/version-group/ignored.d.ts +0 -17
  209. package/dist/version-group/ignored.js +0 -23
  210. package/dist/version-group/index.d.ts +0 -26
  211. package/dist/version-group/index.js +0 -7
  212. package/dist/version-group/lib/clean.d.ts +0 -2
  213. package/dist/version-group/lib/clean.js +0 -6
  214. package/dist/version-group/lib/delete.d.ts +0 -2
  215. package/dist/version-group/lib/delete.js +0 -1
  216. package/dist/version-group/lib/get-highest-version.d.ts +0 -6
  217. package/dist/version-group/lib/get-highest-version.js +0 -8
  218. package/dist/version-group/lib/get-lowest-version.d.ts +0 -6
  219. package/dist/version-group/lib/get-lowest-version.js +0 -8
  220. package/dist/version-group/lib/get-preferred-version.d.ts +0 -5
  221. package/dist/version-group/lib/get-preferred-version.js +0 -53
  222. package/dist/version-group/lib/get-range-score.d.ts +0 -2
  223. package/dist/version-group/lib/get-range-score.js +0 -20
  224. package/dist/version-group/lib/group-by.d.ts +0 -5
  225. package/dist/version-group/lib/group-by.js +0 -11
  226. package/dist/version-group/pinned.d.ts +0 -17
  227. package/dist/version-group/pinned.js +0 -26
  228. package/dist/version-group/same-range.d.ts +0 -19
  229. package/dist/version-group/same-range.js +0 -96
  230. package/dist/version-group/snapped-to.d.ts +0 -17
  231. package/dist/version-group/snapped-to.js +0 -71
  232. package/dist/version-group/standard.d.ts +0 -18
  233. package/dist/version-group/standard.js +0 -119
package/dist/constants.js DELETED
@@ -1,103 +0,0 @@
1
- /** Single source of truth, intended to aid testing or to override */
2
- export const CWD = process.env.MOCK_CWD || process.cwd();
3
- /** Single source of truth for icons used in output */
4
- export const ICON = {
5
- banned: '⦸',
6
- cross: '✘',
7
- debug: '?',
8
- info: 'i',
9
- panic: '!',
10
- rightArrow: '→',
11
- skip: '-',
12
- tick: '✓',
13
- };
14
- export const RANGE = {
15
- ANY: '*',
16
- EXACT: '',
17
- GT: '>',
18
- GTE: '>=',
19
- LOOSE: '.x',
20
- LT: '<',
21
- LTE: '<=',
22
- MINOR: '^',
23
- PATCH: '~',
24
- WORKSPACE: 'workspace:',
25
- };
26
- export const INTERNAL_TYPES = [
27
- 'dev',
28
- 'local',
29
- 'overrides',
30
- 'peer',
31
- 'pnpmOverrides',
32
- 'prod',
33
- 'resolutions',
34
- ];
35
- export const CUSTOM_TYPES = {
36
- dev: {
37
- strategy: 'versionsByName',
38
- path: 'devDependencies',
39
- },
40
- local: {
41
- strategy: 'name~version',
42
- namePath: 'name',
43
- path: 'version',
44
- },
45
- overrides: {
46
- strategy: 'versionsByName',
47
- path: 'overrides',
48
- },
49
- peer: {
50
- strategy: 'versionsByName',
51
- path: 'peerDependencies',
52
- },
53
- pnpmOverrides: {
54
- strategy: 'versionsByName',
55
- path: 'pnpm.overrides',
56
- },
57
- prod: {
58
- strategy: 'versionsByName',
59
- path: 'dependencies',
60
- },
61
- resolutions: {
62
- strategy: 'versionsByName',
63
- path: 'resolutions',
64
- },
65
- };
66
- export const DEFAULT_CONFIG = {
67
- customTypes: CUSTOM_TYPES,
68
- dependencyTypes: ['**'],
69
- filter: '.',
70
- formatBugs: true,
71
- formatRepository: true,
72
- indent: ' ',
73
- lintFormatting: true,
74
- lintSemverRanges: true,
75
- lintVersions: true,
76
- semverGroups: [],
77
- sortAz: [
78
- 'bin',
79
- 'contributors',
80
- 'dependencies',
81
- 'devDependencies',
82
- 'keywords',
83
- 'peerDependencies',
84
- 'resolutions',
85
- 'scripts',
86
- ],
87
- sortExports: [
88
- 'types',
89
- 'node-addons',
90
- 'node',
91
- 'browser',
92
- 'import',
93
- 'require',
94
- 'development',
95
- 'production',
96
- 'default',
97
- ],
98
- sortFirst: ['name', 'description', 'version', 'author'],
99
- sortPackages: true,
100
- source: ['package.json', 'packages/*/package.json'],
101
- specifierTypes: ['**'],
102
- versionGroups: [],
103
- };
@@ -1,25 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { InvalidCustomTypeError } from '../config/get-custom-types.js';
3
- import type { DeprecatedTypesError, RenamedWorkspaceTypeError } from '../config/get-enabled-types.js';
4
- import type { NoSourcesFoundError } from '../get-package-json-files/get-file-paths.js';
5
- import type { GlobError } from '../io/glob-sync.js';
6
- import type { ReadFileError } from '../io/read-file-sync.js';
7
- import type { JsonParseError } from '../io/read-json-file-sync.js';
8
- import type { WriteFileError } from '../io/write-file-sync.js';
9
- import type { SemverGroup } from '../semver-group/index.js';
10
- import type { VersionGroup } from '../version-group/index.js';
11
- type R = Effect.Effect<void>;
12
- export interface ErrorHandlers {
13
- DeprecatedTypesError(err: DeprecatedTypesError): R;
14
- InvalidCustomTypeError(err: InvalidCustomTypeError): R;
15
- RenamedWorkspaceTypeError(err: RenamedWorkspaceTypeError): R;
16
- SemverGroupConfigError(err: SemverGroup.ConfigError): R;
17
- VersionGroupConfigError(err: VersionGroup.ConfigError): R;
18
- GlobError(err: GlobError): R;
19
- JsonParseError(err: JsonParseError): R;
20
- NoSourcesFoundError(err: NoSourcesFoundError): R;
21
- ReadFileError(err: ReadFileError): R;
22
- WriteFileError(err: WriteFileError): R;
23
- }
24
- export declare const defaultErrorHandlers: ErrorHandlers;
25
- export {};
@@ -1,80 +0,0 @@
1
- import { EOL } from 'node:os';
2
- import chalk from 'chalk';
3
- import { Effect } from 'effect';
4
- export const defaultErrorHandlers = {
5
- // getContext
6
- GlobError(err) {
7
- return Effect.logError([
8
- chalk.red('An error was found when processing your source globs'),
9
- chalk.red(' Error:', err.error),
10
- ].join(EOL));
11
- },
12
- JsonParseError(err) {
13
- return Effect.logError([
14
- chalk.red('An error was found when parsing a JSON file'),
15
- chalk.red(' File:', err.filePath),
16
- chalk.red(' Error:', err.errors),
17
- ].join(EOL));
18
- },
19
- NoSourcesFoundError(err) {
20
- return Effect.logError([
21
- chalk.red('No package.json files were found'),
22
- chalk.red(' CWD:', err.CWD),
23
- chalk.red(' Sources:', err.patterns),
24
- ].join(EOL));
25
- },
26
- ReadFileError(err) {
27
- return Effect.logError([
28
- chalk.red('An error was found when reading a file'),
29
- chalk.red(' File:', err.filePath),
30
- chalk.red(' Error:', err.error),
31
- ].join(EOL));
32
- },
33
- // Others
34
- DeprecatedTypesError(err) {
35
- const url = 'https://github.com/JamieMason/syncpack/releases/tag/9.0.0';
36
- return Effect.logError([
37
- chalk.red(`Your syncpack config file contains values deprecated in ${url}`),
38
- chalk.red(' Dependency Types:', err.types),
39
- chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/dependency-types'),
40
- ].join(EOL));
41
- },
42
- InvalidCustomTypeError(err) {
43
- return Effect.logError([
44
- chalk.red('Your syncpack config file contains an invalid custom type'),
45
- chalk.red(' Error:', err.reason),
46
- chalk.red(' Config:', err.config),
47
- chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/custom-types'),
48
- ].join(EOL));
49
- },
50
- RenamedWorkspaceTypeError() {
51
- const url = 'https://github.com/JamieMason/syncpack/releases/tag/11.2.1';
52
- return Effect.logError([
53
- chalk.red(`The "workspace" dependency type was renamed to "local" in ${url}`),
54
- chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/dependency-types'),
55
- ].join(EOL));
56
- },
57
- SemverGroupConfigError(err) {
58
- return Effect.logError([
59
- chalk.red('Your semver group config contains an error'),
60
- chalk.red(' Error:', err.error),
61
- chalk.red(' Config:', err.config),
62
- chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/semver-groups'),
63
- ].join(EOL));
64
- },
65
- VersionGroupConfigError(err) {
66
- return Effect.logError([
67
- chalk.red('Your version group config contains an error'),
68
- chalk.red(' Error:', err.error),
69
- chalk.red(' Config:', err.config),
70
- chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/version-groups'),
71
- ].join(EOL));
72
- },
73
- WriteFileError(err) {
74
- return Effect.logError([
75
- chalk.red('An error was found when writing to a file'),
76
- chalk.red(' File:', err.filePath),
77
- chalk.red(' Error:', err.error),
78
- ].join(EOL));
79
- },
80
- };
@@ -1,23 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { O } from 'ts-toolbelt';
3
- import type { CliConfig, RcConfig } from '../config/types.js';
4
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
5
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
6
- import type { Io } from '../io/index.js';
7
- export interface Ctx {
8
- readonly config: {
9
- readonly cli: Partial<CliConfig>;
10
- readonly rcFile: O.Partial<RcConfig, 'deep'>;
11
- };
12
- /** @TODO: Replace with Effect Exit/Cause */
13
- isInvalid: boolean;
14
- packageJsonFiles: PackageJsonFile[];
15
- packageJsonFilesByName: Record<string, PackageJsonFile>;
16
- }
17
- interface Input {
18
- io: Io;
19
- cli: Partial<CliConfig>;
20
- errorHandlers: ErrorHandlers;
21
- }
22
- export declare function getContext({ io, cli, errorHandlers, }: Input): Effect.Effect<Ctx>;
23
- export {};
@@ -1,18 +0,0 @@
1
- import { Effect, flow, pipe } from 'effect';
2
- import { getPackageJsonFiles } from '../get-package-json-files/index.js';
3
- import { readConfigFile } from '../io/read-config-file.js';
4
- import { keyBy } from './lib/key-by.js';
5
- export function getContext({ io, cli, errorHandlers, }) {
6
- const exitOnError = Effect.flatMap(() => Effect.failSync(() => io.process.exit(1)));
7
- return pipe(Effect.Do, Effect.bind('rcFile', () => readConfigFile(io, cli.configPath)), Effect.bind('packageJsonFiles', ({ rcFile }) => getPackageJsonFiles(io, { cli, rcFile })), Effect.map(({ rcFile, packageJsonFiles }) => ({
8
- config: { cli, rcFile },
9
- isInvalid: false,
10
- packageJsonFiles,
11
- packageJsonFilesByName: keyBy('name', packageJsonFiles),
12
- })), Effect.catchTags({
13
- GlobError: flow(errorHandlers.GlobError, exitOnError),
14
- JsonParseError: flow(errorHandlers.JsonParseError, exitOnError),
15
- NoSourcesFoundError: flow(errorHandlers.NoSourcesFoundError, exitOnError),
16
- ReadFileError: flow(errorHandlers.ReadFileError, exitOnError),
17
- }));
18
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Convert an array of objects to an object, where each member of the array has
3
- * a unique value for the given key. The new object keys each object by its
4
- * value for the given key.
5
- */
6
- export declare function keyBy<A extends any[]>(key: string, array: A): Record<string, A[number]>;
@@ -1,12 +0,0 @@
1
- /**
2
- * Convert an array of objects to an object, where each member of the array has
3
- * a unique value for the given key. The new object keys each object by its
4
- * value for the given key.
5
- */
6
- export function keyBy(key, array) {
7
- return array.reduce((objectsByKeyValue, obj) => {
8
- const value = obj[key];
9
- objectsByKeyValue[value] = obj;
10
- return objectsByKeyValue;
11
- }, {});
12
- }
@@ -1,14 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
3
- import type { Ctx } from '../get-context/index.js';
4
- import type { Io } from '../io/index.js';
5
- import type { SemverGroup } from '../semver-group/index.js';
6
- import type { VersionGroup } from '../version-group/index.js';
7
- import type { Instance } from './instance.js';
8
- interface Instances {
9
- all: Instance[];
10
- semverGroups: SemverGroup.Any[];
11
- versionGroups: VersionGroup.Any[];
12
- }
13
- export declare function getInstances(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<Instances>;
14
- export {};
@@ -1,42 +0,0 @@
1
- import { Effect, flow, pipe } from 'effect';
2
- import { getEnabledTypes } from '../config/get-enabled-types.js';
3
- import { canAddToGroup } from '../guards/can-add-to-group.js';
4
- import { sortByName } from '../lib/sort-by-name.js';
5
- import { createSemverGroups } from '../semver-group/create-semver-groups.js';
6
- import { createVersionGroups } from '../version-group/create-version-groups.js';
7
- export function getInstances(ctx, io, errorHandlers) {
8
- const exitOnError = Effect.flatMap(() => Effect.failSync(() => io.process.exit(1)));
9
- return pipe(Effect.Do, Effect.bind('enabledTypes', () => getEnabledTypes(ctx.config)), Effect.bind('semverGroups', () => createSemverGroups(ctx)), Effect.bind('versionGroups', () => createVersionGroups(ctx)), Effect.bind('instances', acc => pipe(ctx.packageJsonFiles, Effect.forEach(file => file.getInstances(acc.enabledTypes)), Effect.map(instancesByFile => instancesByFile.flat()))), Effect.tap(({ instances, semverGroups, versionGroups }) => Effect.sync(() => {
10
- for (const instance of instances) {
11
- // assign each instance to its semver group, first match wins
12
- for (const group of semverGroups) {
13
- if (canAddToGroup(ctx.packageJsonFilesByName, group, instance)) {
14
- instance.semverGroup = group;
15
- group.instances.push(instance);
16
- break;
17
- }
18
- }
19
- // assign each instance to its version group, first match wins
20
- for (const group of versionGroups) {
21
- if (canAddToGroup(ctx.packageJsonFilesByName, group, instance)) {
22
- instance.versionGroup = group;
23
- group.instances.push(instance);
24
- break;
25
- }
26
- }
27
- }
28
- })), Effect.map(({ instances, semverGroups, versionGroups }) => ({
29
- all: instances,
30
- semverGroups: getSortedAndFiltered(semverGroups),
31
- versionGroups: getSortedAndFiltered(versionGroups),
32
- })), Effect.catchTags({
33
- DeprecatedTypesError: flow(errorHandlers.DeprecatedTypesError, exitOnError),
34
- InvalidCustomTypeError: flow(errorHandlers.InvalidCustomTypeError, exitOnError),
35
- RenamedWorkspaceTypeError: flow(errorHandlers.RenamedWorkspaceTypeError, exitOnError),
36
- SemverGroupConfigError: flow(errorHandlers.SemverGroupConfigError, exitOnError),
37
- VersionGroupConfigError: flow(errorHandlers.VersionGroupConfigError, exitOnError),
38
- }));
39
- function getSortedAndFiltered(groups) {
40
- return groups.filter(group => group.instances.sort(sortByName).length > 0);
41
- }
42
- }
@@ -1,26 +0,0 @@
1
- import type { Effect } from 'effect';
2
- import type { Strategy } from '../config/get-custom-types.js';
3
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
4
- import type { SemverGroup } from '../semver-group/index.js';
5
- import { Specifier } from '../specifier/index.js';
6
- import type { VersionGroup } from '../version-group/index.js';
7
- import type { Delete } from '../version-group/lib/delete.js';
8
- export declare class Instance {
9
- /** The name of this dependency */
10
- name: string;
11
- /** The .name property of the package.json file of this instance */
12
- pkgName: string;
13
- /** The specifier as it is on disk before being fixed */
14
- rawSpecifier: Specifier.Any;
15
- /** The package this dependency is installed in this specific time */
16
- packageJsonFile: PackageJsonFile;
17
- /** Locates where in the file this dependency is installed */
18
- strategy: Strategy.Any;
19
- /** The semver group this instance belongs to */
20
- semverGroup: SemverGroup.Any;
21
- /** The version group this instance belongs to */
22
- versionGroup: VersionGroup.Any;
23
- constructor(name: string, rawSpecifier: string, packageJsonFile: PackageJsonFile, strategy: Strategy.Any);
24
- /** Mutate the package.json file in memory with the latest version specifier */
25
- write(rawSpecifier: string | Delete): Effect.Effect<PackageJsonFile>;
26
- }
@@ -1,35 +0,0 @@
1
- import { Specifier } from '../specifier/index.js';
2
- export class Instance {
3
- /** The name of this dependency */
4
- name;
5
- /** The .name property of the package.json file of this instance */
6
- pkgName;
7
- /** The specifier as it is on disk before being fixed */
8
- rawSpecifier;
9
- /** The package this dependency is installed in this specific time */
10
- packageJsonFile;
11
- /** Locates where in the file this dependency is installed */
12
- strategy;
13
- /** The semver group this instance belongs to */
14
- semverGroup;
15
- /** The version group this instance belongs to */
16
- versionGroup;
17
- constructor(name, rawSpecifier, packageJsonFile, strategy) {
18
- this.name = name;
19
- this.pkgName =
20
- packageJsonFile.jsonFile.contents.name || 'PACKAGE_JSON_HAS_NO_NAME';
21
- this.packageJsonFile = packageJsonFile;
22
- this.strategy = strategy;
23
- this.semverGroup = null;
24
- this.versionGroup = null;
25
- this.rawSpecifier = Specifier.create(this, rawSpecifier);
26
- }
27
- /** Mutate the package.json file in memory with the latest version specifier */
28
- write(rawSpecifier) {
29
- this.rawSpecifier = Specifier.create(this, rawSpecifier);
30
- return this.strategy.write(this.packageJsonFile, [
31
- this.name,
32
- this.rawSpecifier.raw,
33
- ]);
34
- }
35
- }
@@ -1,21 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { Ctx } from '../get-context/index.js';
3
- import type { GlobError } from '../io/glob-sync.js';
4
- import type { Io } from '../io/index.js';
5
- declare const NoSourcesFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
6
- readonly _tag: "NoSourcesFoundError";
7
- };
8
- export declare class NoSourcesFoundError extends NoSourcesFoundError_base<{
9
- readonly CWD: string;
10
- readonly patterns: string[];
11
- }> {
12
- }
13
- /**
14
- * Using --source options and/or config files on disk from
15
- * npm/pnpm/yarn/lerna, return an array of absolute paths to every package.json
16
- * file the user is working with.
17
- *
18
- * @returns Array of absolute file paths to package.json files
19
- */
20
- export declare function getFilePaths(io: Io, config: Ctx['config']): Effect.Effect<string[], GlobError | NoSourcesFoundError>;
21
- export {};
@@ -1,22 +0,0 @@
1
- import { Data, Effect, pipe } from 'effect';
2
- import { uniq } from 'tightrope/array/uniq.js';
3
- import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
4
- import { globSync } from '../io/glob-sync.js';
5
- import { getPatterns } from './get-patterns/index.js';
6
- export class NoSourcesFoundError extends Data.TaggedClass('NoSourcesFoundError') {
7
- }
8
- /**
9
- * Using --source options and/or config files on disk from
10
- * npm/pnpm/yarn/lerna, return an array of absolute paths to every package.json
11
- * file the user is working with.
12
- *
13
- * @returns Array of absolute file paths to package.json files
14
- */
15
- export function getFilePaths(io, config) {
16
- return pipe(Effect.Do, Effect.bind('patterns', () => getPatterns(io, config)), Effect.bind('filePaths', ({ patterns }) => globSync(io, patterns)), Effect.bind('flatFilePaths', ({ filePaths }) => Effect.sync(() => uniq(filePaths.flat()))), Effect.flatMap(({ flatFilePaths, patterns }) => isNonEmptyArray(flatFilePaths)
17
- ? Effect.succeed(flatFilePaths)
18
- : Effect.fail(new NoSourcesFoundError({
19
- CWD: io.process.cwd(),
20
- patterns,
21
- }))));
22
- }
@@ -1,3 +0,0 @@
1
- import { Effect, Option as O } from 'effect';
2
- import type { Io } from '../../io/index.js';
3
- export declare function getLernaPatterns(io: Io): Effect.Effect<O.Option<string[]>>;
@@ -1,12 +0,0 @@
1
- import { join } from 'node:path';
2
- import { Effect, Option as O, pipe } from 'effect';
3
- import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
4
- import { readJsonFileSync } from '../../io/read-json-file-sync.js';
5
- export function getLernaPatterns(io) {
6
- return pipe(readJsonFileSync(io, join(io.process.cwd(), 'lerna.json')), Effect.map(file => isArrayOfStrings(file.contents.packages)
7
- ? O.some(file.contents.packages)
8
- : O.none()), Effect.catchTags({
9
- ReadFileError: () => Effect.succeed(O.none()),
10
- JsonParseError: () => Effect.succeed(O.none()),
11
- }));
12
- }
@@ -1,3 +0,0 @@
1
- import { Effect, Option as O } from 'effect';
2
- import type { Io } from '../../io/index.js';
3
- export declare function getPnpmPatterns(io: Io): Effect.Effect<O.Option<string[]>>;
@@ -1,14 +0,0 @@
1
- import { join } from 'node:path';
2
- import { Effect, Option as O, pipe } from 'effect';
3
- import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
4
- import { readYamlFileSync } from '../../io/read-yaml-file-sync.js';
5
- export function getPnpmPatterns(io) {
6
- return pipe(
7
- // packages:
8
- // - "packages/**"
9
- // - "components/**"
10
- // - "!**/test/**"
11
- readYamlFileSync(io, join(io.process.cwd(), 'pnpm-workspace.yaml')), Effect.map(file => isArrayOfStrings(file?.packages) ? O.some(file.packages) : O.none()), Effect.catchTags({
12
- ReadYamlFileError: () => Effect.succeed(O.none()),
13
- }));
14
- }
@@ -1,3 +0,0 @@
1
- import { Effect, Option as O } from 'effect';
2
- import type { Io } from '../../io/index.js';
3
- export declare function getYarnPatterns(io: Io): Effect.Effect<O.Option<string[]>>;
@@ -1,16 +0,0 @@
1
- import { join } from 'node:path';
2
- import { Effect, Option as O, pipe } from 'effect';
3
- import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
4
- import { isNonEmptyObject } from 'tightrope/guard/is-non-empty-object.js';
5
- import { readJsonFileSync } from '../../io/read-json-file-sync.js';
6
- export function getYarnPatterns(io) {
7
- return pipe(readJsonFileSync(io, join(io.process.cwd(), 'package.json')), Effect.map(file => isNonEmptyObject(file.contents.workspaces) &&
8
- isArrayOfStrings(file.contents.workspaces.packages)
9
- ? O.some(file.contents.workspaces.packages)
10
- : isArrayOfStrings(file.contents.workspaces)
11
- ? O.some(file.contents.workspaces)
12
- : O.none()), Effect.catchTags({
13
- ReadFileError: () => Effect.succeed(O.none()),
14
- JsonParseError: () => Effect.succeed(O.none()),
15
- }));
16
- }
@@ -1,8 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { Ctx } from '../../get-context/index.js';
3
- import type { Io } from '../../io/index.js';
4
- /**
5
- * Find every glob pattern which should be used to find package.json files for
6
- * this monorepo.
7
- */
8
- export declare function getPatterns(io: Io, config: Ctx['config']): Effect.Effect<string[]>;
@@ -1,23 +0,0 @@
1
- import { Effect, Option as O, pipe } from 'effect';
2
- import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
3
- import { getSource } from '../../config/get-source.js';
4
- import { DEFAULT_CONFIG } from '../../constants.js';
5
- import { getLernaPatterns } from './get-lerna-patterns.js';
6
- import { getPnpmPatterns } from './get-pnpm-patterns.js';
7
- import { getYarnPatterns } from './get-yarn-patterns.js';
8
- /**
9
- * Find every glob pattern which should be used to find package.json files for
10
- * this monorepo.
11
- */
12
- export function getPatterns(io, config) {
13
- return pipe(getCliPatterns(), Effect.flatMap(opt => O.isSome(opt) ? Effect.succeed(opt) : getWorkspacePatterns()), Effect.map(O.map(limitToPackageJson)), Effect.map(O.getOrElse(() => [...DEFAULT_CONFIG.source])));
14
- function getCliPatterns() {
15
- return pipe(O.some(getSource(config)), O.filter(isArrayOfStrings), Effect.succeed);
16
- }
17
- function getWorkspacePatterns() {
18
- return pipe(getYarnPatterns(io), Effect.flatMap(opt => O.isSome(opt) ? Effect.succeed(opt) : getPnpmPatterns(io)), Effect.flatMap(opt => O.isSome(opt) ? Effect.succeed(opt) : getLernaPatterns(io)), Effect.map(O.map(patterns => ['package.json', ...patterns])));
19
- }
20
- function limitToPackageJson(patterns) {
21
- return patterns.map(pattern => pattern.includes('package.json') ? pattern : `${pattern}/package.json`);
22
- }
23
- }
@@ -1,10 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { Ctx } from '../get-context/index.js';
3
- import type { GlobError } from '../io/glob-sync.js';
4
- import type { Io } from '../io/index.js';
5
- import type { ReadFileError } from '../io/read-file-sync.js';
6
- import type { JsonParseError } from '../io/read-json-file-sync.js';
7
- import type { NoSourcesFoundError } from './get-file-paths.js';
8
- import { PackageJsonFile } from './package-json-file.js';
9
- /** Create an API for every package.json file needed. */
10
- export declare function getPackageJsonFiles(io: Io, config: Ctx['config']): Effect.Effect<PackageJsonFile[], NoSourcesFoundError | GlobError | ReadFileError | JsonParseError>;
@@ -1,8 +0,0 @@
1
- import { Effect, pipe } from 'effect';
2
- import { readJsonFileSync } from '../io/read-json-file-sync.js';
3
- import { getFilePaths } from './get-file-paths.js';
4
- import { PackageJsonFile } from './package-json-file.js';
5
- /** Create an API for every package.json file needed. */
6
- export function getPackageJsonFiles(io, config) {
7
- return pipe(getFilePaths(io, config), Effect.flatMap(filePaths => Effect.all(filePaths.map(filePath => readJsonFileSync(io, filePath)))), Effect.map(files => files.map(file => new PackageJsonFile(file, config))), Effect.tap(files => Effect.logDebug(`${files.length} package.json files found`)));
8
- }
@@ -1,54 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { Strategy } from '../config/get-custom-types.js';
3
- import type { Ctx } from '../get-context/index.js';
4
- import { Instance } from '../get-instances/instance.js';
5
- import type { RcFile } from '../index.js';
6
- import type { JsonFile } from '../io/read-json-file-sync.js';
7
- export type PackageJson = {
8
- bugs?: {
9
- url: string;
10
- } | string;
11
- config?: {
12
- syncpack?: RcFile;
13
- };
14
- dependencies?: Record<string, string>;
15
- description?: string;
16
- devDependencies?: Record<string, string>;
17
- keywords?: string[];
18
- name?: string;
19
- overrides?: Record<string, string>;
20
- peerDependencies?: Record<string, string>;
21
- pnpm?: {
22
- overrides?: Record<string, string>;
23
- };
24
- repository?: {
25
- directory?: string;
26
- type: string;
27
- url: string;
28
- } | string;
29
- resolutions?: Record<string, string>;
30
- scripts?: Record<string, string>;
31
- version?: string;
32
- workspaces?: string[] | {
33
- packages?: string[];
34
- };
35
- } & Record<string, Record<string, string | string[] | Record<string, string | string[]>> | string | string[] | undefined>;
36
- export declare class PackageJsonFile {
37
- /** resolved configuration */
38
- readonly config: Ctx['config'];
39
- /** ensure only one set of instances is ever created and shared */
40
- private _instances;
41
- /** the wrapped package.json file */
42
- jsonFile: JsonFile<PackageJson>;
43
- /** the .name property from the package.json file */
44
- name: string | undefined;
45
- /** the next package.json file contents after modification, with formatting preserved */
46
- nextJson: string;
47
- constructor(jsonFile: JsonFile<PackageJson>, config: Ctx['config']);
48
- getInstances(enabledTypes: Strategy.Any[]): Effect.Effect<Instance[]>;
49
- /**
50
- * Apply an edit to the raw JSON string which will be written to disk. This string preserves the
51
- * original formatting of the file.
52
- */
53
- applyEdit(fullPath: string[], value: string | undefined): void;
54
- }