syncpack 9.8.4 → 9.8.6

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 (59) hide show
  1. package/LICENSE +12 -13
  2. package/dist/bin-fix-mismatches/fix-mismatches.js +5 -4
  3. package/dist/bin-format/format.js +3 -3
  4. package/dist/bin-list/list.js +5 -3
  5. package/dist/bin-list-mismatches/list-mismatches.js +9 -8
  6. package/dist/get-context/$R.d.ts +8 -9
  7. package/dist/get-context/$R.js +13 -12
  8. package/dist/get-context/get-config/get-custom-types.js +1 -1
  9. package/dist/get-context/get-config/get-enabled-types.js +3 -3
  10. package/dist/get-context/get-config/index.d.ts +2 -3
  11. package/dist/get-context/get-config/index.js +21 -14
  12. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.d.ts +2 -3
  13. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.js +6 -4
  14. package/dist/get-context/get-config/path-strategy/name-and-version-props.js +15 -11
  15. package/dist/get-context/get-config/path-strategy/name-and-version-string.js +17 -12
  16. package/dist/get-context/get-config/path-strategy/types.d.ts +3 -4
  17. package/dist/get-context/get-config/path-strategy/version-string.js +17 -12
  18. package/dist/get-context/get-config/path-strategy/versions-by-name.js +10 -12
  19. package/dist/get-context/get-config/schema/index.d.ts +272 -272
  20. package/dist/get-context/get-config/schema/semver-group.d.ts +18 -18
  21. package/dist/get-context/get-config/schema/version-group.d.ts +40 -40
  22. package/dist/get-context/get-groups/base-group.js +1 -1
  23. package/dist/get-context/get-groups/index.d.ts +2 -3
  24. package/dist/get-context/get-groups/index.js +4 -2
  25. package/dist/get-context/get-groups/version-group/index.d.ts +3 -3
  26. package/dist/get-context/get-groups/version-group/index.js +11 -7
  27. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.d.ts +2 -3
  28. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +5 -5
  29. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.d.ts +2 -3
  30. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.js +4 -4
  31. package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +8 -9
  32. package/dist/get-context/get-groups/version-group/instance-group/index.js +30 -15
  33. package/dist/get-context/get-package-json-files/get-file-paths.d.ts +2 -3
  34. package/dist/get-context/get-package-json-files/get-file-paths.js +14 -24
  35. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +2 -3
  36. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +6 -5
  37. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +2 -3
  38. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +7 -6
  39. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +2 -3
  40. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +7 -6
  41. package/dist/get-context/get-package-json-files/get-patterns/index.d.ts +2 -3
  42. package/dist/get-context/get-package-json-files/get-patterns/index.js +8 -17
  43. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.d.ts +2 -3
  44. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.js +6 -9
  45. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.d.ts +2 -3
  46. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +4 -3
  47. package/dist/get-context/get-package-json-files/index.d.ts +2 -3
  48. package/dist/get-context/get-package-json-files/index.js +7 -5
  49. package/dist/get-context/get-package-json-files/package-json-file/index.js +7 -5
  50. package/dist/get-context/get-package-json-files/package-json-file/instance.js +5 -5
  51. package/dist/get-context/index.js +9 -6
  52. package/dist/lib/disk.js +1 -1
  53. package/dist/lib/is-semver.js +1 -1
  54. package/dist/lib/log.js +1 -1
  55. package/package.json +17 -18
  56. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.d.ts +0 -1
  57. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.js +0 -8
  58. package/dist/get-context/get-package-json-files/get-patterns/props.d.ts +0 -6
  59. package/dist/get-context/get-package-json-files/get-patterns/props.js +0 -24
@@ -1,12 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InstanceGroup = exports.DELETE = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const expect_more_1 = require("expect-more");
4
+ const uniq_1 = require("tightrope/array/uniq");
5
+ const get_1 = require("tightrope/fn/get");
6
+ const identity_1 = require("tightrope/fn/identity");
7
+ const pipe_1 = require("tightrope/fn/pipe");
8
+ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
9
+ const filter_1 = require("tightrope/option/filter");
10
+ const map_1 = require("tightrope/option/map");
11
+ const ok_or_1 = require("tightrope/option/ok-or");
12
+ const result_1 = require("tightrope/result");
13
+ const and_then_1 = require("tightrope/result/and-then");
14
+ const filter_2 = require("tightrope/result/filter");
15
+ const is_ok_1 = require("tightrope/result/is-ok");
16
+ const map_2 = require("tightrope/result/map");
17
+ const map_err_1 = require("tightrope/result/map-err");
18
+ const unwrap_1 = require("tightrope/result/unwrap");
6
19
  const error_1 = require("../../../../lib/error");
7
20
  const is_semver_1 = require("../../../../lib/is-semver");
8
21
  const print_strings_1 = require("../../../../lib/print-strings");
9
- const props_1 = require("../../../get-package-json-files/get-patterns/props");
10
22
  const get_highest_version_1 = require("./get-highest-version");
