syncpack 13.0.0 → 14.0.0-alpha.1

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 (232) hide show
  1. package/index.js +48 -0
  2. package/package.json +16 -72
  3. package/schema.json +917 -0
  4. package/syncpack.d.ts +122 -0
  5. package/LICENSE +0 -20
  6. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +0 -16
  7. package/dist/bin-fix-mismatches/fix-mismatches.js +0 -115
  8. package/dist/bin-fix-mismatches/index.d.ts +0 -2
  9. package/dist/bin-fix-mismatches/index.js +0 -33
  10. package/dist/bin-format/format.d.ts +0 -13
  11. package/dist/bin-format/format.js +0 -92
  12. package/dist/bin-format/index.d.ts +0 -2
  13. package/dist/bin-format/index.js +0 -28
  14. package/dist/bin-lint/index.d.ts +0 -2
  15. package/dist/bin-lint/index.js +0 -17
  16. package/dist/bin-lint/lint.d.ts +0 -11
  17. package/dist/bin-lint/lint.js +0 -52
  18. package/dist/bin-lint-semver-ranges/index.d.ts +0 -2
  19. package/dist/bin-lint-semver-ranges/index.js +0 -30
  20. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +0 -16
  21. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +0 -92
  22. package/dist/bin-list/index.d.ts +0 -2
  23. package/dist/bin-list/index.js +0 -27
  24. package/dist/bin-list/list.d.ts +0 -14
  25. package/dist/bin-list/list.js +0 -151
  26. package/dist/bin-list-mismatches/index.d.ts +0 -2
  27. package/dist/bin-list-mismatches/index.js +0 -29
  28. package/dist/bin-list-mismatches/list-mismatches.d.ts +0 -18
  29. package/dist/bin-list-mismatches/list-mismatches.js +0 -224
  30. package/dist/bin-prompt/index.d.ts +0 -2
  31. package/dist/bin-prompt/index.js +0 -29
  32. package/dist/bin-prompt/prompt.d.ts +0 -11
  33. package/dist/bin-prompt/prompt.js +0 -95
  34. package/dist/bin-set-semver-ranges/index.d.ts +0 -2
  35. package/dist/bin-set-semver-ranges/index.js +0 -32
  36. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +0 -11
  37. package/dist/bin-set-semver-ranges/set-semver-ranges.js +0 -61
  38. package/dist/bin-update/effects.d.ts +0 -52
  39. package/dist/bin-update/effects.js +0 -282
  40. package/dist/bin-update/index.d.ts +0 -2
  41. package/dist/bin-update/index.js +0 -24
  42. package/dist/bin-update/update.d.ts +0 -6
  43. package/dist/bin-update/update.js +0 -59
  44. package/dist/bin.d.ts +0 -2
  45. package/dist/bin.js +0 -37
  46. package/dist/config/get-custom-types.d.ts +0 -19
  47. package/dist/config/get-custom-types.js +0 -57
  48. package/dist/config/get-enabled-types.d.ts +0 -17
  49. package/dist/config/get-enabled-types.js +0 -109
  50. package/dist/config/get-filter.d.ts +0 -2
  51. package/dist/config/get-filter.js +0 -10
  52. package/dist/config/get-indent.d.ts +0 -2
  53. package/dist/config/get-indent.js +0 -9
  54. package/dist/config/get-sort-az.d.ts +0 -2
  55. package/dist/config/get-sort-az.js +0 -8
  56. package/dist/config/get-sort-exports.d.ts +0 -2
  57. package/dist/config/get-sort-exports.js +0 -9
  58. package/dist/config/get-sort-first.d.ts +0 -2
  59. package/dist/config/get-sort-first.js +0 -8
  60. package/dist/config/get-source.d.ts +0 -2
  61. package/dist/config/get-source.js +0 -8
  62. package/dist/config/tag.d.ts +0 -3
  63. package/dist/config/tag.js +0 -2
  64. package/dist/config/types.d.ts +0 -132
  65. package/dist/config/types.js +0 -1
  66. package/dist/constants.d.ts +0 -106
  67. package/dist/constants.js +0 -103
  68. package/dist/error-handlers/default-error-handlers.d.ts +0 -25
  69. package/dist/error-handlers/default-error-handlers.js +0 -80
  70. package/dist/get-context/index.d.ts +0 -23
  71. package/dist/get-context/index.js +0 -18
  72. package/dist/get-context/lib/key-by.d.ts +0 -6
  73. package/dist/get-context/lib/key-by.js +0 -12
  74. package/dist/get-instances/index.d.ts +0 -14
  75. package/dist/get-instances/index.js +0 -42
  76. package/dist/get-instances/instance.d.ts +0 -26
  77. package/dist/get-instances/instance.js +0 -35
  78. package/dist/get-package-json-files/get-file-paths.d.ts +0 -21
  79. package/dist/get-package-json-files/get-file-paths.js +0 -22
  80. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +0 -3
  81. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +0 -12
  82. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +0 -3
  83. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +0 -14
  84. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +0 -3
  85. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +0 -16
  86. package/dist/get-package-json-files/get-patterns/index.d.ts +0 -8
  87. package/dist/get-package-json-files/get-patterns/index.js +0 -23
  88. package/dist/get-package-json-files/index.d.ts +0 -10
  89. package/dist/get-package-json-files/index.js +0 -8
  90. package/dist/get-package-json-files/package-json-file.d.ts +0 -54
  91. package/dist/get-package-json-files/package-json-file.js +0 -44
  92. package/dist/guards/can-add-to-group.d.ts +0 -5
  93. package/dist/guards/can-add-to-group.js +0 -58
  94. package/dist/guards/is-semver.d.ts +0 -2
  95. package/dist/guards/is-semver.js +0 -15
  96. package/dist/guards/is-valid-semver-range.d.ts +0 -3
  97. package/dist/guards/is-valid-semver-range.js +0 -14
  98. package/dist/index.d.ts +0 -2
  99. package/dist/index.js +0 -1
  100. package/dist/io/ask-for-choice.d.ts +0 -14
  101. package/dist/io/ask-for-choice.js +0 -17
  102. package/dist/io/ask-for-input.d.ts +0 -13
  103. package/dist/io/ask-for-input.js +0 -14
  104. package/dist/io/exit-if-invalid.d.ts +0 -4
  105. package/dist/io/exit-if-invalid.js +0 -9
  106. package/dist/io/glob-sync.d.ts +0 -11
  107. package/dist/io/glob-sync.js +0 -14
  108. package/dist/io/index.d.ts +0 -27
  109. package/dist/io/index.js +0 -26
  110. package/dist/io/read-config-file.d.ts +0 -7
  111. package/dist/io/read-config-file.js +0 -24
  112. package/dist/io/read-file-sync.d.ts +0 -12
  113. package/dist/io/read-file-sync.js +0 -9
  114. package/dist/io/read-json-file-sync.d.ts +0 -31
  115. package/dist/io/read-json-file-sync.js +0 -23
  116. package/dist/io/read-yaml-file-sync.d.ts +0 -12
  117. package/dist/io/read-yaml-file-sync.js +0 -9
  118. package/dist/io/to-formatted-json.d.ts +0 -9
  119. package/dist/io/to-formatted-json.js +0 -32
  120. package/dist/io/write-file-sync.d.ts +0 -12
  121. package/dist/io/write-file-sync.js +0 -10
  122. package/dist/io/write-if-changed.d.ts +0 -5
  123. package/dist/io/write-if-changed.js +0 -9
  124. package/dist/lib/format-repository-url.d.ts +0 -1
  125. package/dist/lib/format-repository-url.js +0 -40
  126. package/dist/lib/get-group-header.d.ts +0 -10
  127. package/dist/lib/get-group-header.js +0 -25
  128. package/dist/lib/get.d.ts +0 -11
  129. package/dist/lib/get.js +0 -44
  130. package/dist/lib/pad-start.d.ts +0 -1
  131. package/dist/lib/pad-start.js +0 -3
  132. package/dist/lib/ring-buffer.d.ts +0 -10
  133. package/dist/lib/ring-buffer.js +0 -20
  134. package/dist/lib/set-semver-range.d.ts +0 -3
  135. package/dist/lib/set-semver-range.js +0 -24
  136. package/dist/lib/show-help-on-error.d.ts +0 -2
  137. package/dist/lib/show-help-on-error.js +0 -32
  138. package/dist/lib/sort-by-name.d.ts +0 -5
  139. package/dist/lib/sort-by-name.js +0 -9
  140. package/dist/lib/with-logger.d.ts +0 -2
  141. package/dist/lib/with-logger.js +0 -28
  142. package/dist/option.d.ts +0 -10
  143. package/dist/option.js +0 -30
  144. package/dist/report.d.ts +0 -131
  145. package/dist/report.js +0 -129
  146. package/dist/schema.json +0 -544
  147. package/dist/semver-group/create-semver-groups.d.ts +0 -4
  148. package/dist/semver-group/create-semver-groups.js +0 -83
  149. package/dist/semver-group/disabled.d.ts +0 -26
  150. package/dist/semver-group/disabled.js +0 -28
  151. package/dist/semver-group/filtered-out.d.ts +0 -27
  152. package/dist/semver-group/filtered-out.js +0 -34
  153. package/dist/semver-group/ignored.d.ts +0 -22
  154. package/dist/semver-group/ignored.js +0 -24
  155. package/dist/semver-group/index.d.ts +0 -20
  156. package/dist/semver-group/index.js +0 -7
  157. package/dist/semver-group/with-range.d.ts +0 -22
  158. package/dist/semver-group/with-range.js +0 -45
  159. package/dist/specifier/alias.d.ts +0 -17
  160. package/dist/specifier/alias.js +0 -21
  161. package/dist/specifier/base.d.ts +0 -41
  162. package/dist/specifier/base.js +0 -54
  163. package/dist/specifier/delete.d.ts +0 -17
  164. package/dist/specifier/delete.js +0 -16
  165. package/dist/specifier/exact.d.ts +0 -20
  166. package/dist/specifier/exact.js +0 -21
  167. package/dist/specifier/file.d.ts +0 -8
  168. package/dist/specifier/file.js +0 -7
  169. package/dist/specifier/hosted-git.d.ts +0 -15
  170. package/dist/specifier/hosted-git.js +0 -24
  171. package/dist/specifier/index.d.ts +0 -28
  172. package/dist/specifier/index.js +0 -75
  173. package/dist/specifier/latest.d.ts +0 -19
  174. package/dist/specifier/latest.js +0 -20
  175. package/dist/specifier/lib/non-semver-error.d.ts +0 -11
  176. package/dist/specifier/lib/non-semver-error.js +0 -6
  177. package/dist/specifier/lib/parse-specifier.d.ts +0 -14
  178. package/dist/specifier/lib/parse-specifier.js +0 -18
  179. package/dist/specifier/lib/specific-registry-result.d.ts +0 -9
  180. package/dist/specifier/lib/specific-registry-result.js +0 -1
  181. package/dist/specifier/range.d.ts +0 -19
  182. package/dist/specifier/range.js +0 -20
  183. package/dist/specifier/tag.d.ts +0 -11
  184. package/dist/specifier/tag.js +0 -10
  185. package/dist/specifier/unsupported.d.ts +0 -7
  186. package/dist/specifier/unsupported.js +0 -7
  187. package/dist/specifier/url.d.ts +0 -8
  188. package/dist/specifier/url.js +0 -7
  189. package/dist/specifier/workspace-protocol.d.ts +0 -19
  190. package/dist/specifier/workspace-protocol.js +0 -35
  191. package/dist/strategy/lib/get-non-empty-string-prop.d.ts +0 -3
  192. package/dist/strategy/lib/get-non-empty-string-prop.js +0 -7
  193. package/dist/strategy/name-and-version-props.d.ts +0 -12
  194. package/dist/strategy/name-and-version-props.js +0 -60
  195. package/dist/strategy/named-version-string.d.ts +0 -11
  196. package/dist/strategy/named-version-string.js +0 -52
  197. package/dist/strategy/unnamed-version-string.d.ts +0 -11
  198. package/dist/strategy/unnamed-version-string.js +0 -45
  199. package/dist/strategy/versions-by-name.d.ts +0 -11
  200. package/dist/strategy/versions-by-name.js +0 -27
  201. package/dist/version-group/banned.d.ts +0 -17
  202. package/dist/version-group/banned.js +0 -26
  203. package/dist/version-group/create-version-groups.d.ts +0 -4
  204. package/dist/version-group/create-version-groups.js +0 -118
  205. package/dist/version-group/filtered-out.d.ts +0 -19
  206. package/dist/version-group/filtered-out.js +0 -30
  207. package/dist/version-group/ignored.d.ts +0 -17
  208. package/dist/version-group/ignored.js +0 -23
  209. package/dist/version-group/index.d.ts +0 -26
  210. package/dist/version-group/index.js +0 -7
  211. package/dist/version-group/lib/clean.d.ts +0 -2
  212. package/dist/version-group/lib/clean.js +0 -6
  213. package/dist/version-group/lib/delete.d.ts +0 -2
  214. package/dist/version-group/lib/delete.js +0 -1
  215. package/dist/version-group/lib/get-highest-version.d.ts +0 -6
  216. package/dist/version-group/lib/get-highest-version.js +0 -8
  217. package/dist/version-group/lib/get-lowest-version.d.ts +0 -6
  218. package/dist/version-group/lib/get-lowest-version.js +0 -8
  219. package/dist/version-group/lib/get-preferred-version.d.ts +0 -5
  220. package/dist/version-group/lib/get-preferred-version.js +0 -53
  221. package/dist/version-group/lib/get-range-score.d.ts +0 -2
  222. package/dist/version-group/lib/get-range-score.js +0 -20
  223. package/dist/version-group/lib/group-by.d.ts +0 -5
  224. package/dist/version-group/lib/group-by.js +0 -11
  225. package/dist/version-group/pinned.d.ts +0 -17
  226. package/dist/version-group/pinned.js +0 -26
  227. package/dist/version-group/same-range.d.ts +0 -19
  228. package/dist/version-group/same-range.js +0 -96
  229. package/dist/version-group/snapped-to.d.ts +0 -17
  230. package/dist/version-group/snapped-to.js +0 -71
  231. package/dist/version-group/standard.d.ts +0 -18
  232. package/dist/version-group/standard.js +0 -119
