syncpack 12.2.0 → 12.3.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 (209) hide show
  1. package/README.md +5 -5
  2. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +9 -9
  3. package/dist/bin-fix-mismatches/fix-mismatches.js +43 -54
  4. package/dist/bin-fix-mismatches/index.js +26 -31
  5. package/dist/bin-format/format.d.ts +6 -4
  6. package/dist/bin-format/format.js +78 -53
  7. package/dist/bin-format/index.js +20 -25
  8. package/dist/bin-lint/index.js +15 -20
  9. package/dist/bin-lint/lint.d.ts +4 -4
  10. package/dist/bin-lint/lint.js +51 -19
  11. package/dist/bin-lint-semver-ranges/index.js +24 -29
  12. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +8 -8
  13. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +34 -44
  14. package/dist/bin-list/index.js +24 -29
  15. package/dist/bin-list/list.d.ts +7 -7
  16. package/dist/bin-list/list.js +55 -64
  17. package/dist/bin-list-mismatches/index.js +24 -29
  18. package/dist/bin-list-mismatches/list-mismatches.d.ts +10 -10
  19. package/dist/bin-list-mismatches/list-mismatches.js +62 -70
  20. package/dist/bin-prompt/index.js +26 -31
  21. package/dist/bin-prompt/prompt.d.ts +4 -4
  22. package/dist/bin-prompt/prompt.js +41 -48
  23. package/dist/bin-set-semver-ranges/index.js +26 -31
  24. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +4 -4
  25. package/dist/bin-set-semver-ranges/set-semver-ranges.js +26 -30
  26. package/dist/bin-update/effects.d.ts +18 -18
  27. package/dist/bin-update/effects.js +77 -106
  28. package/dist/bin-update/index.js +23 -28
  29. package/dist/bin-update/update.d.ts +5 -5
  30. package/dist/bin-update/update.js +37 -45
  31. package/dist/bin.js +8 -5
  32. package/dist/config/get-custom-types.d.ts +9 -9
  33. package/dist/config/get-custom-types.js +22 -27
  34. package/dist/config/get-enabled-types.d.ts +8 -8
  35. package/dist/config/get-enabled-types.js +42 -48
  36. package/dist/config/get-filter.d.ts +1 -1
  37. package/dist/config/get-filter.js +6 -9
  38. package/dist/config/get-indent.d.ts +1 -1
  39. package/dist/config/get-indent.js +6 -9
  40. package/dist/config/get-sort-az.d.ts +1 -1
  41. package/dist/config/get-sort-az.js +6 -17
  42. package/dist/config/get-sort-exports.d.ts +2 -0
  43. package/dist/config/get-sort-exports.js +8 -0
  44. package/dist/config/get-sort-first.d.ts +1 -1
  45. package/dist/config/get-sort-first.js +6 -8
  46. package/dist/config/get-source.d.ts +1 -1
  47. package/dist/config/get-source.js +4 -8
  48. package/dist/config/tag.d.ts +1 -1
  49. package/dist/config/tag.js +2 -5
  50. package/dist/config/types.d.ts +16 -5
  51. package/dist/config/types.js +1 -2
  52. package/dist/constants.d.ts +7 -0
  53. package/dist/constants.js +25 -10
  54. package/dist/error-handlers/default-error-handlers.d.ts +10 -10
  55. package/dist/error-handlers/default-error-handlers.js +55 -61
  56. package/dist/get-context/index.d.ts +5 -5
  57. package/dist/get-context/index.js +13 -17
  58. package/dist/get-context/lib/key-by.js +1 -5
  59. package/dist/get-instances/index.d.ts +7 -7
  60. package/dist/get-instances/index.js +19 -23
  61. package/dist/get-instances/instance.d.ts +7 -7
  62. package/dist/get-instances/instance.js +4 -8
  63. package/dist/get-package-json-files/get-file-paths.d.ts +7 -7
  64. package/dist/get-package-json-files/get-file-paths.js +10 -15
  65. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +2 -2
  66. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +8 -12
  67. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +2 -2
  68. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +8 -12
  69. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +2 -2
  70. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +14 -18
  71. package/dist/get-package-json-files/get-patterns/index.d.ts +3 -3
  72. package/dist/get-package-json-files/get-patterns/index.js +11 -15
  73. package/dist/get-package-json-files/index.d.ts +8 -8
  74. package/dist/get-package-json-files/index.js +6 -10
  75. package/dist/get-package-json-files/package-json-file.d.ts +6 -6
  76. package/dist/get-package-json-files/package-json-file.js +8 -12
  77. package/dist/guards/can-add-to-group.d.ts +4 -4
  78. package/dist/guards/can-add-to-group.js +10 -14
  79. package/dist/guards/is-semver.js +3 -7
  80. package/dist/guards/is-valid-semver-range.d.ts +1 -1
  81. package/dist/guards/is-valid-semver-range.js +12 -16
  82. package/dist/index.d.ts +1 -1
  83. package/dist/index.js +1 -2
  84. package/dist/io/ask-for-choice.d.ts +5 -5
  85. package/dist/io/ask-for-choice.js +5 -9
  86. package/dist/io/ask-for-input.d.ts +5 -5
  87. package/dist/io/ask-for-input.js +5 -9
  88. package/dist/io/exit-if-invalid.d.ts +3 -3
  89. package/dist/io/exit-if-invalid.js +5 -9
  90. package/dist/io/glob-sync.d.ts +5 -5
  91. package/dist/io/glob-sync.js +4 -9
  92. package/dist/io/index.d.ts +8 -8
  93. package/dist/io/index.js +12 -38
  94. package/dist/io/read-config-file.d.ts +7 -0
  95. package/dist/io/read-config-file.js +22 -0
  96. package/dist/io/read-file-sync.d.ts +5 -5
  97. package/dist/io/read-file-sync.js +4 -9
  98. package/dist/io/read-json-file-sync.d.ts +8 -8
  99. package/dist/io/read-json-file-sync.js +10 -16
  100. package/dist/io/read-yaml-file-sync.d.ts +5 -5
  101. package/dist/io/read-yaml-file-sync.js +4 -8
  102. package/dist/io/to-json.d.ts +9 -0
  103. package/dist/io/to-json.js +29 -0
  104. package/dist/io/write-file-sync.d.ts +5 -5
  105. package/dist/io/write-file-sync.js +5 -10
  106. package/dist/io/write-if-changed.d.ts +4 -10
  107. package/dist/io/write-if-changed.js +9 -44
  108. package/dist/lib/format-repository-url.js +1 -5
  109. package/dist/lib/get-group-header.d.ts +2 -2
  110. package/dist/lib/get-group-header.js +4 -12
  111. package/dist/lib/get.d.ts +10 -10
  112. package/dist/lib/get.js +15 -19
  113. package/dist/lib/pad-start.js +1 -5
  114. package/dist/lib/ring-buffer.js +1 -5
  115. package/dist/lib/set-semver-range.d.ts +1 -1
  116. package/dist/lib/set-semver-range.js +8 -12
  117. package/dist/lib/show-help-on-error.js +3 -10
  118. package/dist/lib/sort-by-name.js +1 -5
  119. package/dist/lib/with-logger.d.ts +1 -1
  120. package/dist/lib/with-logger.js +17 -24
  121. package/dist/option.d.ts +1 -1
  122. package/dist/option.js +8 -14
  123. package/dist/report.d.ts +2 -2
  124. package/dist/report.js +2 -5
  125. package/dist/schema.json +24 -0
  126. package/dist/semver-group/create-semver-groups.d.ts +3 -3
  127. package/dist/semver-group/create-semver-groups.js +28 -32
  128. package/dist/semver-group/disabled.d.ts +11 -11
  129. package/dist/semver-group/disabled.js +6 -10
  130. package/dist/semver-group/filtered-out.d.ts +12 -12
  131. package/dist/semver-group/filtered-out.js +8 -12
  132. package/dist/semver-group/ignored.d.ts +11 -11
  133. package/dist/semver-group/ignored.js +6 -10
  134. package/dist/semver-group/index.d.ts +6 -7
  135. package/dist/semver-group/index.js +4 -7
  136. package/dist/semver-group/with-range.d.ts +11 -11
  137. package/dist/semver-group/with-range.js +13 -17
  138. package/dist/specifier/alias.d.ts +5 -5
  139. package/dist/specifier/alias.js +9 -13
  140. package/dist/specifier/base.d.ts +7 -7
  141. package/dist/specifier/base.js +9 -13
  142. package/dist/specifier/delete.d.ts +5 -5
  143. package/dist/specifier/delete.js +5 -9
  144. package/dist/specifier/exact.d.ts +6 -6
  145. package/dist/specifier/exact.js +7 -11
  146. package/dist/specifier/file.d.ts +1 -1
  147. package/dist/specifier/file.js +2 -6
  148. package/dist/specifier/hosted-git.d.ts +5 -5
  149. package/dist/specifier/hosted-git.js +9 -13
  150. package/dist/specifier/index.d.ts +13 -13
  151. package/dist/specifier/index.js +28 -31
  152. package/dist/specifier/latest.d.ts +6 -6
  153. package/dist/specifier/latest.js +7 -11
  154. package/dist/specifier/lib/non-semver-error.d.ts +5 -5
  155. package/dist/specifier/lib/non-semver-error.js +3 -7
  156. package/dist/specifier/lib/parse-specifier.d.ts +1 -1
  157. package/dist/specifier/lib/parse-specifier.js +4 -11
  158. package/dist/specifier/lib/specific-registry-result.js +1 -2
  159. package/dist/specifier/range.d.ts +6 -6
  160. package/dist/specifier/range.js +7 -11
  161. package/dist/specifier/tag.d.ts +2 -2
  162. package/dist/specifier/tag.js +2 -6
  163. package/dist/specifier/unsupported.d.ts +1 -1
  164. package/dist/specifier/unsupported.js +2 -6
  165. package/dist/specifier/url.d.ts +1 -1
  166. package/dist/specifier/url.js +2 -6
  167. package/dist/specifier/workspace-protocol.d.ts +7 -7
  168. package/dist/specifier/workspace-protocol.js +9 -13
  169. package/dist/strategy/lib/get-non-empty-string-prop.d.ts +2 -2
  170. package/dist/strategy/lib/get-non-empty-string-prop.js +6 -10
  171. package/dist/strategy/name-and-version-props.d.ts +4 -4
  172. package/dist/strategy/name-and-version-props.js +19 -23
  173. package/dist/strategy/named-version-string.d.ts +4 -4
  174. package/dist/strategy/named-version-string.js +20 -24
  175. package/dist/strategy/unnamed-version-string.d.ts +4 -4
  176. package/dist/strategy/unnamed-version-string.js +17 -21
  177. package/dist/strategy/versions-by-name.d.ts +4 -4
  178. package/dist/strategy/versions-by-name.js +11 -15
  179. package/dist/version-group/banned.d.ts +7 -7
  180. package/dist/version-group/banned.js +8 -12
  181. package/dist/version-group/create-version-groups.d.ts +3 -3
  182. package/dist/version-group/create-version-groups.js +34 -38
  183. package/dist/version-group/filtered-out.d.ts +8 -8
  184. package/dist/version-group/filtered-out.js +8 -12
  185. package/dist/version-group/ignored.d.ts +7 -7
  186. package/dist/version-group/ignored.js +6 -10
  187. package/dist/version-group/index.d.ts +9 -10
  188. package/dist/version-group/index.js +4 -7
  189. package/dist/version-group/lib/clean.js +4 -11
  190. package/dist/version-group/lib/delete.js +1 -4
  191. package/dist/version-group/lib/get-highest-version.d.ts +2 -2
  192. package/dist/version-group/lib/get-highest-version.js +3 -7
  193. package/dist/version-group/lib/get-lowest-version.d.ts +2 -2
  194. package/dist/version-group/lib/get-lowest-version.js +3 -7
  195. package/dist/version-group/lib/get-preferred-version.d.ts +4 -4
  196. package/dist/version-group/lib/get-preferred-version.js +17 -24
  197. package/dist/version-group/lib/get-range-score.js +13 -17
  198. package/dist/version-group/lib/group-by.js +1 -5
  199. package/dist/version-group/pinned.d.ts +7 -7
  200. package/dist/version-group/pinned.js +8 -12
  201. package/dist/version-group/same-range.d.ts +8 -8
  202. package/dist/version-group/same-range.js +23 -30
  203. package/dist/version-group/snapped-to.d.ts +7 -7
  204. package/dist/version-group/snapped-to.js +20 -24
  205. package/dist/version-group/standard.d.ts +7 -7
  206. package/dist/version-group/standard.js +29 -33
  207. package/package.json +30 -37
  208. package/dist/io/read-config-file-sync.d.ts +0 -7
  209. package/dist/io/read-config-file-sync.js +0 -26
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NonSemverError = void 0;
4
- const effect_1 = require("effect");
5
- class NonSemverError extends effect_1.Data.TaggedClass('NonSemverError') {
1
+ import { Data, Effect } from 'effect';
2
+ export class NonSemverError extends Data.TaggedClass('NonSemverError') {
6
3
  static asEffect(specifier) {
7
- return effect_1.Effect.fail(new NonSemverError({ specifier }));
4
+ return Effect.fail(new NonSemverError({ specifier }));
8
5
  }
9
6
  }
10
- exports.NonSemverError = NonSemverError;
@@ -1,5 +1,5 @@
1
1
  import npa from 'npm-package-arg';
2
- import type { PackageJsonFile } from '../../get-package-json-files/package-json-file';
2
+ import type { PackageJsonFile } from '../../get-package-json-files/package-json-file.js';
3
3
  /** Extends npm/npm-package-arg to support "workspace:*" */
4
4
  export interface WorkspaceProtocolResult {
5
5
  type: 'workspaceProtocol';
@@ -1,13 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseSpecifier = void 0;
7
- const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
8
- function parseSpecifier(name, specifier, packageJsonFile) {
1
+ import npa from 'npm-package-arg';
2
+ export function parseSpecifier(name, specifier, packageJsonFile) {
9
3
  if (specifier === 'workspace:*' || specifier === 'workspace:~' || specifier === 'workspace:^') {
10
- const parsed = npm_package_arg_1.default.resolve(name, packageJsonFile.jsonFile.dirPath, specifier.replace('workspace:', 'file:'));
4
+ const parsed = npa.resolve(name, packageJsonFile.jsonFile.dirPath, specifier.replace('workspace:', 'file:'));
11
5
  return {
12
6
  escapedName: parsed.escapedName,
13
7
  name: parsed.name,
@@ -18,6 +12,5 @@ function parseSpecifier(name, specifier, packageJsonFile) {
18
12
  type: 'workspaceProtocol',
19
13
  };
20
14
  }
21
- return npm_package_arg_1.default.resolve(name, specifier, packageJsonFile.jsonFile.dirPath);
15
+ return npa.resolve(name, specifier, packageJsonFile.jsonFile.dirPath);
22
16
  }
23
- exports.parseSpecifier = parseSpecifier;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,8 +1,8 @@
1
1
  import { Effect } from 'effect';
2
- import { Specifier } from '.';
3
- import { BaseSpecifier } from './base';
4
- import { NonSemverError } from './lib/non-semver-error';
5
- import type { SpecificRegistryResult } from './lib/specific-registry-result';
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
6
  type T = SpecificRegistryResult<'range'>;
7
7
  /**
8
8
  * @example "^1.2.3"
@@ -12,8 +12,8 @@ export declare class RangeSpecifier extends BaseSpecifier<T> {
12
12
  /** The public name referenced in config */
13
13
  name: "range";
14
14
  /** Return the semver version including the range */
15
- getSemver(): Effect.Effect<never, NonSemverError, string>;
15
+ getSemver(): Effect.Effect<string, NonSemverError>;
16
16
  /** Get a new `Specifier` from the given semver version applied to this one */
17
- setSemver(version: string): Effect.Effect<never, never, Specifier.Any>;
17
+ setSemver(version: string): Effect.Effect<Specifier.Any>;
18
18
  }
19
19
  export {};
@@ -1,24 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RangeSpecifier = void 0;
4
- const effect_1 = require("effect");
5
- const _1 = require(".");
6
- const base_1 = require("./base");
7
- const non_semver_error_1 = require("./lib/non-semver-error");
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';
8
5
  /**
9
6
  * @example "^1.2.3"
10
7
  */
11
- class RangeSpecifier extends base_1.BaseSpecifier {
8
+ export class RangeSpecifier extends BaseSpecifier {
12
9
  _tag = 'Range';
13
10
  /** The public name referenced in config */
14
11
  name = 'range';
15
12
  /** Return the semver version including the range */
16
13
  getSemver() {
17
- return (0, effect_1.pipe)(this.parse(), effect_1.Effect.mapError(() => new non_semver_error_1.NonSemverError({ specifier: this })), effect_1.Effect.map((parsed) => parsed.fetchSpec));
14
+ return pipe(this.parse(), Effect.mapError(() => new NonSemverError({ specifier: this })), Effect.map((parsed) => parsed.fetchSpec));
18
15
  }
19
16
  /** Get a new `Specifier` from the given semver version applied to this one */
20
17
  setSemver(version) {
21
- return effect_1.Effect.succeed(_1.Specifier.create(this.instance, version));
18
+ return Effect.succeed(Specifier.create(this.instance, version));
22
19
  }
23
20
  }
24
- exports.RangeSpecifier = RangeSpecifier;
@@ -1,5 +1,5 @@
1
- import { BaseSpecifier } from './base';
2
- import type { SpecificRegistryResult } from './lib/specific-registry-result';
1
+ import { BaseSpecifier } from './base.js';
2
+ import type { SpecificRegistryResult } from './lib/specific-registry-result.js';
3
3
  /**
4
4
  * @example "latest"
5
5
  * @example "made-up-by-some-dev"
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TagSpecifier = void 0;
4
- const base_1 = require("./base");
1
+ import { BaseSpecifier } from './base.js';
5
2
  /**
6
3
  * @example "latest"
7
4
  * @example "made-up-by-some-dev"
8
5
  */
9
- class TagSpecifier extends base_1.BaseSpecifier {
6
+ export class TagSpecifier extends BaseSpecifier {
10
7
  _tag = 'Tag';
11
8
  /** The public name referenced in config */
12
9
  name = 'tag';
13
10
  }
14
- exports.TagSpecifier = TagSpecifier;
@@ -1,4 +1,4 @@
1
- import { BaseSpecifier } from './base';
1
+ import { BaseSpecifier } from './base.js';
2
2
  /** A specifier not supported by the `npm` package manager */
3
3
  export declare class UnsupportedSpecifier extends BaseSpecifier<unknown> {
4
4
  _tag: string;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnsupportedSpecifier = void 0;
4
- const base_1 = require("./base");
1
+ import { BaseSpecifier } from './base.js';
5
2
  /** A specifier not supported by the `npm` package manager */
6
- class UnsupportedSpecifier extends base_1.BaseSpecifier {
3
+ export class UnsupportedSpecifier extends BaseSpecifier {
7
4
  _tag = 'Unsupported';
8
5
  /** The public name referenced in config */
9
6
  name = 'unsupported';
10
7
  }
11
- exports.UnsupportedSpecifier = UnsupportedSpecifier;
@@ -1,5 +1,5 @@
1
1
  import type { URLResult } from 'npm-package-arg';
2
- import { BaseSpecifier } from './base';
2
+ import { BaseSpecifier } from './base.js';
3
3
  /** @example "http://x.com/foo.tgz" */
4
4
  export declare class UrlSpecifier extends BaseSpecifier<URLResult> {
5
5
  _tag: string;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UrlSpecifier = void 0;
4
- const base_1 = require("./base");
1
+ import { BaseSpecifier } from './base.js';
5
2
  /** @example "http://x.com/foo.tgz" */
6
- class UrlSpecifier extends base_1.BaseSpecifier {
3
+ export class UrlSpecifier extends BaseSpecifier {
7
4
  _tag = 'Url';
8
5
  /** The public name referenced in config */
9
6
  name = 'url';
10
7
  }
11
- exports.UrlSpecifier = UrlSpecifier;
@@ -1,8 +1,8 @@
1
1
  import { Effect } from 'effect';
2
- import { Specifier } from '.';
3
- import type { Ctx } from '../get-context';
4
- import { BaseSpecifier } from './base';
5
- import type { WorkspaceProtocolResult } from './lib/parse-specifier';
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
6
  /** Represents "workspace:*" and "workspace:~" */
7
7
  export declare class WorkspaceProtocolSpecifier extends BaseSpecifier<WorkspaceProtocolResult> {
8
8
  _tag: string;
@@ -13,7 +13,7 @@ export declare class WorkspaceProtocolSpecifier extends BaseSpecifier<WorkspaceP
13
13
  * with tools which expect values which conform to the spec. This value is
14
14
  * used only when sorting versions.
15
15
  */
16
- getSemverEquivalent(ctx: Ctx): Effect.Effect<never, never, string>;
17
- getSemver(): Effect.Effect<never, never, string>;
18
- setSemver(version: string): Effect.Effect<never, never, Specifier.Any>;
16
+ getSemverEquivalent(ctx: Ctx): Effect.Effect<string>;
17
+ getSemver(): Effect.Effect<string>;
18
+ setSemver(version: string): Effect.Effect<Specifier.Any>;
19
19
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkspaceProtocolSpecifier = void 0;
4
- const effect_1 = require("effect");
5
- const _1 = require(".");
6
- const base_1 = require("./base");
1
+ import { Effect } from 'effect';
2
+ import { BaseSpecifier } from './base.js';
3
+ import { Specifier } from './index.js';
7
4
  /** Represents "workspace:*" and "workspace:~" */
8
- class WorkspaceProtocolSpecifier extends base_1.BaseSpecifier {
5
+ export class WorkspaceProtocolSpecifier extends BaseSpecifier {
9
6
  _tag = 'WorkspaceProtocol';
10
7
  /** The public name referenced in config */
11
8
  name = 'workspace-protocol';
@@ -16,23 +13,22 @@ class WorkspaceProtocolSpecifier extends base_1.BaseSpecifier {
16
13
  */
17
14
  getSemverEquivalent(ctx) {
18
15
  if (this.raw === 'workspace:*') {
19
- return effect_1.Effect.succeed('*');
16
+ return Effect.succeed('*');
20
17
  }
21
18
  if (this.raw === 'workspace:~' || this.raw === 'workspace:^') {
22
19
  const range = this.raw.replace('workspace:', '');
23
20
  const local = ctx.packageJsonFilesByName[this.instance.name];
24
21
  const version = local?.jsonFile?.contents?.version;
25
22
  if (version)
26
- return effect_1.Effect.succeed(`${range}${version}`);
23
+ return Effect.succeed(`${range}${version}`);
27
24
  }
28
- return effect_1.Effect.succeed('0.0.0');
25
+ return Effect.succeed('0.0.0');
29
26
  }
30
27
  // @TODO: this name is inaccurate, check how it is used and change logic or rename
31
28
  getSemver() {
32
- return effect_1.Effect.succeed(this.raw);
29
+ return Effect.succeed(this.raw);
33
30
  }
34
31
  setSemver(version) {
35
- return effect_1.Effect.succeed(_1.Specifier.create(this.instance, version));
32
+ return Effect.succeed(Specifier.create(this.instance, version));
36
33
  }
37
34
  }
38
- exports.WorkspaceProtocolSpecifier = WorkspaceProtocolSpecifier;
@@ -1,3 +1,3 @@
1
1
  import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../../get-package-json-files/package-json-file';
3
- export declare function getNonEmptyStringProp(propPath: string, file: PackageJsonFile): Effect.Effect<never, unknown, string>;
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,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNonEmptyStringProp = void 0;
4
- const effect_1 = require("effect");
5
- const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
6
- const get_1 = require("../../lib/get");
7
- const getOptionOfNonEmptyString = effect_1.Option.liftPredicate(is_non_empty_string_1.isNonEmptyString);
8
- function getNonEmptyStringProp(propPath, file) {
9
- return (0, effect_1.pipe)((0, get_1.get)(file.jsonFile.contents, ...propPath.split('.')), effect_1.Effect.flatMap((value) => getOptionOfNonEmptyString(value)), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`<${file.jsonFile.shortPath}>.${propPath} is not a non-empty string`)));
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`)));
10
7
  }
11
- exports.getNonEmptyStringProp = getNonEmptyStringProp;
@@ -1,12 +1,12 @@
1
1
  import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
3
- import type { Delete } from '../version-group/lib/delete';
2
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
3
+ import type { Delete } from '../version-group/lib/delete.js';
4
4
  export declare class NameAndVersionPropsStrategy {
5
5
  _tag: string;
6
6
  name: string;
7
7
  path: string;
8
8
  namePath: string;
9
9
  constructor(name: string, path: string, namePath: string);
10
- read(file: PackageJsonFile): Effect.Effect<never, never, [string, string][]>;
11
- write(file: PackageJsonFile, [, version]: [string, string | Delete]): Effect.Effect<never, never, PackageJsonFile>;
10
+ read(file: PackageJsonFile): Effect.Effect<[string, string][]>;
11
+ write(file: PackageJsonFile, [, version]: [string, string | Delete]): Effect.Effect<PackageJsonFile>;
12
12
  }
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NameAndVersionPropsStrategy = void 0;
4
- const effect_1 = require("effect");
5
- const is_object_1 = require("tightrope/guard/is-object");
6
- const get_1 = require("../lib/get");
7
- const delete_1 = require("../version-group/lib/delete");
8
- const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
9
- const getOptionOfObject = effect_1.Option.liftPredicate((is_object_1.isObject));
10
- class NameAndVersionPropsStrategy {
1
+ import { Effect, identity, Option, 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 {
11
8
  _tag = 'name~version';
12
9
  name;
13
10
  path;
@@ -18,11 +15,11 @@ class NameAndVersionPropsStrategy {
18
15
  this.namePath = namePath;
19
16
  }
20
17
  read(file) {
21
- return (0, effect_1.pipe)(effect_1.Effect.Do,
18
+ return pipe(Effect.Do,
22
19
  // get the name prop
23
- effect_1.Effect.bind('name', () => (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(this.namePath, file)),
20
+ Effect.bind('name', () => getNonEmptyStringProp(this.namePath, file)),
24
21
  // add the version prop
25
- effect_1.Effect.bind('version', () => (0, effect_1.pipe)((0, get_non_empty_string_prop_1.getNonEmptyStringProp)(this.path, file),
22
+ Effect.bind('version', () => pipe(getNonEmptyStringProp(this.path, file),
26
23
  /**
27
24
  * In order to report a `MissingLocalVersion`, we need to ensure that
28
25
  * a value is returned for `local` package .version properties so we
@@ -34,31 +31,30 @@ class NameAndVersionPropsStrategy {
34
31
  * themselves.
35
32
  */
36
33
  this.name === 'local'
37
- ? effect_1.Effect.catchAll(() => effect_1.Effect.succeed('PACKAGE_JSON_HAS_NO_VERSION'))
38
- : effect_1.Effect.map(effect_1.identity))),
34
+ ? Effect.catchAll(() => Effect.succeed('PACKAGE_JSON_HAS_NO_VERSION'))
35
+ : Effect.map(identity))),
39
36
  // if both are non empty strings, we can return them
40
- effect_1.Effect.map(({ name, version }) => [[name, version]]), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`NameAndVersionPropsStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path} & .${this.namePath}`)),
37
+ Effect.map(({ name, version }) => [[name, version]]), Effect.tapError(() => Effect.logDebug(`NameAndVersionPropsStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path} & .${this.namePath}`)),
41
38
  // if either are invalid, default to empty
42
- effect_1.Effect.catchAll(() => effect_1.Effect.succeed([])));
39
+ Effect.catchAll(() => Effect.succeed([])));
43
40
  }
44
41
  write(file, [, version]) {
45
42
  const path = this.path;
46
43
  const { contents } = file.jsonFile;
47
44
  const isNestedPath = path.includes('.');
48
- const nextValue = version === delete_1.DELETE ? undefined : version;
45
+ const nextValue = version === DELETE ? undefined : version;
49
46
  if (isNestedPath) {
50
47
  const fullPath = path.split('.');
51
48
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
52
49
  const key = fullPath.slice(-1).join('');
53
- return (0, effect_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), effect_1.Effect.flatMap(getOptionOfObject), effect_1.Effect.flatMap((parent) => effect_1.Effect.try(() => {
50
+ return pipe(get(contents, ...pathToParent.split('.')), Effect.flatMap(getOptionOfObject), Effect.flatMap((parent) => Effect.try(() => {
54
51
  parent[key] = nextValue;
55
- })), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), effect_1.Effect.catchAll(() => effect_1.Effect.succeed(file)), effect_1.Effect.map(() => file));
52
+ })), 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));
56
53
  }
57
54
  else {
58
- return (0, effect_1.pipe)(getOptionOfObject(contents), effect_1.Effect.flatMap((parent) => effect_1.Effect.try(() => {
55
+ return pipe(getOptionOfObject(contents), Effect.flatMap((parent) => Effect.try(() => {
59
56
  parent[this.path] = nextValue;
60
- })), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), effect_1.Effect.catchAll(() => effect_1.Effect.succeed(file)), effect_1.Effect.map(() => file));
57
+ })), 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));
61
58
  }
62
59
  }
63
60
  }
64
- exports.NameAndVersionPropsStrategy = NameAndVersionPropsStrategy;
@@ -1,11 +1,11 @@
1
1
  import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
3
- import type { Delete } from '../version-group/lib/delete';
2
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
3
+ import type { Delete } from '../version-group/lib/delete.js';
4
4
  export declare class NamedVersionStringStrategy {
5
5
  _tag: string;
6
6
  name: string;
7
7
  path: string;
8
8
  constructor(name: string, path: string);
9
- read(file: PackageJsonFile): Effect.Effect<never, never, [string, string][]>;
10
- write(file: PackageJsonFile, [name, version]: [string, string | Delete]): Effect.Effect<never, never, PackageJsonFile>;
9
+ read(file: PackageJsonFile): Effect.Effect<[string, string][]>;
10
+ write(file: PackageJsonFile, [name, version]: [string, string | Delete]): Effect.Effect<PackageJsonFile>;
11
11
  }
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NamedVersionStringStrategy = void 0;
4
- const effect_1 = require("effect");
5
- const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
6
- const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
7
- const get_1 = require("../lib/get");
8
- const delete_1 = require("../version-group/lib/delete");
9
- const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
10
- const getOptionOfNonEmptyString = effect_1.Option.liftPredicate(is_non_empty_string_1.isNonEmptyString);
11
- const getOptionOfNonEmptyObject = effect_1.Option.liftPredicate((is_non_empty_object_1.isNonEmptyObject));
12
- class NamedVersionStringStrategy {
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 {
13
10
  _tag = 'name@version';
14
11
  name;
15
12
  path;
@@ -19,35 +16,34 @@ class NamedVersionStringStrategy {
19
16
  }
20
17
  read(file) {
21
18
  const path = this.path;
22
- return (0, effect_1.pipe)(
19
+ return pipe(
23
20
  // get version prop
24
- (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file),
21
+ getNonEmptyStringProp(path, file),
25
22
  // if it is a non empty string, we can read it
26
- effect_1.Effect.map((value) => value.split(/@(.*)/)),
23
+ Effect.map((value) => value.split(/@(.*)/)),
27
24
  // check the string was properly formed
28
- effect_1.Effect.flatMap(([name, version]) => effect_1.Effect.all([getOptionOfNonEmptyString(name), getOptionOfNonEmptyString(version)])),
25
+ Effect.flatMap(([name, version]) => Effect.all([getOptionOfNonEmptyString(name), getOptionOfNonEmptyString(version)])),
29
26
  // return an array of one entry if valid
30
- effect_1.Effect.map(([name, version]) => [[name, version]]), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`NamedVersionStringStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path}`)),
27
+ Effect.map(([name, version]) => [[name, version]]), Effect.tapError(() => Effect.logDebug(`NamedVersionStringStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path}`)),
31
28
  // if value is invalid, default to empty
32
- effect_1.Effect.catchAll(() => effect_1.Effect.succeed([])));
29
+ Effect.catchAll(() => Effect.succeed([])));
33
30
  }
34
31
  write(file, [name, version]) {
35
32
  const { contents } = file.jsonFile;
36
33
  const isNestedPath = this.path.includes('.');
37
- const nextValue = version === delete_1.DELETE ? undefined : `${name}@${version}`;
34
+ const nextValue = version === DELETE ? undefined : `${name}@${version}`;
38
35
  if (isNestedPath) {
39
36
  const fullPath = this.path.split('.');
40
37
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
41
38
  const key = fullPath.slice(-1).join('');
42
- return (0, effect_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), effect_1.Effect.flatMap(getOptionOfNonEmptyObject), effect_1.Effect.flatMap((parent) => effect_1.Effect.try(() => {
39
+ return pipe(get(contents, ...pathToParent.split('.')), Effect.flatMap(getOptionOfNonEmptyObject), Effect.flatMap((parent) => Effect.try(() => {
43
40
  parent[key] = nextValue;
44
- })), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), effect_1.Effect.catchAll(() => effect_1.Effect.succeed(file)), effect_1.Effect.map(() => file));
41
+ })), 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));
45
42
  }
46
43
  else {
47
- return (0, effect_1.pipe)(getOptionOfNonEmptyObject(contents), effect_1.Effect.flatMap((parent) => effect_1.Effect.try(() => {
44
+ return pipe(getOptionOfNonEmptyObject(contents), Effect.flatMap((parent) => Effect.try(() => {
48
45
  parent[this.path] = nextValue;
49
- })), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), effect_1.Effect.catchAll(() => effect_1.Effect.succeed(file)), effect_1.Effect.map(() => file));
46
+ })), 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));
50
47
  }
51
48
  }
52
49
  }
53
- exports.NamedVersionStringStrategy = NamedVersionStringStrategy;
@@ -1,11 +1,11 @@
1
1
  import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
3
- import type { Delete } from '../version-group/lib/delete';
2
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
3
+ import type { Delete } from '../version-group/lib/delete.js';
4
4
  export declare class UnnamedVersionStringStrategy {
5
5
  _tag: string;
6
6
  name: string;
7
7
  path: string;
8
8
  constructor(name: string, path: string);
9
- read(file: PackageJsonFile): Effect.Effect<never, never, [string, string][]>;
10
- write(file: PackageJsonFile, [, version]: [string, string | Delete]): Effect.Effect<never, never, PackageJsonFile>;
9
+ read(file: PackageJsonFile): Effect.Effect<[string, string][]>;
10
+ write(file: PackageJsonFile, [, version]: [string, string | Delete]): Effect.Effect<PackageJsonFile>;
11
11
  }
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnnamedVersionStringStrategy = void 0;
4
- const effect_1 = require("effect");
5
- const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
6
- const get_1 = require("../lib/get");
7
- const delete_1 = require("../version-group/lib/delete");
8
- const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
9
- const getOptionOfNonEmptyObject = effect_1.Option.liftPredicate((is_non_empty_object_1.isNonEmptyObject));
10
- class UnnamedVersionStringStrategy {
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 {
11
8
  _tag = 'version';
12
9
  name;
13
10
  path;
@@ -16,34 +13,33 @@ class UnnamedVersionStringStrategy {
16
13
  this.path = path;
17
14
  }
18
15
  read(file) {
19
- return (0, effect_1.pipe)(
16
+ return pipe(
20
17
  // get version prop
21
- (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(this.path, file),
18
+ getNonEmptyStringProp(this.path, file),
22
19
  // if it is a non empty string, we can read it
23
- effect_1.Effect.map((version) => {
20
+ Effect.map((version) => {
24
21
  const name = this.path.split('.').slice(-1).join('');
25
22
  return [[name, version]];
26
- }), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`UnnamedVersionStringStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path}`)),
23
+ }), Effect.tapError(() => Effect.logDebug(`UnnamedVersionStringStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path}`)),
27
24
  // if value is invalid, default to empty
28
- effect_1.Effect.catchAll(() => effect_1.Effect.succeed([])));
25
+ Effect.catchAll(() => Effect.succeed([])));
29
26
  }
30
27
  write(file, [, version]) {
31
28
  const { contents } = file.jsonFile;
32
29
  const isNestedPath = this.path.includes('.');
33
- const nextValue = version === delete_1.DELETE ? undefined : version;
30
+ const nextValue = version === DELETE ? undefined : version;
34
31
  if (isNestedPath) {
35
32
  const fullPath = this.path.split('.');
36
33
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
37
34
  const key = fullPath.slice(-1).join('');
38
- return (0, effect_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), effect_1.Effect.flatMap(getOptionOfNonEmptyObject), effect_1.Effect.flatMap((parent) => effect_1.Effect.try(() => {
35
+ return pipe(get(contents, ...pathToParent.split('.')), Effect.flatMap(getOptionOfNonEmptyObject), Effect.flatMap((parent) => Effect.try(() => {
39
36
  parent[key] = nextValue;
40
- })), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), effect_1.Effect.catchAll(() => effect_1.Effect.succeed(file)), effect_1.Effect.map(() => file));
37
+ })), 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));
41
38
  }
42
39
  else {
43
- return (0, effect_1.pipe)(getOptionOfNonEmptyObject(contents), effect_1.Effect.flatMap((parent) => effect_1.Effect.try(() => {
40
+ return pipe(getOptionOfNonEmptyObject(contents), Effect.flatMap((parent) => Effect.try(() => {
44
41
  parent[this.path] = nextValue;
45
- })), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}`)), effect_1.Effect.catchAll(() => effect_1.Effect.succeed(file)), effect_1.Effect.map(() => file));
42
+ })), 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
43
  }