11
23
  const get_lowest_version_1 = require("./get-lowest-version");
12
24
  exports.DELETE = Symbol('DELETE');
@@ -21,7 +33,7 @@ class InstanceGroup {
21
33
  return this.instances.some((obj) => !(0, is_semver_1.isSemver)(obj.version));
22
34
  }
23
35
  getUniqueVersions() {
24
- return Array.from(new Set(this.instances.map((obj) => obj.version))).sort();
36
+ return (0, uniq_1.uniq)(this.instances.map((obj) => obj.version)).sort();
25
37
  }
26
38
  hasMismatchingVersions() {
27
39
  return this.getUniqueVersions().length > 1;
@@ -36,15 +48,15 @@ class InstanceGroup {
36
48
  getExpectedVersion() {
37
49
  const versionGroup = this.versionGroup;
38
50
  if (versionGroup.isBanned())
39
- return ts_belt_1.R.Ok(exports.DELETE);
51
+ return new result_1.Ok(exports.DELETE);
40
52
  if (versionGroup.isUnpinned())
41
- return (0, ts_belt_1.pipe)(versionGroup.getPinnedVersion(), ts_belt_1.O.toResult(new error_1.BaseError(`${this.name} is in a versionGroup with pinVersion configuration, but the pinVersion value is not valid`)));
42
- if (versionGroup.hasSnappedToPackages() && ts_belt_1.R.getExn(this.isUnsnapped()))
53
+ return (0, pipe_1.pipe)(versionGroup.getPinnedVersion(), (0, ok_or_1.okOr)(new error_1.BaseError(`${this.name} is in a versionGroup with pinVersion configuration, but the pinVersion value is not valid`)));
54
+ if (versionGroup.hasSnappedToPackages() && (0, unwrap_1.unwrap)(this.isUnsnapped()))
43
55
  return this.getSnappedVersion();
44
56
  if (this.hasWorkspaceInstance())
45
57
  return this.getWorkspaceVersion();
46
58
  if (this.hasUnsupportedVersion()) {
47
- return ts_belt_1.R.Error(new error_1.BaseError(`${this.name} contains unsupported versions: ${(0, print_strings_1.printStrings)(this.getUniqueVersions())}`));
59
+ return new result_1.Err(new error_1.BaseError(`${this.name} contains unsupported versions: ${(0, print_strings_1.printStrings)(this.getUniqueVersions())}`));
48
60
  }
49
61
  return versionGroup.groupConfig.preferVersion ===
50
62
  'lowestSemver'
@@ -61,28 +73,31 @@ class InstanceGroup {
61
73
  }
62
74
  /** Get the first version matched by the `snapTo` packages */
63
75
  getSnappedVersion() {
64
- return (0, ts_belt_1.pipe)(this.versionGroup.getSnappedToPackages(), ts_belt_1.O.flatMap((pkgNames) => ts_belt_1.O.fromFalsy(this.instances
76
+ return (0, pipe_1.pipe)(this.versionGroup.getSnappedToPackages(), (0, map_1.map)((pkgNames) => this.instances
65
77
  .filter(({ pkgName }) => pkgNames.includes(pkgName))
66
78
  .map(({ version }) => version)
67
- .find(Boolean))), ts_belt_1.O.filter(expect_more_1.isNonEmptyString), ts_belt_1.O.toResult(new error_1.BaseError(`${this.name} is in a versionGroup with snapTo configuration, but ${this.name} was not found in those packages`)));
79
+ .find(Boolean) || ''), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString), (0, ok_or_1.okOr)(new error_1.BaseError(`${this.name} is in a versionGroup with snapTo configuration, but ${this.name} was not found in those packages`)));
68
80
  }
69
81
  /** Is `snapTo` defined and this group does not match that version? */
70
82
  isUnsnapped() {
71
83
  return this.versionGroup.hasSnappedToPackages()
72
- ? (0, ts_belt_1.pipe)(this.getSnappedVersion(), ts_belt_1.R.map((nextVersion) => this.instances.some(({ version }) => version !== nextVersion)))
73
- : ts_belt_1.R.Ok(false);
84
+ ? (0, pipe_1.pipe)(this.getSnappedVersion(), (0, map_2.map)((nextVersion) => this.instances.some(({ version }) => version !== nextVersion)))
85
+ : new result_1.Ok(false);
74
86
  }
75
87
  /** Get version of dependency which is developed in this monorepo */
76
88
  getWorkspaceVersion() {
77
- return (0, ts_belt_1.pipe)(this.getWorkspaceInstance(), (0, props_1.props)('packageJsonFile.contents.version', expect_more_1.isNonEmptyString), ts_belt_1.O.toResult(new error_1.BaseError(`Expected to find a package.json file developed in this monorepo with a "name" property of "${this.name}" and a valid "version" property`)));
89
+ return (0, pipe_1.pipe)(this.getWorkspaceInstance(), (0, and_then_1.andThen)((instance) => (0, get_1.get)(instance, 'packageJsonFile', 'contents', 'version')), (0, filter_2.filter)(is_non_empty_string_1.isNonEmptyString, ''), identity_1.identity, (0, map_err_1.mapErr)(() => new error_1.BaseError(`Expected to find a package.json file developed in this monorepo with a "name" property of "${this.name}" and a valid "version" property`)));
78
90
  }
79
91
  /** Find instance of this dependency which is developed in this monorepo */
80
92
  getWorkspaceInstance() {
81
- return ts_belt_1.O.fromFalsy(this.instances.find(({ pathDef }) => pathDef.name === 'workspace'));
93
+ const instance = this.instances.find(({ pathDef }) => pathDef.name === 'workspace');
94
+ return instance
95
+ ? new result_1.Ok(instance)
96
+ : new result_1.Err(new error_1.BaseError('Workspace instance not found'));
82
97
  }
83
98
  /** Is an instance of this dependency developed in this monorepo? */
84
99
  hasWorkspaceInstance() {
85
- return (0, ts_belt_1.pipe)(this.getWorkspaceInstance(), ts_belt_1.O.toUndefined) !== undefined;
100
+ return (0, is_ok_1.isOk)(this.getWorkspaceInstance());
86
101
  }
87
102
  }
88
103
  exports.InstanceGroup = InstanceGroup;
@@ -1,8 +1,7 @@
1
- import { R } from '@mobily/ts-belt';
1
+ import type { Result } from 'tightrope/result';
2
2
  import type { Disk } from '../../lib/disk';
3
- import { BaseError } from '../../lib/error';
4
3
  import type { Syncpack } from '../../types';
5
- type SafeFilePaths = R.Result<string[], BaseError>;
4
+ type SafeFilePaths = Result<string[]>;
6
5
  /**
7
6
  * Using --source options and/or config files on disk from npm/pnpm/yarn/lerna,
8
7
  * return an array of absolute paths to every package.json file the user is
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFilePaths = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const is_array_of_strings_1 = require("expect-more/dist/is-array-of-strings");
6
- const is_empty_array_1 = require("expect-more/dist/is-empty-array");
4
+ const flat_1 = require("tightrope/array/flat");
5
+ const uniq_1 = require("tightrope/array/uniq");
6
+ const pipe_1 = require("tightrope/fn/pipe");
7
+ const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
8
+ const and_then_1 = require("tightrope/result/and-then");
9
+ const filter_1 = require("tightrope/result/filter");
10
+ const from_try_1 = require("tightrope/result/from-try");
11
+ const map_1 = require("tightrope/result/map");
12
+ const map_err_1 = require("tightrope/result/map-err");
7
13
  const _R_1 = require("../$R");
8
- const error_1 = require("../../lib/error");
9
14
  const print_strings_1 = require("../../lib/print-strings");
10
15
  const get_patterns_1 = require("./get-patterns");
11
16
  /**
@@ -16,25 +21,10 @@ const get_patterns_1 = require("./get-patterns");
16
21
  * @returns Array of absolute file paths to package.json files
17
22
  */
18
23
  function getFilePaths(disk, program) {
19
- return (0, ts_belt_1.pipe)(program, (0, get_patterns_1.getPatterns)(disk), ts_belt_1.R.flatMap(resolvePatterns));
20
- function resolvePatterns(patterns) {
21
- const quoted = (0, print_strings_1.printStrings)(patterns);
22
- const ERR_NO_MATCH = `No package.json files matched the patterns: ${quoted}`;
23
- return (0, ts_belt_1.pipe)(patterns, _R_1.$R.onlyOk(resolvePattern), ts_belt_1.R.mapError(error_1.BaseError.map(ERR_NO_MATCH)), ts_belt_1.R.map((0, ts_belt_1.flow)(ts_belt_1.A.flat, ts_belt_1.A.uniq, removeReadonlyType)));
24
- }
25
- function resolvePattern(pattern) {
26
- const ERR_GLOB_MISS = `No package.json files match pattern "${pattern}"`;
27
- const ERR_INVALID = `"glob" returned unexpected data on pattern "${pattern}"`;
28
- const ERR_GLOB_THROW = `"glob" threw on pattern "${pattern}"`;
29
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => disk.globSync(pattern)), ts_belt_1.R.mapError(error_1.BaseError.map(ERR_GLOB_THROW)), ts_belt_1.R.flatMap((filePaths) => (0, is_empty_array_1.isEmptyArray)(filePaths)
30
- ? ts_belt_1.R.Error(new error_1.BaseError(ERR_GLOB_MISS))
31
- : (0, is_array_of_strings_1.isArrayOfStrings)(filePaths)
32
- ? ts_belt_1.R.Ok((0, ts_belt_1.pipe)(filePaths, ts_belt_1.A.flat, ts_belt_1.A.uniq, removeReadonlyType))
33
- : ts_belt_1.R.Error(new error_1.BaseError(ERR_INVALID))));
34
- }
35
- /** Remove unwanted readonly type */
36
- function removeReadonlyType(value) {
37
- return value;
38
- }
24
+ return (0, pipe_1.pipe)(program, (0, get_patterns_1.getPatterns)(disk), (0, and_then_1.andThen)(function resolvePatterns(patterns) {
25
+ return (0, pipe_1.pipe)(patterns, _R_1.$R.onlyOk(function resolvePattern(pattern) {
26
+ return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => disk.globSync(pattern)), (0, filter_1.filter)(is_array_of_strings_1.isArrayOfStrings, `"glob" did not match "${pattern}"`), (0, map_1.map)(flat_1.flat), (0, map_1.map)(uniq_1.uniq), _R_1.$R.tapErrVerbose);
27
+ }), (0, map_1.map)(flat_1.flat), (0, map_1.map)(uniq_1.uniq), (0, map_err_1.mapErr)(() => new Error(`No files matched ${(0, print_strings_1.printStrings)(patterns)}`)));
28
+ }));
39
29
  }
