syncpack 9.7.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 (70) hide show
  1. package/LICENSE +12 -13
  2. package/dist/bin-fix-mismatches/fix-mismatches.js +8 -4
  3. package/dist/bin-format/format.js +5 -4
  4. package/dist/bin-list/list.js +13 -7
  5. package/dist/bin-list-mismatches/list-mismatches.js +16 -11
  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 -1
  11. package/dist/get-context/get-config/index.js +28 -15
  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 +294 -256
  20. package/dist/get-context/get-config/schema/index.js +7 -7
  21. package/dist/get-context/get-config/schema/lib/non-empty-string.d.ts +2 -0
  22. package/dist/get-context/get-config/schema/lib/non-empty-string.js +5 -0
  23. package/dist/get-context/get-config/schema/semver-group.d.ts +18 -18
  24. package/dist/get-context/get-config/schema/version-group.d.ts +49 -37
  25. package/dist/get-context/get-config/schema/version-group.js +14 -8
  26. package/dist/get-context/get-groups/base-group.js +1 -1
  27. package/dist/get-context/get-groups/index.d.ts +5 -3
  28. package/dist/get-context/get-groups/index.js +14 -2
  29. package/dist/get-context/get-groups/version-group/index.d.ts +6 -4
  30. package/dist/get-context/get-groups/version-group/index.js +18 -14
  31. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.d.ts +2 -3
  32. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +6 -6
  33. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.d.ts +2 -0
  34. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.js +44 -0
  35. package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +15 -6
  36. package/dist/get-context/get-groups/version-group/instance-group/index.js +49 -30
  37. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +3 -1
  38. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +20 -4
  39. package/dist/get-context/get-package-json-files/get-file-paths.d.ts +2 -3
  40. package/dist/get-context/get-package-json-files/get-file-paths.js +14 -24
  41. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +2 -3
  42. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +6 -5
  43. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +2 -3
  44. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +7 -6
  45. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +2 -3
  46. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +7 -6
  47. package/dist/get-context/get-package-json-files/get-patterns/index.d.ts +2 -3
  48. package/dist/get-context/get-package-json-files/get-patterns/index.js +8 -17
  49. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.d.ts +2 -3
  50. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.js +6 -9
  51. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.d.ts +2 -3
  52. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +4 -3
  53. package/dist/get-context/get-package-json-files/index.d.ts +2 -1
  54. package/dist/get-context/get-package-json-files/index.js +7 -5
  55. package/dist/get-context/get-package-json-files/package-json-file/index.js +7 -5
  56. package/dist/get-context/get-package-json-files/package-json-file/instance.d.ts +2 -1
  57. package/dist/get-context/get-package-json-files/package-json-file/instance.js +7 -6
  58. package/dist/get-context/index.d.ts +3 -2
  59. package/dist/get-context/index.js +22 -10
  60. package/dist/lib/disk.js +1 -1
  61. package/dist/lib/is-semver.js +1 -1
  62. package/dist/lib/log.js +7 -2
  63. package/dist/types.d.ts +1 -1
  64. package/package.json +17 -18
  65. package/dist/get-context/get-all-instances.d.ts +0 -3
  66. package/dist/get-context/get-all-instances.js +0 -8
  67. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.d.ts +0 -1
  68. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.js +0 -8
  69. package/dist/get-context/get-package-json-files/get-patterns/props.d.ts +0 -6
  70. package/dist/get-context/get-package-json-files/get-patterns/props.js +0 -24
