syncpack 10.7.2 → 10.9.3

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 (67) hide show
  1. package/dist/bin-fix-mismatches/effects.js +9 -9
  2. package/dist/bin-format/format.js +4 -3
  3. package/dist/bin-lint-semver-ranges/effects.js +10 -10
  4. package/dist/bin-list/effects.js +16 -14
  5. package/dist/bin-list-mismatches/effects.js +22 -22
  6. package/dist/bin-prompt/effects.js +15 -15
  7. package/dist/bin-set-semver-ranges/effects.js +10 -10
  8. package/dist/bin-update/effects.js +36 -30
  9. package/dist/bin-update/update.js +1 -1
  10. package/dist/config/get-enabled-types.js +1 -1
  11. package/dist/create-program/effects.d.ts +4 -4
  12. package/dist/create-program/semver-ranges.js +6 -6
  13. package/dist/create-program/versions.js +6 -6
  14. package/dist/env/create-env.js +28 -7
  15. package/dist/env/default-env.js +2 -1
  16. package/dist/env/exit-if-invalid.js +1 -1
  17. package/dist/env/write-if-changed.js +1 -1
  18. package/dist/get-context/index.js +1 -1
  19. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +1 -1
  20. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +1 -1
  21. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +9 -6
  22. package/dist/get-package-json-files/get-patterns/read-json-safe.js +5 -2
  23. package/dist/get-package-json-files/package-json-file.d.ts +4 -2
  24. package/dist/get-package-json-files/package-json-file.js +5 -4
  25. package/dist/get-semver-groups/filtered-out.d.ts +3 -3
  26. package/dist/get-semver-groups/ignored.d.ts +3 -3
  27. package/dist/get-semver-groups/index.d.ts +16 -16
  28. package/dist/get-semver-groups/index.js +5 -5
  29. package/dist/get-semver-groups/with-range.d.ts +4 -4
  30. package/dist/get-semver-groups/with-range.js +9 -9
  31. package/dist/get-version-groups/banned.d.ts +3 -3
  32. package/dist/get-version-groups/filtered-out.d.ts +3 -3
  33. package/dist/get-version-groups/ignored.d.ts +3 -3
  34. package/dist/get-version-groups/index.d.ts +70 -22
  35. package/dist/get-version-groups/index.js +53 -5
  36. package/dist/get-version-groups/lib/{sort.js → compare-semver.js} +0 -5
  37. package/dist/get-version-groups/lib/get-highest-version.js +2 -2
  38. package/dist/get-version-groups/lib/get-lowest-version.js +2 -2
  39. package/dist/get-version-groups/lib/get-unique-specifiers.d.ts +2 -0
  40. package/dist/get-version-groups/lib/get-unique-specifiers.js +11 -0
  41. package/dist/get-version-groups/pinned.d.ts +3 -3
  42. package/dist/get-version-groups/pinned.js +1 -1
  43. package/dist/get-version-groups/same-range.d.ts +3 -3
  44. package/dist/get-version-groups/same-range.js +4 -1
  45. package/dist/get-version-groups/snapped-to.d.ts +3 -3
  46. package/dist/get-version-groups/snapped-to.js +4 -3
  47. package/dist/get-version-groups/standard.d.ts +4 -4
  48. package/dist/get-version-groups/standard.js +19 -29
  49. package/dist/guards/can-add-to-group.d.ts +2 -2
  50. package/dist/guards/is-loose-semver.d.ts +1 -0
  51. package/dist/guards/is-loose-semver.js +1 -0
  52. package/dist/guards/is-semver.d.ts +1 -0
  53. package/dist/guards/is-semver.js +1 -0
  54. package/dist/guards/is-valid-semver-range.d.ts +1 -0
  55. package/dist/guards/is-valid-semver-range.js +1 -0
  56. package/dist/instance/create.d.ts +4 -0
  57. package/dist/instance/create.js +142 -0
  58. package/dist/instance/index.d.ts +122 -0
  59. package/dist/instance/index.js +154 -0
  60. package/package.json +18 -16
  61. package/dist/get-package-json-files/instance.d.ts +0 -21
  62. package/dist/get-package-json-files/instance.js +0 -23
  63. package/dist/get-version-groups/lib/get-unique-versions.d.ts +0 -2
  64. package/dist/get-version-groups/lib/get-unique-versions.js +0 -8
  65. package/dist/guards/is-supported.d.ts +0 -1
  66. package/dist/guards/is-supported.js +0 -17
  67. /package/dist/get-version-groups/lib/{sort.d.ts → compare-semver.d.ts} +0 -0
@@ -3,7 +3,7 @@ import * as Effect from '@effect/io/Effect';
3
3
  import type { Union } from 'ts-toolbelt';