40
30
  exports.getFilePaths = getFilePaths;
@@ -1,4 +1,3 @@
1
- import { R } from '@mobily/ts-belt';
1
+ import type { Result } from 'tightrope/result';
2
2
  import type { Disk } from '../../../lib/disk';
3
- import { BaseError } from '../../../lib/error';
4
- export declare function getLernaPatterns(disk: Disk): () => R.Result<string[], BaseError>;
3
+ export declare function getLernaPatterns(disk: Disk): () => Result<string[]>;
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLernaPatterns = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
4
  const path_1 = require("path");
5
+ const get_1 = require("tightrope/fn/get");
6
+ const pipe_1 = require("tightrope/fn/pipe");
7
+ const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
8
+ const and_then_1 = require("tightrope/result/and-then");
9
+ const filter_1 = require("tightrope/result/filter");
6
10
  const constants_1 = require("../../../constants");
7
- const error_1 = require("../../../lib/error");
8
- const get_array_of_strings_1 = require("./lib/get-array-of-strings");
9
11
  const read_json_safe_1 = require("./read-json-safe");
10
12
  function getLernaPatterns(disk) {
11
- const getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('packages');
12
13
  return function getLernaPatterns() {
13
- return (0, ts_belt_1.pipe)((0, path_1.join)(constants_1.CWD, 'lerna.json'), (0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.flatMap(({ contents }) => (0, ts_belt_1.pipe)(getPackages(contents), ts_belt_1.O.toResult(new error_1.BaseError('no lerna patterns found')))));
14
+ return (0, pipe_1.pipe)((0, path_1.join)(constants_1.CWD, 'lerna.json'), (0, read_json_safe_1.readJsonSafe)(disk), (0, and_then_1.andThen)((file) => (0, get_1.get)(file, 'contents', 'packages')), (0, filter_1.filter)(is_array_of_strings_1.isArrayOfStrings, 'no lerna patterns found'));
14
15
  };
15
16
  }
16
17
  exports.getLernaPatterns = getLernaPatterns;
@@ -1,4 +1,3 @@
1
- import { R } from '@mobily/ts-belt';
1
+ import type { Result } from 'tightrope/result';
2
2
  import type { Disk } from '../../../lib/disk';
3
- import { BaseError } from '../../../lib/error';
4
- export declare function getPnpmPatterns(disk: Disk): () => R.Result<string[], BaseError>;
3
+ export declare function getPnpmPatterns(disk: Disk): () => Result<string[]>;
@@ -1,21 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPnpmPatterns = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
4
  const path_1 = require("path");
5
+ const get_1 = require("tightrope/fn/get");
6
+ const pipe_1 = require("tightrope/fn/pipe");
7
+ const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
8
+ const and_then_1 = require("tightrope/result/and-then");
9
+ const filter_1 = require("tightrope/result/filter");
6
10
  const constants_1 = require("../../../constants");
7
- const error_1 = require("../../../lib/error");
8
- const get_array_of_strings_1 = require("./lib/get-array-of-strings");
9
11
  const read_yaml_safe_1 = require("./read-yaml-safe");
10
- const getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('packages');
11
12
  function getPnpmPatterns(disk) {
12
13
  return function getPnpmPatterns() {
13
- return (0, ts_belt_1.pipe)(
14
+ return (0, pipe_1.pipe)(
14
15
  // packages:
15
16
  // - "packages/**"
16
17
  // - "components/**"
17
18
  // - "!**/test/**"
18
- (0, path_1.join)(constants_1.CWD, 'pnpm-workspace.yaml'), (0, read_yaml_safe_1.readYamlSafe)(disk), ts_belt_1.R.flatMap((packageJson) => (0, ts_belt_1.pipe)(getPackages(packageJson), ts_belt_1.O.match(ts_belt_1.F.identity, () => getPackages(packageJson)), ts_belt_1.O.toResult(new error_1.BaseError('no pnpm patterns found')))));
19
+ (0, path_1.join)(constants_1.CWD, 'pnpm-workspace.yaml'), (0, read_yaml_safe_1.readYamlSafe)(disk), (0, and_then_1.andThen)((file) => (0, get_1.get)(file, 'packages')), (0, filter_1.filter)(is_array_of_strings_1.isArrayOfStrings, 'no pnpm patterns found'));
19
20
  };
20
21
  }
21
22
  exports.getPnpmPatterns = getPnpmPatterns;
@@ -1,4 +1,3 @@
1
- import { R } from '@mobily/ts-belt';
1
+ import type { Result } from 'tightrope/result';
2
2
  import type { Disk } from '../../../lib/disk';
3
- import { BaseError } from '../../../lib/error';
4
- export declare function getYarnPatterns(disk: Disk): () => R.Result<string[], BaseError>;
3
+ export declare function getYarnPatterns(disk: Disk): () => Result<string[]>;
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getYarnPatterns = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
4
  const path_1 = require("path");
5
+ const get_1 = require("tightrope/fn/get");
6
+ const pipe_1 = require("tightrope/fn/pipe");
7
+ const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
8
+ const and_then_1 = require("tightrope/result/and-then");
9
+ const filter_1 = require("tightrope/result/filter");
10
+ const or_else_1 = require("tightrope/result/or-else");
6
11
  const constants_1 = require("../../../constants");
7
- const error_1 = require("../../../lib/error");
8
- const get_array_of_strings_1 = require("./lib/get-array-of-strings");
9
12
  const read_json_safe_1 = require("./read-json-safe");
10
13
  function getYarnPatterns(disk) {
11
- const getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('workspaces');
12
- const getPackagesNested = (0, get_array_of_strings_1.getArrayOfStrings)('workspaces.packages');
13
14
  return function getYarnPatterns() {
14
- return (0, ts_belt_1.pipe)((0, path_1.join)(constants_1.CWD, 'package.json'), (0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.flatMap(({ contents }) => (0, ts_belt_1.pipe)(getPackages(contents), ts_belt_1.O.match(ts_belt_1.F.identity, () => getPackagesNested(contents)), ts_belt_1.O.toResult(new error_1.BaseError('no yarn patterns found')))));
15
+ return (0, pipe_1.pipe)((0, path_1.join)(constants_1.CWD, 'package.json'), (0, read_json_safe_1.readJsonSafe)(disk), (0, and_then_1.andThen)((file) => (0, pipe_1.pipe)((0, get_1.get)(file, 'contents', 'workspaces', 'packages'), (0, or_else_1.orElse)(() => (0, get_1.get)(file, 'contents', 'workspaces')))), (0, filter_1.filter)(is_array_of_strings_1.isArrayOfStrings, 'no yarn patterns found'));
15
16
  };
16
17
  }
17
18
  exports.getYarnPatterns = getYarnPatterns;
@@ -1,6 +1,5 @@
1
- import { R } from '@mobily/ts-belt';
1
+ import type { Result } from 'tightrope/result';
2
2
  import type { Disk } from '../../../lib/disk';
3
- import { BaseError } from '../../../lib/error';
4
3
  import type { Syncpack } from '../../../types';
5
4
  /**
6
5
  * Find every glob pattern which should be used to find package.json files for
@@ -8,4 +7,4 @@ import type { Syncpack } from '../../../types';
8
7
  *
9
8
  * @returns `['./package.json', './packages/* /package.json']`
10
9
  */
11
- export declare function getPatterns(disk: Disk): (program: Syncpack.Config.SyncpackRc) => R.Result<string[], BaseError>;
10
+ export declare function getPatterns(disk: Disk): (program: Syncpack.Config.SyncpackRc) => Result<string[]>;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPatterns = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const is_array_of_strings_1 = require("expect-more/dist/is-array-of-strings");
4
+ const pipe_1 = require("tightrope/fn/pipe");
5
+ const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
6
+ const result_1 = require("tightrope/result");
7
+ const from_guard_1 = require("tightrope/result/from-guard");
8
+ const map_1 = require("tightrope/result/map");
9
+ const or_else_1 = require("tightrope/result/or-else");
6
10
  const constants_1 = require("../../../constants");
7
- const error_1 = require("../../../lib/error");
8
11
  const get_lerna_patterns_1 = require("./get-lerna-patterns");
9
12
  const get_pnpm_patterns_1 = require("./get-pnpm-patterns");
10
13
  const get_yarn_patterns_1 = require("./get-yarn-patterns");
@@ -16,21 +19,9 @@ const get_yarn_patterns_1 = require("./get-yarn-patterns");
16
19
  */
17
20
  function getPatterns(disk) {
18
21
  return function getPatterns(program) {
19
- const getters = [
20
- getCliPatterns,
21
- (0, get_yarn_patterns_1.getYarnPatterns)(disk),
22
- (0, get_pnpm_patterns_1.getPnpmPatterns)(disk),
23
- (0, get_lerna_patterns_1.getLernaPatterns)(disk),
24
- ];
25
- const initialResult = ts_belt_1.R.Error(new error_1.BaseError('getPatterns did not try any sources'));
26
- const res = ts_belt_1.A.reduce(getters, initialResult, (previousResult, getNextResult) => {
27
- if (ts_belt_1.R.isOk(previousResult))
28
- return previousResult;
29
- return getNextResult();
30
- });
31
- return (0, ts_belt_1.pipe)(res, ts_belt_1.R.map(addRootDir), ts_belt_1.R.map(limitToPackageJson), ts_belt_1.R.handleError(() => constants_1.DEFAULT_SOURCES), ts_belt_1.R.mapError(ts_belt_1.F.identity));
22
+ return (0, pipe_1.pipe)(getCliPatterns(), (0, or_else_1.orElse)((0, get_yarn_patterns_1.getYarnPatterns)(disk)), (0, or_else_1.orElse)((0, get_pnpm_patterns_1.getPnpmPatterns)(disk)), (0, or_else_1.orElse)((0, get_lerna_patterns_1.getLernaPatterns)(disk)), (0, map_1.map)(addRootDir), (0, map_1.map)(limitToPackageJson), (0, or_else_1.orElse)(() => new result_1.Ok(constants_1.DEFAULT_SOURCES)));
32
23
  function getCliPatterns() {
33
- return ts_belt_1.R.fromPredicate(program.source, is_array_of_strings_1.isArrayOfStrings, new error_1.BaseError('No --source options provided'));
24
+ return (0, from_guard_1.fromGuard)(is_array_of_strings_1.isArrayOfStrings, new Error('No --source options provided'), program.source);
34
25
  }
35
26
  function addRootDir(patterns) {
36
27
  return ['package.json', ...patterns];
@@ -1,6 +1,5 @@
1
- import { R } from '@mobily/ts-belt';
1
+ import type { Result } from 'tightrope/result';
2
2
  import type { Disk } from '../../../lib/disk';
3
- import { BaseError } from '../../../lib/error';
4
3
  export interface JsonFile<T> {
5
4
  /** absolute path on disk to this file */
6
5
  readonly filePath: string;
@@ -9,4 +8,4 @@ export interface JsonFile<T> {
9
8
  /** raw file contents of the file */
10
9
  readonly json: string;
11
10
  }
12
- export declare function readJsonSafe<T>(disk: Disk): (filePath: string) => R.Result<JsonFile<T>, BaseError>;
11
+ export declare function readJsonSafe<T>(disk: Disk): (filePath: string) => Result<JsonFile<T>>;
@@ -1,17 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readJsonSafe = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const error_1 = require("../../../lib/error");
4
+ const pipe_1 = require("tightrope/fn/pipe");
5
+ const and_then_1 = require("tightrope/result/and-then");
6
+ const from_try_1 = require("tightrope/result/from-try");
7
+ const map_1 = require("tightrope/result/map");
8
+ const map_err_1 = require("tightrope/result/map-err");
6
9
  function readJsonSafe(disk) {
7
10
  return function readJsonSafe(filePath) {
8
- return (0, ts_belt_1.pipe)(readFileSafe(filePath), ts_belt_1.R.flatMap((0, ts_belt_1.flow)((parseJsonSafe), ts_belt_1.R.mapError(error_1.BaseError.map(`Failed to parse JSON file at ${filePath}`)), ts_belt_1.R.map(({ contents, json }) => ({ contents, filePath, json })))));
11
+ return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => disk.readFileSync(filePath)), (0, and_then_1.andThen)((json) => (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => JSON.parse(json)), (0, map_1.map)((contents) => ({ contents, json })))), (0, map_1.map)(({ contents, json }) => ({ contents, filePath, json })), (0, map_err_1.mapErr)(() => new Error(`Failed to read JSON file at ${filePath}`)));
9
12
  };
10
- function readFileSafe(filePath) {
11
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => disk.readFileSync(filePath)), ts_belt_1.R.mapError(error_1.BaseError.map(`Failed to read JSON file at ${filePath}`)));
12
- }
13
13
  }
14
14
  exports.readJsonSafe = readJsonSafe;
15
- function parseJsonSafe(json) {
16
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => JSON.parse(json)), ts_belt_1.R.mapError(error_1.BaseError.map('Failed to parse JSON')), ts_belt_1.R.map((contents) => ({ contents, json })));
17
- }
@@ -1,4 +1,3 @@
1
- import { R } from '@mobily/ts-belt';
1
+ import type { Result } from 'tightrope/result';
2
2
  import type { Disk } from '../../../lib/disk';