package/LICENSE CHANGED
@@ -1,21 +1,20 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 Jamie Mason
3
+ Copyright (c) 2017-2023 Jamie Mason
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
11
 
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fixMismatches = void 0;
4
- const is_object_1 = require("expect-more/dist/is-object");
5
- const is_undefined_1 = require("expect-more/dist/is-undefined");
4
+ const pipe_1 = require("tightrope/fn/pipe");
5
+ const is_object_1 = require("tightrope/guard/is-object");
6
+ const is_undefined_1 = require("tightrope/guard/is-undefined");
7
+ const tap_1 = require("tightrope/result/tap");
8
+ const _R_1 = require("../get-context/$R");
6
9
  function fixMismatches(ctx) {
7
10
  ctx.versionGroups.forEach((versionGroup) => {
8
11
  const invalidGroups = versionGroup.getInvalidInstanceGroups();
@@ -12,8 +15,9 @@ function fixMismatches(ctx) {
12
15
  // Set the correct version on each instance.
13
16
  invalidGroups.forEach((instanceGroup) => {
14
17
  if (!instanceGroup.hasUnsupportedVersion()) {
15
- const nextVersion = instanceGroup.getExpectedVersion();
16
- instanceGroup.instances.forEach((instance) => instance.setVersion(nextVersion));
18
+ (0, pipe_1.pipe)(instanceGroup.getExpectedVersion(), (0, tap_1.tap)((nextVersion) => {
19
+ instanceGroup.instances.forEach((instance) => instance.setVersion(nextVersion));
20
+ }), _R_1.$R.tapErrVerbose);
17
21
  }
18
22
  });
19
23
  });
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.format = void 0;
4
- const is_array_1 = require("expect-more/dist/is-array");
5
- const is_non_empty_string_1 = require("expect-more/dist/is-non-empty-string");
6
- const is_object_1 = require("expect-more/dist/is-object");
4
+ const is_array_1 = require("tightrope/guard/is-array");
5
+ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
6
+ const is_object_1 = require("tightrope/guard/is-object");
7
7
  function format(ctx) {
8
- const { sortAz, sortFirst, packageJsonFiles } = ctx;
8
+ const { packageJsonFiles } = ctx;
9
+ const { sortAz, sortFirst } = ctx.config;
9
10
  packageJsonFiles.forEach((packageJsonFile) => {
10
11
  const { contents } = packageJsonFile;
11
12
  const sortedKeys = Object.keys(contents).sort();
@@ -28,7 +28,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.list = void 0;
30
30
  const chalk_1 = __importDefault(require("chalk"));
31
+ const pipe_1 = require("tightrope/fn/pipe");
32
+ const unwrap_1 = require("tightrope/option/unwrap");
33
+ const tap_1 = require("tightrope/result/tap");
31
34
  const constants_1 = require("../constants");
35
+ const _R_1 = require("../get-context/$R");
32
36
  const log = __importStar(require("../lib/log"));
33
37
  function list(ctx) {
34
38
  const hasUserGroups = ctx.versionGroups.length > 1;
@@ -63,12 +67,14 @@ function list(ctx) {
63
67
  console.log((0, chalk_1.default) `{dim -} {white ${instanceGroup.name}} {dim ${instanceGroup.getUniqueVersions()}}`);
64
68
  }
65
69
  function logVersionMismatch(instanceGroup) {
66
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} ${instanceGroup
67
- .getUniqueVersions()
68
- .map((version) => version === instanceGroup.getExpectedVersion()
69
- ? chalk_1.default.green(version)
70
- : chalk_1.default.red(version))
71
- .join(chalk_1.default.dim(', '))}`);
70
+ (0, pipe_1.pipe)(instanceGroup.getExpectedVersion(), (0, tap_1.tap)((expectedVersion) => {
71
+ const uniqueVersions = instanceGroup.getUniqueVersions();
72
+ console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} ${uniqueVersions
73
+ .map((version) => version === expectedVersion
74
+ ? chalk_1.default.green(version)
75
+ : chalk_1.default.red(version))
76
+ .join(chalk_1.default.dim(', '))}`);
77
+ }), _R_1.$R.tapErrVerbose);
72
78
  }
73
79
  function logIgnored(instanceGroup) {
74
80
  console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip} ${instanceGroup.name}} is ignored in this version group`);
@@ -77,7 +83,7 @@ function list(ctx) {
77
83
  console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red is banned in this version group}`);
78
84
  }
