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
@@ -1,92 +0,0 @@
1
- import { EOL } from 'node:os';
2
- import chalk from 'chalk-template';
3
- import { Context, Effect, pipe } from 'effect';
4
- import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
5
- import { CliConfigTag } from '../config/tag.js';
6
- import { ICON } from '../constants.js';
7
- import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
8
- import { getContext } from '../get-context/index.js';
9
- import { getInstances } from '../get-instances/index.js';
10
- import { exitIfInvalid } from '../io/exit-if-invalid.js';
11
- import { IoTag } from '../io/index.js';
12
- import { getSemverGroupHeader } from '../lib/get-group-header.js';
13
- import { padStart } from '../lib/pad-start.js';
14
- import { withLogger } from '../lib/with-logger.js';
15
- export function lintSemverRanges({ io, cli, errorHandlers = defaultErrorHandlers, }) {
16
- return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(ctx => pipeline(ctx, io, errorHandlers)), Effect.flatMap(exitIfInvalid), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
17
- }
18
- /** Exported to be reused by `syncpack lint` */
19
- export function pipeline(ctx, io, errorHandlers) {
20
- return Effect.gen(function* ($) {
21
- // no semver groups have been configured, they are disabled by default
22
- if (!isNonEmptyArray(ctx.config.rcFile.semverGroups)) {
23
- yield* $(logSemverGroupsDisabledWarning());
24
- return ctx;
25
- }
26
- const { semverGroups } = yield* $(getInstances(ctx, io, errorHandlers));
27
- let index = 0;
28
- for (const group of semverGroups) {
29
- const groupSize = group.instances.length;
30
- let validCount = 0;
31
- if (group._tag === 'Ignored') {
32
- yield* $(Effect.logInfo(getSemverGroupHeader({ group, index })));
33
- yield* $(logIgnoredSize(groupSize));
34
- }
35
- else if (group._tag === 'WithRange') {
36
- yield* $(Effect.logInfo(getSemverGroupHeader({ group, index })));
37
- for (const instance of group.instances) {
38
- const report = yield* $(group.inspect(instance));
39
- if (report._tag === 'Valid') {
40
- validCount++;
41
- continue;
42
- }
43
- ctx.isInvalid = true;
44
- if (report._tag === 'SemverRangeMismatch') {
45
- yield* $(logSemverRangeMismatch(report));
46
- }
47
- else if (report._tag === 'UnsupportedMismatch') {
48
- yield* $(logUnsupportedMismatch(report));
49
- }
50
- }
51
- }
52
- if (validCount > 0) {
53
- yield* $(logValidSize(validCount));
54
- }
55
- index++;
56
- }
57
- return ctx;
58
- });
59
- }
60
- export function logSemverGroupsDisabledWarning() {
61
- return Effect.logInfo([
62
- chalk `{red ${ICON.panic} it looks like semver ranges have not yet been configured for this project}`,
63
- chalk ` {red see the guide at} {yellow https://jamiemason.github.io/syncpack/guide/semver-groups}`,
64
- ].join(EOL));
65
- }
66
- export function logIgnoredSize(amount) {
67
- const msg = chalk `${padStart(amount)} {dim ${ICON.skip}} ${amount} ignored`;
68
- return Effect.logInfo(msg);
69
- }
70
- function logValidSize(amount) {
71
- const msg = chalk `{green ${ICON.tick}} {dim ${amount} valid}`;
72
- return Effect.logInfo(msg);
73
- }
74
- function logSemverRangeMismatch(report) {
75
- const _tag = report._tag;
76
- const instance = report.fixable.instance;
77
- const name = instance.name;
78
- const actual = instance.rawSpecifier.raw;
79
- const expected = report.fixable.raw;
80
- const propPath = instance.strategy.path;
81
- const filePath = instance.packageJsonFile.jsonFile.shortPath;
82
- return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${filePath} > ${propPath}} {blue [${_tag}]}`);
83
- }
84
- function logUnsupportedMismatch(report) {
85
- const _tag = report._tag;
86
- const instance = report.unfixable;
87
- const name = instance.name;
88
- const actual = instance.rawSpecifier.raw;
89
- const propPath = instance.strategy.path;
90
- const filePath = instance.packageJsonFile.jsonFile.shortPath;
91
- return Effect.logInfo(chalk `{red ${ICON.cross} name {white ${name}} or version {white ${actual}} are not supported} {gray ${filePath} > ${propPath}} {blue [${_tag}]}`);
92
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import { Effect } from 'effect';
4
- import { io } from '../io/index.js';
5
- import { showHelpOnError } from '../lib/show-help-on-error.js';
6
- import { option } from '../option.js';
7
- import { list } from './list.js';
8
- program.description(' List all dependencies required by your packages.');
9
- program.on('--help', () => { });
10
- showHelpOnError(program);
11
- program
12
- .option(...option.source)
13
- .option(...option.filter)
14
- .option(...option.config)
15
- .option(...option.specs)
16
- .option(...option.types)
17
- .parse(process.argv);
18
- Effect.runPromise(list({
19
- io,
20
- cli: {
21
- configPath: program.opts().config,
22
- filter: program.opts().filter,
23
- source: program.opts().source,
24
- specs: program.opts().specs,
25
- types: program.opts().types,
26
- },
27
- }));
@@ -1,14 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { CliConfig } from '../config/types.js';
3
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
4
- import type { Ctx } from '../get-context/index.js';
5
- import type { Io } from '../io/index.js';
6
- interface Input {
7
- io: Io;
8
- cli: Partial<CliConfig>;
9
- errorHandlers?: ErrorHandlers;
10
- }
11
- export declare function list({ io, cli, errorHandlers }: Input): Effect.Effect<unknown, never, never>;
12
- export declare function pipeline(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<Ctx>;
13
- export declare function logOtherCommands(): Effect.Effect<void, never, never>;
14
- export {};
@@ -1,151 +0,0 @@
1
- import { EOL } from 'node:os';
2
- import chalk from 'chalk-template';
3
- import { Context, Effect, pipe } from 'effect';
4
- import { CliConfigTag } from '../config/tag.js';
5
- import { ICON } from '../constants.js';
6
- import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
7
- import { getContext } from '../get-context/index.js';
8
- import { getInstances } from '../get-instances/index.js';
9
- import { exitIfInvalid } from '../io/exit-if-invalid.js';
10
- import { IoTag } from '../io/index.js';
11
- import { getVersionGroupHeader } from '../lib/get-group-header.js';
12
- import { padStart } from '../lib/pad-start.js';
13
- import { withLogger } from '../lib/with-logger.js';
14
- export function list({ io, cli, errorHandlers = defaultErrorHandlers }) {
15
- return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(ctx => pipeline(ctx, io, errorHandlers)), Effect.flatMap(exitIfInvalid), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
16
- }
17
- export function pipeline(ctx, io, errorHandlers) {
18
- return Effect.gen(function* ($) {
19
- const { versionGroups } = yield* $(getInstances(ctx, io, errorHandlers));
20
- let index = 0;
21
- for (const group of versionGroups) {
22
- yield* $(Effect.logInfo(getVersionGroupHeader({ group, index })));
23
- yield* $(onGroupTag[group._tag](group));
24
- if (group._tag === 'Banned' ||
25
- group._tag === 'FilteredOut' ||
26
- group._tag === 'Ignored') {
27
- if (group._tag === 'Banned') {
28
- ctx.isInvalid = true;
29
- }
30
- index++;
31
- continue;
32
- }
33
- for (const groupReport of yield* $(group.inspectAll())) {
34
- const matches = new Set();
35
- const mismatches = new Set();
36
- for (const report of groupReport.reports) {
37
- if (report.isInvalid) {
38
- ctx.isInvalid = true;
39
- }
40
- switch (report._tagGroup) {
41
- case 'Valid': {
42
- const actual = report.specifier.raw;
43
- matches.add(chalk `{gray ${actual}}`);
44
- break;
45
- }
46
- case 'Fixable': {
47
- mismatches.add(getLogForFixable(report));
48
- break;
49
- }
50
- case 'Unfixable': {
51
- mismatches.add(getLogForUnfixable(report));
52
- break;
53
- }
54
- }
55
- }
56
- if (mismatches.size === 0) {
57
- yield* $(logMatchingReport(groupReport, matches));
58
- }
59
- else {
60
- yield* $(logMismatchingReport(groupReport, mismatches));
61
- }
62
- }
63
- index++;
64
- }
65
- yield* $(logOtherCommands());
66
- return ctx;
67
- });
68
- }
69
- const onGroupTag = {
70
- Banned(group) {
71
- return Effect.gen(function* ($) {
72
- for (const groupReport of yield* $(group.inspectAll())) {
73
- const name = groupReport.name;
74
- const usages = `${padStart(groupReport.reports.length)}x`;
75
- const invalidLabel = chalk `{gray ${usages}} {red ${name}}`;
76
- const msg = chalk `${invalidLabel} {gray [Banned]}`;
77
- yield* $(Effect.logInfo(msg));
78
- }
79
- });
80
- },
81
- FilteredOut(group) {
82
- return Effect.gen(function* ($) {
83
- for (const groupReport of yield* $(group.inspectAll())) {
84
- const name = groupReport.name;
85
- const usages = `${padStart(groupReport.reports.length)}x`;
86
- const invalidLabel = chalk `{gray ${usages}} {gray ${name}}`;
87
- const msg = chalk `${invalidLabel} {gray [FilteredOut]}`;
88
- yield* $(Effect.logInfo(msg));
89
- }
90
- });
91
- },
92
- Ignored(group) {
93
- return Effect.gen(function* ($) {
94
- for (const groupReport of yield* $(group.inspectAll())) {
95
- const name = groupReport.name;
96
- const usages = `${padStart(groupReport.reports.length)}x`;
97
- const invalidLabel = chalk `{gray ${usages}} {gray ${name}}`;
98
- const msg = chalk `${invalidLabel} {gray [Ignored]}`;
99
- yield* $(Effect.logInfo(msg));
100
- }
101
- });
102
- },
103
- Pinned(_group) {
104
- return Effect.void;
105
- },
106
- SameRange(_group) {
107
- return Effect.void;
108
- },
109
- SnappedTo(_group) {
110
- return Effect.void;
111
- },
112
- Standard(_group) {
113
- return Effect.void;
114
- },
115
- };
116
- function logMatchingReport(groupReport, messages) {
117
- const name = groupReport.name;
118
- const usages = `${padStart(groupReport.reports.length)}x`;
119
- const label = chalk `{gray ${usages}} ${name}{gray :}`;
120
- return Effect.logInfo(chalk `${label} ${[...messages].join(chalk `{gray , }`)}`);
121
- }
122
- function logMismatchingReport(groupReport, messages) {
123
- const name = groupReport.name;
124
- const usages = `${padStart(groupReport.reports.length)}x`;
125
- const label = chalk `{gray ${usages}} {red ${name}}{gray :}`;
126
- const indent = usages.replace(/./g, ' ');
127
- return Effect.logInfo(chalk `${label}${['', ...messages].join(chalk `${EOL}${indent} {red ${ICON.cross}} `)}`);
128
- }
129
- function getLogForFixable(report) {
130
- const _tag = report._tag;
131
- const actual = report.fixable.instance.rawSpecifier.raw;
132
- const expected = report.fixable.raw;
133
- return chalk `{red ${actual}} {gray ${ICON.rightArrow}} {green ${expected}} {gray [${_tag}]}`;
134
- }
135
- function getLogForUnfixable(report) {
136
- const _tag = report._tag;
137
- const actual = report.unfixable.rawSpecifier.raw;
138
- return chalk `{red ${actual}} {gray ${ICON.rightArrow}} {gray [${_tag}]}`;
139
- }
140
- export function logOtherCommands() {
141
- return Effect.logInfo([
142
- '',
143
- ' What next?',
144
- chalk `{dim -} {yellow syncpack list-mismatches} to see more detail about mismatching versions`,
145
- chalk `{dim -} {yellow syncpack fix-mismatches} to fix version mismatches automatically`,
146
- chalk `{dim -} {yellow syncpack format} to sort and prettify your package.json files`,
147
- chalk `{dim -} {yellow syncpack update} to choose updates from the npm registry`,
148
- chalk `{dim -} {yellow syncpack --help} for everything else`,
149
- '',
150
- ].join(EOL));
151
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import { Effect } from 'effect';
4
- import { io } from '../io/index.js';
5
- import { showHelpOnError } from '../lib/show-help-on-error.js';
6
- import { option } from '../option.js';
7
- import { listMismatches } from './list-mismatches.js';
8
- program.description(`
9
- List dependencies which are required by multiple packages, where the version
10
- is not the same across every package.`.replace(/^\n/, ''));
11
- program.on('--help', () => { });
12
- showHelpOnError(program);
13
- program
14
- .option(...option.source)
15
- .option(...option.filter)
16
- .option(...option.config)
17
- .option(...option.specs)
18
- .option(...option.types)
19
- .parse(process.argv);
20
- Effect.runPromise(listMismatches({
21
- io,
22
- cli: {
23
- configPath: program.opts().config,
24
- filter: program.opts().filter,
25
- source: program.opts().source,
26
- specs: program.opts().specs,
27
- types: program.opts().types,
28
- },
29
- }));
@@ -1,18 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { CliConfig } from '../config/types.js';
3
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
4
- import type { Ctx } from '../get-context/index.js';
5
- import type { Io } from '../io/index.js';
6
- interface Input {
7
- io: Io;
8
- cli: Partial<CliConfig>;
9
- errorHandlers?: ErrorHandlers;
10
- }
11
- export declare function listMismatches({ io, cli, errorHandlers, }: Input): Effect.Effect<unknown, never, never>;
12
- /** Exported to be reused by `syncpack lint` */
13
- export declare function pipeline(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<Ctx>;
14
- export declare const logMissingLocalVersion: (report: any) => Effect.Effect<void>;
15
- export declare const logMissingSnappedToMismatch: (report: any) => Effect.Effect<void>;
16
- export declare const logUnsupportedMismatch: (report: any) => Effect.Effect<void>;
17
- export declare const logSameRangeMismatch: (report: any) => Effect.Effect<void>;
18
- export {};
@@ -1,224 +0,0 @@
1
- import { EOL } from 'node:os';
2
- import chalk from 'chalk-template';
3
- import { Context, Effect, pipe } from 'effect';
4
- import { CliConfigTag } from '../config/tag.js';
5
- import { ICON } from '../constants.js';
6
- import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
7
- import { getContext } from '../get-context/index.js';
8
- import { getInstances } from '../get-instances/index.js';
9
- import { exitIfInvalid } from '../io/exit-if-invalid.js';
10
- import { IoTag } from '../io/index.js';
11
- import { getVersionGroupHeader } from '../lib/get-group-header.js';
12
- import { padStart } from '../lib/pad-start.js';
13
- import { withLogger } from '../lib/with-logger.js';
14
- export function listMismatches({ io, cli, errorHandlers = defaultErrorHandlers, }) {
15
- return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(ctx => pipeline(ctx, io, errorHandlers)), Effect.flatMap(exitIfInvalid), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
16
- }
17
- /** Exported to be reused by `syncpack lint` */
18
- export function pipeline(ctx, io, errorHandlers) {
19
- return Effect.gen(function* ($) {
20
- const { versionGroups } = yield* $(getInstances(ctx, io, errorHandlers));
21
- let index = 0;
22
- for (const group of versionGroups) {
23
- const countByReportGroup = {
24
- Excluded: 0,
25
- Fixable: 0,
26
- Unfixable: 0,
27
- Valid: 0,
28
- };
29
- yield* $(Effect.logInfo(getVersionGroupHeader({ group, index })));
30
- for (const groupReport of yield* $(group.inspectAll())) {
31
- for (const report of groupReport.reports) {
32
- countByReportGroup[report._tagGroup]++;
33
- if (report.isInvalid) {
34
- ctx.isInvalid = true;
35
- }
36
- const logReport = onReportTag[report._tag];
37
- if (logReport) {
38
- yield* $(logReport(report));
39
- }
40
- }
41
- }
42
- yield* $(onReportGroup.Valid(countByReportGroup.Valid));
43
- yield* $(onReportGroup.Fixable(countByReportGroup.Fixable));
44
- yield* $(onReportGroup.Unfixable(countByReportGroup.Unfixable));
45
- yield* $(onReportGroup.Excluded(countByReportGroup.Excluded));
46
- index++;
47
- }
48
- return ctx;
49
- });
50
- }
51
- const onReportGroup = {
52
- Excluded(amount) {
53
- if (amount === 0) {
54
- return Effect.void;
55
- }
56
- const msg = chalk `{gray ${padStart(amount)} ${ICON.rightArrow} ignored}`;
57
- return Effect.logInfo(msg);
58
- },
59
- Fixable(amount) {
60
- if (amount === 0) {
61
- return Effect.void;
62
- }
63
- const msg = chalk `${padStart(amount)} {green ${ICON.tick}} can be auto-fixed`;
64
- return Effect.logInfo(msg);
65
- },
66
- Unfixable(amount) {
67
- if (amount === 0) {
68
- return Effect.void;
69
- }
70
- const msg = chalk `{red ${padStart(amount)} ${ICON.panic} can be fixed manually using} {blue syncpack prompt}`;
71
- return Effect.logInfo(msg);
72
- },
73
- Valid(amount) {
74
- if (amount === 0) {
75
- return Effect.void;
76
- }
77
- const msg = chalk `${padStart(amount)} {green ${ICON.tick}} already valid`;
78
- return Effect.logInfo(msg);
79
- },
80
- };
81
- const onReportTag = {
82
- Banned(report) {
83
- const _tag = report._tag;
84
- const instance = report.fixable.instance;
85
- const name = instance.name;
86
- const jsonFile = instance.packageJsonFile.jsonFile;
87
- const path = instance.strategy.path;
88
- const shortPath = jsonFile.shortPath;
89
- return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red banned} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
90
- },
91
- Disabled(_report) {
92
- return Effect.void;
93
- },
94
- FilteredOut(_report) {
95
- return Effect.void;
96
- },
97
- HighestSemverMismatch(report) {
98
- const _tag = report._tag;
99
- const fixable = report.fixable;
100
- const instance = fixable.instance;
101
- const jsonFile = instance.packageJsonFile.jsonFile;
102
- const actual = instance.rawSpecifier.raw;
103
- const expected = fixable.raw;
104
- const name = instance.name;
105
- const path = instance.strategy.path;
106
- const shortPath = jsonFile.shortPath;
107
- return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
108
- },
109
- Ignored(_report) {
110
- return Effect.void;
111
- },
112
- LocalPackageMismatch(report) {
113
- const _tag = report._tag;
114
- const fixable = report.fixable;
115
- const instance = fixable.instance;
116
- const actual = instance.rawSpecifier.raw;
117
- const expected = fixable.raw;
118
- const name = instance.name;
119
- const path = instance.strategy.path;
120
- const shortPath = instance.packageJsonFile.jsonFile.shortPath;
121
- return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
122
- },
123
- LowestSemverMismatch(report) {
124
- const _tag = report._tag;
125
- const fixable = report.fixable;
126
- const instance = fixable.instance;
127
- const actual = instance.rawSpecifier.raw;
128
- const expected = fixable.raw;
129
- const name = instance.name;
130
- const path = instance.strategy.path;
131
- const shortPath = instance.packageJsonFile.jsonFile.shortPath;
132
- return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
133
- },
134
- MissingLocalVersion(report) {
135
- const instance = report.unfixable;
136
- const localPath = report.localInstance.packageJsonFile.jsonFile.shortPath;
137
- const jsonFile = instance.packageJsonFile.jsonFile;
138
- const actual = instance.rawSpecifier.raw;
139
- const name = instance.name;
140
- const path = instance.strategy.path;
141
- const shortPath = jsonFile.shortPath;
142
- return Effect.logInfo([
143
- chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {blue [MissingLocalVersion]}`,
144
- chalk ` {red ${localPath} does not have a .version property which is exact semver}`,
145
- ].join(EOL));
146
- },
147
- MissingSnappedToMismatch(report) {
148
- const instance = report.unfixable;
149
- const jsonFile = instance.packageJsonFile.jsonFile;
150
- const actual = instance.rawSpecifier.raw;
151
- const name = instance.name;
152
- const path = instance.strategy.path;
153
- const shortPath = jsonFile.shortPath;
154
- return Effect.logInfo([
155
- chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {blue [MissingSnappedToMismatch]}`,
156
- chalk ` {red no package in this groups .snapTo array depend on ${name}}`,
157
- ].join(EOL));
158
- },
159
- PinnedMismatch(report) {
160
- const _tag = report._tag;
161
- const fixable = report.fixable;
162
- const instance = fixable.instance;
163
- const actual = instance.rawSpecifier.raw;
164
- const expected = fixable.raw;
165
- const name = instance.name;
166
- const path = instance.strategy.path;
167
- const shortPath = instance.packageJsonFile.jsonFile.shortPath;
168
- return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
169
- },
170
- SameRangeMismatch(report) {
171
- const instance = report.unfixable;
172
- const jsonFile = instance.packageJsonFile.jsonFile;
173
- const actual = instance.rawSpecifier.raw;
174
- const name = instance.name;
175
- const path = instance.strategy.path;
176
- const shortPath = jsonFile.shortPath;
177
- const mismatches = report.mismatches;
178
- return Effect.logInfo([
179
- chalk `{red ${ICON.cross}} ${name} {red range ${actual} does not include ${mismatches.join(', ')}} {gray ${shortPath} > ${path}} {blue [SameRangeMismatch]}`,
180
- chalk ` {gray use {blue syncpack prompt} to fix this manually}`,
181
- ].join(EOL));
182
- },
183
- SemverRangeMismatch(report) {
184
- const _tag = report._tag;
185
- const fixable = report.fixable;
186
- const instance = fixable.instance;
187
- const actual = instance.rawSpecifier.raw;
188
- const expected = fixable.raw;
189
- const name = instance.name;
190
- const path = instance.strategy.path;
191
- const shortPath = instance.packageJsonFile.jsonFile.shortPath;
192
- return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
193
- },
194
- SnappedToMismatch(report) {
195
- const _tag = report._tag;
196
- const fixable = report.fixable;
197
- const instance = fixable.instance;
198
- const actual = instance.rawSpecifier.raw;
199
- const expected = fixable.raw;
200
- const name = instance.name;
201
- const path = instance.strategy.path;
202
- const shortPath = instance.packageJsonFile.jsonFile.shortPath;
203
- return Effect.logInfo(chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`);
204
- },
205
- UnsupportedMismatch(report) {
206
- const instance = report.unfixable;
207
- const jsonFile = instance.packageJsonFile.jsonFile;
208
- const actual = instance.rawSpecifier.raw;
209
- const name = instance.name;
210
- const path = instance.strategy.path;
211
- const shortPath = jsonFile.shortPath;
212
- return Effect.logInfo([
213
- chalk `{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {blue [UnsupportedMismatch]}`,
214
- chalk ` {red use {blue syncpack prompt} to fix this manually}`,
215
- ].join(EOL));
216
- },
217
- Valid(_report) {
218
- return Effect.void;
219
- },
220
- };
221
- export const logMissingLocalVersion = onReportTag.MissingLocalVersion;
222
- export const logMissingSnappedToMismatch = onReportTag.MissingSnappedToMismatch;
223
- export const logUnsupportedMismatch = onReportTag.UnsupportedMismatch;
224
- export const logSameRangeMismatch = onReportTag.SameRangeMismatch;
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import { Effect } from 'effect';
4
- import { io } from '../io/index.js';
5
- import { showHelpOnError } from '../lib/show-help-on-error.js';
6
- import { option } from '../option.js';
7
- import { prompt } from './prompt.js';
8
- program.description(' displays a series of prompts to fix mismatches which syncpack cannot fix automatically');
9
- program.on('--help', () => { });
10
- showHelpOnError(program);
11
- program
12
- .option(...option.source)
13
- .option(...option.filter)
14
- .option(...option.config)
15
- .option(...option.specs)
16
- .option(...option.types)
17
- .option(...option.indent)
18
- .parse(process.argv);
19
- Effect.runPromise(prompt({
20
- io,
21
- cli: {
22
- configPath: program.opts().config,
23
- filter: program.opts().filter,
24
- source: program.opts().source,
25
- specs: program.opts().specs,
26
- types: program.opts().types,
27
- indent: program.opts().indent,
28
- },
29
- }));
@@ -1,11 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { CliConfig } from '../config/types.js';
3
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
4
- import type { Io } from '../io/index.js';
5
- interface Input {
6
- io: Io;
7
- cli: Partial<CliConfig>;
8
- errorHandlers?: ErrorHandlers;
9
- }
10
- export declare function prompt({ io, cli, errorHandlers, }: Input): Effect.Effect<unknown, never, never>;
11
- export {};