3
- import { BaseError } from '../../../lib/error';
4
- export declare function readYamlSafe<T = unknown>(disk: Disk): (filePath: string) => R.Result<T, BaseError>;
3
+ export declare function readYamlSafe<T = unknown>(disk: Disk): (filePath: string) => Result<T>;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readYamlSafe = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const error_1 = require("../../../lib/error");
4
+ const pipe_1 = require("tightrope/fn/pipe");
5
+ const from_try_1 = require("tightrope/result/from-try");
6
+ const map_err_1 = require("tightrope/result/map-err");
6
7
  function readYamlSafe(disk) {
7
8
  return function readYamlSafe(filePath) {
8
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => disk.readYamlFileSync(filePath)), ts_belt_1.R.mapError(error_1.BaseError.map(`Failed to read YAML file at ${filePath}`)));
9
+ return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => disk.readYamlFileSync(filePath)), (0, map_err_1.mapErr)(() => new Error(`Failed to read YAML file at ${filePath}`)));
9
10
  };
10
11
  }
11
12
  exports.readYamlSafe = readYamlSafe;
@@ -1,7 +1,6 @@
1
- import { R } from '@mobily/ts-belt';
1
+ import type { Result } from 'tightrope/result';
2
2
  import type { Disk } from '../../lib/disk';