79
85
  function logUnpinned(instanceGroup) {
80
- const pinVersion = instanceGroup.versionGroup.getPinnedVersion();
86
+ const pinVersion = (0, unwrap_1.unwrap)(instanceGroup.versionGroup.getPinnedVersion());
81
87
  console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross} ${instanceGroup.name}} {dim.red is pinned to ${pinVersion} in this version group}`);
82
88
  }
83
89
  function logUnsupportedMismatches(instanceGroup) {
@@ -28,6 +28,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.listMismatches = void 0;
30
30
  const chalk_1 = __importDefault(require("chalk"));
31
+ const unwrap_1 = require("tightrope/option/unwrap");
32
+ const unwrap_2 = require("tightrope/result/unwrap");
31
33
  const log = __importStar(require("../lib/log"));
32
34
  function listMismatches(ctx) {
33
35
  const hasUserGroups = ctx.versionGroups.length > 1;
@@ -54,7 +56,7 @@ function listMismatches(ctx) {
54
56
  if (instanceGroup.hasWorkspaceInstance()) {
55
57
  return logWorkspaceMismatch(instanceGroup);
56
58
  }
57
- logHighestVersionMismatch(instanceGroup);
59
+ logHighLowVersionMismatch(instanceGroup);
58
60
  });
59
61
  });
60
62
  return ctx;
@@ -76,7 +78,7 @@ function listMismatches(ctx) {
76
78
  }
77
79
  function logUnpinned(instanceGroup) {
78
80
  const name = instanceGroup.name;
79
- const pinVersion = instanceGroup.versionGroup.getPinnedVersion();
81
+ const pinVersion = (0, unwrap_1.unwrap)(instanceGroup.versionGroup.getPinnedVersion());
80
82
  log.invalid(name, (0, chalk_1.default) `is pinned in this version group at {reset.green ${pinVersion}}`);
81
83
  // Log each of the dependencies mismatches
82
84
  instanceGroup.instances.forEach((instance) => {
@@ -88,10 +90,10 @@ function listMismatches(ctx) {
88
90
  function logSnappedTo(instanceGroup) {
89
91
  const name = instanceGroup.name;
90
92
  const versionGroup = instanceGroup.versionGroup;
91
- const snappedVersion = instanceGroup.getSnappedVersion();
92
- const packages = versionGroup.getSnappedToPackages().join(' || ');
93
- const version = instanceGroup.getExpectedVersion();
94
- log.invalid(name, (0, chalk_1.default) `should snap to {reset.green ${version}}, used by ${packages}`);
93
+ const snappedVersion = (0, unwrap_2.unwrap)(instanceGroup.getSnappedVersion());
94
+ const snappedToPackages = (0, unwrap_1.unwrap)(versionGroup.getSnappedToPackages()).join(' || ');
95
+ const version = (0, unwrap_2.unwrap)(instanceGroup.getExpectedVersion());
96
+ log.invalid(name, (0, chalk_1.default) `should snap to {reset.green ${version}}, used by ${snappedToPackages}`);
95
97
  // Log each of the dependencies mismatches
96
98
  instanceGroup.instances.forEach((instance) => {
97
99
  if (instance.version !== snappedVersion) {
@@ -101,9 +103,9 @@ function listMismatches(ctx) {
101
103
  }
102
104
  function logWorkspaceMismatch(instanceGroup) {
103
105
  const name = instanceGroup.name;
104
- const workspaceInstance = instanceGroup.getWorkspaceInstance();
106
+ const workspaceInstance = (0, unwrap_2.unwrap)(instanceGroup.getWorkspaceInstance());
105
107
  const shortPath = workspaceInstance?.packageJsonFile.shortPath;
106
- const expected = instanceGroup.getExpectedVersion();
108
+ const expected = (0, unwrap_2.unwrap)(instanceGroup.getExpectedVersion());
107
109
  log.invalid(name, (0, chalk_1.default) `{reset.green ${expected}} {dim is developed in this repo at ${shortPath}}`);
108
110
  // Log each of the dependencies mismatches
109
111
  instanceGroup.instances.forEach((instance) => {
@@ -112,10 +114,13 @@ function listMismatches(ctx) {
112
114
  }
113
115
  });
114
116
  }
115
- function logHighestVersionMismatch(instanceGroup) {
117
+ function logHighLowVersionMismatch(instanceGroup) {
116
118
  const name = instanceGroup.name;
117
- const expected = instanceGroup.getExpectedVersion();
118
- log.invalid(name, (0, chalk_1.default) `{reset.green ${expected}} {dim is the highest valid semver version in use}`);
119
+ const preference = instanceGroup.versionGroup
120
+ .groupConfig.preferVersion;
121
+ const direction = preference === 'highestSemver' ? 'highest' : 'lowest';
122
+ const expected = (0, unwrap_2.unwrap)(instanceGroup.getExpectedVersion());
123
+ log.invalid(name, (0, chalk_1.default) `{reset.green ${expected}} {dim is the ${direction} valid semver version in use}`);
119
124
  // Log each of the dependencies mismatches
120
125
  instanceGroup.instances.forEach((instance) => {
121
126
  if (instance.version !== expected) {
@@ -1,13 +1,12 @@
1
- import { R } from '@mobily/ts-belt';
2
- import { BaseError } from '../lib/error';
3
- /** Additional helpers for https://mobily.github.io/ts-belt/api/result */
1
+ import type { AnyResult } from 'tightrope/fn/types';
2
+ import type { Result } from 'tightrope/result';
4
3
  export declare const $R: {
5
4
  /**
6
- * Return a single `R.Ok<output[]>` containing an array of the output of every
7
- * `R.Result` returned by `getResult(input)` which succeeded, or a single
8
- * `R.Error<BaseError>` if none succeeded.
5
+ * Return a single `Ok<output[]>` containing an array of the output of every
6
+ * `Result` returned by `getResult(input)` which succeeded, or a single
7
+ * `Err<BaseError>` if none succeeded.
9
8
  */
10
- onlyOk<Input, Output = Input>(getResult: (value: Input) => R.Result<Output, BaseError>): (inputs: Input[]) => R.Result<Output[], BaseError>;
11
- /** Log verbose only when R.Result is an R.Err */
12
- tapErrVerbose<T extends R.Result<unknown, BaseError>>(result: T): T;
9
+ onlyOk<Input, Output = Input>(getResult: (value: Input) => Result<Output, unknown>): (inputs: Input[]) => Result<Output[], unknown>;
10
+ /** Log verbose only when Result is an Err */
11
+ tapErrVerbose<T extends AnyResult>(result: T): T;
13
12
  };
@@ -1,34 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.$R = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
4
+ const result_1 = require("tightrope/result");
5
+ const is_err_1 = require("tightrope/result/is-err");
6
+ const unwrap_1 = require("tightrope/result/unwrap");
5
7
  const error_1 = require("../lib/error");
6
8
  const log_1 = require("../lib/log");
7
- /** Additional helpers for https://mobily.github.io/ts-belt/api/result */
8
9
  exports.$R = {
9
10
  /**
10
- * Return a single `R.Ok<output[]>` containing an array of the output of every
11
- * `R.Result` returned by `getResult(input)` which succeeded, or a single
12
- * `R.Error<BaseError>` if none succeeded.
11
+ * Return a single `Ok<output[]>` containing an array of the output of every
12
+ * `Result` returned by `getResult(input)` which succeeded, or a single
13
+ * `Err<BaseError>` if none succeeded.
13
14
  */
14
15
  onlyOk(getResult) {
15
16
  return (inputs) => {
16
17
  const outputs = [];
17
18
  for (const value of inputs) {
18
19
  const result = getResult(value);
19
- if (ts_belt_1.R.isError(result))
20
+ if ((0, is_err_1.isErr)(result))
20
21
  continue;
21
- outputs.push(ts_belt_1.R.getExn(result));
22
+ outputs.push((0, unwrap_1.unwrap)(result));
22
23
  }
23
24
  return outputs.length > 0
24
- ? ts_belt_1.R.Ok(outputs)
25
- : ts_belt_1.R.Error(new error_1.BaseError('No R.Ok() returned by $R.onlyOk'));
25
+ ? new result_1.Ok(outputs)
26
+ : new result_1.Err(new error_1.BaseError('No Ok() returned by $R.onlyOk'));
26
27
  };
27
28
  },
28
- /** Log verbose only when R.Result is an R.Err */
29
+ /** Log verbose only when Result is an Err */
29
30
  tapErrVerbose(result) {
30
- if (ts_belt_1.R.isError(result))
31
- (0, log_1.verbose)(result._0.message);
31
+ if ((0, is_err_1.isErr)(result))
32
+ (0, log_1.verbose)(result.value);
32
33
  return result;
33
34
  },
34
35
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCustomTypes = void 0;
4
- const is_object_1 = require("expect-more/dist/is-object");
4
+ const is_object_1 = require("tightrope/guard/is-object");
5
5
  function getCustomTypes({ customTypes, }) {
6
6
  return customTypes
7
7
  ? Object.keys(customTypes)
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEnabledTypes = void 0;
4
- const is_array_of_strings_1 = require("expect-more/dist/is-array-of-strings");
5
- const is_non_empty_array_1 = require("expect-more/dist/is-non-empty-array");
6
- const is_non_empty_string_1 = require("expect-more/dist/is-non-empty-string");
4
+ const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
5
+ const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
6
+ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
7
7
  function getEnabledTypes(allTypes, { dependencyTypes, types }) {
8
8
  const enabledNames = (0, is_non_empty_string_1.isNonEmptyString)(types)
9
9
  ? types.split(',')
@@ -1,7 +1,8 @@
1
+ import type { Result } from 'tightrope/result';
1
2
  import type { Disk } from '../../lib/disk';
2
3
  import type { Syncpack } from '../../types';
3
4
  /**
4
5
  * Take all configuration from the command line and config file, combine it, and
5
6
  * set defaults for anything which hasn't been defined.
6
7
  */
7
- export declare const getConfig: (disk: Disk, fromCli: Partial<Syncpack.Config.Cli>) => Syncpack.Config.Private;
8
+ export declare function getConfig(disk: Disk, fromCli: Partial<Syncpack.Config.Cli>): Result<Syncpack.Config.Private>;
@@ -24,6 +24,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getConfig = void 0;
27
+ const pipe_1 = require("tightrope/fn/pipe");
28
+ const is_array_of_objects_1 = require("tightrope/guard/is-array-of-objects");
29
+ const is_array_of_strings_1 = require("tightrope/guard/is-array-of-strings");
30
+ const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
31
+ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
32
+ const is_string_1 = require("tightrope/guard/is-string");
33
+ const from_try_1 = require("tightrope/result/from-try");
34
+ const map_err_1 = require("tightrope/result/map-err");
35
+ const error_1 = require("../../lib/error");
27
36
  const log_1 = require("../../lib/log");
28
37
  const get_core_types_1 = require("./get-core-types");
29
38
  const get_custom_types_1 = require("./get-custom-types");
@@ -33,22 +42,27 @@ const ConfigSchema = __importStar(require("./schema"));
33
42
  * Take all configuration from the command line and config file, combine it, and
34
43
  * set defaults for anything which hasn't been defined.
35
44
  */
36
- const getConfig = (disk, fromCli) => {
45
+ function getConfig(disk, fromCli) {
46
+ const ERR_READING_CONFIG = 'Error reading config';
47
+ return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => unSafeGetConfig(disk, fromCli)), (0, map_err_1.mapErr)(error_1.BaseError.map(ERR_READING_CONFIG)));
48
+ }
49
+ exports.getConfig = getConfig;
50
+ function unSafeGetConfig(disk, fromCli) {
37
51
  (0, log_1.verbose)('cli arguments:', fromCli);
38
52
  const fromRcFile = disk.readConfigFileSync(fromCli.configPath);
39
53
  (0, log_1.verbose)('rcfile contents:', fromRcFile);
40
54
  const fromPublic = ConfigSchema.Public.parse({
41
- customTypes: getConfigByName('customTypes'),
55
+ customTypes: getConfigByName('customTypes', is_non_empty_object_1.isNonEmptyObject),
42
56
  dependencyTypes: fromRcFile?.dependencyTypes,
43
- filter: getConfigByName('filter'),
44
- indent: getConfigByName('indent'),
45
- semverGroups: getConfigByName('semverGroups'),
46
- semverRange: getConfigByName('semverRange'),
47
- sortAz: getConfigByName('sortAz'),
48
- sortFirst: getConfigByName('sortFirst'),
49
- source: getConfigByName('source'),
57
+ filter: getConfigByName('filter', is_non_empty_string_1.isNonEmptyString),
58
+ indent: getConfigByName('indent', is_string_1.isString),
59
+ semverGroups: getConfigByName('semverGroups', is_array_of_objects_1.isArrayOfObjects),
60
+ semverRange: getConfigByName('semverRange', is_string_1.isString),
61
+ sortAz: getConfigByName('sortAz', is_array_of_strings_1.isArrayOfStrings),
62
+ sortFirst: getConfigByName('sortFirst', is_array_of_strings_1.isArrayOfStrings),
63
+ source: getConfigByName('source', is_array_of_strings_1.isArrayOfStrings),
50
64
  types: fromCli?.types,
51
- versionGroups: getConfigByName('versionGroups'),
65
+ versionGroups: getConfigByName('versionGroups', is_array_of_objects_1.isArrayOfObjects),
52
66
  });
53
67
  (0, log_1.verbose)('user config:', fromPublic);
54
68
  const coreTypes = (0, get_core_types_1.getCoreTypes)();
@@ -75,11 +89,10 @@ const getConfig = (disk, fromCli) => {
75
89
  allConfig.versionGroups.push(allConfig.defaultVersionGroup);
76
90
  (0, log_1.verbose)('final config:', allConfig);
77
91
  return allConfig;
78
- function getConfigByName(name) {
79
- if (typeof fromCli[name] !== 'undefined')
92
+ function getConfigByName(name, isValid) {
93
+ if (isValid(fromCli[name]))
80
94
  return fromCli[name];
81
- if (typeof fromRcFile[name] !== 'undefined')
95
+ if (isValid(fromRcFile[name]))
82
96
  return fromRcFile[name];
83
97
  }
84
- };
85
- exports.getConfig = getConfig;
98
+ }
@@ -1,4 +1,3 @@
1
- import type { R } from '@mobily/ts-belt';
2
- import { BaseError } from '../../../../lib/error';
1
+ import type { Result } from 'tightrope/result';
3
2
  import type { PackageJsonFile } from '../../../get-package-json-files/package-json-file';
4
- export declare function getNonEmptyStringProp(propPath: string, file: PackageJsonFile): R.Result<string, BaseError>;
3
+ export declare function getNonEmptyStringProp(propPath: string, file: PackageJsonFile): Result<string>;
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNonEmptyStringProp = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const is_non_empty_string_1 = require("expect-more/dist/is-non-empty-string");
4
+ const get_1 = require("tightrope/fn/get");
5
+ const pipe_1 = require("tightrope/fn/pipe");
6
+ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
7
+ const filter_1 = require("tightrope/result/filter");
8
+ const map_err_1 = require("tightrope/result/map-err");
6
9
  const error_1 = require("../../../../lib/error");
7
- const props_1 = require("../../../get-package-json-files/get-patterns/props");
8
10
  function getNonEmptyStringProp(propPath, file) {
9
- return (0, ts_belt_1.pipe)(file.contents, (0, props_1.props)(propPath, is_non_empty_string_1.isNonEmptyString), ts_belt_1.O.toResult(new error_1.BaseError(`Failed to get ${propPath} in ${file.shortPath}`)));
11
+ return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...propPath.split('.')), (0, filter_1.filter)(is_non_empty_string_1.isNonEmptyString, ''), (0, map_err_1.mapErr)(() => new error_1.BaseError(`Failed to get ${propPath} in ${file.shortPath}`)));
10
12
  }
11
13
  exports.getNonEmptyStringProp = getNonEmptyStringProp;
@@ -1,20 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nameAndVersionProps = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const is_object_1 = require("expect-more/dist/is-object");
4
+ const get_1 = require("tightrope/fn/get");
5
+ const pipe_1 = require("tightrope/fn/pipe");
6
+ const and_then_1 = require("tightrope/result/and-then");
7
+ const from_try_1 = require("tightrope/result/from-try");
8
+ const map_1 = require("tightrope/result/map");
9
+ const map_err_1 = require("tightrope/result/map-err");
10
+ const tap_1 = require("tightrope/result/tap");
6
11
  const error_1 = require("../../../lib/error");
7
- const props_1 = require("../../get-package-json-files/get-patterns/props");
8
12
  const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
9
13
  exports.nameAndVersionProps = {
10
14
  read(file, pathDef) {
11
- return (0, ts_belt_1.pipe)(
15
+ return (0, pipe_1.pipe)(
12
16
  // get name prop
13
- (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(pathDef.namePath, file), ts_belt_1.R.mapError(() => new error_1.BaseError(`Strategy<name~version> failed to get ${pathDef.namePath} in ${file.shortPath}`)),
17
+ (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(pathDef.namePath, file), (0, map_err_1.mapErr)(() => new error_1.BaseError(`Strategy<name~version> failed to get ${pathDef.namePath} in ${file.shortPath}`)),
14
18
  // add the version prop
15
- ts_belt_1.R.flatMap((name) => (0, ts_belt_1.pipe)((0, get_non_empty_string_prop_1.getNonEmptyStringProp)(pathDef.path, file), ts_belt_1.R.map((version) => ({ name, version })), ts_belt_1.R.mapError(() => new error_1.BaseError(`Strategy<name~version> failed to get ${pathDef.path} in ${file.shortPath}`)))),
19
+ (0, and_then_1.andThen)((name) => (0, pipe_1.pipe)((0, get_non_empty_string_prop_1.getNonEmptyStringProp)(pathDef.path, file), (0, map_1.map)((version) => ({ name, version })), (0, map_err_1.mapErr)(() => new error_1.BaseError(`Strategy<name~version> failed to get ${pathDef.path} in ${file.shortPath}`)))),
16
20
  // if both are non empty strings, we can return them
17
- ts_belt_1.R.map(({ name, version }) => [[name, version]]));
21
+ (0, map_1.map)(({ name, version }) => [[name, version]]));
18
22
  },
19
23
  write(file, pathDef, [, version]) {
20
24
  const { contents, shortPath } = file;
@@ -23,14 +27,14 @@ exports.nameAndVersionProps = {
23
27
  const fullPath = pathDef.path.split('.');
24
28
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
25
29
  const key = fullPath.slice(-1).join('');
26
- return (0, ts_belt_1.pipe)(contents, (0, props_1.props)(pathToParent, is_object_1.isObject), ts_belt_1.O.toResult(onError()), ts_belt_1.R.tap((parent) => {
30
+ return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
27
31
  parent[key] = version;
28
- }), ts_belt_1.R.mapError(onError), ts_belt_1.R.map(() => file));
32
+ }), (0, map_err_1.mapErr)(onError), (0, map_1.map)(() => file));
29
33
  }
30
34
  else {
31
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => {
35
+ return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
32
36
  contents[pathDef.path] = version;
33
- }), ts_belt_1.R.mapError(onError), ts_belt_1.R.map(() => file));
37
+ }), (0, map_err_1.mapErr)(onError), (0, map_1.map)(() => file));
34
38
  }
35
39
  function onError() {
36
40
  const msg = `Strategy<name~version> failed to set ${pathDef.path} in ${shortPath}`;
@@ -1,23 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nameAndVersionString = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const is_non_empty_string_1 = require("expect-more/dist/is-non-empty-string");
6
- const is_object_1 = require("expect-more/dist/is-object");
4
+ const get_1 = require("tightrope/fn/get");
5
+ const pipe_1 = require("tightrope/fn/pipe");
6
+ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
7
+ const result_1 = require("tightrope/result");
8
+ const and_then_1 = require("tightrope/result/and-then");
9
+ const from_try_1 = require("tightrope/result/from-try");
10
+ const map_1 = require("tightrope/result/map");
11
+ const map_err_1 = require("tightrope/result/map-err");
12
+ const tap_1 = require("tightrope/result/tap");
7
13
  const error_1 = require("../../../lib/error");
8
- const props_1 = require("../../get-package-json-files/get-patterns/props");
9
14
  const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
10
15
  exports.nameAndVersionString = {
11
16
  read(file, pathDef) {
12
- return (0, ts_belt_1.pipe)(
17
+ return (0, pipe_1.pipe)(
13
18
  // get version prop
14
19
  (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(pathDef.path, file),
15
20
  // if it is a non empty string, we can read it
16
- ts_belt_1.R.flatMap((value) => {
21
+ (0, and_then_1.andThen)((value) => {
17
22
  const [name, version] = value.split('@');
18
23
  return (0, is_non_empty_string_1.isNonEmptyString)(name) && (0, is_non_empty_string_1.isNonEmptyString)(version)
19
- ? ts_belt_1.R.Ok([[name, version]])
20
- : ts_belt_1.R.Error(new error_1.BaseError(`Strategy<name@version> failed to get ${pathDef.path} in ${file.shortPath}`));
24
+ ? new result_1.Ok([[name, version]])
25
+ : new result_1.Err(new error_1.BaseError(`Strategy<name@version> failed to get ${pathDef.path} in ${file.shortPath}`));
21
26
  }));
22
27
  },
23
28
  write(file, pathDef, [name, version]) {
@@ -27,14 +32,14 @@ exports.nameAndVersionString = {
27
32
  const fullPath = pathDef.path.split('.');
28
33
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
29
34
  const key = fullPath.slice(-1).join('');
30
- return (0, ts_belt_1.pipe)(contents, (0, props_1.props)(pathToParent, is_object_1.isObject), ts_belt_1.O.toResult(onError()), ts_belt_1.R.tap((parent) => {
35
+ return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
31
36
  parent[key] = `${name}@${version}`;
32
- }), ts_belt_1.R.mapError(onError), ts_belt_1.R.map(() => file));
37
+ }), (0, map_err_1.mapErr)(onError), (0, map_1.map)(() => file));
33
38
  }
34
39
  else {
35
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => {
40
+ return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
36
41
  contents[pathDef.path] = `${name}@${version}`;
37
- }), ts_belt_1.R.mapError(onError), ts_belt_1.R.map(() => file));
42
+ }), (0, map_err_1.mapErr)(onError), (0, map_1.map)(() => file));
38
43
  }
39
44
  function onError() {
40
45
  const msg = `Strategy<name@version> failed to set ${pathDef.path} in ${shortPath}`;
@@ -1,5 +1,4 @@
1
- import type { R } from '@mobily/ts-belt';
2
- import type { BaseError } from '../../../lib/error';
1
+ import type { Result } from 'tightrope/result';
3
2
  import type { Syncpack } from '../../../types';
4
3
  import type { PackageJsonFile } from '../../get-package-json-files/package-json-file';
5
4
  export type PathDef<T extends Syncpack.PathDefinition['strategy']> = Syncpack.PathDefinition & {
@@ -9,7 +8,7 @@ export type PathDef<T extends Syncpack.PathDefinition['strategy']> = Syncpack.Pa
9
8
  export type Entry = [string, string];
10
9
  export interface Strategy<T extends Syncpack.PathDefinition['strategy']> {
11
10
  /** Read from in-memory package.json file */
12
- read(file: PackageJsonFile, pathDef: PathDef<T>): R.Result<Entry[], BaseError>;
11
+ read(file: PackageJsonFile, pathDef: PathDef<T>): Result<Entry[]>;
13
12
  /** Mutate in-memory package.json file */
14
- write(file: PackageJsonFile, pathDef: PathDef<T>, entry: [string, string | undefined]): R.Result<PackageJsonFile, BaseError>;
13
+ write(file: PackageJsonFile, pathDef: PathDef<T>, entry: [string, string | undefined]): Result<PackageJsonFile>;
15
14
  }
@@ -1,23 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.versionString = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const is_non_empty_string_1 = require("expect-more/dist/is-non-empty-string");
6
- const is_object_1 = require("expect-more/dist/is-object");
4
+ const get_1 = require("tightrope/fn/get");
5
+ const pipe_1 = require("tightrope/fn/pipe");
6
+ const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
7
+ const result_1 = require("tightrope/result");
8
+ const and_then_1 = require("tightrope/result/and-then");
9
+ const from_try_1 = require("tightrope/result/from-try");
10
+ const map_1 = require("tightrope/result/map");
11
+ const map_err_1 = require("tightrope/result/map-err");
12
+ const tap_1 = require("tightrope/result/tap");
7
13
  const error_1 = require("../../../lib/error");
8
- const props_1 = require("../../get-package-json-files/get-patterns/props");
9
14
  const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
10
15
  exports.versionString = {
11
16
  read(file, pathDef) {
12
- return (0, ts_belt_1.pipe)(
17
+ return (0, pipe_1.pipe)(
13
18
  // get version prop
14
19
  (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(pathDef.path, file),
15
20
  // if it is a non empty string, we can read it
16
- ts_belt_1.R.flatMap((version) => {
21
+ (0, and_then_1.andThen)((version) => {
17
22
  const name = pathDef.path.split('.').slice(-1).join('');
18
23
  return (0, is_non_empty_string_1.isNonEmptyString)(version)
19
- ? ts_belt_1.R.Ok([[name, version]])
20
- : ts_belt_1.R.Error(new error_1.BaseError(`Strategy<version> failed to get ${pathDef.path} in ${file.shortPath}`));
24
+ ? new result_1.Ok([[name, version]])
25
+ : new result_1.Err(new error_1.BaseError(`Strategy<version> failed to get ${pathDef.path} in ${file.shortPath}`));
21
26
  }));
22
27
  },
23
28
  write(file, pathDef, [, version]) {
@@ -27,14 +32,14 @@ exports.versionString = {
27
32
  const fullPath = pathDef.path.split('.');
28
33
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
29
34
  const key = fullPath.slice(-1).join('');
30
- return (0, ts_belt_1.pipe)(contents, (0, props_1.props)(pathToParent, is_object_1.isObject), ts_belt_1.O.toResult(onError()), ts_belt_1.R.tap((parent) => {
35
+ return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
31
36
  parent[key] = version;
32
- }), ts_belt_1.R.mapError(onError), ts_belt_1.R.map(() => file));
37
+ }), (0, map_err_1.mapErr)(onError), (0, map_1.map)(() => file));
33
38
  }
34
39
  else {
35
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(() => {
40
+ return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
36
41
  contents[pathDef.path] = version;
37
- }), ts_belt_1.R.mapError(onError), ts_belt_1.R.map(() => file));
42
+ }), (0, map_err_1.mapErr)(onError), (0, map_1.map)(() => file));
38
43
  }
39
44
  function onError() {
40
45
  const msg = `Strategy<version> failed to set ${pathDef.path} in ${shortPath}`;
@@ -1,23 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.versionsByName = void 0;
4
- const ts_belt_1 = require("@mobily/ts-belt");
5
- const is_non_empty_object_1 = require("expect-more/dist/is-non-empty-object");
6
- const is_object_1 = require("expect-more/dist/is-object");
4
+ const get_1 = require("tightrope/fn/get");
5
+ const pipe_1 = require("tightrope/fn/pipe");
6
+ const is_non_empty_object_1 = require("tightrope/guard/is-non-empty-object");
7
+ const filter_1 = require("tightrope/result/filter");
8
+ const map_1 = require("tightrope/result/map");
9
+ const map_err_1 = require("tightrope/result/map-err");
10
+ const tap_1 = require("tightrope/result/tap");
7
11
  const error_1 = require("../../../lib/error");
8
- const props_1 = require("../../get-package-json-files/get-patterns/props");
9
12
  exports.versionsByName = {
10
13
  read(file, pathDef) {
11
- return (0, ts_belt_1.pipe)(file.contents, (0, props_1.props)(pathDef.path, is_non_empty_object_1.isNonEmptyObject), ts_belt_1.O.map(Object.entries), ts_belt_1.O.toResult(new error_1.BaseError(`Strategy<versionsByName> failed to get ${pathDef.path} in ${file.shortPath}`)));
14
+ return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...pathDef.path.split('.')), (0, filter_1.filter)((is_non_empty_object_1.isNonEmptyObject), ''), (0, map_1.map)((Object.entries)), (0, map_err_1.mapErr)(() => new error_1.BaseError(`Strategy<versionsByName> failed to get ${pathDef.path} in ${file.shortPath}`)));
12
15
  },
13
16
  write(file, pathDef, [name, version]) {
14
- const { contents, shortPath } = file;
15
- return (0, ts_belt_1.pipe)(contents, (0, props_1.props)(pathDef.path, is_object_1.isObject), ts_belt_1.O.toResult(onError()), ts_belt_1.R.tap((parent) => {
17
+ return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...pathDef.path.split('.')), (0, tap_1.tap)((parent) => {
16
18
  parent[name] = version;
17
- }), ts_belt_1.R.mapError(onError), ts_belt_1.R.map(() => file));
18
- function onError() {
19
- const msg = `Strategy<versionsByName> failed to set ${pathDef.path} in ${shortPath}`;
20
- return new error_1.BaseError(msg);
21
- }
19
+ }), (0, map_err_1.mapErr)(() => new error_1.BaseError(`Strategy<versionsByName> failed to set ${pathDef.path} in ${file.shortPath}`)), (0, map_1.map)(() => file));
22
20
  },
23
21
  };