syncpack 12.0.0 → 12.1.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 (43) hide show
  1. package/dist/bin-fix-mismatches/fix-mismatches.js +8 -19
  2. package/dist/bin-fix-mismatches/index.js +1 -1
  3. package/dist/bin-format/index.js +1 -1
  4. package/dist/bin-lint/index.js +1 -1
  5. package/dist/bin-lint-semver-ranges/index.js +1 -1
  6. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +5 -5
  7. package/dist/bin-list/index.js +1 -1
  8. package/dist/bin-list/list.d.ts +2 -0
  9. package/dist/bin-list/list.js +76 -48
  10. package/dist/bin-list-mismatches/index.js +1 -1
  11. package/dist/bin-list-mismatches/list-mismatches.d.ts +4 -5
  12. package/dist/bin-list-mismatches/list-mismatches.js +185 -220
  13. package/dist/bin-prompt/prompt.js +7 -3
  14. package/dist/bin-set-semver-ranges/index.js +1 -1
  15. package/dist/config/get-custom-types.js +2 -1
  16. package/dist/config/types.d.ts +4 -5
  17. package/dist/constants.d.ts +39 -8
  18. package/dist/constants.js +31 -0
  19. package/dist/io/index.d.ts +2 -2
  20. package/dist/io/index.js +1 -1
  21. package/dist/io/read-config-file-sync.js +1 -1
  22. package/dist/option.d.ts +1 -1
  23. package/dist/report.d.ts +64 -99
  24. package/dist/report.js +81 -16
  25. package/dist/schema.json +75 -74
  26. package/dist/semver-group/disabled.js +1 -3
  27. package/dist/semver-group/filtered-out.js +1 -3
  28. package/dist/semver-group/ignored.js +1 -3
  29. package/dist/semver-group/index.d.ts +1 -2
  30. package/dist/semver-group/with-range.js +4 -12
  31. package/dist/specifier/index.d.ts +1 -2
  32. package/dist/specifier/lib/parse-specifier.js +1 -1
  33. package/dist/specifier/workspace-protocol.js +3 -2
  34. package/dist/strategy/name-and-version-props.js +4 -4
  35. package/dist/version-group/banned.js +1 -3
  36. package/dist/version-group/filtered-out.js +1 -1
  37. package/dist/version-group/ignored.js +1 -1
  38. package/dist/version-group/index.d.ts +1 -2
  39. package/dist/version-group/pinned.js +2 -2
  40. package/dist/version-group/same-range.js +5 -10
  41. package/dist/version-group/snapped-to.js +7 -17
  42. package/dist/version-group/standard.js +38 -49
  43. package/package.json +19 -13