3
- import type { BaseError } from '../../lib/error';
4
3
  import type { Syncpack } from '../../types';
5
4
  import { PackageJsonFile } from './package-json-file';
6
5
  /** Create an API for every package.json file needed. */
7
- export declare function getPackageJsonFiles(disk: Disk, config: Syncpack.Config.Private): R.Result<PackageJsonFile[], BaseError>;
6
+ export declare function getPackageJsonFiles(disk: Disk, config: Syncpack.Config.Private): Result<PackageJsonFile[]>;
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPackageJsonFiles = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
4
+ const flow_1 = require("tightrope/fn/flow");
5
+ const pipe_1 = require("tightrope/fn/pipe");
6
+ const result_1 = require("tightrope/result");
7
+ const and_then_1 = require("tightrope/result/and-then");
8
+ const map_1 = require("tightrope/result/map");
9
+ const or_1 = require("tightrope/result/or");
5
10
  const _R_1 = require("../$R");
6
11
  const get_file_paths_1 = require("./get-file-paths");
7
12
  const read_json_safe_1 = require("./get-patterns/read-json-safe");
8
13
  const package_json_file_1 = require("./package-json-file");
9
14
  /** Create an API for every package.json file needed. */
10
15
  function getPackageJsonFiles(disk, config) {
11
- return (0, ts_belt_1.pipe)((0, get_file_paths_1.getFilePaths)(disk, config), ts_belt_1.R.flatMap(_R_1.$R.onlyOk(resolvePackageJson(disk))), ts_belt_1.R.recover([]));
12
- function resolvePackageJson(disk) {
13
- return (0, ts_belt_1.flow)((0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.map((jsonFile) => new package_json_file_1.PackageJsonFile(jsonFile, config, disk)), _R_1.$R.tapErrVerbose);
14
- }
16
+ return (0, pipe_1.pipe)((0, get_file_paths_1.getFilePaths)(disk, config), (0, and_then_1.andThen)(_R_1.$R.onlyOk((0, flow_1.flow)((0, read_json_safe_1.readJsonSafe)(disk), (0, map_1.map)((jsonFile) => new package_json_file_1.PackageJsonFile(jsonFile, config, disk)), _R_1.$R.tapErrVerbose))), (0, or_1.or)(new result_1.Ok([])));
15
17
  }
16
18
  exports.getPackageJsonFiles = getPackageJsonFiles;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PackageJsonFile = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
4
  const path_1 = require("path");
5
+ const pipe_1 = require("tightrope/fn/pipe");
6
+ const result_1 = require("tightrope/result");
7
+ const unwrap_or_1 = require("tightrope/result/unwrap-or");
6
8
  const constants_1 = require("../../../constants");
7
9
  const log_1 = require("../../../lib/log");
8
10
  const newlines_1 = require("../../../lib/newlines");
@@ -48,13 +50,13 @@ class PackageJsonFile {
48
50
  const strategyName = pathDef.strategy;
49
51
  switch (strategyName) {
50
52
  case 'name@version':
51
- return (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), ts_belt_1.R.getWithDefault([]));
53
+ return (0, pipe_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), (0, unwrap_or_1.unwrapOr)(new result_1.Ok([])));
52
54
  case 'name~version':
53
- return (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), ts_belt_1.R.getWithDefault([]));
55
+ return (0, pipe_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), (0, unwrap_or_1.unwrapOr)(new result_1.Ok([])));
54
56
  case 'version':
