syncpack 12.3.0 → 12.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +9 -9
  2. package/dist/bin-fix-mismatches/fix-mismatches.js +43 -54
  3. package/dist/bin-fix-mismatches/index.js +26 -31
  4. package/dist/bin-format/format.d.ts +6 -6
  5. package/dist/bin-format/format.js +27 -32
  6. package/dist/bin-format/index.js +20 -25
  7. package/dist/bin-lint/index.js +15 -20
  8. package/dist/bin-lint/lint.d.ts +4 -4
  9. package/dist/bin-lint/lint.js +28 -35
  10. package/dist/bin-lint-semver-ranges/index.js +24 -29
  11. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +8 -8
  12. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +34 -44
  13. package/dist/bin-list/index.js +24 -29
  14. package/dist/bin-list/list.d.ts +7 -7
  15. package/dist/bin-list/list.js +55 -64
  16. package/dist/bin-list-mismatches/index.js +24 -29
  17. package/dist/bin-list-mismatches/list-mismatches.d.ts +10 -10
  18. package/dist/bin-list-mismatches/list-mismatches.js +62 -70
  19. package/dist/bin-prompt/index.js +26 -31
  20. package/dist/bin-prompt/prompt.d.ts +4 -4
  21. package/dist/bin-prompt/prompt.js +41 -48
  22. package/dist/bin-set-semver-ranges/index.js +26 -31
  23. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +4 -4
  24. package/dist/bin-set-semver-ranges/set-semver-ranges.js +26 -30
  25. package/dist/bin-update/effects.d.ts +18 -18
  26. package/dist/bin-update/effects.js +77 -106
  27. package/dist/bin-update/index.js +23 -28
  28. package/dist/bin-update/update.d.ts +5 -5
  29. package/dist/bin-update/update.js +33 -40
  30. package/dist/bin.js +8 -5
  31. package/dist/config/get-custom-types.d.ts +9 -9
  32. package/dist/config/get-custom-types.js +22 -27
  33. package/dist/config/get-enabled-types.d.ts +8 -8
  34. package/dist/config/get-enabled-types.js +42 -48
  35. package/dist/config/get-filter.d.ts +1 -1
  36. package/dist/config/get-filter.js +6 -10
  37. package/dist/config/get-indent.d.ts +1 -1
  38. package/dist/config/get-indent.js +6 -10
  39. package/dist/config/get-sort-az.d.ts +1 -1
  40. package/dist/config/get-sort-az.js +6 -10
  41. package/dist/config/get-sort-exports.d.ts +1 -1
  42. package/dist/config/get-sort-exports.js +6 -10
  43. package/dist/config/get-sort-first.d.ts +1 -1
  44. package/dist/config/get-sort-first.js +6 -10
  45. package/dist/config/get-source.d.ts +1 -1
  46. package/dist/config/get-source.js +4 -8
  47. package/dist/config/tag.d.ts +1 -1
  48. package/dist/config/tag.js +2 -5
  49. package/dist/config/types.d.ts +2 -5
  50. package/dist/config/types.js +1 -2
  51. package/dist/constants.js +7 -10
  52. package/dist/error-handlers/default-error-handlers.d.ts +10 -10
  53. package/dist/error-handlers/default-error-handlers.js +55 -61
  54. package/dist/get-context/index.d.ts +5 -5
  55. package/dist/get-context/index.js +13 -17
  56. package/dist/get-context/lib/key-by.js +1 -5
  57. package/dist/get-instances/index.d.ts +7 -7
  58. package/dist/get-instances/index.js +19 -23
  59. package/dist/get-instances/instance.d.ts +7 -7
  60. package/dist/get-instances/instance.js +4 -8
  61. package/dist/get-package-json-files/get-file-paths.d.ts +7 -7
  62. package/dist/get-package-json-files/get-file-paths.js +10 -15
  63. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +2 -2
  64. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +8 -12
  65. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +2 -2
  66. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +8 -12
  67. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +2 -2
  68. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +14 -18
  69. package/dist/get-package-json-files/get-patterns/index.d.ts +3 -3
  70. package/dist/get-package-json-files/get-patterns/index.js +11 -15
  71. package/dist/get-package-json-files/index.d.ts +8 -8
  72. package/dist/get-package-json-files/index.js +6 -10
  73. package/dist/get-package-json-files/package-json-file.d.ts +6 -6
  74. package/dist/get-package-json-files/package-json-file.js +8 -12
  75. package/dist/guards/can-add-to-group.d.ts +4 -4
  76. package/dist/guards/can-add-to-group.js +10 -14
  77. package/dist/guards/is-semver.js +3 -7
  78. package/dist/guards/is-valid-semver-range.d.ts +1 -1
  79. package/dist/guards/is-valid-semver-range.js +12 -16
  80. package/dist/index.d.ts +1 -1
  81. package/dist/index.js +1 -2
  82. package/dist/io/ask-for-choice.d.ts +5 -5
  83. package/dist/io/ask-for-choice.js +5 -9
  84. package/dist/io/ask-for-input.d.ts +5 -5
  85. package/dist/io/ask-for-input.js +5 -9
  86. package/dist/io/exit-if-invalid.d.ts +3 -3
  87. package/dist/io/exit-if-invalid.js +5 -9
  88. package/dist/io/glob-sync.d.ts +5 -5
  89. package/dist/io/glob-sync.js +4 -9
  90. package/dist/io/index.d.ts +8 -8
  91. package/dist/io/index.js +12 -38
  92. package/dist/io/read-config-file.d.ts +7 -0
  93. package/dist/io/read-config-file.js +22 -0
  94. package/dist/io/read-file-sync.d.ts +5 -5
  95. package/dist/io/read-file-sync.js +4 -9
  96. package/dist/io/read-json-file-sync.d.ts +8 -8
  97. package/dist/io/read-json-file-sync.js +10 -16
  98. package/dist/io/read-yaml-file-sync.d.ts +5 -5
  99. package/dist/io/read-yaml-file-sync.js +4 -8
  100. package/dist/io/to-json.d.ts +2 -2
  101. package/dist/io/to-json.js +8 -12
  102. package/dist/io/write-file-sync.d.ts +5 -5
  103. package/dist/io/write-file-sync.js +5 -10
  104. package/dist/io/write-if-changed.d.ts +4 -4
  105. package/dist/io/write-if-changed.js +9 -16
  106. package/dist/lib/format-repository-url.js +1 -5
  107. package/dist/lib/get-group-header.d.ts +2 -2
  108. package/dist/lib/get-group-header.js +4 -12
  109. package/dist/lib/get.d.ts +10 -10
  110. package/dist/lib/get.js +15 -19
  111. package/dist/lib/pad-start.js +1 -5
  112. package/dist/lib/ring-buffer.js +1 -5
  113. package/dist/lib/set-semver-range.d.ts +1 -1
  114. package/dist/lib/set-semver-range.js +8 -12
  115. package/dist/lib/show-help-on-error.js +3 -10
  116. package/dist/lib/sort-by-name.js +1 -5
  117. package/dist/lib/with-logger.d.ts +1 -1
  118. package/dist/lib/with-logger.js +17 -24
  119. package/dist/option.d.ts +1 -1
  120. package/dist/option.js +8 -14
  121. package/dist/report.d.ts +2 -2
  122. package/dist/report.js +2 -5
  123. package/dist/semver-group/create-semver-groups.d.ts +3 -3
  124. package/dist/semver-group/create-semver-groups.js +28 -32
  125. package/dist/semver-group/disabled.d.ts +11 -11
  126. package/dist/semver-group/disabled.js +6 -10
  127. package/dist/semver-group/filtered-out.d.ts +12 -12
  128. package/dist/semver-group/filtered-out.js +8 -12
  129. package/dist/semver-group/ignored.d.ts +11 -11
  130. package/dist/semver-group/ignored.js +6 -10
  131. package/dist/semver-group/index.d.ts +6 -7
  132. package/dist/semver-group/index.js +4 -7
  133. package/dist/semver-group/with-range.d.ts +11 -11
  134. package/dist/semver-group/with-range.js +13 -17
  135. package/dist/specifier/alias.d.ts +5 -5
  136. package/dist/specifier/alias.js +9 -13
  137. package/dist/specifier/base.d.ts +7 -7
  138. package/dist/specifier/base.js +9 -13
  139. package/dist/specifier/delete.d.ts +5 -5
  140. package/dist/specifier/delete.js +5 -9
  141. package/dist/specifier/exact.d.ts +6 -6
  142. package/dist/specifier/exact.js +7 -11
  143. package/dist/specifier/file.d.ts +1 -1
  144. package/dist/specifier/file.js +2 -6
  145. package/dist/specifier/hosted-git.d.ts +5 -5
  146. package/dist/specifier/hosted-git.js +9 -13
  147. package/dist/specifier/index.d.ts +13 -13
  148. package/dist/specifier/index.js +28 -31
  149. package/dist/specifier/latest.d.ts +6 -6
  150. package/dist/specifier/latest.js +7 -11
  151. package/dist/specifier/lib/non-semver-error.d.ts +5 -5
  152. package/dist/specifier/lib/non-semver-error.js +3 -7
  153. package/dist/specifier/lib/parse-specifier.d.ts +1 -1
  154. package/dist/specifier/lib/parse-specifier.js +4 -11
  155. package/dist/specifier/lib/specific-registry-result.js +1 -2
  156. package/dist/specifier/range.d.ts +6 -6
  157. package/dist/specifier/range.js +7 -11
  158. package/dist/specifier/tag.d.ts +2 -2
  159. package/dist/specifier/tag.js +2 -6
  160. package/dist/specifier/unsupported.d.ts +1 -1
  161. package/dist/specifier/unsupported.js +2 -6
  162. package/dist/specifier/url.d.ts +1 -1
  163. package/dist/specifier/url.js +2 -6
  164. package/dist/specifier/workspace-protocol.d.ts +7 -7
  165. package/dist/specifier/workspace-protocol.js +9 -13
  166. package/dist/strategy/lib/get-non-empty-string-prop.d.ts +2 -2
  167. package/dist/strategy/lib/get-non-empty-string-prop.js +6 -10
  168. package/dist/strategy/name-and-version-props.d.ts +4 -4
  169. package/dist/strategy/name-and-version-props.js +19 -23
  170. package/dist/strategy/named-version-string.d.ts +4 -4
  171. package/dist/strategy/named-version-string.js +20 -24
  172. package/dist/strategy/unnamed-version-string.d.ts +4 -4
  173. package/dist/strategy/unnamed-version-string.js +17 -21
  174. package/dist/strategy/versions-by-name.d.ts +4 -4
  175. package/dist/strategy/versions-by-name.js +11 -15
  176. package/dist/version-group/banned.d.ts +7 -7
  177. package/dist/version-group/banned.js +8 -12
  178. package/dist/version-group/create-version-groups.d.ts +3 -3
  179. package/dist/version-group/create-version-groups.js +34 -38
  180. package/dist/version-group/filtered-out.d.ts +8 -8
  181. package/dist/version-group/filtered-out.js +8 -12
  182. package/dist/version-group/ignored.d.ts +7 -7
  183. package/dist/version-group/ignored.js +6 -10
  184. package/dist/version-group/index.d.ts +9 -10
  185. package/dist/version-group/index.js +4 -7
  186. package/dist/version-group/lib/clean.js +4 -11
  187. package/dist/version-group/lib/delete.js +1 -4
  188. package/dist/version-group/lib/get-highest-version.d.ts +2 -2
  189. package/dist/version-group/lib/get-highest-version.js +3 -7
  190. package/dist/version-group/lib/get-lowest-version.d.ts +2 -2
  191. package/dist/version-group/lib/get-lowest-version.js +3 -7
  192. package/dist/version-group/lib/get-preferred-version.d.ts +4 -4
  193. package/dist/version-group/lib/get-preferred-version.js +17 -24
  194. package/dist/version-group/lib/get-range-score.js +13 -17
  195. package/dist/version-group/lib/group-by.js +1 -5
  196. package/dist/version-group/pinned.d.ts +7 -7
  197. package/dist/version-group/pinned.js +8 -12
  198. package/dist/version-group/same-range.d.ts +8 -8
  199. package/dist/version-group/same-range.js +23 -30
  200. package/dist/version-group/snapped-to.d.ts +7 -7
  201. package/dist/version-group/snapped-to.js +20 -24
  202. package/dist/version-group/standard.d.ts +7 -7
  203. package/dist/version-group/standard.js +29 -33
  204. package/package.json +30 -37
  205. package/dist/io/read-config-file-sync.d.ts +0 -7
  206. package/dist/io/read-config-file-sync.js +0 -26