@@ -1,6 +0,0 @@
1
- import { Data, Effect } from 'effect';
2
- export class NonSemverError extends Data.TaggedClass('NonSemverError') {
3
- static asEffect(specifier) {
4
- return Effect.fail(new NonSemverError({ specifier }));
5
- }
6
- }
@@ -1,14 +0,0 @@
1
- import npa from 'npm-package-arg';
2
- import type { PackageJsonFile } from '../../get-package-json-files/package-json-file.js';
3
- /** Extends npm/npm-package-arg to support "workspace:*" */
4
- export interface WorkspaceProtocolResult {
5
- type: 'workspaceProtocol';
6
- raw: string;
7
- name: string | null;
8
- escapedName: string | null;
9
- scope: string | null;
10
- rawSpec: string;
11
- saveSpec: string;
12
- }
13
- export type NpmPackageArgResult = ReturnType<typeof npa.resolve> | WorkspaceProtocolResult;
14
- export declare function parseSpecifier(name: string, specifier: string, packageJsonFile: PackageJsonFile): NpmPackageArgResult;
@@ -1,18 +0,0 @@
1
- import npa from 'npm-package-arg';
2
- export function parseSpecifier(name, specifier, packageJsonFile) {
3
- if (specifier === 'workspace:*' ||
4
- specifier === 'workspace:~' ||
5
- specifier === 'workspace:^') {
6
- const parsed = npa.resolve(name, packageJsonFile.jsonFile.dirPath, specifier.replace('workspace:', 'file:'));
7
- return {
8
- escapedName: parsed.escapedName,
9
- name: parsed.name,
10
- raw: parsed.raw.replace('file:', 'workspace:'),
11
- rawSpec: parsed.rawSpec.replace('file:', 'workspace:'),
12
- saveSpec: parsed.saveSpec.replace('file:', 'workspace:'),
13
- scope: parsed.scope,
14
- type: 'workspaceProtocol',
15
- };
16
- }
17
- return npa.resolve(name, specifier, packageJsonFile.jsonFile.dirPath);
18
- }
@@ -1,9 +0,0 @@
1
- import type { RegistryResult } from 'npm-package-arg';
2
- /**
3
- * A helper to create specific classes for each of the possible
4
- * `RegistryResult` types from npm/npm-package-arg. Instead of grouping them
5
- * together we are being more specific
6
- */
7
- export type SpecificRegistryResult<T extends RegistryResult['type'] | 'local'> = Omit<RegistryResult, 'type'> & {
8
- type: T;
9
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { Effect } from 'effect';
2
- import { BaseSpecifier } from './base.js';
3
- import { Specifier } from './index.js';
4
- import { NonSemverError } from './lib/non-semver-error.js';
5
- import type { SpecificRegistryResult } from './lib/specific-registry-result.js';
6
- type T = SpecificRegistryResult<'range'>;
7
- /**
8
- * @example "^1.2.3"
9
- */
10
- export declare class RangeSpecifier extends BaseSpecifier<T> {
11
- _tag: string;
12
- /** The public name referenced in config */
13
- name: "range";
14
- /** Return the semver version including the range */
15
- getSemver(): Effect.Effect<string, NonSemverError>;
16
- /** Get a new `Specifier` from the given semver version applied to this one */
17
- setSemver(version: string): Effect.Effect<Specifier.Any>;
18
- }
19
- export {};
@@ -1,20 +0,0 @@
1
- import { Effect, pipe } from 'effect';
2
- import { BaseSpecifier } from './base.js';
3
- import { Specifier } from './index.js';
4
- import { NonSemverError } from './lib/non-semver-error.js';
5
- /**
6
- * @example "^1.2.3"
7
- */
8
- export class RangeSpecifier extends BaseSpecifier {
9
- _tag = 'Range';
10
- /** The public name referenced in config */
11
- name = 'range';
12
- /** Return the semver version including the range */
13
- getSemver() {
14
- return pipe(this.parse(), Effect.mapError(() => new NonSemverError({ specifier: this })), Effect.map(parsed => parsed.fetchSpec));
15
- }
16
- /** Get a new `Specifier` from the given semver version applied to this one */
17
- setSemver(version) {
18
- return Effect.succeed(Specifier.create(this.instance, version));
19
- }
20
- }
@@ -1,11 +0,0 @@
1
- import { BaseSpecifier } from './base.js';
2
- import type { SpecificRegistryResult } from './lib/specific-registry-result.js';
3
- /**
4
- * @example "latest"
5
- * @example "made-up-by-some-dev"
6
- */
7
- export declare class TagSpecifier extends BaseSpecifier<SpecificRegistryResult<'tag'>> {
8
- _tag: string;
9
- /** The public name referenced in config */
10
- name: "tag";
11
- }
@@ -1,10 +0,0 @@
1
- import { BaseSpecifier } from './base.js';
2
- /**
3
- * @example "latest"
4
- * @example "made-up-by-some-dev"
5
- */
6
- export class TagSpecifier extends BaseSpecifier {
7
- _tag = 'Tag';
8
- /** The public name referenced in config */
9
- name = 'tag';
10
- }
@@ -1,7 +0,0 @@
1
- import { BaseSpecifier } from './base.js';
2
- /** A specifier not supported by the `npm` package manager */
3
- export declare class UnsupportedSpecifier extends BaseSpecifier<unknown> {
4
- _tag: string;
5
- /** The public name referenced in config */
6
- name: "unsupported";
7
- }
@@ -1,7 +0,0 @@
1
- import { BaseSpecifier } from './base.js';
2
- /** A specifier not supported by the `npm` package manager */
3
- export class UnsupportedSpecifier extends BaseSpecifier {
4
- _tag = 'Unsupported';
5
- /** The public name referenced in config */
6
- name = 'unsupported';
7
- }
@@ -1,8 +0,0 @@
1
- import type { URLResult } from 'npm-package-arg';
2
- import { BaseSpecifier } from './base.js';
3
- /** @example "http://x.com/foo.tgz" */
4
- export declare class UrlSpecifier extends BaseSpecifier<URLResult> {
5
- _tag: string;
6
- /** The public name referenced in config */
7
- name: "url";
8
- }
@@ -1,7 +0,0 @@
1
- import { BaseSpecifier } from './base.js';
2
- /** @example "http://x.com/foo.tgz" */
3
- export class UrlSpecifier extends BaseSpecifier {
4
- _tag = 'Url';
5
- /** The public name referenced in config */
6
- name = 'url';
7
- }
@@ -1,19 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { Ctx } from '../get-context/index.js';
3
- import { BaseSpecifier } from './base.js';
4
- import { Specifier } from './index.js';
5
- import type { WorkspaceProtocolResult } from './lib/parse-specifier.js';
6
- /** Represents "workspace:*" and "workspace:~" */
7
- export declare class WorkspaceProtocolSpecifier extends BaseSpecifier<WorkspaceProtocolResult> {
8
- _tag: string;
9
- /** The public name referenced in config */
10
- name: "workspace-protocol";
11
- /**
12
- * Return an equivalent value which actually is semver, so that it can be used
13
- * with tools which expect values which conform to the spec. This value is
14
- * used only when sorting versions.
15
- */
16
- getSemverEquivalent(ctx: Ctx): Effect.Effect<string>;
17
- getSemver(): Effect.Effect<string>;
18
- setSemver(version: string): Effect.Effect<Specifier.Any>;
19
- }
@@ -1,35 +0,0 @@
1
- import { Effect } from 'effect';
2
- import { BaseSpecifier } from './base.js';
3
- import { Specifier } from './index.js';
4
- /** Represents "workspace:*" and "workspace:~" */
5
- export class WorkspaceProtocolSpecifier extends BaseSpecifier {
6
- _tag = 'WorkspaceProtocol';
7
- /** The public name referenced in config */
8
- name = 'workspace-protocol';
9
- /**
10
- * Return an equivalent value which actually is semver, so that it can be used
11
- * with tools which expect values which conform to the spec. This value is
12
- * used only when sorting versions.
13
- */
14
- getSemverEquivalent(ctx) {
15
- if (this.raw === 'workspace:*') {
16
- return Effect.succeed('*');
17
- }
18
- if (this.raw === 'workspace:~' || this.raw === 'workspace:^') {
19
- const range = this.raw.replace('workspace:', '');
20
- const local = ctx.packageJsonFilesByName[this.instance.name];
21
- const version = local?.jsonFile?.contents?.version;
22
- if (version) {
23
- return Effect.succeed(`${range}${version}`);
24
- }
25
- }
26
- return Effect.succeed('0.0.0');
27
- }
28
- // @TODO: this name is inaccurate, check how it is used and change logic or rename
29
- getSemver() {
30
- return Effect.succeed(this.raw);
31
- }
32
- setSemver(version) {
33
- return Effect.succeed(Specifier.create(this.instance, version));
34
- }
35
- }
@@ -1,3 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../../get-package-json-files/package-json-file.js';
3
- export declare function getNonEmptyStringProp(propPath: string, file: PackageJsonFile): Effect.Effect<string, unknown>;
@@ -1,7 +0,0 @@
1
- import { Effect, Option, pipe } from 'effect';
2
- import { isNonEmptyString } from 'tightrope/guard/is-non-empty-string.js';
3
- import { get } from '../../lib/get.js';
4
- const getOptionOfNonEmptyString = Option.liftPredicate(isNonEmptyString);
5
- export function getNonEmptyStringProp(propPath, file) {
6
- return pipe(get(file.jsonFile.contents, ...propPath.split('.')), Effect.flatMap(value => getOptionOfNonEmptyString(value)), Effect.tapError(() => Effect.logDebug(`<${file.jsonFile.shortPath}>.${propPath} is not a non-empty string`)));
7
- }
@@ -1,12 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
3
- import type { Delete } from '../version-group/lib/delete.js';
4
- export declare class NameAndVersionPropsStrategy {
5
- _tag: string;
6
- name: string;
7
- path: string;
8
- namePath: string;
9
- constructor(name: string, path: string, namePath: string);
10
- read(file: PackageJsonFile): Effect.Effect<[string, string][]>;
11
- write(file: PackageJsonFile, [, version]: [string, string | Delete]): Effect.Effect<PackageJsonFile>;
12
- }
@@ -1,60 +0,0 @@
1
- import { Effect, Option, identity, pipe } from 'effect';
2
- import { isObject } from 'tightrope/guard/is-object.js';
3
- import { get } from '../lib/get.js';
4
- import { DELETE } from '../version-group/lib/delete.js';
5
- import { getNonEmptyStringProp } from './lib/get-non-empty-string-prop.js';
6
- const getOptionOfObject = Option.liftPredicate((isObject));
7
- export class NameAndVersionPropsStrategy {
8
- _tag = 'name~version';
9
- name;
10
- path;
11
- namePath;
12
- constructor(name, path, namePath) {
13
- this.name = name;
14
- this.path = path;
15
- this.namePath = namePath;
16
- }
17
- read(file) {
18
- return pipe(Effect.Do,
19
- // get the name prop
20
- Effect.bind('name', () => getNonEmptyStringProp(this.namePath, file)),
21
- // add the version prop
22
- Effect.bind('version', () => pipe(getNonEmptyStringProp(this.path, file),
23
- /**
24
- * In order to report a `MissingLocalVersion`, we need to ensure that
25
- * a value is returned for `local` package .version properties so we
26
- * can know that `this.name` is a package developed in this repo but
27
- * that its version is missing.
28
- *
29
- * Not doing this results in the invalid local package being ignored
30
- * and each installation of it being checked for mismatches amongst
31
- * themselves.
32
- */
33
- this.name === 'local'
34
- ? Effect.catchAll(() => Effect.succeed('PACKAGE_JSON_HAS_NO_VERSION'))
35
- : Effect.map(identity))),
36
- // if both are non empty strings, we can return them
37
- Effect.map(({ name, version }) => [[name, version]]), Effect.tapError(() => Effect.logDebug(`NameAndVersionPropsStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path} & .${this.namePath}`)),
38
- // if either are invalid, default to empty
39
- Effect.catchAll(() => Effect.succeed([])));
40
- }
41
- write(file, [, version]) {
42
- const path = this.path;
43
- const { contents } = file.jsonFile;
44
- const isNestedPath = path.includes('.');
45
- const nextValue = version === DELETE ? undefined : version;
46
- if (isNestedPath) {
47
- const fullPath = path.split('.');
48
- const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
49
- const key = fullPath.slice(-1).join('');
50
- return pipe(get(contents, ...pathToParent.split('.')), Effect.flatMap(getOptionOfObject), Effect.flatMap(parent => Effect.try(() => {
51
- parent[key] = nextValue;
52
- file.applyEdit(fullPath, nextValue);
53
- })), Effect.tapError(() => Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), Effect.catchAll(() => Effect.succeed(file)), Effect.map(() => file));
54
- }
55
- return pipe(getOptionOfObject(contents), Effect.flatMap(parent => Effect.try(() => {
56
- parent[this.path] = nextValue;
57
- file.applyEdit([this.path], nextValue);
58
- })), Effect.tapError(() => Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), Effect.catchAll(() => Effect.succeed(file)), Effect.map(() => file));
59
- }
60
- }
@@ -1,11 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
3
- import type { Delete } from '../version-group/lib/delete.js';
4
- export declare class NamedVersionStringStrategy {
5
- _tag: string;
6
- name: string;
7
- path: string;
8
- constructor(name: string, path: string);
9
- read(file: PackageJsonFile): Effect.Effect<[string, string][]>;
10
- write(file: PackageJsonFile, [name, version]: [string, string | Delete]): Effect.Effect<PackageJsonFile>;
11
- }
@@ -1,52 +0,0 @@
1
- import { Effect, Option, pipe } from 'effect';
2
- import { isNonEmptyObject } from 'tightrope/guard/is-non-empty-object.js';
3
- import { isNonEmptyString } from 'tightrope/guard/is-non-empty-string.js';
4
- import { get } from '../lib/get.js';
5
- import { DELETE } from '../version-group/lib/delete.js';
6
- import { getNonEmptyStringProp } from './lib/get-non-empty-string-prop.js';
7
- const getOptionOfNonEmptyString = Option.liftPredicate(isNonEmptyString);
8
- const getOptionOfNonEmptyObject = Option.liftPredicate((isNonEmptyObject));
9
- export class NamedVersionStringStrategy {
10
- _tag = 'name@version';
11
- name;
12
- path;
13
- constructor(name, path) {
14
- this.name = name;
15
- this.path = path;
16
- }
17
- read(file) {
18
- const path = this.path;
19
- return pipe(
20
- // get version prop
21
- getNonEmptyStringProp(path, file),
22
- // if it is a non empty string, we can read it
23
- Effect.map(value => value.split(/@(.*)/)),
24
- // check the string was properly formed
25
- Effect.flatMap(([name, version]) => Effect.all([
26
- getOptionOfNonEmptyString(name),
27
- getOptionOfNonEmptyString(version),
28
- ])),
29
- // return an array of one entry if valid
30
- Effect.map(([name, version]) => [[name, version]]), Effect.tapError(() => Effect.logDebug(`NamedVersionStringStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path}`)),
31
- // if value is invalid, default to empty
32
- Effect.catchAll(() => Effect.succeed([])));
33
- }
34
- write(file, [name, version]) {
35
- const { contents } = file.jsonFile;
36
- const isNestedPath = this.path.includes('.');
37
- const nextValue = version === DELETE ? undefined : `${name}@${version}`;
38
- if (isNestedPath) {
39
- const fullPath = this.path.split('.');
40
- const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
41
- const key = fullPath.slice(-1).join('');
42
- return pipe(get(contents, ...pathToParent.split('.')), Effect.flatMap(getOptionOfNonEmptyObject), Effect.flatMap(parent => Effect.try(() => {
43
- parent[key] = nextValue;
44
- file.applyEdit(fullPath, nextValue);
45
- })), Effect.tapError(() => Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), Effect.catchAll(() => Effect.succeed(file)), Effect.map(() => file));
46
- }
47
- return pipe(getOptionOfNonEmptyObject(contents), Effect.flatMap(parent => Effect.try(() => {
48
- parent[this.path] = nextValue;
49
- file.applyEdit([this.path], nextValue);
50
- })), Effect.tapError(() => Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), Effect.catchAll(() => Effect.succeed(file)), Effect.map(() => file));
51
- }
52
- }
@@ -1,11 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
3
- import type { Delete } from '../version-group/lib/delete.js';
4
- export declare class UnnamedVersionStringStrategy {
5
- _tag: string;
6
- name: string;
7
- path: string;
8
- constructor(name: string, path: string);
9
- read(file: PackageJsonFile): Effect.Effect<[string, string][]>;
10
- write(file: PackageJsonFile, [, version]: [string, string | Delete]): Effect.Effect<PackageJsonFile>;
11
- }
@@ -1,45 +0,0 @@
1
- import { Effect, Option, pipe } from 'effect';
2
- import { isNonEmptyObject } from 'tightrope/guard/is-non-empty-object.js';
3
- import { get } from '../lib/get.js';
4
- import { DELETE } from '../version-group/lib/delete.js';
5
- import { getNonEmptyStringProp } from './lib/get-non-empty-string-prop.js';
6
- const getOptionOfNonEmptyObject = Option.liftPredicate((isNonEmptyObject));
7
- export class UnnamedVersionStringStrategy {
8
- _tag = 'version';
9
- name;
10
- path;
11
- constructor(name, path) {
12
- this.name = name;
13
- this.path = path;
14
- }
15
- read(file) {
16
- return pipe(
17
- // get version prop
18
- getNonEmptyStringProp(this.path, file),
19
- // if it is a non empty string, we can read it
20
- Effect.map((version) => {
21
- const name = this.path.split('.').slice(-1).join('');
22
- return [[name, version]];
23
- }), Effect.tapError(() => Effect.logDebug(`UnnamedVersionStringStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path}`)),
24
- // if value is invalid, default to empty
25
- Effect.catchAll(() => Effect.succeed([])));
26
- }
27
- write(file, [, version]) {
28
- const { contents } = file.jsonFile;
29
- const isNestedPath = this.path.includes('.');
30
- const nextValue = version === DELETE ? undefined : version;
31
- if (isNestedPath) {
32
- const fullPath = this.path.split('.');
33
- const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
34
- const key = fullPath.slice(-1).join('');
35
- return pipe(get(contents, ...pathToParent.split('.')), Effect.flatMap(getOptionOfNonEmptyObject), Effect.flatMap(parent => Effect.try(() => {
36
- parent[key] = nextValue;
37
- file.applyEdit(fullPath, nextValue);
38
- })), Effect.tapError(() => Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), Effect.catchAll(() => Effect.succeed(file)), Effect.map(() => file));
39
- }
40
- return pipe(getOptionOfNonEmptyObject(contents), Effect.flatMap(parent => Effect.try(() => {
41
- parent[this.path] = nextValue;
42
- file.applyEdit([this.path], nextValue);
43
- })), Effect.tapError(() => Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), Effect.catchAll(() => Effect.succeed(file)), Effect.map(() => file));
44
- }
45
- }
@@ -1,11 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
3
- import type { Delete } from '../version-group/lib/delete.js';
4
- export declare class VersionsByNameStrategy {
5
- _tag: string;
6
- name: string;
7
- path: string;
8
- constructor(name: string, path: string);
9
- read(file: PackageJsonFile): Effect.Effect<[string, string][]>;
10
- write(file: PackageJsonFile, [name, version]: [string, string | Delete]): Effect.Effect<PackageJsonFile>;
11
- }
@@ -1,27 +0,0 @@
1
- import { Effect, Option, pipe } from 'effect';
2
- import { isNonEmptyObject } from 'tightrope/guard/is-non-empty-object.js';
3
- import { get } from '../lib/get.js';
4
- import { DELETE } from '../version-group/lib/delete.js';
5
- const getOptionOfNonEmptyObject = Option.liftPredicate((isNonEmptyObject));
6
- export class VersionsByNameStrategy {
7
- _tag = 'versionsByName';
8
- name;
9
- path;
10
- constructor(name, path) {
11
- this.name = name;
12
- this.path = path;
13
- }
14
- read(file) {
15
- return pipe(get(file.jsonFile.contents, ...this.path.split('.')), Effect.flatMap(value => getOptionOfNonEmptyObject(value)), Effect.map(obj => Object.entries(obj)), Effect.tapError(() => Effect.logDebug(`VersionsByNameStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path}`)),
16
- // if value is invalid, default to empty
17
- Effect.catchAll(() => Effect.succeed([])));
18
- }
19
- write(file, [name, version]) {
20
- const nextValue = version === DELETE ? undefined : version;
21
- const fullPath = this.path.split('.');
22
- return pipe(get(file.jsonFile.contents, ...fullPath), Effect.flatMap(getOptionOfNonEmptyObject), Effect.flatMap(parent => Effect.try(() => {
23
- parent[name] = nextValue;
24
- file.applyEdit(fullPath.concat(name), nextValue);
25
- })), Effect.tapError(() => Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}.${name}`)), Effect.catchAll(() => Effect.succeed(file)), Effect.map(() => file));
26
- }
27
- }
@@ -1,17 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { VersionGroupConfig } from '../config/types.js';
3
- import type { Instance } from '../get-instances/instance.js';
4
- import { Report } from '../report.js';
5
- declare const BannedVersionGroup_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
6
- readonly _tag: "Banned";
7
- };
8
- export declare class BannedVersionGroup extends BannedVersionGroup_base<{
9
- config: VersionGroupConfig.Banned;
10
- instances: Instance[];
11
- }> {
12
- groupType: string;
13
- constructor(config: VersionGroupConfig.Banned);
14
- canAdd(_: Instance): boolean;
15
- inspectAll(): Effect.Effect<Report.Version.Group[]>;
16
- }
17
- export {};
@@ -1,26 +0,0 @@
1
- import { Data, Effect } from 'effect';
2
- import { Report } from '../report.js';
3
- import { Specifier } from '../specifier/index.js';
4
- import { DELETE } from './lib/delete.js';
5
- import { groupBy } from './lib/group-by.js';
6
- export class BannedVersionGroup extends Data.TaggedClass('Banned') {
7
- groupType = 'versionGroup';
8
- constructor(config) {
9
- super({
10
- config,
11
- instances: [],
12
- });
13
- }
14
- canAdd(_) {
15
- return true;
16
- }
17
- inspectAll() {
18
- return Effect.succeed(Object.entries(groupBy('name', this.instances)).map(([name, instances]) => ({
19
- name,
20
- reports: instances.map(instance =>
21
- // ✘ package should not be used
22
- // ✓ is a mismatch we can auto-fix
23
- new Report.Banned(Specifier.create(instance, DELETE))),
24
- })));
25
- }
26
- }
@@ -1,4 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { Ctx } from '../get-context/index.js';
3
- import { VersionGroup } from './index.js';
4
- export declare function createVersionGroups(ctx: Ctx): Effect.Effect<VersionGroup.Any[], VersionGroup.ConfigError>;
@@ -1,118 +0,0 @@
1
- import { Effect } from 'effect';
2
- import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
3
- import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
4
- import { isNonEmptyString } from 'tightrope/guard/is-non-empty-string.js';
5
- import { isObject } from 'tightrope/guard/is-object.js';
6
- import { BannedVersionGroup } from './banned.js';
7
- import { FilteredOutVersionGroup } from './filtered-out.js';
8
- import { IgnoredVersionGroup } from './ignored.js';
9
- import { VersionGroup } from './index.js';
10
- import { PinnedVersionGroup } from './pinned.js';
11
- import { SameRangeVersionGroup } from './same-range.js';
12
- import { SnappedToVersionGroup } from './snapped-to.js';
13
- import { StandardVersionGroup } from './standard.js';
14
- export function createVersionGroups(ctx) {
15
- const { rcFile } = ctx.config;
16
- const versionGroups = [Effect.succeed(new FilteredOutVersionGroup(ctx))];
17
- if (isNonEmptyArray(rcFile.versionGroups)) {
18
- rcFile.versionGroups.forEach((config) => {
19
- if (!isObject(config)) {
20
- return versionGroups.push(Effect.fail(new VersionGroup.ConfigError({
21
- config,
22
- error: 'config is not an object',
23
- })));
24
- }
25
- const mutuallyExclusiveProps = ['isBanned', 'isIgnored', 'pinVersion', 'snapTo', 'policy'].filter(prop => Boolean(config[prop]));
26
- if (mutuallyExclusiveProps.length > 1) {
27
- return versionGroups.push(Effect.fail(new VersionGroup.ConfigError({
28
- config,
29
- error: `it's unclear what kind of version group you want, as it contains both ${mutuallyExclusiveProps.join(' and ')}`,
30
- })));
31
- }
32
- const label = isNonEmptyString(config.label) ? config.label : '';
33
- const dependencyTypes = isArrayOfStrings(config.dependencyTypes)
34
- ? config.dependencyTypes
35
- : ['**'];
36
- const dependencies = isArrayOfStrings(config.dependencies)
37
- ? config.dependencies
38
- : ['**'];
39
- const packages = isArrayOfStrings(config.packages)
40
- ? config.packages
41
- : ['**'];
42
- const specifierTypes = isArrayOfStrings(config.specifierTypes)
43
- ? config.specifierTypes
44
- : ['**'];
45
- if (config.isBanned === true) {
46
- versionGroups.push(Effect.succeed(new BannedVersionGroup({
47
- dependencies,
48
- dependencyTypes,
49
- specifierTypes,
50
- isBanned: true,
51
- label,
52
- packages,
53
- })));
54
- }
55
- else if (config.isIgnored === true) {
56
- versionGroups.push(Effect.succeed(new IgnoredVersionGroup({
57
- dependencies,
58
- dependencyTypes,
59
- specifierTypes,
60
- isIgnored: true,
61
- label,
62
- packages,
63
- })));
64
- }
65
- else if (isNonEmptyString(config.pinVersion)) {
66
- versionGroups.push(Effect.succeed(new PinnedVersionGroup({
67
- dependencies,
68
- dependencyTypes,
69
- specifierTypes,
70
- label,
71
- packages,
72
- pinVersion: config.pinVersion,
73
- })));
74
- }
75
- else if (isArrayOfStrings(config.snapTo)) {
76
- versionGroups.push(Effect.succeed(new SnappedToVersionGroup({
77
- dependencies,
78
- dependencyTypes,
79
- specifierTypes,
80
- label,
81
- packages,
82
- snapTo: config.snapTo,
83
- })));
84
- }
85
- else if (config.policy === 'sameRange') {
86
- versionGroups.push(Effect.succeed(new SameRangeVersionGroup(ctx, {
87
- dependencies,
88
- dependencyTypes,
89
- specifierTypes,
90
- label,
91
- packages,
92
- policy: config.policy,
93
- })));
94
- }
95
- else {
96
- versionGroups.push(Effect.succeed(new StandardVersionGroup(false, {
97
- dependencies,
98
- dependencyTypes,
99
- specifierTypes,
100
- label,
101
- packages,
102
- preferVersion: config.preferVersion === 'lowestSemver'
103
- ? 'lowestSemver'
104
- : 'highestSemver',
105
- })));
106
- }
107
- });
108
- }
109
- versionGroups.push(Effect.succeed(new StandardVersionGroup(true, {
110
- dependencies: ['**'],
111
- dependencyTypes: ['**'],
112
- specifierTypes: ['**'],
113
- label: 'Default Version Group',
114
- packages: ['**'],
115
- preferVersion: 'highestSemver',
116
- })));
117
- return Effect.all(versionGroups);
118
- }