55
- return (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), ts_belt_1.R.getWithDefault([]));
57
+ return (0, pipe_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), (0, unwrap_or_1.unwrapOr)(new result_1.Ok([])));
56
58
  case 'versionsByName':
57
- return (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), ts_belt_1.R.getWithDefault([]));
59
+ return (0, pipe_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), (0, unwrap_or_1.unwrapOr)(new result_1.Ok([])));
58
60
  default:
59
61
  return (0, path_strategy_1.exhaustiveCheck)(strategyName);
60
62
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Instance = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
4
+ const pipe_1 = require("tightrope/fn/pipe");
5
5
  const _R_1 = require("../../$R");
6
6
  const path_strategy_1 = require("../../get-config/path-strategy");
7
7
  const instance_group_1 = require("../../get-groups/version-group/instance-group");
@@ -27,16 +27,16 @@ class Instance {
27
27
  const file = this.packageJsonFile;
28
28
  switch (strategyName) {
29
29
  case 'name@version':
30
- (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
30
+ (0, pipe_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
31
31
  break;
32
32
  case 'name~version':
33
- (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
33
+ (0, pipe_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
34
34
  break;
35
35
  case 'version':
36
- (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
36
+ (0, pipe_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
37
37
  break;
38
38
  case 'versionsByName':
39
- (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
39
+ (0, pipe_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
40
40
  break;
41
41
  default:
42
42
  return (0, path_strategy_1.exhaustiveCheck)(strategyName);
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getContext = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
4
+ const pipe_1 = require("tightrope/fn/pipe");
5
+ const and_then_1 = require("tightrope/result/and-then");
6
+ const map_1 = require("tightrope/result/map");
7
+ const unwrap_1 = require("tightrope/result/unwrap");
5
8
  const disk_1 = require("../lib/disk");
6
9
  const _R_1 = require("./$R");
7
10
  const get_config_1 = require("./get-config");
@@ -16,15 +19,15 @@ const get_package_json_files_1 = require("./get-package-json-files");
16
19
  * system and can focus solely on transformation logic.
17
20
  */
18
21
  function getContext(program, disk = disk_1.disk) {
19
- return (0, ts_belt_1.pipe)(
22
+ return (0, pipe_1.pipe)(
20
23
  // merge CLI options, .syncpackrc contents, and default config
21
- (0, get_config_1.getConfig)(disk, program), ts_belt_1.R.flatMap((config) => (0, ts_belt_1.pipe)(
24
+ (0, get_config_1.getConfig)(disk, program), (0, and_then_1.andThen)((config) => (0, pipe_1.pipe)(
22
25
  // get the package.json file which match the globs in config
23
- (0, get_package_json_files_1.getPackageJsonFiles)(disk, config), ts_belt_1.R.flatMap((packageJsonFiles) => (0, ts_belt_1.pipe)(
26
+ (0, get_package_json_files_1.getPackageJsonFiles)(disk, config), (0, and_then_1.andThen)((packageJsonFiles) => (0, pipe_1.pipe)(
24
27
  // allocate dependencies into semver and version groups
25
28
  (0, get_groups_1.getGroups)(config, packageJsonFiles),
26
29
  // combine everything into the final config
27
- ts_belt_1.R.map(({ semverGroups, versionGroups }) => ({
30
+ (0, map_1.map)(({ semverGroups, versionGroups }) => ({
28
31
  config,
29
32
  disk,
30
33
  isInvalid: false,
@@ -35,6 +38,6 @@ function getContext(program, disk = disk_1.disk) {
35
38
  // if anything errored at any stage, log it when in verbose mode
36
39
  _R_1.$R.tapErrVerbose,
37
40
  // throw if anything errored, can't do anything without this data
38
- ts_belt_1.R.getExn);
41
+ unwrap_1.unwrap);
39
42
  }
40
43
  exports.getContext = getContext;
package/dist/lib/disk.js CHANGED
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.disk = void 0;
4
4
  const cosmiconfig_1 = require("cosmiconfig");
5
- const is_non_empty_object_1 = require("expect-more/dist/is-non-empty-object");
6
5
  const fs_extra_1 = require("fs-extra");
7
6
  const glob_1 = require("glob");
8
7
  const path_1 = require("path");
9
8
  const read_yaml_file_1 = require("read-yaml-file");
9
+ const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
10
10
  const constants_1 = require("../constants");
11
11
  const log_1 = require("./log");
12
12
  const client = (0, cosmiconfig_1.cosmiconfigSync)('syncpack');
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isLooseSemver = exports.isSemver = exports.isValidSemverRange = void 0;
4
- const is_string_1 = require("expect-more/dist/is-string");
4
+ const is_string_1 = require("tightrope/guard/is-string");
5
5
  const constants_1 = require("../constants");
6
6
  function isValidSemverRange(value) {
7
7
  return (value === constants_1.RANGE.ANY ||
package/dist/lib/log.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.versionGroupHeader = exports.semverGroupHeader = exports.invalid = exports.valid = exports.skip = exports.fixed = exports.verbose = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const is_string_1 = require("expect-more/dist/is-string");
8
+ const is_string_1 = require("tightrope/guard/is-string");
9
9
  const util_1 = require("util");
10
10
  const constants_1 = require("../constants");
11
11
  function verbose(...values) {