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
package/dist/constants.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_CONFIG = exports.CUSTOM_TYPES = exports.INTERNAL_TYPES = exports.RANGE = exports.ICON = exports.CWD = void 0;
4
1
  /** Single source of truth, intended to aid testing or to override */
5
- exports.CWD = process.env.MOCK_CWD || process.cwd();
2
+ export const CWD = process.env.MOCK_CWD || process.cwd();
6
3
  /** Single source of truth for icons used in output */
7
- exports.ICON = {
4
+ export const ICON = {
8
5
  banned: '⦸',
9
6
  cross: '✘',
10
7
  debug: '?',
@@ -14,7 +11,7 @@ exports.ICON = {
14
11
  skip: '-',
15
12
  tick: '✓',
16
13
  };
17
- exports.RANGE = {
14
+ export const RANGE = {
18
15
  ANY: '*',
19
16
  EXACT: '',
20
17
  GT: '>',
@@ -26,7 +23,7 @@ exports.RANGE = {
26
23
  PATCH: '~',
27
24
  WORKSPACE: 'workspace:',
28
25
  };
29
- exports.INTERNAL_TYPES = [
26
+ export const INTERNAL_TYPES = [
30
27
  'dev',
31
28
  'local',
32
29
  'overrides',
@@ -35,7 +32,7 @@ exports.INTERNAL_TYPES = [
35
32
  'prod',
36
33
  'resolutions',
37
34
  ];
38
- exports.CUSTOM_TYPES = {
35
+ export const CUSTOM_TYPES = {
39
36
  dev: {
40
37
  strategy: 'versionsByName',
41
38
  path: 'devDependencies',
@@ -66,8 +63,8 @@ exports.CUSTOM_TYPES = {
66
63
  path: 'resolutions',
67
64
  },
68
65
  };
69
- exports.DEFAULT_CONFIG = {
70
- customTypes: exports.CUSTOM_TYPES,
66
+ export const DEFAULT_CONFIG = {
67
+ customTypes: CUSTOM_TYPES,
71
68
  dependencyTypes: ['**'],
72
69
  filter: '.',
73
70
  formatBugs: true,
@@ -1,14 +1,14 @@
1
1
  import { Effect } from 'effect';
2
- import type { InvalidCustomTypeError } from '../config/get-custom-types';
3
- import type { DeprecatedTypesError, RenamedWorkspaceTypeError } from '../config/get-enabled-types';
4
- import type { NoSourcesFoundError } from '../get-package-json-files/get-file-paths';
5
- import type { GlobError } from '../io/glob-sync';
6
- import type { ReadFileError } from '../io/read-file-sync';
7
- import type { JsonParseError } from '../io/read-json-file-sync';
8
- import type { WriteFileError } from '../io/write-file-sync';
9
- import type { SemverGroup } from '../semver-group';
10
- import type { VersionGroup } from '../version-group';
11
- type R = Effect.Effect<never, never, void>;
2
+ import type { InvalidCustomTypeError } from '../config/get-custom-types.js';
3
+ import type { DeprecatedTypesError, RenamedWorkspaceTypeError } from '../config/get-enabled-types.js';
4
+ import type { NoSourcesFoundError } from '../get-package-json-files/get-file-paths.js';
5
+ import type { GlobError } from '../io/glob-sync.js';
6
+ import type { ReadFileError } from '../io/read-file-sync.js';
7
+ import type { JsonParseError } from '../io/read-json-file-sync.js';
8
+ import type { WriteFileError } from '../io/write-file-sync.js';
9
+ import type { SemverGroup } from '../semver-group/index.js';
10
+ import type { VersionGroup } from '../version-group/index.js';
11
+ type R = Effect.Effect<void>;
12
12
  export interface ErrorHandlers {
13
13
  DeprecatedTypesError(err: DeprecatedTypesError): R;
14
14
  InvalidCustomTypeError(err: InvalidCustomTypeError): R;
@@ -1,86 +1,80 @@
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.defaultErrorHandlers = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const effect_1 = require("effect");
9
- const os_1 = require("os");
10
- exports.defaultErrorHandlers = {
1
+ import chalk from 'chalk';
2
+ import { Effect } from 'effect';
3
+ import { EOL } from 'os';
4
+ export const defaultErrorHandlers = {
11
5
  // getContext
12
6
  GlobError(err) {
13
- return effect_1.Effect.logError([
14
- chalk_1.default.red('An error was found when processing your source globs'),
15
- chalk_1.default.red(' Error:', err.error),
16
- ].join(os_1.EOL));
7
+ return Effect.logError([
8
+ chalk.red('An error was found when processing your source globs'),
9
+ chalk.red(' Error:', err.error),
10
+ ].join(EOL));
17
11
  },
18
12
  JsonParseError(err) {
19
- return effect_1.Effect.logError([
20
- chalk_1.default.red('An error was found when parsing a JSON file'),
21
- chalk_1.default.red(' File:', err.filePath),
22
- chalk_1.default.red(' Error:', err.error),
23
- ].join(os_1.EOL));
13
+ return Effect.logError([
14
+ chalk.red('An error was found when parsing a JSON file'),
15
+ chalk.red(' File:', err.filePath),
16
+ chalk.red(' Error:', err.error),
17
+ ].join(EOL));
24
18
  },
25
19
  NoSourcesFoundError(err) {
26
- return effect_1.Effect.logError([
27
- chalk_1.default.red('No package.json files were found'),
28
- chalk_1.default.red(' CWD:', err.CWD),
29
- chalk_1.default.red(' Sources:', err.patterns),
30
- ].join(os_1.EOL));
20
+ return Effect.logError([
21
+ chalk.red('No package.json files were found'),
22
+ chalk.red(' CWD:', err.CWD),
23
+ chalk.red(' Sources:', err.patterns),
24
+ ].join(EOL));
31
25
  },
32
26
  ReadFileError(err) {
33
- return effect_1.Effect.logError([
34
- chalk_1.default.red('An error was found when reading a file'),
35
- chalk_1.default.red(' File:', err.filePath),
36
- chalk_1.default.red(' Error:', err.error),
37
- ].join(os_1.EOL));
27
+ return Effect.logError([
28
+ chalk.red('An error was found when reading a file'),
29
+ chalk.red(' File:', err.filePath),
30
+ chalk.red(' Error:', err.error),
31
+ ].join(EOL));
38
32
  },
39
33
  // Others
40
34
  DeprecatedTypesError(err) {
41
35
  const url = 'https://github.com/JamieMason/syncpack/releases/tag/9.0.0';
42
- return effect_1.Effect.logError([
43
- chalk_1.default.red(`Your syncpack config file contains values deprecated in ${url}`),
44
- chalk_1.default.red(' Dependency Types:', err.types),
45
- chalk_1.default.red(' Docs: https://jamiemason.github.io/syncpack/config/dependency-types'),
46
- ].join(os_1.EOL));
36
+ return Effect.logError([
37
+ chalk.red(`Your syncpack config file contains values deprecated in ${url}`),
38
+ chalk.red(' Dependency Types:', err.types),
39
+ chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/dependency-types'),
40
+ ].join(EOL));
47
41
  },
48
42
  InvalidCustomTypeError(err) {
49
- return effect_1.Effect.logError([
50
- chalk_1.default.red('Your syncpack config file contains an invalid custom type'),
51
- chalk_1.default.red(' Error:', err.reason),
52
- chalk_1.default.red(' Config:', err.config),
53
- chalk_1.default.red(' Docs: https://jamiemason.github.io/syncpack/config/custom-types'),
54
- ].join(os_1.EOL));
43
+ return Effect.logError([
44
+ chalk.red('Your syncpack config file contains an invalid custom type'),
45
+ chalk.red(' Error:', err.reason),
46
+ chalk.red(' Config:', err.config),
47
+ chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/custom-types'),
48
+ ].join(EOL));
55
49
  },
56
50
  RenamedWorkspaceTypeError() {
57
51
  const url = 'https://github.com/JamieMason/syncpack/releases/tag/11.2.1';
58
- return effect_1.Effect.logError([
59
- chalk_1.default.red(`The "workspace" dependency type was renamed to "local" in ${url}`),
60
- chalk_1.default.red(' Docs: https://jamiemason.github.io/syncpack/config/dependency-types'),
61
- ].join(os_1.EOL));
52
+ return Effect.logError([
53
+ chalk.red(`The "workspace" dependency type was renamed to "local" in ${url}`),
54
+ chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/dependency-types'),
55
+ ].join(EOL));
62
56
  },
63
57
  SemverGroupConfigError(err) {
64
- return effect_1.Effect.logError([
65
- chalk_1.default.red('Your semver group config contains an error'),
66
- chalk_1.default.red(' Error:', err.error),
67
- chalk_1.default.red(' Config:', err.config),
68
- chalk_1.default.red(' Docs: https://jamiemason.github.io/syncpack/config/semver-groups'),
69
- ].join(os_1.EOL));
58
+ return Effect.logError([
59
+ chalk.red('Your semver group config contains an error'),
60
+ chalk.red(' Error:', err.error),
61
+ chalk.red(' Config:', err.config),
62
+ chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/semver-groups'),
63
+ ].join(EOL));
70
64
  },
71
65
  VersionGroupConfigError(err) {
72
- return effect_1.Effect.logError([
73
- chalk_1.default.red('Your version group config contains an error'),
74
- chalk_1.default.red(' Error:', err.error),
75
- chalk_1.default.red(' Config:', err.config),
76
- chalk_1.default.red(' Docs: https://jamiemason.github.io/syncpack/config/version-groups'),
77
- ].join(os_1.EOL));
66
+ return Effect.logError([
67
+ chalk.red('Your version group config contains an error'),
68
+ chalk.red(' Error:', err.error),
69
+ chalk.red(' Config:', err.config),
70
+ chalk.red(' Docs: https://jamiemason.github.io/syncpack/config/version-groups'),
71
+ ].join(EOL));
78
72
  },
79
73
  WriteFileError(err) {
80
- return effect_1.Effect.logError([
81
- chalk_1.default.red('An error was found when writing to a file'),
82
- chalk_1.default.red(' File:', err.filePath),
83
- chalk_1.default.red(' Error:', err.error),
84
- ].join(os_1.EOL));
74
+ return Effect.logError([
75
+ chalk.red('An error was found when writing to a file'),
76
+ chalk.red(' File:', err.filePath),
77
+ chalk.red(' Error:', err.error),
78
+ ].join(EOL));
85
79
  },
86
80
  };
@@ -1,9 +1,9 @@
1
1
  import { Effect } from 'effect';
2
2
  import type { O } from 'ts-toolbelt';
3
- import { type CliConfig, type RcConfig } from '../config/types';
4
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers';
5
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
6
- import type { Io } from '../io';
3
+ import { type CliConfig, type RcConfig } from '../config/types.js';
4
+ import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
5
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
6
+ import type { Io } from '../io/index.js';
7
7
  export interface Ctx {
8
8
  readonly config: {
9
9
  readonly cli: Partial<CliConfig>;
@@ -19,5 +19,5 @@ interface Input {
19
19
  cli: Partial<CliConfig>;
20
20
  errorHandlers: ErrorHandlers;
21
21
  }
22
- export declare function getContext({ io, cli, errorHandlers }: Input): Effect.Effect<never, never, Ctx>;
22
+ export declare function getContext({ io, cli, errorHandlers }: Input): Effect.Effect<Ctx>;
23
23
  export {};
@@ -1,22 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContext = void 0;
4
- const effect_1 = require("effect");
5
- const get_package_json_files_1 = require("../get-package-json-files");
6
- const read_config_file_sync_1 = require("../io/read-config-file-sync");
7
- const key_by_1 = require("./lib/key-by");
8
- function getContext({ io, cli, errorHandlers }) {
9
- const exitOnError = effect_1.Effect.flatMap(() => effect_1.Effect.failSync(() => io.process.exit(1)));
10
- return (0, effect_1.pipe)(effect_1.Effect.Do, effect_1.Effect.bind('rcFile', () => (0, read_config_file_sync_1.readConfigFileSync)(io, cli.configPath)), effect_1.Effect.bind('packageJsonFiles', ({ rcFile }) => (0, get_package_json_files_1.getPackageJsonFiles)(io, { cli, rcFile })), effect_1.Effect.map(({ rcFile, packageJsonFiles }) => ({
1
+ import { Effect, flow, pipe } from 'effect';
2
+ import { getPackageJsonFiles } from '../get-package-json-files/index.js';
3
+ import { readConfigFile } from '../io/read-config-file.js';
4
+ import { keyBy } from './lib/key-by.js';
5
+ export function getContext({ io, cli, errorHandlers }) {
6
+ const exitOnError = Effect.flatMap(() => Effect.failSync(() => io.process.exit(1)));
7
+ return pipe(Effect.Do, Effect.bind('rcFile', () => readConfigFile(io, cli.configPath)), Effect.bind('packageJsonFiles', ({ rcFile }) => getPackageJsonFiles(io, { cli, rcFile })), Effect.map(({ rcFile, packageJsonFiles }) => ({
11
8
  config: { cli, rcFile },
12
9
  isInvalid: false,
13
10
  packageJsonFiles,
14
- packageJsonFilesByName: (0, key_by_1.keyBy)('name', packageJsonFiles),
15
- })), effect_1.Effect.catchTags({
16
- GlobError: (0, effect_1.flow)(errorHandlers.GlobError, exitOnError),
17
- JsonParseError: (0, effect_1.flow)(errorHandlers.JsonParseError, exitOnError),
18
- NoSourcesFoundError: (0, effect_1.flow)(errorHandlers.NoSourcesFoundError, exitOnError),
19
- ReadFileError: (0, effect_1.flow)(errorHandlers.ReadFileError, exitOnError),
11
+ packageJsonFilesByName: keyBy('name', packageJsonFiles),
12
+ })), Effect.catchTags({
13
+ GlobError: flow(errorHandlers.GlobError, exitOnError),
14
+ JsonParseError: flow(errorHandlers.JsonParseError, exitOnError),
15
+ NoSourcesFoundError: flow(errorHandlers.NoSourcesFoundError, exitOnError),
16
+ ReadFileError: flow(errorHandlers.ReadFileError, exitOnError),
20
17
  }));
21
18
  }
22
- exports.getContext = getContext;
@@ -1,16 +1,12 @@
1
- "use strict";
2
1
  /**
3
2
  * Convert an array of objects to an object, where each member of the array has
4
3
  * a unique value for the given key. The new object keys each object by its
5
4
  * value for the given key.
6
5
  */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.keyBy = void 0;
9
- function keyBy(key, array) {
6
+ export function keyBy(key, array) {
10
7
  return array.reduce((objectsByKeyValue, obj) => {
11
8
  const value = obj[key];
12
9
  objectsByKeyValue[value] = obj;
13
10
  return objectsByKeyValue;
14
11
  }, {});
15
12
  }
16
- exports.keyBy = keyBy;
@@ -1,14 +1,14 @@
1
1
  import { Effect } from 'effect';
2
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers';
3
- import type { Ctx } from '../get-context';
4
- import type { Io } from '../io';
5
- import type { SemverGroup } from '../semver-group';
6
- import type { VersionGroup } from '../version-group';
7
- import type { Instance } from './instance';
2
+ import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
3
+ import type { Ctx } from '../get-context/index.js';
4
+ import type { Io } from '../io/index.js';
5
+ import type { SemverGroup } from '../semver-group/index.js';
6
+ import type { VersionGroup } from '../version-group/index.js';
7
+ import type { Instance } from './instance.js';
8
8
  interface Instances {
9
9
  all: Instance[];
10
10
  semverGroups: SemverGroup.Any[];
11
11
  versionGroups: VersionGroup.Any[];
12
12
  }
13
- export declare function getInstances(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<never, never, Instances>;
13
+ export declare function getInstances(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<Instances>;
14
14
  export {};
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInstances = void 0;
4
- const effect_1 = require("effect");
5
- const get_enabled_types_1 = require("../config/get-enabled-types");
6
- const can_add_to_group_1 = require("../guards/can-add-to-group");
7
- const sort_by_name_1 = require("../lib/sort-by-name");
8
- const create_semver_groups_1 = require("../semver-group/create-semver-groups");
9
- const create_version_groups_1 = require("../version-group/create-version-groups");
10
- function getInstances(ctx, io, errorHandlers) {
11
- const exitOnError = effect_1.Effect.flatMap(() => effect_1.Effect.failSync(() => io.process.exit(1)));
12
- return (0, effect_1.pipe)(effect_1.Effect.Do, effect_1.Effect.bind('enabledTypes', () => (0, get_enabled_types_1.getEnabledTypes)(ctx.config)), effect_1.Effect.bind('semverGroups', () => (0, create_semver_groups_1.createSemverGroups)(ctx)), effect_1.Effect.bind('versionGroups', () => (0, create_version_groups_1.createVersionGroups)(ctx)), effect_1.Effect.bind('instances', (acc) => (0, effect_1.pipe)(ctx.packageJsonFiles, effect_1.Effect.forEach((file) => file.getInstances(acc.enabledTypes)), effect_1.Effect.map((instancesByFile) => instancesByFile.flat()))), effect_1.Effect.tap(({ instances, semverGroups, versionGroups }) => effect_1.Effect.sync(() => {
1
+ import { Effect, flow, pipe } from 'effect';
2
+ import { getEnabledTypes } from '../config/get-enabled-types.js';
3
+ import { canAddToGroup } from '../guards/can-add-to-group.js';
4
+ import { sortByName } from '../lib/sort-by-name.js';
5
+ import { createSemverGroups } from '../semver-group/create-semver-groups.js';
6
+ import { createVersionGroups } from '../version-group/create-version-groups.js';
7
+ export function getInstances(ctx, io, errorHandlers) {
8
+ const exitOnError = Effect.flatMap(() => Effect.failSync(() => io.process.exit(1)));
9
+ return pipe(Effect.Do, Effect.bind('enabledTypes', () => getEnabledTypes(ctx.config)), Effect.bind('semverGroups', () => createSemverGroups(ctx)), Effect.bind('versionGroups', () => createVersionGroups(ctx)), Effect.bind('instances', (acc) => pipe(ctx.packageJsonFiles, Effect.forEach((file) => file.getInstances(acc.enabledTypes)), Effect.map((instancesByFile) => instancesByFile.flat()))), Effect.tap(({ instances, semverGroups, versionGroups }) => Effect.sync(() => {
13
10
  for (const instance of instances) {
14
11
  // assign each instance to its semver group, first match wins
15
12
  assignToSemverGroup: for (const group of semverGroups) {
16
- if ((0, can_add_to_group_1.canAddToGroup)(ctx.packageJsonFilesByName, group, instance)) {
13
+ if (canAddToGroup(ctx.packageJsonFilesByName, group, instance)) {
17
14
  instance.semverGroup = group;
18
15
  group.instances.push(instance);
19
16
  break assignToSemverGroup;
@@ -21,26 +18,25 @@ function getInstances(ctx, io, errorHandlers) {
21
18
  }
22
19
  // assign each instance to its version group, first match wins
23
20
  assignToVersionGroup: for (const group of versionGroups) {
24
- if ((0, can_add_to_group_1.canAddToGroup)(ctx.packageJsonFilesByName, group, instance)) {
21
+ if (canAddToGroup(ctx.packageJsonFilesByName, group, instance)) {
25
22
  instance.versionGroup = group;
26
23
  group.instances.push(instance);
27
24
  break assignToVersionGroup;
28
25
  }
29
26
  }
30
27
  }
31
- })), effect_1.Effect.map(({ instances, semverGroups, versionGroups }) => ({
28
+ })), Effect.map(({ instances, semverGroups, versionGroups }) => ({
32
29
  all: instances,
33
30
  semverGroups: getSortedAndFiltered(semverGroups),
34
31
  versionGroups: getSortedAndFiltered(versionGroups),
35
- })), effect_1.Effect.catchTags({
36
- DeprecatedTypesError: (0, effect_1.flow)(errorHandlers.DeprecatedTypesError, exitOnError),
37
- InvalidCustomTypeError: (0, effect_1.flow)(errorHandlers.InvalidCustomTypeError, exitOnError),
38
- RenamedWorkspaceTypeError: (0, effect_1.flow)(errorHandlers.RenamedWorkspaceTypeError, exitOnError),
39
- SemverGroupConfigError: (0, effect_1.flow)(errorHandlers.SemverGroupConfigError, exitOnError),
40
- VersionGroupConfigError: (0, effect_1.flow)(errorHandlers.VersionGroupConfigError, exitOnError),
32
+ })), Effect.catchTags({
33
+ DeprecatedTypesError: flow(errorHandlers.DeprecatedTypesError, exitOnError),
34
+ InvalidCustomTypeError: flow(errorHandlers.InvalidCustomTypeError, exitOnError),
35
+ RenamedWorkspaceTypeError: flow(errorHandlers.RenamedWorkspaceTypeError, exitOnError),
36
+ SemverGroupConfigError: flow(errorHandlers.SemverGroupConfigError, exitOnError),
37
+ VersionGroupConfigError: flow(errorHandlers.VersionGroupConfigError, exitOnError),
41
38
  }));
42
39
  function getSortedAndFiltered(groups) {
43
- return groups.filter((group) => group.instances.sort(sort_by_name_1.sortByName).length > 0);
40
+ return groups.filter((group) => group.instances.sort(sortByName).length > 0);
44
41
  }
45
42
  }
46
- exports.getInstances = getInstances;
@@ -1,10 +1,10 @@
1
1
  import type { Effect } from 'effect';
2
- import type { Strategy } from '../config/get-custom-types';
3
- import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
4
- import type { SemverGroup } from '../semver-group';
5
- import { Specifier } from '../specifier';
6
- import type { VersionGroup } from '../version-group';
7
- import type { Delete } from '../version-group/lib/delete';
2
+ import type { Strategy } from '../config/get-custom-types.js';
3
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
4
+ import type { SemverGroup } from '../semver-group/index.js';
5
+ import { Specifier } from '../specifier/index.js';
6
+ import type { VersionGroup } from '../version-group/index.js';
7
+ import type { Delete } from '../version-group/lib/delete.js';
8
8
  export declare class Instance {
9
9
  /** The name of this dependency */
10
10
  name: string;
@@ -22,5 +22,5 @@ export declare class Instance {
22
22
  versionGroup: VersionGroup.Any;
23
23
  constructor(name: string, rawSpecifier: string, packageJsonFile: PackageJsonFile, strategy: Strategy.Any);
24
24
  /** Mutate the package.json file in memory with the latest version specifier */
25
- write(rawSpecifier: string | Delete): Effect.Effect<never, never, PackageJsonFile>;
25
+ write(rawSpecifier: string | Delete): Effect.Effect<PackageJsonFile>;
26
26
  }
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Instance = void 0;
4
- const specifier_1 = require("../specifier");
5
- class Instance {
1
+ import { Specifier } from '../specifier/index.js';
2
+ export class Instance {
6
3
  /** The name of this dependency */
7
4
  name;
8
5
  /** The .name property of the package.json file of this instance */
@@ -24,12 +21,11 @@ class Instance {
24
21
  this.strategy = strategy;
25
22
  this.semverGroup = null;
26
23
  this.versionGroup = null;
27
- this.rawSpecifier = specifier_1.Specifier.create(this, rawSpecifier);
24
+ this.rawSpecifier = Specifier.create(this, rawSpecifier);
28
25
  }
29
26
  /** Mutate the package.json file in memory with the latest version specifier */
30
27
  write(rawSpecifier) {
31
- this.rawSpecifier = specifier_1.Specifier.create(this, rawSpecifier);
28
+ this.rawSpecifier = Specifier.create(this, rawSpecifier);
32
29
  return this.strategy.write(this.packageJsonFile, [this.name, this.rawSpecifier.raw]);
33
30
  }
34
31
  }
35
- exports.Instance = Instance;
@@ -1,10 +1,10 @@
1
- import { Data, 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
- declare const NoSourcesFoundError_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 { Ctx } from '../get-context/index.js';
3
+ import type { GlobError } from '../io/glob-sync.js';
4
+ import type { Io } from '../io/index.js';
5
+ declare const NoSourcesFoundError_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
6
  readonly _tag: "NoSourcesFoundError";
7
- }>;
7
+ };
8
8
  export declare class NoSourcesFoundError extends NoSourcesFoundError_base<{
9
9
  readonly CWD: string;
10
10
  readonly patterns: string[];
@@ -17,5 +17,5 @@ export declare class NoSourcesFoundError extends NoSourcesFoundError_base<{
17
17
  *
18
18
  * @returns Array of absolute file paths to package.json files
19
19
  */
20
- export declare function getFilePaths(io: Io, config: Ctx['config']): Effect.Effect<never, GlobError | NoSourcesFoundError, string[]>;
20
+ export declare function getFilePaths(io: Io, config: Ctx['config']): Effect.Effect<string[], GlobError | NoSourcesFoundError>;
21
21
  export {};
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFilePaths = exports.NoSourcesFoundError = void 0;
4
- const effect_1 = require("effect");
5
- const uniq_1 = require("tightrope/array/uniq");
6
- const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
7
- const glob_sync_1 = require("../io/glob-sync");
8
- const get_patterns_1 = require("./get-patterns");
9
- class NoSourcesFoundError extends effect_1.Data.TaggedClass('NoSourcesFoundError') {
1
+ import { Data, Effect, pipe } from 'effect';
2
+ import { uniq } from 'tightrope/array/uniq.js';
3
+ import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
4
+ import { globSync } from '../io/glob-sync.js';
5
+ import { getPatterns } from './get-patterns/index.js';
6
+ export class NoSourcesFoundError extends Data.TaggedClass('NoSourcesFoundError') {
10
7
  }
11
- exports.NoSourcesFoundError = NoSourcesFoundError;
12
8
  /**
13
9
  * Using --source options and/or config files on disk from
14
10
  * npm/pnpm/yarn/lerna, return an array of absolute paths to every package.json
@@ -16,12 +12,11 @@ exports.NoSourcesFoundError = NoSourcesFoundError;
16
12
  *
17
13
  * @returns Array of absolute file paths to package.json files
18
14
  */
19
- function getFilePaths(io, config) {
20
- return (0, effect_1.pipe)(effect_1.Effect.Do, effect_1.Effect.bind('patterns', () => (0, get_patterns_1.getPatterns)(io, config)), effect_1.Effect.bind('filePaths', ({ patterns }) => (0, glob_sync_1.globSync)(io, patterns)), effect_1.Effect.bind('flatFilePaths', ({ filePaths }) => effect_1.Effect.sync(() => (0, uniq_1.uniq)(filePaths.flat()))), effect_1.Effect.flatMap(({ flatFilePaths, patterns }) => (0, is_non_empty_array_1.isNonEmptyArray)(flatFilePaths)
21
- ? effect_1.Effect.succeed(flatFilePaths)
22
- : effect_1.Effect.fail(new NoSourcesFoundError({
15
+ export function getFilePaths(io, config) {
16
+ return pipe(Effect.Do, Effect.bind('patterns', () => getPatterns(io, config)), Effect.bind('filePaths', ({ patterns }) => globSync(io, patterns)), Effect.bind('flatFilePaths', ({ filePaths }) => Effect.sync(() => uniq(filePaths.flat()))), Effect.flatMap(({ flatFilePaths, patterns }) => isNonEmptyArray(flatFilePaths)
17
+ ? Effect.succeed(flatFilePaths)
18
+ : Effect.fail(new NoSourcesFoundError({
23
19
  CWD: io.process.cwd(),
24
20
  patterns,
25
21
  }))));
26
22
  }
27
- exports.getFilePaths = getFilePaths;
@@ -1,3 +1,3 @@
1
1
  import { Effect, Option as O } from 'effect';
2
- import type { Io } from '../../io';
3
- export declare function getLernaPatterns(io: Io): Effect.Effect<never, never, O.Option<string[]>>;
2
+ import type { Io } from '../../io/index.js';
3
+ export declare function getLernaPatterns(io: Io): Effect.Effect<O.Option<string[]>>;
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLernaPatterns = void 0;
4
- const effect_1 = require("effect");
5
- const path_1 = require("path");
6
- const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
7
- const read_json_file_sync_1 = require("../../io/read-json-file-sync");
8
- function getLernaPatterns(io) {
9
- return (0, effect_1.pipe)((0, read_json_file_sync_1.readJsonFileSync)(io, (0, path_1.join)(io.process.cwd(), 'lerna.json')), effect_1.Effect.map((file) => (0, is_array_of_strings_1.isArrayOfStrings)(file.contents.packages) ? effect_1.Option.some(file.contents.packages) : effect_1.Option.none()), effect_1.Effect.catchTags({
10
- ReadFileError: () => effect_1.Effect.succeed(effect_1.Option.none()),
11
- JsonParseError: () => effect_1.Effect.succeed(effect_1.Option.none()),
1
+ import { Effect, Option as O, pipe } from 'effect';
2
+ import { join } from 'path';
3
+ import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
4
+ import { readJsonFileSync } from '../../io/read-json-file-sync.js';
5
+ export function getLernaPatterns(io) {
6
+ return pipe(readJsonFileSync(io, join(io.process.cwd(), 'lerna.json')), Effect.map((file) => isArrayOfStrings(file.contents.packages) ? O.some(file.contents.packages) : O.none()), Effect.catchTags({
7
+ ReadFileError: () => Effect.succeed(O.none()),
8
+ JsonParseError: () => Effect.succeed(O.none()),
12
9
  }));
13
10
  }
14
- exports.getLernaPatterns = getLernaPatterns;
@@ -1,3 +1,3 @@
1
1
  import { Effect, Option as O } from 'effect';
2
- import { type Io } from '../../io';
3
- export declare function getPnpmPatterns(io: Io): Effect.Effect<never, never, O.Option<string[]>>;
2
+ import { type Io } from '../../io/index.js';
3
+ export declare function getPnpmPatterns(io: Io): Effect.Effect<O.Option<string[]>>;
@@ -1,18 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPnpmPatterns = void 0;
4
- const effect_1 = require("effect");
5
- const path_1 = require("path");
6
- const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
7
- const read_yaml_file_sync_1 = require("../../io/read-yaml-file-sync");
8
- function getPnpmPatterns(io) {
9
- return (0, effect_1.pipe)(
1
+ import { Effect, Option as O, pipe } from 'effect';
2
+ import { join } from 'path';
3
+ import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
4
+ import { readYamlFileSync } from '../../io/read-yaml-file-sync.js';
5
+ export function getPnpmPatterns(io) {
6
+ return pipe(
10
7
  // packages:
11
8
  // - "packages/**"
12
9
  // - "components/**"
13
10
  // - "!**/test/**"
14
- (0, read_yaml_file_sync_1.readYamlFileSync)(io, (0, path_1.join)(io.process.cwd(), 'pnpm-workspace.yaml')), effect_1.Effect.map((file) => ((0, is_array_of_strings_1.isArrayOfStrings)(file?.packages) ? effect_1.Option.some(file.packages) : effect_1.Option.none())), effect_1.Effect.catchTags({
15
- ReadYamlFileError: () => effect_1.Effect.succeed(effect_1.Option.none()),
11
+ readYamlFileSync(io, join(io.process.cwd(), 'pnpm-workspace.yaml')), Effect.map((file) => (isArrayOfStrings(file?.packages) ? O.some(file.packages) : O.none())), Effect.catchTags({
12
+ ReadYamlFileError: () => Effect.succeed(O.none()),
16
13
  }));
17
14
  }
18
- exports.getPnpmPatterns = getPnpmPatterns;
@@ -1,3 +1,3 @@
1
1
  import { Effect, Option as O } from 'effect';
2
- import type { Io } from '../../io';
3
- export declare function getYarnPatterns(io: Io): Effect.Effect<never, never, O.Option<string[]>>;
2
+ import type { Io } from '../../io/index.js';
3
+ export declare function getYarnPatterns(io: Io): Effect.Effect<O.Option<string[]>>;
@@ -1,20 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getYarnPatterns = void 0;
4
- const effect_1 = require("effect");
5
- const path_1 = require("path");
6
- const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
7
- const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
8
- const read_json_file_sync_1 = require("../../io/read-json-file-sync");
9
- function getYarnPatterns(io) {
10
- return (0, effect_1.pipe)((0, read_json_file_sync_1.readJsonFileSync)(io, (0, path_1.join)(io.process.cwd(), 'package.json')), effect_1.Effect.map((file) => (0, is_non_empty_object_1.isNonEmptyObject)(file.contents.workspaces) &&
11
- (0, is_array_of_strings_1.isArrayOfStrings)(file.contents.workspaces.packages)
12
- ? effect_1.Option.some(file.contents.workspaces.packages)
13
- : (0, is_array_of_strings_1.isArrayOfStrings)(file.contents.workspaces)
14
- ? effect_1.Option.some(file.contents.workspaces)
15
- : effect_1.Option.none()), effect_1.Effect.catchTags({
16
- ReadFileError: () => effect_1.Effect.succeed(effect_1.Option.none()),
17
- JsonParseError: () => effect_1.Effect.succeed(effect_1.Option.none()),
1
+ import { Effect, Option as O, pipe } from 'effect';
2
+ import { join } from 'path';
3
+ import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
4
+ import { isNonEmptyObject } from 'tightrope/guard/is-non-empty-object.js';
5
+ import { readJsonFileSync } from '../../io/read-json-file-sync.js';
6
+ export function getYarnPatterns(io) {
7
+ return pipe(readJsonFileSync(io, join(io.process.cwd(), 'package.json')), Effect.map((file) => isNonEmptyObject(file.contents.workspaces) &&
8
+ isArrayOfStrings(file.contents.workspaces.packages)
9
+ ? O.some(file.contents.workspaces.packages)
10
+ : isArrayOfStrings(file.contents.workspaces)
11
+ ? O.some(file.contents.workspaces)
12
+ : O.none()), Effect.catchTags({
13
+ ReadFileError: () => Effect.succeed(O.none()),
14
+ JsonParseError: () => Effect.succeed(O.none()),
18
15
  }));
19
16
  }
20
- exports.getYarnPatterns = getYarnPatterns;