4
4
  import type { DeprecatedTypesError } from '../config/get-enabled-types';
5
5
  import type { Ctx } from '../get-context';
6
- import type { Instance } from '../get-package-json-files/instance';
6
+ import type { Instance } from '../instance';
7
7
  import { BannedVersionGroup } from './banned';
8
8
  import { FilteredOutVersionGroup } from './filtered-out';
9
9
  import { IgnoredVersionGroup } from './ignored';
@@ -16,27 +16,39 @@ export declare namespace VersionGroupReport {
16
16
  const Banned_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
17
17
  _tag: "Banned";
18
18
  }>;
19
+ /**
20
+ * Every instance in this `BannedVersionGroup` matched its configuration and
21
+ * will be removed if fixed
22
+ */
19
23
  export class Banned extends Banned_base<{
20
24
  name: string;
21
- instances: Instance[];
25
+ instances: Instance.Any[];
22
26
  readonly isValid: false;
23
27
  }> {
24
28
  }
25
29
  const FilteredOut_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
26
30
  _tag: "FilteredOut";
27
31
  }>;
32
+ /**
33
+ * Every instance in this `FilteredOutVersionGroup` has name which does not
34
+ * match the RegExp produced by the `--filter` option.
35
+ */
28
36
  export class FilteredOut extends FilteredOut_base<{
29
37
  name: string;
30
- instances: Instance[];
38
+ instances: Instance.Any[];
31
39
  readonly isValid: true;
32
40
  }> {
33
41
  }
34
42
  const HighestSemverMismatch_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
35
43
  _tag: "HighestSemverMismatch";
36
44
  }>;
45
+ /**
46
+ * One or more instances has a version which is not identical to the others,
47
+ * to resolve this issue the highest semver version present should be used
48
+ */
37
49
  export class HighestSemverMismatch extends HighestSemverMismatch_base<{
38
50
  name: string;
39
- instances: Instance[];
51
+ instances: Instance.Any[];
40
52
  readonly isValid: false;
41
53
  readonly expectedVersion: string;
42
54
  }> {
@@ -44,18 +56,25 @@ export declare namespace VersionGroupReport {
44
56
  const Ignored_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
45
57
  _tag: "Ignored";
46
58
  }>;
59
+ /**
60
+ * Every instance in this `IgnoredVersionGroup` matched its configuration
61
+ */
47
62
  export class Ignored extends Ignored_base<{
48
63
  name: string;
49
- instances: Instance[];
64
+ instances: Instance.Any[];
50
65
  readonly isValid: true;
51
66
  }> {
52
67
  }
53
68
  const LowestSemverMismatch_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
54
69
  _tag: "LowestSemverMismatch";
55
70
  }>;
71
+ /**
72
+ * One or more instances has a version which is not identical to the others,
73
+ * to resolve this issue the lowest semver version present should be used
74
+ */
56
75
  export class LowestSemverMismatch extends LowestSemverMismatch_base<{
57
76
  name: string;
58
- instances: Instance[];
77
+ instances: Instance.Any[];
59
78
  readonly isValid: false;
60
79
  readonly expectedVersion: string;
61
80
  }> {
@@ -63,9 +82,13 @@ export declare namespace VersionGroupReport {
63
82
  const PinnedMismatch_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
64
83
  _tag: "PinnedMismatch";
65
84
  }>;
85
+ /**
86
+ * One or more instances has a version which is not identical to the
87
+ * `pinVersion` value set in this `PinnedVersionGroup`
88
+ */
66
89
  export class PinnedMismatch extends PinnedMismatch_base<{
67
90
  name: string;
68
- instances: Instance[];
91
+ instances: Instance.Any[];
69
92
  readonly isValid: false;
70
93
  readonly expectedVersion: string;
71
94
  }> {
@@ -73,56 +96,81 @@ export declare namespace VersionGroupReport {
73
96
  const SameRangeMismatch_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
74
97
  _tag: "SameRangeMismatch";
75
98
  }>;
99
+ /**
100
+ * One or more instances has a version which is not satisfied by the semver
101
+ * version ranges defined by every other instance of this same dependency. In
102
+ * a `SameRangeVersionGroup`, each version does not have to be indentical, but
103
+ * they do have to all satisfy the ranges set by the others.
104
+ */
76
105
  export class SameRangeMismatch extends SameRangeMismatch_base<{
77
106
  name: string;
78
- instances: Instance[];
107
+ instances: Instance.Any[];
79
108
  readonly isValid: false;
80
109
  }> {
81
110
  }
82
111
  const SnappedToMismatch_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
83
112
  _tag: "SnappedToMismatch";
84
113
  }>;
114
+ /**
115
+ * One or more instances has a version which does not match the version used
116
+ * in any of the locally developed packages whose names are set in the
117
+ * `snapTo` array of this `SnappedToVersionGroup`
118
+ */
85
119
  export class SnappedToMismatch extends SnappedToMismatch_base<{
86
120
  name: string;
87
- instances: Instance[];
121
+ instances: Instance.Any[];
88
122
  readonly isValid: false;
89
123
  readonly expectedVersion: string;
90
124
  readonly snapTo: string[];
91
125
  }> {
92
126
  }
93
- const UnsupportedMismatch_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
94
- _tag: "UnsupportedMismatch";
127
+ const NonSemverMismatch_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
128
+ _tag: "NonSemverMismatch";
95
129
  }>;