47
44
  }
48
45
  }
49
- exports.UnnamedVersionStringStrategy = UnnamedVersionStringStrategy;
@@ -1,11 +1,11 @@
1
1
  import { Effect } from 'effect';
2
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
3
- import type { Delete } from '../version-group/lib/delete';
2
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
3
+ import type { Delete } from '../version-group/lib/delete.js';
4
4
  export declare class VersionsByNameStrategy {
5
5
  _tag: string;
6
6
  name: string;
7
7
  path: string;
8
8
  constructor(name: string, path: string);
9
- read(file: PackageJsonFile): Effect.Effect<never, never, [string, string][]>;
10
- write(file: PackageJsonFile, [name, version]: [string, string | Delete]): Effect.Effect<never, never, PackageJsonFile>;
9
+ read(file: PackageJsonFile): Effect.Effect<[string, string][]>;
10
+ write(file: PackageJsonFile, [name, version]: [string, string | Delete]): Effect.Effect<PackageJsonFile>;
11
11
  }
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VersionsByNameStrategy = void 0;
4
- const effect_1 = require("effect");
5
- const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
6
- const get_1 = require("../lib/get");
7
- const delete_1 = require("../version-group/lib/delete");
8
- const getOptionOfNonEmptyObject = effect_1.Option.liftPredicate((is_non_empty_object_1.isNonEmptyObject));
9
- class VersionsByNameStrategy {
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 {
10
7
  _tag = 'versionsByName';
11
8
  name;
12
9
  path;
@@ -15,15 +12,14 @@ class VersionsByNameStrategy {
15
12
  this.path = path;
16
13
  }
17
14
  read(file) {
18
- return (0, effect_1.pipe)((0, get_1.get)(file.jsonFile.contents, ...this.path.split('.')), effect_1.Effect.flatMap((value) => getOptionOfNonEmptyObject(value)), effect_1.Effect.map((obj) => Object.entries(obj)), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`VersionsByNameStrategy#${this.name} found nothing at <${file.jsonFile.shortPath}>.${this.path}`)),
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}`)),
19
16
  // if value is invalid, default to empty
20
- effect_1.Effect.catchAll(() => effect_1.Effect.succeed([])));
17
+ Effect.catchAll(() => Effect.succeed([])));
21
18
  }
22
19
  write(file, [name, version]) {
23
- const nextValue = version === delete_1.DELETE ? undefined : version;
24
- return (0, effect_1.pipe)((0, get_1.get)(file.jsonFile.contents, ...this.path.split('.')), effect_1.Effect.flatMap(getOptionOfNonEmptyObject), effect_1.Effect.flatMap((parent) => effect_1.Effect.try(() => {
20
+ const nextValue = version === DELETE ? undefined : version;
21
+ return pipe(get(file.jsonFile.contents, ...this.path.split('.')), Effect.flatMap(getOptionOfNonEmptyObject), Effect.flatMap((parent) => Effect.try(() => {
25
22
  parent[name] = nextValue;
26
- })), effect_1.Effect.tapError(() => effect_1.Effect.logDebug(`strategy ${this._tag} with name ${this.name} failed to write to <${file.jsonFile.shortPath}>.${this.path}.${name}`)), effect_1.Effect.catchAll(() => effect_1.Effect.succeed(file)), effect_1.Effect.map(() => file));
23
+ })), 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));
27
24
  }
28
25
  }
29
- exports.VersionsByNameStrategy = VersionsByNameStrategy;