@@ -43,38 +43,27 @@ function fixMismatches({ io, cli, errorHandlers = default_error_handlers_1.defau
43
43
  }
44
44
  for (const groupReport of yield* $(group.inspectAll())) {
45
45
  for (const report of groupReport.reports) {
46
- const _tag = report._tag;
47
- if (_tag === 'Valid') {
46
+ if (report._tagGroup === 'Valid') {
48
47
  validCount++;
49
48
  }
50
- else if (_tag === 'Banned' ||
51
- _tag === 'HighestSemverMismatch' ||
52
- _tag === 'LocalPackageMismatch' ||
53
- _tag === 'LowestSemverMismatch' ||
54
- _tag === 'PinnedMismatch' ||
55
- _tag === 'SemverRangeMismatch' ||
56
- _tag === 'SnappedToMismatch') {
49
+ else if (report._tagGroup === 'Fixable') {
57
50
  fixedCount++;
58
51
  yield* $(fixMismatch(report));
59
52
  }
60
- else if (_tag === 'MissingLocalVersion') {
53
+ else if (report._tagGroup === 'Unfixable') {
61
54
  ctx.isInvalid = true;
62
55
  unfixableCount++;
56
+ }
57
+ if (report._tag === 'MissingLocalVersion') {
63
58
  yield* $((0, list_mismatches_1.logMissingLocalVersion)(report));
64
59
  }
65
- else if (_tag === 'MissingSnappedToMismatch') {
66
- ctx.isInvalid = true;
67
- unfixableCount++;
60
+ else if (report._tag === 'MissingSnappedToMismatch') {
68
61
  yield* $((0, list_mismatches_1.logMissingSnappedToMismatch)(report));
69
62
  }
70
- else if (_tag === 'UnsupportedMismatch') {
71
- ctx.isInvalid = true;
72
- unfixableCount++;
63
+ else if (report._tag === 'UnsupportedMismatch') {
73
64
  yield* $((0, list_mismatches_1.logUnsupportedMismatch)(report));
74
65
  }
75
- else if (_tag === 'SameRangeMismatch') {
76
- ctx.isInvalid = true;
77
- unfixableCount++;
66
+ else if (report._tag === 'SameRangeMismatch') {
78
67
  yield* $((0, list_mismatches_1.logSameRangeMismatch)(report));
79
68
  }
80
69
  }
@@ -55,7 +55,7 @@ commander_1.program
55
55
  .option(...option_1.option.config)
56
56
  .option(...option_1.option.indent)
57
57
  .parse(process.argv);
58
- effect_1.Effect.runSync((0, fix_mismatches_1.fixMismatches)({
58
+ effect_1.Effect.runPromise((0, fix_mismatches_1.fixMismatches)({
59
59
  io: io_1.io,
60
60
  cli: {
61
61
  configPath: commander_1.program.opts().config,
@@ -48,7 +48,7 @@ commander_1.program
48
48
  .option(...option_1.option.config)
49
49
  .option(...option_1.option.indent)
50
50
  .parse(process.argv);
51
- effect_1.Effect.runSync((0, format_1.format)({
51
+ effect_1.Effect.runPromise((0, format_1.format)({
52
52
  io: io_1.io,
53
53
  cli: {
54
54
  configPath: commander_1.program.opts().config,
@@ -35,7 +35,7 @@ Reference:
35
35
  });
36
36
  (0, show_help_on_error_1.showHelpOnError)(commander_1.program);
37
37
  commander_1.program.option(...option_1.option.config).parse(process.argv);
38
- effect_1.Effect.runSync((0, lint_1.lint)({
38
+ effect_1.Effect.runPromise((0, lint_1.lint)({
39
39
  io: io_1.io,
40
40
  cli: {
41
41
  configPath: commander_1.program.opts().config,
@@ -57,7 +57,7 @@ commander_1.program
57
57
  .option(...option_1.option.config)
58
58
  .option(...option_1.option.types)
59
59
  .parse(process.argv);
60
- effect_1.Effect.runSync((0, lint_semver_ranges_1.lintSemverRanges)({
60
+ effect_1.Effect.runPromise((0, lint_semver_ranges_1.lintSemverRanges)({
61
61
  io: io_1.io,
62
62
  cli: {
63
63
  configPath: commander_1.program.opts().config,
@@ -43,17 +43,17 @@ function pipeline(ctx, io, errorHandlers) {
43
43
  yield* $(effect_1.Effect.logInfo((0, get_group_header_1.getSemverGroupHeader)({ group, index })));
44
44
  for (const instance of group.instances) {
45
45
  const report = yield* $(group.inspect(instance));
46
+ if (report._tag === 'Valid') {
47
+ validCount++;
48
+ continue;
49
+ }
50
+ ctx.isInvalid = true;
46
51
  if (report._tag === 'SemverRangeMismatch') {
47
- ctx.isInvalid = true;
48
52
  yield* $(logSemverRangeMismatch(report));
49
53
  }
50
54
  else if (report._tag === 'UnsupportedMismatch') {
51
- ctx.isInvalid = true;
52
55
  yield* $(logUnsupportedMismatch(report));
53
56
  }
54
- else {
55
- validCount++;
56
- }
57
57
  }
58
58
  }
59
59
  if (validCount > 0)
@@ -49,7 +49,7 @@ commander_1.program
49
49
  .option(...option_1.option.config)
50
50
  .option(...option_1.option.types)
51
51
  .parse(process.argv);
52
- effect_1.Effect.runSync((0, list_1.list)({
52
+ effect_1.Effect.runPromise((0, list_1.list)({
53
53
  io: io_1.io,
54
54
  cli: {
55
55
  configPath: commander_1.program.opts().config,
@@ -1,6 +1,7 @@
1
1
  import { Effect } from 'effect';
2
2
  import { type CliConfig } from '../config/types';
3
3
  import type { ErrorHandlers } from '../error-handlers/default-error-handlers';
4
+ import type { Ctx } from '../get-context';
4
5
  import type { Io } from '../io';
5
6
  interface Input {
6
7
  io: Io;
@@ -8,5 +9,6 @@ interface Input {
8
9
  errorHandlers?: ErrorHandlers;
9
10
  }
10
11
  export declare function list({ io, cli, errorHandlers }: Input): Effect.Effect<never, never, unknown>;
12
+ export declare function pipeline(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<never, never, Ctx>;
11
13
  export declare function logOtherCommands(): Effect.Effect<never, never, void>;
12
14
  export {};
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.logOtherCommands = exports.list = void 0;
6
+ exports.logOtherCommands = exports.pipeline = exports.list = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const effect_1 = require("effect");
9
9
  const os_1 = require("os");
@@ -18,32 +18,19 @@ const get_group_header_1 = require("../lib/get-group-header");
18
18
  const pad_start_1 = require("../lib/pad-start");
19
19
  const with_logger_1 = require("../lib/with-logger");
20
20
  function list({ io, cli, errorHandlers = default_error_handlers_1.defaultErrorHandlers }) {
21
- return (0, effect_1.pipe)((0, get_context_1.getContext)({ io, cli, errorHandlers }), effect_1.Effect.flatMap((ctx) => effect_1.Effect.gen(function* ($) {
21
+ return (0, effect_1.pipe)((0, get_context_1.getContext)({ io, cli, errorHandlers }), effect_1.Effect.flatMap((ctx) => pipeline(ctx, io, errorHandlers)), effect_1.Effect.flatMap(exit_if_invalid_1.exitIfInvalid), effect_1.Effect.provide((0, effect_1.pipe)(effect_1.Context.empty(), effect_1.Context.add(tag_1.CliConfigTag, cli), effect_1.Context.add(io_1.IoTag, io))), with_logger_1.withLogger);
22
+ }
23
+ exports.list = list;
24
+ function pipeline(ctx, io, errorHandlers) {
25
+ return effect_1.Effect.gen(function* ($) {
22
26
  const { versionGroups } = yield* $((0, get_instances_1.getInstances)(ctx, io, errorHandlers));
23
27
  let index = 0;
24
28
  for (const group of versionGroups) {
25
- const groupSize = group.instances.length;
26
- if (group._tag === 'FilteredOut') {
27
- index++;
28
- continue;
29
- }
30
29
  yield* $(effect_1.Effect.logInfo((0, get_group_header_1.getVersionGroupHeader)({ group, index })));
31
- if (group._tag === 'Ignored') {
32
- const usages = `${(0, pad_start_1.padStart)(groupSize)}x`;
33
- const msg = (0, chalk_1.default) `{gray ${usages} ignored}`;
34
- yield* $(effect_1.Effect.logInfo(msg));
35
- index++;
36
- continue;
37
- }
38
- if (group._tag === 'Banned') {
39
- for (const groupReport of yield* $(group.inspectAll())) {
40
- const name = groupReport.name;
41
- const usages = `${(0, pad_start_1.padStart)(groupReport.reports.length)}x`;
42
- const invalidLabel = (0, chalk_1.default) `{gray ${usages}} {red ${name}}{gray :}`;
43
- const msg = (0, chalk_1.default) `${invalidLabel} {red banned}`;
44
- yield* $(effect_1.Effect.logInfo(msg));
45
- }
46
- ctx.isInvalid = true;
30
+ yield* $(onGroupTag[group._tag](group));
31
+ if (group._tag === 'Banned' || group._tag === 'FilteredOut' || group._tag === 'Ignored') {
32
+ if (group._tag === 'Banned')
33
+ ctx.isInvalid = true;
47
34
  index++;
48
35
  continue;
49
36
  }
@@ -51,28 +38,22 @@ function list({ io, cli, errorHandlers = default_error_handlers_1.defaultErrorHa
51
38
  const matches = new Set();
52
39
  const mismatches = new Set();
53
40
  for (const report of groupReport.reports) {
54
- const _tag = report._tag;
55
- if (_tag === 'Valid') {
56
- const actual = report.specifier.raw;
57
- matches.add(report.specifier._tag === 'UnsupportedSpecifier'
58
- ? (0, chalk_1.default) `{gray ${actual}} {blue [UnsupportedMismatch]}`
59
- : (0, chalk_1.default) `{gray ${actual}}`);
60
- }
61
- else if (_tag === 'HighestSemverMismatch' ||
62
- _tag === 'LocalPackageMismatch' ||
63
- _tag === 'LowestSemverMismatch' ||
64
- _tag === 'PinnedMismatch' ||
65
- _tag === 'SemverRangeMismatch' ||
66
- _tag === 'SnappedToMismatch') {
67
- mismatches.add(getLogForFixable(report));
68
- ctx.isInvalid = true;
69
- }
70
- else if (_tag === 'MissingLocalVersion' ||
71
- _tag === 'MissingSnappedToMismatch' ||
72
- _tag === 'UnsupportedMismatch' ||
73
- _tag === 'SameRangeMismatch') {
74
- mismatches.add(getLogForUnfixable(report));
41
+ if (report.isInvalid)
75
42
  ctx.isInvalid = true;
43
+ switch (report._tagGroup) {
44
+ case 'Valid': {
45
+ const actual = report.specifier.raw;
46
+ matches.add((0, chalk_1.default) `{gray ${actual}}`);
47
+ break;
48
+ }
49
+ case 'Fixable': {
50
+ mismatches.add(getLogForFixable(report));
51
+ break;
52
+ }
53
+ case 'Unfixable': {
54
+ mismatches.add(getLogForUnfixable(report));
55
+ break;
56
+ }
76
57
  }
77
58
  }
78
59
  if (mismatches.size === 0) {
@@ -86,9 +67,56 @@ function list({ io, cli, errorHandlers = default_error_handlers_1.defaultErrorHa
86
67
  }
87
68
  yield* $(logOtherCommands());
88
69
  return ctx;
89
- })), effect_1.Effect.flatMap(exit_if_invalid_1.exitIfInvalid), effect_1.Effect.provide((0, effect_1.pipe)(effect_1.Context.empty(), effect_1.Context.add(tag_1.CliConfigTag, cli), effect_1.Context.add(io_1.IoTag, io))), with_logger_1.withLogger);
70
+ });
90
71
  }
91
- exports.list = list;
72
+ exports.pipeline = pipeline;
73
+ const onGroupTag = {
74
+ Banned(group) {
75
+ return effect_1.Effect.gen(function* ($) {
76
+ for (const groupReport of yield* $(group.inspectAll())) {
77
+ const name = groupReport.name;
78
+ const usages = `${(0, pad_start_1.padStart)(groupReport.reports.length)}x`;
79
+ const invalidLabel = (0, chalk_1.default) `{gray ${usages}} {red ${name}}`;
80
+ const msg = (0, chalk_1.default) `${invalidLabel} {gray [Banned]}`;
81
+ yield* $(effect_1.Effect.logInfo(msg));
82
+ }
83
+ });
84
+ },
85
+ FilteredOut(group) {
86
+ return effect_1.Effect.gen(function* ($) {
87
+ for (const groupReport of yield* $(group.inspectAll())) {
88
+ const name = groupReport.name;
89
+ const usages = `${(0, pad_start_1.padStart)(groupReport.reports.length)}x`;
90
+ const invalidLabel = (0, chalk_1.default) `{gray ${usages}} {gray ${name}}`;
91
+ const msg = (0, chalk_1.default) `${invalidLabel} {gray [FilteredOut]}`;
92
+ yield* $(effect_1.Effect.logInfo(msg));
93
+ }
94
+ });
95
+ },
96
+ Ignored(group) {
97
+ return effect_1.Effect.gen(function* ($) {
98
+ for (const groupReport of yield* $(group.inspectAll())) {
99
+ const name = groupReport.name;
100
+ const usages = `${(0, pad_start_1.padStart)(groupReport.reports.length)}x`;
101
+ const invalidLabel = (0, chalk_1.default) `{gray ${usages}} {gray ${name}}`;
102
+ const msg = (0, chalk_1.default) `${invalidLabel} {gray [Ignored]}`;
103
+ yield* $(effect_1.Effect.logInfo(msg));
104
+ }
105
+ });
106
+ },
107
+ Pinned(_group) {
108
+ return effect_1.Effect.unit;
109
+ },
110
+ SameRange(_group) {
111
+ return effect_1.Effect.unit;
112
+ },
113
+ SnappedTo(_group) {
114
+ return effect_1.Effect.unit;
115
+ },
116
+ Standard(_group) {
117
+ return effect_1.Effect.unit;
118
+ },
119
+ };
92
120
  function logMatchingReport(groupReport, messages) {
93
121
  const name = groupReport.name;
94
122
  const usages = `${(0, pad_start_1.padStart)(groupReport.reports.length)}x`;
@@ -106,12 +134,12 @@ function getLogForFixable(report) {
106
134
  const _tag = report._tag;
107
135
  const actual = report.fixable.instance.rawSpecifier;
108
136
  const expected = report.fixable.raw;
109
- return (0, chalk_1.default) `{red ${actual}} {gray ${constants_1.ICON.rightArrow}} {green ${expected}} {blue [${_tag}]}`;
137
+ return (0, chalk_1.default) `{red ${actual}} {gray ${constants_1.ICON.rightArrow}} {green ${expected}} {gray [${_tag}]}`;
110
138
  }
111
139
  function getLogForUnfixable(report) {
112
140
  const _tag = report._tag;
113
141
  const actual = report.unfixable.rawSpecifier;
114
- return (0, chalk_1.default) `{red ${actual}} {gray ${constants_1.ICON.rightArrow}} {blue [${_tag}]}`;
142
+ return (0, chalk_1.default) `{red ${actual}} {gray ${constants_1.ICON.rightArrow}} {gray [${_tag}]}`;
115
143
  }
116
144
  function logOtherCommands() {
117
145
  return effect_1.Effect.logInfo([
@@ -51,7 +51,7 @@ commander_1.program
51
51
  .option(...option_1.option.config)
52
52
  .option(...option_1.option.types)
53
53
  .parse(process.argv);
54
- effect_1.Effect.runSync((0, list_mismatches_1.listMismatches)({
54
+ effect_1.Effect.runPromise((0, list_mismatches_1.listMismatches)({
55
55
  io: io_1.io,
56
56
  cli: {
57
57
  configPath: commander_1.program.opts().config,
@@ -3,7 +3,6 @@ import { type CliConfig } from '../config/types';
3
3
  import type { ErrorHandlers } from '../error-handlers/default-error-handlers';
4
4
  import type { Ctx } from '../get-context';
5
5
  import type { Io } from '../io';
6
- import type { Report } from '../report';
7
6
  interface Input {
8
7
  io: Io;
9
8
  cli: Partial<CliConfig>;
@@ -12,8 +11,8 @@ interface Input {
12
11
  export declare function listMismatches({ io, cli, errorHandlers }: Input): Effect.Effect<never, never, unknown>;
13
12
  /** Exported to be reused by `syncpack lint` */
14
13
  export declare function pipeline(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<never, never, Ctx>;
15
- export declare function logMissingLocalVersion(report: Report.MissingLocalVersion): Effect.Effect<never, never, void>;
16
- export declare function logMissingSnappedToMismatch(report: Report.MissingSnappedToMismatch): Effect.Effect<never, never, void>;
17
- export declare function logUnsupportedMismatch(report: Report.UnsupportedMismatch): Effect.Effect<never, never, void>;
18
- export declare function logSameRangeMismatch(report: Report.SameRangeMismatch): Effect.Effect<never, never, void>;
14
+ export declare const logMissingLocalVersion: (report: any) => Effect.Effect<never, never, void>;
15
+ export declare const logMissingSnappedToMismatch: (report: any) => Effect.Effect<never, never, void>;
16
+ export declare const logUnsupportedMismatch: (report: any) => Effect.Effect<never, never, void>;
17
+ export declare const logSameRangeMismatch: (report: any) => Effect.Effect<never, never, void>;
19
18
  export {};