96
- export class UnsupportedMismatch extends UnsupportedMismatch_base<{
130
+ /**
131
+ * One or more instances has a version which does not match the others and
132
+ * also, at least one of the instances has a version which is not semver.
133
+ * Syncpack cannot guess what any given Developer will want to do in this
134
+ * situation
135
+ */
136
+ export class NonSemverMismatch extends NonSemverMismatch_base<{
97
137
  name: string;
98
- instances: Instance[];
138
+ instances: Instance.Any[];
99
139
  readonly isValid: false;
100
140
  }> {
101
141
  }
102
142
  const Valid_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
103
143
  _tag: "Valid";
104
144
  }>;
145
+ /**
146
+ * Every instance satisfies the rules of the Version Group they belong to
147
+ */
105
148
  export class Valid extends Valid_base<{
106
149
  name: string;
107
- instances: Instance[];
150
+ instances: Instance.Any[];
108
151
  readonly isValid: true;
109
152
  }> {
110
153
  }
111
- const WorkspaceMismatch_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
112
- _tag: "WorkspaceMismatch";
154
+ const LocalPackageMismatch_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
155
+ _tag: "LocalPackageMismatch";
113
156
  }>;
114
- export class WorkspaceMismatch extends WorkspaceMismatch_base<{
157
+ /**
158
+ * This dependency is one of the packages developed in this monorepo and one
159
+ * or more of the packages in this monorepo depend on it with a version which
160
+ * is not identical to the `.version` property of its package.json file
161
+ */
162
+ export class LocalPackageMismatch extends LocalPackageMismatch_base<{
115
163
  name: string;
116
- instances: Instance[];
164
+ instances: Instance.Any[];
117
165
  readonly isValid: false;
118
166
  readonly expectedVersion: string;
119
- readonly workspaceInstance: Instance;
167
+ readonly localPackageInstance: Instance.Any;
120
168
  }> {
121
169
  }
122
170
  export type ValidCases = Union.Strict<FilteredOut | Ignored | Valid>;
123
- export type InvalidCases = Union.Strict<Banned | HighestSemverMismatch | LowestSemverMismatch | PinnedMismatch | SameRangeMismatch | SnappedToMismatch | UnsupportedMismatch | WorkspaceMismatch>;
124
- export type FixableCases = Union.Strict<HighestSemverMismatch | LowestSemverMismatch | PinnedMismatch | SnappedToMismatch | WorkspaceMismatch>;
125
- export type UnfixableCases = Union.Strict<SameRangeMismatch | UnsupportedMismatch | WorkspaceMismatch>;
171
+ export type InvalidCases = Union.Strict<Banned | HighestSemverMismatch | LowestSemverMismatch | PinnedMismatch | SameRangeMismatch | SnappedToMismatch | NonSemverMismatch | LocalPackageMismatch>;
172
+ export type FixableCases = Union.Strict<HighestSemverMismatch | LowestSemverMismatch | PinnedMismatch | SnappedToMismatch | LocalPackageMismatch>;
173
+ export type UnfixableCases = Union.Strict<SameRangeMismatch | NonSemverMismatch | LocalPackageMismatch>;
126
174
  export type HighLowSemverMismatch = VersionGroupReport.HighestSemverMismatch | VersionGroupReport.LowestSemverMismatch;
127
175
  export type Any = Union.Strict<ValidCases | InvalidCases>;
128
176
  export {};
@@ -43,45 +43,93 @@ const snapped_to_1 = require("./snapped-to");
43
43
  const standard_1 = require("./standard");
44
44
  var VersionGroupReport;
45
45
  (function (VersionGroupReport) {
46
+ /**
47
+ * Every instance in this `BannedVersionGroup` matched its configuration and
48
+ * will be removed if fixed
49
+ */
46
50
  class Banned extends Data.TaggedClass('Banned') {
47
51
  }
48
52
  VersionGroupReport.Banned = Banned;
53
+ /**
54
+ * Every instance in this `FilteredOutVersionGroup` has name which does not
55
+ * match the RegExp produced by the `--filter` option.
56
+ */
49
57
  class FilteredOut extends Data.TaggedClass('FilteredOut') {
50
58
  }
51
59
  VersionGroupReport.FilteredOut = FilteredOut;
60
+ /**
61
+ * One or more instances has a version which is not identical to the others,
62
+ * to resolve this issue the highest semver version present should be used
63
+ */
52
64
  class HighestSemverMismatch extends Data.TaggedClass('HighestSemverMismatch') {
53
65
  }
54
66
  VersionGroupReport.HighestSemverMismatch = HighestSemverMismatch;
67
+ /**
68
+ * Every instance in this `IgnoredVersionGroup` matched its configuration
69
+ */
55
70
  class Ignored extends Data.TaggedClass('Ignored') {
56
71
  }
57
72
  VersionGroupReport.Ignored = Ignored;
73
+ /**
74
+ * One or more instances has a version which is not identical to the others,
75
+ * to resolve this issue the lowest semver version present should be used
76
+ */
58
77
  class LowestSemverMismatch extends Data.TaggedClass('LowestSemverMismatch') {
59
78
  }
60
79
  VersionGroupReport.LowestSemverMismatch = LowestSemverMismatch;
80
+ /**
81
+ * One or more instances has a version which is not identical to the
82
+ * `pinVersion` value set in this `PinnedVersionGroup`
83
+ */
61
84
  class PinnedMismatch extends Data.TaggedClass('PinnedMismatch') {
62
85
  }
63
86
  VersionGroupReport.PinnedMismatch = PinnedMismatch;
87
+ /**
88
+ * One or more instances has a version which is not satisfied by the semver
89
+ * version ranges defined by every other instance of this same dependency. In
90
+ * a `SameRangeVersionGroup`, each version does not have to be indentical, but
91
+ * they do have to all satisfy the ranges set by the others.
92
+ */
64
93
  class SameRangeMismatch extends Data.TaggedClass('SameRangeMismatch') {
65
94
  }
66
95
  VersionGroupReport.SameRangeMismatch = SameRangeMismatch;
96
+ /**
97
+ * One or more instances has a version which does not match the version used
98
+ * in any of the locally developed packages whose names are set in the
99
+ * `snapTo` array of this `SnappedToVersionGroup`
100
+ */
67
101
  class SnappedToMismatch extends Data.TaggedClass('SnappedToMismatch') {
68
102
  }
69
103
  VersionGroupReport.SnappedToMismatch = SnappedToMismatch;
70
- class UnsupportedMismatch extends Data.TaggedClass('UnsupportedMismatch') {
104
+ /**
105
+ * One or more instances has a version which does not match the others and
106
+ * also, at least one of the instances has a version which is not semver.
107
+ * Syncpack cannot guess what any given Developer will want to do in this
108
+ * situation
109
+ */
110
+ class NonSemverMismatch extends Data.TaggedClass('NonSemverMismatch') {
71
111
  }
72
- VersionGroupReport.UnsupportedMismatch = UnsupportedMismatch;
112
+ VersionGroupReport.NonSemverMismatch = NonSemverMismatch;
113
+ /**
114
+ * Every instance satisfies the rules of the Version Group they belong to
115
+ */
73
116
  class Valid extends Data.TaggedClass('Valid') {
74
117
  }
75
118
  VersionGroupReport.Valid = Valid;
76
- class WorkspaceMismatch extends Data.TaggedClass('WorkspaceMismatch') {
119
+ /**
120
+ * This dependency is one of the packages developed in this monorepo and one
121
+ * or more of the packages in this monorepo depend on it with a version which
122
+ * is not identical to the `.version` property of its package.json file
123
+ */
124
+ class LocalPackageMismatch extends Data.TaggedClass('LocalPackageMismatch') {
77
125
  }
78
- VersionGroupReport.WorkspaceMismatch = WorkspaceMismatch;
126
+ VersionGroupReport.LocalPackageMismatch = LocalPackageMismatch;
79
127
  })(VersionGroupReport || (exports.VersionGroupReport = VersionGroupReport = {}));
80
128
  class VersionGroupConfigError extends Data.TaggedClass('VersionGroupConfigError') {
81
129
  }
82
130
  exports.VersionGroupConfigError = VersionGroupConfigError;
83
131
  function getVersionGroups(ctx) {
84
- return (0, Function_1.pipe)(Effect.Do(), Effect.bind('enabledTypes', () => (0, get_enabled_types_1.getEnabledTypes)(ctx.config)), Effect.bind('versionGroups', () => createVersionGroups(ctx)), Effect.flatMap(({ enabledTypes, versionGroups }) => {
132
+ return (0, Function_1.pipe)(Effect.Do, Effect.bind('enabledTypes', () => (0, get_enabled_types_1.getEnabledTypes)(ctx.config)), Effect.bind('versionGroups', () => createVersionGroups(ctx)), Effect.flatMap(({ enabledTypes, versionGroups }) => {
85
133
  for (const file of ctx.packageJsonFiles) {
86
134
  instances: for (const instance of file.getInstances(enabledTypes)) {
87
135
  for (const group of versionGroups) {
@@ -6,17 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.compareSemver = void 0;
7
7
  const gt_1 = __importDefault(require("semver/functions/gt"));
8
8
  const lt_1 = __importDefault(require("semver/functions/lt"));
9
- const is_supported_1 = require("../../guards/is-supported");
10
9
  const clean_1 = require("./clean");
11
10
  const get_range_score_1 = require("./get-range-score");
12
11
  const EQ = 0;
13
12
  const LT = -1;
14
13
  const GT = 1;
15
14
  function compareSemver(a, b) {
16
- if (!(0, is_supported_1.isSupported)(a))
17
- throw new Error(`"${a}" is not supported`);
18
- if (!(0, is_supported_1.isSupported)(b))
19
- throw new Error(`"${b}" is not supported`);
20
15
  if (a.startsWith('workspace:'))
21
16
  return LT;
22
17
  if (b.startsWith('workspace:'))
@@ -6,8 +6,8 @@ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
6
6
  const filter_1 = require("tightrope/result/filter");
7
7
  const from_try_1 = require("tightrope/result/from-try");
8
8
  const map_1 = require("tightrope/result/map");
9
- const sort_1 = require("./sort");
9
+ const compare_semver_1 = require("./compare-semver");
10
10
  function getHighestVersion(versions) {
11
- return (0, Function_1.pipe)((0, from_try_1.fromTry)(() => [...versions].sort(sort_1.compareSemver)), (0, map_1.map)((sorted) => sorted[sorted.length - 1]), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString, 'getHighestVersion(): did not return a version'));
11
+ return (0, Function_1.pipe)((0, from_try_1.fromTry)(() => [...versions].sort(compare_semver_1.compareSemver)), (0, map_1.map)((sorted) => sorted[sorted.length - 1]), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString, 'getHighestVersion(): did not return a version'));
12
12
  }
13
13
  exports.getHighestVersion = getHighestVersion;
@@ -6,8 +6,8 @@ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
6
6
  const filter_1 = require("tightrope/result/filter");
7
7
  const from_try_1 = require("tightrope/result/from-try");
8
8
  const map_1 = require("tightrope/result/map");
9
- const sort_1 = require("./sort");
9
+ const compare_semver_1 = require("./compare-semver");
10
10
  function getLowestVersion(versions) {
11
- return (0, Function_1.pipe)((0, from_try_1.fromTry)(() => [...versions].sort(sort_1.compareSemver)), (0, map_1.map)(([lowest]) => lowest), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString, 'getLowestVersion(): did not return a version'));
11
+ return (0, Function_1.pipe)((0, from_try_1.fromTry)(() => [...versions].sort(compare_semver_1.compareSemver)), (0, map_1.map)(([lowest]) => lowest), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString, 'getLowestVersion(): did not return a version'));
12
12
  }
13
13
  exports.getLowestVersion = getLowestVersion;
@@ -0,0 +1,2 @@
1
+ import type { Instance } from '../../instance';
2
+ export declare function getUniqueSpecifiers(instances: Instance.Any[]): Instance.Any[];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUniqueSpecifiers = void 0;
4
+ function getUniqueSpecifiers(instances) {
5
+ const instancesBySpecifier = {};
6
+ instances.forEach((instance) => {
7
+ instancesBySpecifier[instance.specifier] = instance;
8
+ });
9
+ return Object.values(instancesBySpecifier);
10
+ }
11
+ exports.getUniqueSpecifiers = getUniqueSpecifiers;
@@ -2,16 +2,16 @@ import * as Data from '@effect/data/Data';
2
2
  import * as Effect from '@effect/io/Effect';
3
3
  import { VersionGroupReport } from '.';
4
4
  import type { VersionGroupConfig } from '../config/types';
5
- import type { Instance } from '../get-package-json-files/instance';
5
+ import type { Instance } from '../instance';
6
6
  declare const PinnedVersionGroup_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
7
7
  _tag: "Pinned";
8
8
  }>;
9
9
  export declare class PinnedVersionGroup extends PinnedVersionGroup_base<{
10
10
  config: VersionGroupConfig.Pinned;
11
- instances: Instance[];
11
+ instances: Instance.Any[];
12
12
  }> {
13
13
  constructor(config: VersionGroupConfig.Pinned);
14
- canAdd(_: Instance): boolean;
14
+ canAdd(_: Instance.Any): boolean;
15
15
  inspect(): Effect.Effect<never, VersionGroupReport.PinnedMismatch, VersionGroupReport.Valid>[];
16
16
  }
17
17
  export {};
@@ -62,5 +62,5 @@ class PinnedVersionGroup extends Data.TaggedClass('Pinned') {
62
62
  }
63
63
  exports.PinnedVersionGroup = PinnedVersionGroup;
64
64
  function hasMismatch(pinVersion, instances) {
65
- return instances.some((instance) => instance.version !== pinVersion);
65
+ return instances.some((instance) => instance.specifier !== pinVersion);
66
66
  }
@@ -2,16 +2,16 @@ import * as Data from '@effect/data/Data';
2
2
  import * as Effect from '@effect/io/Effect';
3
3
  import { VersionGroupReport } from '.';
4
4
  import type { VersionGroupConfig } from '../config/types';
5
- import type { Instance } from '../get-package-json-files/instance';
5
+ import type { Instance } from '../instance';
6
6
  declare const SameRangeVersionGroup_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
7
7
  _tag: "SameRange";
8
8
  }>;
9
9
  export declare class SameRangeVersionGroup extends SameRangeVersionGroup_base<{
10
10
  config: VersionGroupConfig.SameRange;
11
- instances: Instance[];
11
+ instances: Instance.Any[];
12
12
  }> {
13
13
  constructor(config: VersionGroupConfig.SameRange);
14
- canAdd(_: Instance): boolean;
14
+ canAdd(_: Instance.Any): boolean;
15
15
  inspect(): Effect.Effect<never, VersionGroupReport.SameRangeMismatch, VersionGroupReport.Valid>[];
16
16
  }
17
17
  export {};
@@ -66,5 +66,8 @@ exports.SameRangeVersionGroup = SameRangeVersionGroup;
66
66
  /** Every range must fall within every other range */
67
67
  function hasMismatch(instances) {
68
68
  const loose = true;
69
- return instances.some((a) => instances.some((b) => !(0, intersects_1.default)(a.version, b.version, loose)));
69
+ return instances.some((a) => instances.some((b) => !(0, intersects_1.default)(aliasWorkspaceRange(a.specifier), aliasWorkspaceRange(b.specifier), loose)));
70
+ }
71
+ function aliasWorkspaceRange(version) {
72
+ return version.startsWith('workspace:*') ? '*' : version;
70
73
  }
@@ -2,16 +2,16 @@ import * as Data from '@effect/data/Data';
2
2
  import * as Effect from '@effect/io/Effect';
3
3
  import { VersionGroupReport } from '.';
4
4
  import type { VersionGroupConfig } from '../config/types';
5
- import type { Instance } from '../get-package-json-files/instance';
5
+ import type { Instance } from '../instance';
6
6
  declare const SnappedToVersionGroup_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
7
7
  _tag: "SnappedTo";
8
8
  }>;
9
9
  export declare class SnappedToVersionGroup extends SnappedToVersionGroup_base<{
10
10
  config: VersionGroupConfig.SnappedTo;
11
- instances: Instance[];
11
+ instances: Instance.Any[];
12
12
  }> {
13
13
  constructor(config: VersionGroupConfig.SnappedTo);
14
- canAdd(_: Instance): boolean;
14
+ canAdd(_: Instance.Any): boolean;
15
15
  inspect(): Effect.Effect<never, VersionGroupReport.SnappedToMismatch, VersionGroupReport.Valid>[];
16
16
  }
17
17
  export {};
@@ -64,14 +64,15 @@ class SnappedToVersionGroup extends Data.TaggedClass('SnappedTo') {
64
64
  }
65
65
  exports.SnappedToVersionGroup = SnappedToVersionGroup;
66
66
  function getExpectedVersion(snapTo, instances) {
67
- const expectedVersion = instances
67
+ var _a;
68
+ const expectedVersion = (_a = instances
68
69
  .filter((i) => snapTo.includes(i.pkgName))
69
- .find((i) => i.version)?.version;
70
+ .find((i) => i.specifier)) === null || _a === void 0 ? void 0 : _a.specifier;
70
71
  if (expectedVersion)
71
72
  return expectedVersion;
72
73
  // @FIXME: create tagged error for this
73
74
  throw new Error('versionGroup.snapTo does not match any package versions');
74
75
  }
75
76
  function hasMismatch(expectedVersion, instances) {
76
- return instances.some((instance) => instance.version !== expectedVersion);
77
+ return instances.some((instance) => instance.specifier !== expectedVersion);
77
78
  }
@@ -2,17 +2,17 @@ import * as Data from '@effect/data/Data';
2
2
  import * as Effect from '@effect/io/Effect';
3
3
  import { VersionGroupReport } from '.';
4
4
  import type { VersionGroupConfig } from '../config/types';
5
- import type { Instance } from '../get-package-json-files/instance';
5
+ import type { Instance } from '../instance';
6
6
  declare const StandardVersionGroup_base: new <A extends Record<string, any>>(args: Data.IsEqualTo<Omit<A, keyof import("@effect/data/Equal").Equal>, {}> extends true ? void : Omit<A, keyof import("@effect/data/Equal").Equal>) => Data.Data<A & {
7
7
  _tag: "Standard";
8
8
  }>;
9
9
  export declare class StandardVersionGroup extends StandardVersionGroup_base<{
10
10
  config: VersionGroupConfig.Standard;
11
- instances: Instance[];
11
+ instances: Instance.Any[];
12
12
  isCatchAll: boolean;
13
13
  }> {
14
14
  constructor(isCatchAll: boolean, config: VersionGroupConfig.Standard);
15
- canAdd(_: Instance): boolean;
16
- inspect(): Effect.Effect<never, VersionGroupReport.WorkspaceMismatch | VersionGroupReport.UnsupportedMismatch | VersionGroupReport.HighestSemverMismatch | VersionGroupReport.LowestSemverMismatch, VersionGroupReport.Valid>[];
15
+ canAdd(_: Instance.Any): boolean;
16
+ inspect(): Effect.Effect<never, VersionGroupReport.LocalPackageMismatch | VersionGroupReport.NonSemverMismatch | VersionGroupReport.HighestSemverMismatch | VersionGroupReport.LowestSemverMismatch, VersionGroupReport.Valid>[];
17
17
  }
18
18
  export {};
@@ -25,13 +25,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.StandardVersionGroup = void 0;
27
27
  const Data = __importStar(require("@effect/data/Data"));
28
+ const Option = __importStar(require("@effect/data/Option"));
28
29
  const Effect = __importStar(require("@effect/io/Effect"));
29
30
  const unwrap_1 = require("tightrope/result/unwrap");
30
31
  const _1 = require(".");
31
- const is_supported_1 = require("../guards/is-supported");
32
32
  const get_highest_version_1 = require("./lib/get-highest-version");
33
33
  const get_lowest_version_1 = require("./lib/get-lowest-version");
34
- const get_unique_versions_1 = require("./lib/get-unique-versions");
34
+ const get_unique_specifiers_1 = require("./lib/get-unique-specifiers");
35
35
  const group_by_1 = require("./lib/group-by");
36
36
  class StandardVersionGroup extends Data.TaggedClass('Standard') {
37
37
  constructor(isCatchAll, config) {
@@ -47,6 +47,7 @@ class StandardVersionGroup extends Data.TaggedClass('Standard') {
47
47
  inspect() {
48
48
  const instancesByName = (0, group_by_1.groupBy)('name', this.instances);
49
49
  return Object.entries(instancesByName).map(([name, instances]) => {
50
+ var _a;
50
51
  if (!hasMismatch(instances)) {
51
52
  return Effect.succeed(new _1.VersionGroupReport.Valid({
52
53
  name,
@@ -54,32 +55,24 @@ class StandardVersionGroup extends Data.TaggedClass('Standard') {
54
55
  isValid: true,
55
56
  }));
56
57
  }
57
- const wsInstance = getWorkspaceInstance(instances);
58
- const wsFile = wsInstance?.packageJsonFile;
59
- const wsVersion = wsFile?.contents?.version;
60
- const isWorkspacePackage = wsInstance && wsVersion;
61
- if (isWorkspacePackage) {
62
- const nonWsInstances = getNonWorkspaceInstances(instances);
63
- if (!hasMismatch(nonWsInstances)) {
64
- return Effect.succeed(new _1.VersionGroupReport.Valid({
65
- name,
66
- instances,
67
- isValid: true,
68
- }));
69
- }
70
- return Effect.fail(new _1.VersionGroupReport.WorkspaceMismatch({
58
+ if (hasNonSemverSpecifiers(instances)) {
59
+ return Effect.fail(new _1.VersionGroupReport.NonSemverMismatch({
71
60
  name,
72
61
  instances,
73
62
  isValid: false,
74
- expectedVersion: wsVersion,
75
- workspaceInstance: wsInstance,
76
63
  }));
77
64
  }
78
- if (hasUnsupported(instances)) {
79
- return Effect.fail(new _1.VersionGroupReport.UnsupportedMismatch({
65
+ const localPackageInstance = getLocalPackageInstance(instances);
66
+ const localPackageFile = localPackageInstance === null || localPackageInstance === void 0 ? void 0 : localPackageInstance.packageJsonFile;
67
+ const localPackageVersion = (_a = localPackageFile === null || localPackageFile === void 0 ? void 0 : localPackageFile.contents) === null || _a === void 0 ? void 0 : _a.version;
68
+ const isLocalPackage = localPackageInstance && localPackageVersion;
69
+ if (isLocalPackage) {
70
+ return Effect.fail(new _1.VersionGroupReport.LocalPackageMismatch({
80
71
  name,
81
72
  instances,
82
73
  isValid: false,
74
+ expectedVersion: localPackageVersion,
75
+ localPackageInstance,
83
76
  }));
84
77
  }
85
78
  const preferVersion = this.config.preferVersion;
@@ -102,18 +95,15 @@ class StandardVersionGroup extends Data.TaggedClass('Standard') {
102
95
  }
103
96
  exports.StandardVersionGroup = StandardVersionGroup;
104
97
  function getExpectedVersion(preferVersion, instances) {
105
- const versions = (0, get_unique_versions_1.getUniqueVersions)(instances);
98
+ const versions = (0, get_unique_specifiers_1.getUniqueSpecifiers)(instances).map((i) => i.specifier);
106
99
  return (0, unwrap_1.unwrap)(preferVersion === 'highestSemver' ? (0, get_highest_version_1.getHighestVersion)(versions) : (0, get_lowest_version_1.getLowestVersion)(versions));
107
100
  }
108
101
  function hasMismatch(instances) {
109
- return (0, get_unique_versions_1.getUniqueVersions)(instances).length > 1;
102
+ return (0, get_unique_specifiers_1.getUniqueSpecifiers)(instances).length > 1;
110
103
  }
111
- function hasUnsupported(instances) {
112
- return instances.some((instance) => !(0, is_supported_1.isSupported)(instance.version));
104
+ function hasNonSemverSpecifiers(instances) {
105
+ return instances.some((instance) => Option.isNone(instance.getSemverSpecifier()));
113
106
  }
114
- function getWorkspaceInstance(instances) {
115
- return instances.find((instance) => instance.strategy.name === 'workspace');
116
- }
117
- function getNonWorkspaceInstances(instances) {
118
- return instances.filter((instance) => instance.strategy.name !== 'workspace');
107
+ function getLocalPackageInstance(instances) {
108
+ return instances.find((instance) => instance.strategy.name === 'localPackage');
119
109
  }
@@ -1,4 +1,4 @@
1
- import type { Instance } from '../get-package-json-files/instance';
2
1
  import type { AnySemverGroup } from '../get-semver-groups';
3
2
  import type { AnyVersionGroup } from '../get-version-groups';
4
- export declare function canAddToGroup(group: AnySemverGroup | AnyVersionGroup, instance: Instance): boolean;
3
+ import type { Instance } from '../instance';
4
+ export declare function canAddToGroup(group: AnySemverGroup | AnyVersionGroup, instance: Instance.Any): boolean;
@@ -1 +1,2 @@
1
+ /** @deprecated */
1
2
  export declare function isLooseSemver(version: unknown): boolean;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isLooseSemver = void 0;
4
4
  const is_string_1 = require("tightrope/guard/is-string");
5
5
  const is_semver_1 = require("./is-semver");
6
+ /** @deprecated */
6
7
  function isLooseSemver(version) {
7
8
  return (0, is_string_1.isString)(version) && (0, is_semver_1.isSemver)(version) && version.search(/\.x(\.|$)/) !== -1;
8
9
  }
@@ -1 +1,2 @@
1
+ /** @deprecated */
1
2
  export declare function isSemver(version: unknown): boolean;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isSemver = void 0;
4
4
  const is_string_1 = require("tightrope/guard/is-string");
5
+ /** @deprecated */
5
6
  function isSemver(version) {
6
7
  const range = '(~|\\^|>=|>|<=|<)?';
7
8
  const ints = '[0-9]+';
@@ -1,2 +1,3 @@
1
1
  import type { SemverRange } from '../config/types';
2
+ /** @deprecated */
2
3
  export declare function isValidSemverRange(value: unknown): value is SemverRange;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isValidSemverRange = void 0;
4
4
  const constants_1 = require("../constants");
5
+ /** @deprecated */
5
6
  function isValidSemverRange(value) {
6
7
  return (value === constants_1.RANGE.ANY ||
7
8
  value === constants_1.RANGE.EXACT ||
@@ -0,0 +1,4 @@
1
+ import { Instance } from '.';
2
+ import type { Strategy } from '../config/get-custom-types';
3
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
4
+ export declare function createInstance(strategy: Strategy.Any, name: string, packageJsonFile: PackageJsonFile, specifier: string): Instance.Any;