@@ -1,8 +1,8 @@
1
1
  import { Effect } from 'effect';
2
- import type { Ctx } from '../../get-context';
3
- import type { Io } from '../../io';
2
+ import type { Ctx } from '../../get-context/index.js';
3
+ import type { Io } from '../../io/index.js';
4
4
  /**
5
5
  * Find every glob pattern which should be used to find package.json files for
6
6
  * this monorepo.
7
7
  */
8
- export declare function getPatterns(io: Io, config: Ctx['config']): Effect.Effect<never, never, string[]>;
8
+ export declare function getPatterns(io: Io, config: Ctx['config']): Effect.Effect<string[]>;
@@ -1,27 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPatterns = void 0;
4
- const effect_1 = require("effect");
5
- const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
6
- const get_source_1 = require("../../config/get-source");
7
- const constants_1 = require("../../constants");
8
- const get_lerna_patterns_1 = require("./get-lerna-patterns");
9
- const get_pnpm_patterns_1 = require("./get-pnpm-patterns");
10
- const get_yarn_patterns_1 = require("./get-yarn-patterns");
1
+ import { Effect, Option as O, pipe } from 'effect';
2
+ import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
3
+ import { getSource } from '../../config/get-source.js';
4
+ import { DEFAULT_CONFIG } from '../../constants.js';
5
+ import { getLernaPatterns } from './get-lerna-patterns.js';
6
+ import { getPnpmPatterns } from './get-pnpm-patterns.js';
7
+ import { getYarnPatterns } from './get-yarn-patterns.js';
11
8
  /**
12
9
  * Find every glob pattern which should be used to find package.json files for
13
10
  * this monorepo.
14
11
  */
15
- function getPatterns(io, config) {
16
- return (0, effect_1.pipe)(getCliPatterns(), effect_1.Effect.flatMap((opt) => (effect_1.Option.isSome(opt) ? effect_1.Effect.succeed(opt) : getWorkspacePatterns())), effect_1.Effect.map(effect_1.Option.map(limitToPackageJson)), effect_1.Effect.map(effect_1.Option.getOrElse(() => [...constants_1.DEFAULT_CONFIG.source])));
12
+ export function getPatterns(io, config) {
13
+ return pipe(getCliPatterns(), Effect.flatMap((opt) => (O.isSome(opt) ? Effect.succeed(opt) : getWorkspacePatterns())), Effect.map(O.map(limitToPackageJson)), Effect.map(O.getOrElse(() => [...DEFAULT_CONFIG.source])));
17
14
  function getCliPatterns() {
18
- return (0, effect_1.pipe)(effect_1.Option.some((0, get_source_1.getSource)(config)), effect_1.Option.filter(is_array_of_strings_1.isArrayOfStrings), effect_1.Effect.succeed);
15
+ return pipe(O.some(getSource(config)), O.filter(isArrayOfStrings), Effect.succeed);
19
16
  }
20
17
  function getWorkspacePatterns() {
21
- return (0, effect_1.pipe)((0, get_yarn_patterns_1.getYarnPatterns)(io), effect_1.Effect.flatMap((opt) => (effect_1.Option.isSome(opt) ? effect_1.Effect.succeed(opt) : (0, get_pnpm_patterns_1.getPnpmPatterns)(io))), effect_1.Effect.flatMap((opt) => (effect_1.Option.isSome(opt) ? effect_1.Effect.succeed(opt) : (0, get_lerna_patterns_1.getLernaPatterns)(io))), effect_1.Effect.map(effect_1.Option.map((patterns) => ['package.json', ...patterns])));
18
+ return pipe(getYarnPatterns(io), Effect.flatMap((opt) => (O.isSome(opt) ? Effect.succeed(opt) : getPnpmPatterns(io))), Effect.flatMap((opt) => (O.isSome(opt) ? Effect.succeed(opt) : getLernaPatterns(io))), Effect.map(O.map((patterns) => ['package.json', ...patterns])));
22
19
  }
23
20
  function limitToPackageJson(patterns) {
24
21
  return patterns.map((pattern) => pattern.includes('package.json') ? pattern : `${pattern}/package.json`);
25
22
  }
26
23
  }
27
- exports.getPatterns = getPatterns;
@@ -1,10 +1,10 @@
1
1
  import { Effect } from 'effect';
2
- import type { Ctx } from '../get-context';
3
- import type { Io } from '../io';
4
- import type { GlobError } from '../io/glob-sync';
5
- import type { ReadFileError } from '../io/read-file-sync';
6
- import type { JsonParseError } from '../io/read-json-file-sync';
7
- import type { NoSourcesFoundError } from './get-file-paths';
8
- import { PackageJsonFile } from './package-json-file';
2
+ import type { Ctx } from '../get-context/index.js';
3
+ import type { GlobError } from '../io/glob-sync.js';
4
+ import type { Io } from '../io/index.js';
5
+ import type { ReadFileError } from '../io/read-file-sync.js';
6
+ import type { JsonParseError } from '../io/read-json-file-sync.js';
7
+ import type { NoSourcesFoundError } from './get-file-paths.js';
8
+ import { PackageJsonFile } from './package-json-file.js';
9
9
  /** Create an API for every package.json file needed. */
10
- export declare function getPackageJsonFiles(io: Io, config: Ctx['config']): Effect.Effect<never, NoSourcesFoundError | GlobError | ReadFileError | JsonParseError, PackageJsonFile[]>;
10
+ export declare function getPackageJsonFiles(io: Io, config: Ctx['config']): Effect.Effect<PackageJsonFile[], NoSourcesFoundError | GlobError | ReadFileError | JsonParseError>;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPackageJsonFiles = void 0;
4
- const effect_1 = require("effect");
5
- const read_json_file_sync_1 = require("../io/read-json-file-sync");
6
- const get_file_paths_1 = require("./get-file-paths");
7
- const package_json_file_1 = require("./package-json-file");
1
+ import { Effect, pipe } from 'effect';
2
+ import { readJsonFileSync } from '../io/read-json-file-sync.js';
3
+ import { getFilePaths } from './get-file-paths.js';
4
+ import { PackageJsonFile } from './package-json-file.js';
8
5
  /** Create an API for every package.json file needed. */
9
- function getPackageJsonFiles(io, config) {
10
- return (0, effect_1.pipe)((0, get_file_paths_1.getFilePaths)(io, config), effect_1.Effect.flatMap((filePaths) => effect_1.Effect.all(filePaths.map((filePath) => (0, read_json_file_sync_1.readJsonFileSync)(io, filePath)))), effect_1.Effect.map((files) => files.map((file) => new package_json_file_1.PackageJsonFile(file, config))), effect_1.Effect.tap((files) => effect_1.Effect.logDebug(`${files.length} package.json files found`)));
6
+ export function getPackageJsonFiles(io, config) {
7
+ return pipe(getFilePaths(io, config), Effect.flatMap((filePaths) => Effect.all(filePaths.map((filePath) => readJsonFileSync(io, filePath)))), Effect.map((files) => files.map((file) => new PackageJsonFile(file, config))), Effect.tap((files) => Effect.logDebug(`${files.length} package.json files found`)));
11
8
  }
12
- exports.getPackageJsonFiles = getPackageJsonFiles;
@@ -1,9 +1,9 @@
1
1
  import { Effect } from 'effect';
2
- import type { RcFile } from '..';
3
- import type { Strategy } from '../config/get-custom-types';
4
- import type { Ctx } from '../get-context';
5
- import { Instance } from '../get-instances/instance';
6
- import type { JsonFile } from '../io/read-json-file-sync';
2
+ import type { Strategy } from '../config/get-custom-types.js';
3
+ import type { Ctx } from '../get-context/index.js';
4
+ import { Instance } from '../get-instances/instance.js';
5
+ import type { RcFile } from '../index.js';
6
+ import type { JsonFile } from '../io/read-json-file-sync.js';
7
7
  export type PackageJson = {
8
8
  bugs?: {
9
9
  url: string;
@@ -43,5 +43,5 @@ export declare class PackageJsonFile {
43
43
  /** the .name property from the package.json file */
44
44
  name: string | undefined;
45
45
  constructor(jsonFile: JsonFile<PackageJson>, config: Ctx['config']);
46
- getInstances(enabledTypes: Strategy.Any[]): Effect.Effect<never, never, Instance[]>;
46
+ getInstances(enabledTypes: Strategy.Any[]): Effect.Effect<Instance[]>;
47
47
  }
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PackageJsonFile = void 0;
4
- const effect_1 = require("effect");
5
- const instance_1 = require("../get-instances/instance");
6
- class PackageJsonFile {
1
+ import { Effect, pipe } from 'effect';
2
+ import { Instance } from '../get-instances/instance.js';
3
+ export class PackageJsonFile {
7
4
  /** resolved configuration */
8
5
  config;
9
6
  /** ensure only one set of instances is ever created and shared */
@@ -20,14 +17,13 @@ class PackageJsonFile {
20
17
  }
21
18
  getInstances(enabledTypes) {
22
19
  if (!this._instances) {
23
- return (0, effect_1.pipe)(effect_1.Effect.all(enabledTypes.map((strategy) => (0, effect_1.pipe)(strategy.read(this), effect_1.Effect.map((entries) => entries.map(([name, rawSpecifier]) => new instance_1.Instance(name, rawSpecifier, this, strategy)))))), effect_1.Effect.map((array) => array.flat()), effect_1.Effect.tapBoth({
24
- onSuccess: (instances) => effect_1.Effect.logDebug(`found ${instances.length} instances in <${this.jsonFile.shortPath}>`),
25
- onFailure: () => effect_1.Effect.logError(`failed to get instances from <${this.jsonFile.shortPath}>`),
26
- }), effect_1.Effect.catchAll(() => effect_1.Effect.succeed([])), effect_1.Effect.tap((instances) => effect_1.Effect.sync(() => {
20
+ return pipe(Effect.all(enabledTypes.map((strategy) => pipe(strategy.read(this), Effect.map((entries) => entries.map(([name, rawSpecifier]) => new Instance(name, rawSpecifier, this, strategy)))))), Effect.map((array) => array.flat()), Effect.tapBoth({
21
+ onSuccess: (instances) => Effect.logDebug(`found ${instances.length} instances in <${this.jsonFile.shortPath}>`),
22
+ onFailure: () => Effect.logError(`failed to get instances from <${this.jsonFile.shortPath}>`),
23
+ }), Effect.catchAll(() => Effect.succeed([])), Effect.tap((instances) => Effect.sync(() => {
27
24
  this._instances = instances;
28
25
  })));
29
26
  }
30
- return effect_1.Effect.succeed(this._instances);
27
+ return Effect.succeed(this._instances);
31
28
  }
32
29
  }
33
- exports.PackageJsonFile = PackageJsonFile;
@@ -1,5 +1,5 @@
1
- import type { Ctx } from '../get-context';
2
- import type { Instance } from '../get-instances/instance';
3
- import type { SemverGroup } from '../semver-group';
4
- import type { VersionGroup } from '../version-group';
1
+ import type { Ctx } from '../get-context/index.js';
2
+ import type { Instance } from '../get-instances/instance.js';
3
+ import type { SemverGroup } from '../semver-group/index.js';
4
+ import type { VersionGroup } from '../version-group/index.js';
5
5
  export declare function canAddToGroup(packageJsonFilesByName: Ctx['packageJsonFilesByName'], group: SemverGroup.Any | VersionGroup.Any, instance: Instance): boolean;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.canAddToGroup = void 0;
4
- const minimatch_1 = require("minimatch");
5
- const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
6
- function canAddToGroup(packageJsonFilesByName, group, instance) {
1
+ import { minimatch } from 'minimatch';
2
+ import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
3
+ export function canAddToGroup(packageJsonFilesByName, group, instance) {
7
4
  const { dependencies, dependencyTypes, packages, specifierTypes } = group.config;
8
5
  return (group.canAdd(instance) &&
9
6
  matchesDependencyTypes(dependencyTypes, instance) &&
@@ -11,22 +8,21 @@ function canAddToGroup(packageJsonFilesByName, group, instance) {
11
8
  matchesDependencies(packageJsonFilesByName, group, dependencies, instance) &&
12
9
  matchesSpecifierTypes(specifierTypes, instance));
13
10
  }
14
- exports.canAddToGroup = canAddToGroup;
15
11
  function matchesDependencies(packageJsonFilesByName, group, dependencies, instance) {
16
12
  // matches if not defined
17
- if (!(0, is_non_empty_array_1.isNonEmptyArray)(dependencies))
13
+ if (!isNonEmptyArray(dependencies))
18
14
  return true;
19
15
  return dependencies.some((pattern) => (pattern === '$LOCAL' &&
20
16
  instance.name in packageJsonFilesByName &&
21
17
  ((group.groupType === 'versionGroup' && instance.versionGroup === null) ||
22
18
  (group.groupType === 'semverGroup' && instance.semverGroup === null))) ||
23
- (0, minimatch_1.minimatch)(instance.name, pattern));
19
+ minimatch(instance.name, pattern));
24
20
  }
25
21
  function matchesPackages(packages, instance) {
26
22
  // matches if not defined
27
- if (!(0, is_non_empty_array_1.isNonEmptyArray)(packages))
23
+ if (!isNonEmptyArray(packages))
28
24
  return true;
29
- return packages.some((pattern) => (0, minimatch_1.minimatch)(instance.pkgName, pattern));
25
+ return packages.some((pattern) => minimatch(instance.pkgName, pattern));
30
26
  }
31
27
  function matchesDependencyTypes(dependencyTypes, instance) {
32
28
  return matchesKnownList(dependencyTypes, instance.strategy.name);
@@ -36,7 +32,7 @@ function matchesSpecifierTypes(specifierTypes, instance) {
36
32
  }
37
33
  function matchesKnownList(values, value) {
38
34
  // matches if not defined
39
- if (!(0, is_non_empty_array_1.isNonEmptyArray)(values))
35
+ if (!isNonEmptyArray(values))
40
36
  return true;
41
37
  if (values.join('') === '**')
42
38
  return true;
@@ -50,7 +46,7 @@ function matchesKnownList(values, value) {
50
46
  positive.push(name);
51
47
  }
52
48
  });
53
- if ((0, is_non_empty_array_1.isNonEmptyArray)(negative) && !negative.includes(value))
49
+ if (isNonEmptyArray(negative) && !negative.includes(value))
54
50
  return true;
55
- return (0, is_non_empty_array_1.isNonEmptyArray)(positive) && positive.includes(value);
51
+ return isNonEmptyArray(positive) && positive.includes(value);
56
52
  }
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSemver = void 0;
4
- const is_string_1 = require("tightrope/guard/is-string");
1
+ import { isString } from 'tightrope/guard/is-string.js';
5
2
  /** @deprecated migrate to make better use of npm-package-arg */
6
- function isSemver(version) {
3
+ export function isSemver(version) {
7
4
  const range = '(~|\\^|>=|>|<=|<)?';
8
5
  const ints = '[0-9]+';
9
6
  const intsOrX = '([0-9]+|x)';
@@ -11,7 +8,6 @@ function isSemver(version) {
11
8
  const major = new RegExp(`^${range}${ints}$`);
12
9
  const minor = new RegExp(`^${range}${ints}${dot}${intsOrX}$`);
13
10
  const patch = new RegExp(`^${range}${ints}${dot}${intsOrX}${dot}${intsOrX}$`);
14
- return ((0, is_string_1.isString)(version) &&
11
+ return (isString(version) &&
15
12
  (version.search(major) !== -1 || version.search(minor) !== -1 || version.search(patch) !== -1));
16
13
  }
17
- exports.isSemver = isSemver;
@@ -1,3 +1,3 @@
1
- import type { SemverRange } from '../config/types';
1
+ import type { SemverRange } from '../config/types.js';
2
2
  /** @deprecated migrate to make better use of npm-package-arg */
3
3
  export declare function isValidSemverRange(value: unknown): value is SemverRange;
@@ -1,18 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidSemverRange = void 0;
4
- const constants_1 = require("../constants");
1
+ import { RANGE } from '../constants.js';
5
2
  /** @deprecated migrate to make better use of npm-package-arg */
6
- function isValidSemverRange(value) {
7
- return (value === constants_1.RANGE.ANY ||
8
- value === constants_1.RANGE.EXACT ||
9
- value === constants_1.RANGE.GT ||
10
- value === constants_1.RANGE.GTE ||
11
- value === constants_1.RANGE.LOOSE ||
12
- value === constants_1.RANGE.LT ||
13
- value === constants_1.RANGE.LTE ||
14
- value === constants_1.RANGE.MINOR ||
15
- value === constants_1.RANGE.PATCH ||
16
- value === constants_1.RANGE.WORKSPACE);
3
+ export function isValidSemverRange(value) {
4
+ return (value === RANGE.ANY ||
5
+ value === RANGE.EXACT ||
6
+ value === RANGE.GT ||
7
+ value === RANGE.GTE ||
8
+ value === RANGE.LOOSE ||
9
+ value === RANGE.LT ||
10
+ value === RANGE.LTE ||
11
+ value === RANGE.MINOR ||
12
+ value === RANGE.PATCH ||
13
+ value === RANGE.WORKSPACE);
17
14
  }
18
- exports.isValidSemverRange = isValidSemverRange;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { RcConfig } from './config/types';
1
+ import type { RcConfig } from './config/types.js';
2
2
  export type RcFile = Partial<RcConfig>;
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,8 +1,8 @@
1
- import { Data, Effect } from 'effect';
2
- import type { Io } from '.';
3
- declare const AskForChoiceError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<Omit<A, keyof import("effect/Equal").Equal>, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" | keyof import("effect/Equal").Equal ? never : P]: A[P]; }) => Data.Data<Readonly<A> & {
1
+ import { Effect } from 'effect';
2
+ import type { Io } from './index.js';
3
+ declare const AskForChoiceError_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> & {
4
4
  readonly _tag: "AskForChoiceError";
5
- }>;
5
+ };
6
6
  declare class AskForChoiceError extends AskForChoiceError_base<{
7
7
  readonly error: string;
8
8
  }> {
@@ -10,5 +10,5 @@ declare class AskForChoiceError extends AskForChoiceError_base<{
10
10
  export declare function askForChoice(opts: {
11
11
  message: string;
12
12
  choices: string[];
13
- }): Effect.Effect<Io, AskForChoiceError, string>;
13
+ }): Effect.Effect<string, AskForChoiceError, Io>;
14
14
  export {};
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.askForChoice = void 0;
4
- const effect_1 = require("effect");
5
- const _1 = require(".");
6
- class AskForChoiceError extends effect_1.Data.TaggedClass('AskForChoiceError') {
1
+ import { Data, Effect, pipe } from 'effect';
2
+ import { IoTag } from './index.js';
3
+ class AskForChoiceError extends Data.TaggedClass('AskForChoiceError') {
7
4
  }
8
- function askForChoice(opts) {
9
- return (0, effect_1.pipe)(_1.IoTag, effect_1.Effect.flatMap((io) => effect_1.Effect.tryPromise({
5
+ export function askForChoice(opts) {
6
+ return pipe(IoTag, Effect.flatMap((io) => Effect.tryPromise({
10
7
  try: () => io.enquirer
11
8
  .prompt({
12
9
  type: 'select',
@@ -18,4 +15,3 @@ function askForChoice(opts) {
18
15
  catch: (err) => new AskForChoiceError({ error: String(err) }),
19
16
  })));
20
17
  }
21
- exports.askForChoice = askForChoice;
@@ -1,13 +1,13 @@
1
- import { Data, Effect } from 'effect';
2
- import type { Io } from '.';
3
- declare const AskForInputError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<Omit<A, keyof import("effect/Equal").Equal>, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" | keyof import("effect/Equal").Equal ? never : P]: A[P]; }) => Data.Data<Readonly<A> & {
1
+ import { Effect } from 'effect';
2
+ import type { Io } from './index.js';
3
+ declare const AskForInputError_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> & {
4
4
  readonly _tag: "AskForInputError";
5
- }>;
5
+ };
6
6
  declare class AskForInputError extends AskForInputError_base<{
7
7
  readonly error: string;
8
8
  }> {
9
9
  }
10
10
  export declare function askForInput(opts: {
11
11
  message: string;
12
- }): Effect.Effect<Io, AskForInputError, string>;
12
+ }): Effect.Effect<string, AskForInputError, Io>;
13
13
  export {};
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.askForInput = void 0;
4
- const effect_1 = require("effect");
5
- const _1 = require(".");
6
- class AskForInputError extends effect_1.Data.TaggedClass('AskForInputError') {
1
+ import { Data, Effect, pipe } from 'effect';
2
+ import { IoTag } from './index.js';
3
+ class AskForInputError extends Data.TaggedClass('AskForInputError') {
7
4
  }
8
- function askForInput(opts) {
9
- return (0, effect_1.pipe)(_1.IoTag, effect_1.Effect.flatMap((io) => effect_1.Effect.tryPromise({
5
+ export function askForInput(opts) {
6
+ return pipe(IoTag, Effect.flatMap((io) => Effect.tryPromise({
10
7
  try: () => io.enquirer.prompt({
11
8
  name: 'version',
12
9
  type: 'input',
@@ -15,4 +12,3 @@ function askForInput(opts) {
15
12
  catch: (err) => new AskForInputError({ error: String(err) }),
16
13
  })));
17
14
  }
18
- exports.askForInput = askForInput;
@@ -1,4 +1,4 @@
1
1
  import { Effect } from 'effect';
2
- import { type Io } from '.';
3
- import type { Ctx } from '../get-context';
4
- export declare function exitIfInvalid(ctx: Ctx): Effect.Effect<Io, never, Ctx>;
2
+ import type { Ctx } from '../get-context/index.js';
3
+ import { type Io } from './index.js';
4
+ export declare function exitIfInvalid(ctx: Ctx): Effect.Effect<Ctx, never, Io>;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exitIfInvalid = void 0;
4
- const effect_1 = require("effect");
5
- const _1 = require(".");
6
- function exitIfInvalid(ctx) {
7
- return (0, effect_1.pipe)(_1.IoTag, effect_1.Effect.tap((io) => effect_1.Effect.sync(() => {
1
+ import { Effect, pipe } from 'effect';
2
+ import { IoTag } from './index.js';
3
+ export function exitIfInvalid(ctx) {
4
+ return pipe(IoTag, Effect.tap((io) => Effect.sync(() => {
8
5
  if (ctx.isInvalid) {
9
6
  io.process.exit(1);
10
7
  }
11
- })), effect_1.Effect.map(() => ctx));
8
+ })), Effect.map(() => ctx));
12
9
  }
13
- exports.exitIfInvalid = exitIfInvalid;
@@ -1,11 +1,11 @@
1
- import { Data, Effect } from 'effect';
2
- import type { Io } from '.';
3
- declare const GlobError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<Omit<A, keyof import("effect/Equal").Equal>, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" | keyof import("effect/Equal").Equal ? never : P]: A[P]; }) => Data.Data<Readonly<A> & {
1
+ import { Effect } from 'effect';
2
+ import type { Io } from './index.js';
3
+ declare const GlobError_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> & {
4
4
  readonly _tag: "GlobError";
5
- }>;
5
+ };
6
6
  export declare class GlobError extends GlobError_base<{
7
7
  readonly error: string;
8
8
  }> {
9
9
  }
10
- export declare function globSync(io: Io, patterns: string[]): Effect.Effect<never, GlobError, string[]>;
10
+ export declare function globSync(io: Io, patterns: string[]): Effect.Effect<string[], GlobError>;
11
11
  export {};
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.globSync = exports.GlobError = void 0;
4
- const effect_1 = require("effect");
5
- class GlobError extends effect_1.Data.TaggedClass('GlobError') {
1
+ import { Data, Effect } from 'effect';
2
+ export class GlobError extends Data.TaggedClass('GlobError') {
6
3
  }
7
- exports.GlobError = GlobError;
8
- function globSync(io, patterns) {
9
- return effect_1.Effect.try({
4
+ export function globSync(io, patterns) {
5
+ return Effect.try({
10
6
  try: () => io.globby.sync(patterns, {
11
7
  absolute: true,
12
8
  cwd: io.process.cwd(),
@@ -16,4 +12,3 @@ function globSync(io, patterns) {
16
12
  catch: (err) => new GlobError({ error: String(err) }),
17
13
  });
18
14
  }
19
- exports.globSync = globSync;
@@ -1,27 +1,27 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import { cosmiconfig } from 'cosmiconfig';
3
3
  import { Context } from 'effect';
4
- import { prompt } from 'enquirer';
5
- import * as fs from 'fs';
6
- import * as globby from 'globby';
7
- import * as readYamlFile from 'read-yaml-file';
4
+ import enquirer from 'enquirer';
5
+ import fs from 'fs';
6
+ import { globbySync } from 'globby';
7
+ import { sync as readYamlFileSync } from 'read-yaml-file';
8
8
  export interface Io {
9
9
  cosmiconfig: {
10
10
  cosmiconfig: typeof cosmiconfig;
11
11
  };
12
12
  enquirer: {
13
- prompt: typeof prompt<any>;
13
+ prompt: typeof enquirer.prompt<any>;
14
14
  };
15
15
  fs: typeof fs;
16
16
  globby: {
17
- sync: typeof globby.sync;
17
+ sync: typeof globbySync;
18
18
  };
19
19
  process: {
20
20
  cwd: typeof process.cwd;
21
21
  exit: typeof process.exit;
22
22
  };
23
23
  readYamlFile: {
24
- sync: typeof readYamlFile.sync<any>;
24
+ sync: typeof readYamlFileSync<any>;
25
25
  };
26
26
  }
27
27
  export declare const IoTag: Context.Tag<Io, Io>;
package/dist/io/index.js CHANGED
@@ -1,52 +1,26 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.io = exports.IoTag = void 0;
27
- const cosmiconfig_1 = require("cosmiconfig");
28
- const effect_1 = require("effect");
29
- const enquirer_1 = require("enquirer");
30
- const fs = __importStar(require("fs"));
31
- const globby = __importStar(require("globby"));
32
- const readYamlFile = __importStar(require("read-yaml-file"));
33
- exports.IoTag = effect_1.Context.Tag();
34
- exports.io = {
1
+ import { cosmiconfig } from 'cosmiconfig';
2
+ import { Context } from 'effect';
3
+ import enquirer from 'enquirer';
4
+ import fs from 'fs';
5
+ import { globbySync } from 'globby';
6
+ import { sync as readYamlFileSync } from 'read-yaml-file';
7
+ export const IoTag = Context.GenericTag('@services/IoTag');
8
+ export const io = {
35
9
  cosmiconfig: {
36
- cosmiconfig: cosmiconfig_1.cosmiconfig,
10
+ cosmiconfig,
37
11
  },
38
12
  enquirer: {
39
- prompt: enquirer_1.prompt,
13
+ prompt: enquirer.prompt,
40
14
  },
41
15
  fs: fs,
42
16
  globby: {
43
- sync: globby.sync,
17
+ sync: globbySync,
44
18
  },
45
19
  process: {
46
20
  cwd: process.cwd,
47
21
  exit: process.exit,
48
22
  },
49
23
  readYamlFile: {
50
- sync: readYamlFile.sync,
24
+ sync: readYamlFileSync,
51
25
  },
52
26
  };
@@ -0,0 +1,7 @@
1
+ import { Effect } from 'effect';
2
+ import type { O } from 'ts-toolbelt';
3
+ import type { RcConfig } from '../config/types.js';
4
+ import type { Io } from './index.js';
5
+ type UnverifiedRcConfig = O.Partial<RcConfig, 'deep'>;
6
+ export declare function readConfigFile(io: Io, configPath?: string): Effect.Effect<UnverifiedRcConfig>;
7
+ export {};
@@ -0,0 +1,22 @@
1
+ import { Effect, Option, pipe } from 'effect';
2
+ import { join } from 'path';
3
+ import { isNonEmptyObject } from 'tightrope/guard/is-non-empty-object.js';
4
+ import { readJsonFileSync } from './read-json-file-sync.js';
5
+ const getOptionOfNonEmptyObject = Option.liftPredicate((isNonEmptyObject));
6
+ export function readConfigFile(io, configPath) {
7
+ return pipe(Effect.try(() => io.cosmiconfig.cosmiconfig('syncpack')), Effect.flatMap((client) => Effect.tryPromise(() => (configPath ? client.load(configPath) : client.search()))), Effect.flatMap((result) => result !== null ? getValueFromCosmiconfig(result) : findConfigInPackageJson(io)), Effect.tap((config) => Effect.logDebug(`config file found: ${JSON.stringify(config)}`)), Effect.tapError(() => Effect.logDebug('no config file found, will use defaults')), Effect.catchAll(() => Effect.succeed({})));
8
+ }
9
+ /**
10
+ * Look for a .config.syncpack property in the root package.json.
11
+ * @see https://github.com/JamieMason/syncpack/issues/86
12
+ */
13
+ function findConfigInPackageJson(io) {
14
+ return pipe(Effect.Do, Effect.bind('rcPath', () => Effect.succeed(join(io.process.cwd(), 'package.json'))), Effect.bind('packageJson', ({ rcPath }) => readJsonFileSync(io, rcPath)), Effect.bind('config', ({ packageJson }) => Effect.try(() => packageJson.contents?.config?.syncpack)), Effect.flatMap(({ config }) => getOptionOfNonEmptyObject(config)), Effect.tapBoth({
15
+ onSuccess: () => Effect.logDebug('config found in <package.json>.config.syncpack'),
16
+ onFailure: () => Effect.logDebug('config not found in <package.json>.config.syncpack'),
17
+ }));
18
+ }
19
+ /** Extract the value from a successful search by cosmiconfig */
20
+ function getValueFromCosmiconfig(result) {
21
+ return pipe(Effect.succeed(result), Effect.tap((result) => Effect.logDebug(`cosmiconfig found ${result.filepath}`)), Effect.flatMap((result) => getOptionOfNonEmptyObject(result.config)));
22
+ }
@@ -1,12 +1,12 @@
1
- import { Data, Effect } from 'effect';
2
- import type { Io } from '.';
3
- declare const ReadFileError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<Omit<A, keyof import("effect/Equal").Equal>, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" | keyof import("effect/Equal").Equal ? never : P]: A[P]; }) => Data.Data<Readonly<A> & {
1
+ import { Effect } from 'effect';
2
+ import type { Io } from './index.js';
3
+ declare const ReadFileError_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> & {
4
4
  readonly _tag: "ReadFileError";
5
- }>;
5
+ };
6
6
  export declare class ReadFileError extends ReadFileError_base<{
7
7
  readonly filePath: string;
8
8
  readonly error: string;
9
9
  }> {
10
10
  }
11
- export declare function readFileSync(io: Io, filePath: string): Effect.Effect<never, ReadFileError, string>;
11
+ export declare function readFileSync(io: Io, filePath: string): Effect.Effect<string, ReadFileError>;
12
12
  export {};