syncpack 9.3.2 → 9.7.4

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 (91) hide show
  1. package/dist/bin-fix-mismatches/fix-mismatches-cli.js +4 -4
  2. package/dist/bin-fix-mismatches/fix-mismatches.js +14 -15
  3. package/dist/bin-fix-mismatches/index.js +50 -48
  4. package/dist/bin-format/format-cli.js +4 -4
  5. package/dist/bin-format/format.js +19 -18
  6. package/dist/bin-format/index.js +43 -46
  7. package/dist/bin-lint-semver-ranges/index.js +59 -48
  8. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +4 -4
  9. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +13 -35
  10. package/dist/bin-list/index.js +43 -46
  11. package/dist/bin-list/list-cli.js +4 -4
  12. package/dist/bin-list/list.js +21 -28
  13. package/dist/bin-list-mismatches/index.js +46 -47
  14. package/dist/bin-list-mismatches/list-mismatches-cli.js +4 -4
  15. package/dist/bin-list-mismatches/list-mismatches.js +49 -38
  16. package/dist/bin-set-semver-ranges/index.js +62 -49
  17. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +4 -4
  18. package/dist/bin-set-semver-ranges/set-semver-ranges.js +4 -4
  19. package/dist/bin.js +8 -8
  20. package/dist/constants.d.ts +2 -1
  21. package/dist/constants.js +6 -5
  22. package/dist/get-context/$R.js +14 -36
  23. package/dist/get-context/get-all-instances.js +3 -3
  24. package/dist/get-context/get-config/get-core-types.js +11 -41
  25. package/dist/get-context/get-config/get-custom-types.js +7 -19
  26. package/dist/get-context/get-config/get-enabled-types.js +9 -11
  27. package/dist/get-context/get-config/index.js +29 -59
  28. package/dist/get-context/get-config/path-strategy/index.js +8 -8
  29. package/dist/get-context/get-config/path-strategy/lib/get-non-empty-string-prop.js +6 -6
  30. package/dist/get-context/get-config/path-strategy/name-and-version-props.js +23 -49
  31. package/dist/get-context/get-config/path-strategy/name-and-version-string.js +26 -42
  32. package/dist/get-context/get-config/path-strategy/types.js +1 -1
  33. package/dist/get-context/get-config/path-strategy/version-string.js +25 -41
  34. package/dist/get-context/get-config/path-strategy/versions-by-name.js +14 -30
  35. package/dist/get-context/get-config/schema/base-group.d.ts +2 -2
  36. package/dist/get-context/get-config/schema/base-group.js +5 -5
  37. package/dist/get-context/get-config/schema/index.d.ts +254 -164
  38. package/dist/get-context/get-config/schema/index.js +40 -63
  39. package/dist/get-context/get-config/schema/paths.js +12 -12
  40. package/dist/get-context/get-config/schema/semver-group.d.ts +24 -24
  41. package/dist/get-context/get-config/schema/semver-group.js +11 -18
  42. package/dist/get-context/get-config/schema/semver-range.js +4 -4
  43. package/dist/get-context/get-config/schema/version-group.d.ts +77 -40
  44. package/dist/get-context/get-config/schema/version-group.js +20 -21
  45. package/dist/get-context/get-groups/base-group.d.ts +4 -1
  46. package/dist/get-context/get-groups/base-group.js +18 -19
  47. package/dist/get-context/get-groups/index.d.ts +2 -1
  48. package/dist/get-context/get-groups/index.js +31 -37
  49. package/dist/get-context/get-groups/semver-group.d.ts +0 -1
  50. package/dist/get-context/get-groups/semver-group.js +23 -66
  51. package/dist/get-context/get-groups/version-group/index.d.ts +2 -1
  52. package/dist/get-context/get-groups/version-group/index.js +29 -68
  53. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.d.ts +3 -1
  54. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +36 -45
  55. package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +2 -1
  56. package/dist/get-context/get-groups/version-group/instance-group/index.js +55 -47
  57. package/dist/get-context/get-groups/version-group/instance-group/lib/clean.d.ts +2 -0
  58. package/dist/get-context/get-groups/version-group/instance-group/lib/clean.js +13 -0
  59. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +2 -0
  60. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +22 -0
  61. package/dist/get-context/get-groups/version-group/instance-group/lib/get-range-score.d.ts +2 -0
  62. package/dist/get-context/get-groups/version-group/instance-group/lib/get-range-score.js +23 -0
  63. package/dist/get-context/get-package-json-files/get-file-paths.js +18 -19
  64. package/dist/get-context/get-package-json-files/get-patterns/get-lerna-patterns.js +9 -12
  65. package/dist/get-context/get-package-json-files/get-patterns/get-pnpm-patterns.js +9 -11
  66. package/dist/get-context/get-package-json-files/get-patterns/get-yarn-patterns.js +10 -13
  67. package/dist/get-context/get-package-json-files/get-patterns/index.js +15 -42
  68. package/dist/get-context/get-package-json-files/get-patterns/lib/get-array-of-strings.js +4 -6
  69. package/dist/get-context/get-package-json-files/get-patterns/props.js +9 -33
  70. package/dist/get-context/get-package-json-files/get-patterns/read-json-safe.js +6 -9
  71. package/dist/get-context/get-package-json-files/get-patterns/read-yaml-safe.js +4 -4
  72. package/dist/get-context/get-package-json-files/index.js +7 -7
  73. package/dist/get-context/get-package-json-files/package-json-file/index.js +32 -55
  74. package/dist/get-context/get-package-json-files/package-json-file/instance.js +14 -15
  75. package/dist/get-context/index.js +19 -24
  76. package/dist/lib/disk.js +28 -29
  77. package/dist/lib/error.js +13 -31
  78. package/dist/lib/exit-if-invalid.js +1 -1
  79. package/dist/lib/is-semver.d.ts +1 -1
  80. package/dist/lib/is-semver.js +15 -7
  81. package/dist/lib/log.js +33 -58
  82. package/dist/lib/newlines.js +11 -11
  83. package/dist/lib/print-strings.js +2 -2
  84. package/dist/lib/set-semver-range.js +8 -8
  85. package/dist/lib/show-help-on-error.js +31 -8
  86. package/dist/lib/sort-by-name.js +1 -1
  87. package/dist/lib/write-if-changed.js +3 -3
  88. package/dist/option.js +8 -13
  89. package/dist/types.d.ts +2 -0
  90. package/dist/types.js +1 -1
  91. package/package.json +20 -16
@@ -0,0 +1,2 @@
1
+ /** Is this next version to be inspected higher than the current highest? */
2
+ export declare function compareSemver(next: string, highest: string | undefined): '*' | 'invalid' | 'gt' | 'lt' | 'eq';
@@ -0,0 +1,22 @@
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.compareSemver = void 0;
7
+ const gt_1 = __importDefault(require("semver/functions/gt"));
8
+ const is_semver_1 = require("../../../../../lib/is-semver");
9
+ const clean_1 = require("./clean");
10
+ /** Is this next version to be inspected higher than the current highest? */
11
+ function compareSemver(next, highest) {
12
+ if (next === '*')
13
+ return '*';
14
+ if (!(0, is_semver_1.isSemver)(next))
15
+ return 'invalid';
16
+ if (!highest || (0, gt_1.default)((0, clean_1.clean)(next), highest))
17
+ return 'gt';
18
+ if ((0, gt_1.default)((0, clean_1.clean)(next), highest))
19
+ return 'lt';
20
+ return 'eq';
21
+ }
22
+ exports.compareSemver = compareSemver;
@@ -0,0 +1,2 @@
1
+ /** Rank a Semver Range according to its greediness */
2
+ export declare function getRangeScore(version: string): number;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRangeScore = void 0;
4
+ const constants_1 = require("../../../../../constants");
5
+ const scoresByRange = {
6
+ [constants_1.RANGE.ANY]: 8,
7
+ [constants_1.RANGE.GT]: 7,
8
+ [constants_1.RANGE.GTE]: 6,
9
+ [constants_1.RANGE.MINOR]: 5,
10
+ [constants_1.RANGE.LOOSE]: 4,
11
+ [constants_1.RANGE.PATCH]: 3,
12
+ [constants_1.RANGE.EXACT]: 2,
13
+ [constants_1.RANGE.LTE]: 1,
14
+ [constants_1.RANGE.LT]: 0,
15
+ };
16
+ /** Rank a Semver Range according to its greediness */
17
+ function getRangeScore(version) {
18
+ const range = version.indexOf('.x') !== -1
19
+ ? constants_1.RANGE.LOOSE
20
+ : version.slice(0, version.search(/[0-9]/));
21
+ return scoresByRange[range] || 0;
22
+ }
23
+ exports.getRangeScore = getRangeScore;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFilePaths = void 0;
4
- var ts_belt_1 = require("@mobily/ts-belt");
5
- var expect_more_1 = require("expect-more");
6
- var _R_1 = require("../$R");
7
- var error_1 = require("../../lib/error");
8
- var print_strings_1 = require("../../lib/print-strings");
9
- var get_patterns_1 = require("./get-patterns");
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");
7
+ const _R_1 = require("../$R");
8
+ const error_1 = require("../../lib/error");
9
+ const print_strings_1 = require("../../lib/print-strings");
10
+ const get_patterns_1 = require("./get-patterns");
10
11
  /**
11
12
  * Using --source options and/or config files on disk from npm/pnpm/yarn/lerna,
12
13
  * return an array of absolute paths to every package.json file the user is
@@ -17,21 +18,19 @@ var get_patterns_1 = require("./get-patterns");
17
18
  function getFilePaths(disk, program) {
18
19
  return (0, ts_belt_1.pipe)(program, (0, get_patterns_1.getPatterns)(disk), ts_belt_1.R.flatMap(resolvePatterns));
19
20
  function resolvePatterns(patterns) {
20
- var quoted = (0, print_strings_1.printStrings)(patterns);
21
- var ERR_NO_MATCH = "No package.json files matched the patterns: ".concat(quoted);
21
+ const quoted = (0, print_strings_1.printStrings)(patterns);
22
+ const ERR_NO_MATCH = `No package.json files matched the patterns: ${quoted}`;
22
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)));
23
24
  }
24
25
  function resolvePattern(pattern) {
25
- var ERR_GLOB_MISS = "No package.json files match pattern \"".concat(pattern, "\"");
26
- var ERR_INVALID = "\"glob\" returned unexpected data on pattern \"".concat(pattern, "\"");
27
- var ERR_GLOB_THROW = "\"glob\" threw on pattern \"".concat(pattern, "\"");
28
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(function () { return disk.globSync(pattern); }), ts_belt_1.R.mapError(error_1.BaseError.map(ERR_GLOB_THROW)), ts_belt_1.R.flatMap(function (filePaths) {
29
- return (0, expect_more_1.isEmptyArray)(filePaths)
30
- ? ts_belt_1.R.Error(new error_1.BaseError(ERR_GLOB_MISS))
31
- : (0, expect_more_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
- }));
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))));
35
34
  }
36
35
  /** Remove unwanted readonly type */
37
36
  function removeReadonlyType(value) {
@@ -1,19 +1,16 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLernaPatterns = void 0;
4
- var ts_belt_1 = require("@mobily/ts-belt");
5
- var path_1 = require("path");
6
- var constants_1 = require("../../../constants");
7
- var error_1 = require("../../../lib/error");
8
- var get_array_of_strings_1 = require("./lib/get-array-of-strings");
9
- var read_json_safe_1 = require("./read-json-safe");
4
+ const ts_belt_1 = require("@mobily/ts-belt");
5
+ const path_1 = require("path");
6
+ 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
+ const read_json_safe_1 = require("./read-json-safe");
10
10
  function getLernaPatterns(disk) {
11
- var getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('packages');
11
+ const getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('packages');
12
12
  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(function (_a) {
14
- var contents = _a.contents;
15
- return (0, ts_belt_1.pipe)(getPackages(contents), ts_belt_1.O.toResult(new error_1.BaseError('no lerna patterns found')));
16
- }));
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')))));
17
14
  };
18
15
  }
19
16
  exports.getLernaPatterns = getLernaPatterns;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPnpmPatterns = void 0;
4
- var ts_belt_1 = require("@mobily/ts-belt");
5
- var path_1 = require("path");
6
- var constants_1 = require("../../../constants");
7
- var error_1 = require("../../../lib/error");
8
- var get_array_of_strings_1 = require("./lib/get-array-of-strings");
9
- var read_yaml_safe_1 = require("./read-yaml-safe");
10
- var getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('packages');
4
+ const ts_belt_1 = require("@mobily/ts-belt");
5
+ const path_1 = require("path");
6
+ 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
+ const read_yaml_safe_1 = require("./read-yaml-safe");
10
+ const getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('packages');
11
11
  function getPnpmPatterns(disk) {
12
12
  return function getPnpmPatterns() {
13
13
  return (0, ts_belt_1.pipe)(
@@ -15,9 +15,7 @@ function getPnpmPatterns(disk) {
15
15
  // - "packages/**"
16
16
  // - "components/**"
17
17
  // - "!**/test/**"
18
- (0, path_1.join)(constants_1.CWD, 'pnpm-workspace.yaml'), (0, read_yaml_safe_1.readYamlSafe)(disk), ts_belt_1.R.flatMap(function (packageJson) {
19
- return (0, ts_belt_1.pipe)(getPackages(packageJson), ts_belt_1.O.match(ts_belt_1.F.identity, function () { return getPackages(packageJson); }), ts_belt_1.O.toResult(new error_1.BaseError('no pnpm patterns found')));
20
- }));
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')))));
21
19
  };
22
20
  }
23
21
  exports.getPnpmPatterns = getPnpmPatterns;
@@ -1,20 +1,17 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getYarnPatterns = void 0;
4
- var ts_belt_1 = require("@mobily/ts-belt");
5
- var path_1 = require("path");
6
- var constants_1 = require("../../../constants");
7
- var error_1 = require("../../../lib/error");
8
- var get_array_of_strings_1 = require("./lib/get-array-of-strings");
9
- var read_json_safe_1 = require("./read-json-safe");
4
+ const ts_belt_1 = require("@mobily/ts-belt");
5
+ const path_1 = require("path");
6
+ 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
+ const read_json_safe_1 = require("./read-json-safe");
10
10
  function getYarnPatterns(disk) {
11
- var getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('workspaces');
12
- var getPackagesNested = (0, get_array_of_strings_1.getArrayOfStrings)('workspaces.packages');
11
+ const getPackages = (0, get_array_of_strings_1.getArrayOfStrings)('workspaces');
12
+ const getPackagesNested = (0, get_array_of_strings_1.getArrayOfStrings)('workspaces.packages');
13
13
  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(function (_a) {
15
- var contents = _a.contents;
16
- return (0, ts_belt_1.pipe)(getPackages(contents), ts_belt_1.O.match(ts_belt_1.F.identity, function () { return getPackagesNested(contents); }), ts_belt_1.O.toResult(new error_1.BaseError('no yarn patterns found')));
17
- }));
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')))));
18
15
  };
19
16
  }
20
17
  exports.getYarnPatterns = getYarnPatterns;
@@ -1,38 +1,13 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
- if (ar || !(i in from)) {
21
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
- ar[i] = from[i];
23
- }
24
- }
25
- return to.concat(ar || Array.prototype.slice.call(from));
26
- };
27
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
28
3
  exports.getPatterns = void 0;
29
- var ts_belt_1 = require("@mobily/ts-belt");
30
- var expect_more_1 = require("expect-more");
31
- var constants_1 = require("../../../constants");
32
- var error_1 = require("../../../lib/error");
33
- var get_lerna_patterns_1 = require("./get-lerna-patterns");
34
- var get_pnpm_patterns_1 = require("./get-pnpm-patterns");
35
- var get_yarn_patterns_1 = require("./get-yarn-patterns");
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 constants_1 = require("../../../constants");
7
+ const error_1 = require("../../../lib/error");
8
+ const get_lerna_patterns_1 = require("./get-lerna-patterns");
9
+ const get_pnpm_patterns_1 = require("./get-pnpm-patterns");
10
+ const get_yarn_patterns_1 = require("./get-yarn-patterns");
36
11
  /**
37
12
  * Find every glob pattern which should be used to find package.json files for
38
13
  * this monorepo.
@@ -41,29 +16,27 @@ var get_yarn_patterns_1 = require("./get-yarn-patterns");
41
16
  */
42
17
  function getPatterns(disk) {
43
18
  return function getPatterns(program) {
44
- var getters = [
19
+ const getters = [
45
20
  getCliPatterns,
46
21
  (0, get_yarn_patterns_1.getYarnPatterns)(disk),
47
22
  (0, get_pnpm_patterns_1.getPnpmPatterns)(disk),
48
23
  (0, get_lerna_patterns_1.getLernaPatterns)(disk),
49
24
  ];
50
- var initialResult = ts_belt_1.R.Error(new error_1.BaseError('getPatterns did not try any sources'));
51
- var res = ts_belt_1.A.reduce(getters, initialResult, function (previousResult, getNextResult) {
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) => {
52
27
  if (ts_belt_1.R.isOk(previousResult))
53
28
  return previousResult;
54
29
  return getNextResult();
55
30
  });
56
- return (0, ts_belt_1.pipe)(res, ts_belt_1.R.map(addRootDir), ts_belt_1.R.map(limitToPackageJson), ts_belt_1.R.handleError(function () { return constants_1.DEFAULT_SOURCES; }), ts_belt_1.R.mapError(ts_belt_1.F.identity));
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));
57
32
  function getCliPatterns() {
58
- return ts_belt_1.R.fromPredicate(program.source, expect_more_1.isArrayOfStrings, new error_1.BaseError('No --source options provided'));
33
+ return ts_belt_1.R.fromPredicate(program.source, is_array_of_strings_1.isArrayOfStrings, new error_1.BaseError('No --source options provided'));
59
34
  }
60
35
  function addRootDir(patterns) {
61
- return __spreadArray(['package.json'], __read(patterns), false);
36
+ return ['package.json', ...patterns];
62
37
  }
63
38
  function limitToPackageJson(patterns) {
64
- return patterns.map(function (pattern) {
65
- return pattern.includes('package.json') ? pattern : "".concat(pattern, "/package.json");
66
- });
39
+ return patterns.map((pattern) => pattern.includes('package.json') ? pattern : `${pattern}/package.json`);
67
40
  }
68
41
  };
69
42
  }
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getArrayOfStrings = void 0;
4
- var expect_more_1 = require("expect-more");
5
- var props_1 = require("../props");
4
+ const is_array_of_strings_1 = require("expect-more/dist/is-array-of-strings");
5
+ const props_1 = require("../props");
6
6
  // Yarn's config for this can be in more than one place
7
- var getArrayOfStrings = function (path) {
8
- return (0, props_1.props)(path, expect_more_1.isArrayOfStrings);
9
- };
7
+ const getArrayOfStrings = (path) => (0, props_1.props)(path, is_array_of_strings_1.isArrayOfStrings);
10
8
  exports.getArrayOfStrings = getArrayOfStrings;
@@ -1,46 +1,22 @@
1
1
  "use strict";
2
- var __values = (this && this.__values) || function(o) {
3
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
- if (m) return m.call(o);
5
- if (o && typeof o.length === "number") return {
6
- next: function () {
7
- if (o && i >= o.length) o = void 0;
8
- return { value: o && o[i++], done: !o };
9
- }
10
- };
11
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
- };
13
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.props = void 0;
15
- var ts_belt_1 = require("@mobily/ts-belt");
16
- var isWalkable = function (value) {
17
- return value !== null && typeof value !== 'undefined';
18
- };
4
+ const ts_belt_1 = require("@mobily/ts-belt");
5
+ const isWalkable = (value) => value !== null && typeof value !== 'undefined';
19
6
  /**
20
7
  * Safely read nested properties of any value.
21
8
  * @param keys 'child.grandChild.greatGrandChild'
22
9
  */
23
10
  function props(keys, predicate) {
24
11
  return function getNestedProp(obj) {
25
- var e_1, _a;
26
- var next = obj;
27
- try {
28
- for (var _b = __values(keys.split('.')), _c = _b.next(); !_c.done; _c = _b.next()) {
29
- var key = _c.value;
30
- if (isWalkable(next) && key in next) {
31
- next = next[key];
32
- }
33
- else {
34
- return ts_belt_1.O.None;
35
- }
12
+ let next = obj;
13
+ for (const key of keys.split('.')) {
14
+ if (isWalkable(next) && key in next) {
15
+ next = next[key];
36
16
  }
37
- }
38
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
39
- finally {
40
- try {
41
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
17
+ else {
18
+ return ts_belt_1.O.None;
42
19
  }
43
- finally { if (e_1) throw e_1.error; }
44
20
  }
45
21
  return ts_belt_1.O.fromPredicate(next, predicate);
46
22
  };
@@ -1,20 +1,17 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readJsonSafe = void 0;
4
- var ts_belt_1 = require("@mobily/ts-belt");
5
- var error_1 = require("../../../lib/error");
4
+ const ts_belt_1 = require("@mobily/ts-belt");
5
+ const error_1 = require("../../../lib/error");
6
6
  function readJsonSafe(disk) {
7
7
  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 ".concat(filePath))), ts_belt_1.R.map(function (_a) {
9
- var contents = _a.contents, json = _a.json;
10
- return ({ contents: contents, filePath: filePath, json: json });
11
- }))));
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 })))));
12
9
  };
13
10
  function readFileSafe(filePath) {
14
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(function () { return disk.readFileSync(filePath); }), ts_belt_1.R.mapError(error_1.BaseError.map("Failed to read JSON file at ".concat(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}`)));
15
12
  }
16
13
  }
17
14
  exports.readJsonSafe = readJsonSafe;
18
15
  function parseJsonSafe(json) {
19
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(function () { return JSON.parse(json); }), ts_belt_1.R.mapError(error_1.BaseError.map('Failed to parse JSON')), ts_belt_1.R.map(function (contents) { return ({ contents: contents, json: 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 })));
20
17
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readYamlSafe = void 0;
4
- var ts_belt_1 = require("@mobily/ts-belt");
5
- var error_1 = require("../../../lib/error");
4
+ const ts_belt_1 = require("@mobily/ts-belt");
5
+ const error_1 = require("../../../lib/error");
6
6
  function readYamlSafe(disk) {
7
7
  return function readYamlSafe(filePath) {
8
- return (0, ts_belt_1.pipe)(ts_belt_1.R.fromExecution(function () { return disk.readYamlFileSync(filePath); }), ts_belt_1.R.mapError(error_1.BaseError.map("Failed to read YAML file at ".concat(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
9
  };
10
10
  }
11
11
  exports.readYamlSafe = readYamlSafe;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPackageJsonFiles = void 0;
4
- var ts_belt_1 = require("@mobily/ts-belt");
5
- var _R_1 = require("../$R");
6
- var get_file_paths_1 = require("./get-file-paths");
7
- var read_json_safe_1 = require("./get-patterns/read-json-safe");
8
- var package_json_file_1 = require("./package-json-file");
4
+ const ts_belt_1 = require("@mobily/ts-belt");
5
+ const _R_1 = require("../$R");
6
+ const get_file_paths_1 = require("./get-file-paths");
7
+ const read_json_safe_1 = require("./get-patterns/read-json-safe");
8
+ const package_json_file_1 = require("./package-json-file");
9
9
  /** Create an API for every package.json file needed. */
10
10
  function getPackageJsonFiles(disk, config) {
11
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.getWithDefault([]));
12
12
  function resolvePackageJson(disk) {
13
- return (0, ts_belt_1.flow)((0, read_json_safe_1.readJsonSafe)(disk), ts_belt_1.R.map(function (jsonFile) { return new package_json_file_1.PackageJsonFile(jsonFile, config, 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)));
14
14
  }
15
15
  }
16
16
  exports.getPackageJsonFiles = getPackageJsonFiles;
@@ -1,31 +1,15 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
19
3
  exports.PackageJsonFile = void 0;
20
- var ts_belt_1 = require("@mobily/ts-belt");
21
- var path_1 = require("path");
22
- var constants_1 = require("../../../constants");
23
- var log_1 = require("../../../lib/log");
24
- var newlines_1 = require("../../../lib/newlines");
25
- var path_strategy_1 = require("../../get-config/path-strategy");
26
- var instance_1 = require("./instance");
27
- var PackageJsonFile = /** @class */ (function () {
28
- function PackageJsonFile(jsonFile, config, disk) {
4
+ const ts_belt_1 = require("@mobily/ts-belt");
5
+ const path_1 = require("path");
6
+ const constants_1 = require("../../../constants");
7
+ const log_1 = require("../../../lib/log");
8
+ const newlines_1 = require("../../../lib/newlines");
9
+ const path_strategy_1 = require("../../get-config/path-strategy");
10
+ const instance_1 = require("./instance");
11
+ class PackageJsonFile {
12
+ constructor(jsonFile, config, disk) {
29
13
  this.contents = jsonFile.contents;
30
14
  this.disk = disk;
31
15
  this.filePath = jsonFile.filePath;
@@ -33,41 +17,35 @@ var PackageJsonFile = /** @class */ (function () {
33
17
  this.config = config;
34
18
  this.shortPath = (0, path_1.relative)(constants_1.CWD, jsonFile.filePath);
35
19
  }
36
- PackageJsonFile.prototype.hasChanged = function () {
20
+ hasChanged() {
37
21
  return this.json !== this.getSource();
38
- };
39
- PackageJsonFile.prototype.write = function () {
22
+ }
23
+ write() {
40
24
  this.disk.writeFileSync(this.filePath, this.getSource());
41
- };
42
- PackageJsonFile.prototype.getSource = function () {
43
- var contents = this.contents;
44
- var indent = this.config.indent;
45
- var EOL = newlines_1.newlines.detect(this.json);
46
- var source = "".concat(JSON.stringify(contents, null, indent)).concat(EOL);
25
+ }
26
+ getSource() {
27
+ const contents = this.contents;
28
+ const indent = this.config.indent;
29
+ const EOL = newlines_1.newlines.detect(this.json);
30
+ const source = `${JSON.stringify(contents, null, indent)}${EOL}`;
47
31
  return newlines_1.newlines.fix(source, EOL);
48
- };
49
- PackageJsonFile.prototype.getInstances = function () {
50
- var _this = this;
32
+ }
33
+ getInstances() {
51
34
  return this.config.enabledTypes
52
- .flatMap(function (pathDef) {
53
- return _this.getPathEntries(pathDef, _this).map(function (_a) {
54
- var _b = __read(_a, 2), name = _b[0], version = _b[1];
55
- return new instance_1.Instance(pathDef, name, _this, version);
56
- });
57
- })
58
- .filter(function (instance) {
59
- var pathDef = instance.pathDef, name = instance.name, version = instance.version;
60
- var filter = _this.config.filter;
35
+ .flatMap((pathDef) => this.getPathEntries(pathDef, this).map(([name, version]) => new instance_1.Instance(pathDef, name, this, version)))
36
+ .filter((instance) => {
37
+ const { pathDef, name, version } = instance;
38
+ const filter = this.config.filter;
61
39
  if (name.search(new RegExp(filter)) === -1) {
62
- (0, log_1.verbose)("skip, name \"".concat(name, "\" does not match filter \"").concat(filter, "\""));
40
+ (0, log_1.verbose)(`skip, name "${name}" does not match filter "${filter}"`);
63
41
  return false;
64
42
  }
65
- (0, log_1.verbose)("add ".concat(name, "@").concat(version, " to ").concat(pathDef.name, ":").concat(pathDef.strategy, " ").concat(_this.shortPath));
43
+ (0, log_1.verbose)(`add ${name}@${version} to ${pathDef.name}:${pathDef.strategy} ${this.shortPath}`);
66
44
  return true;
67
45
  });
68
- };
69
- PackageJsonFile.prototype.getPathEntries = function (pathDef, file) {
70
- var strategyName = pathDef.strategy;
46
+ }
47
+ getPathEntries(pathDef, file) {
48
+ const strategyName = pathDef.strategy;
71
49
  switch (strategyName) {
72
50
  case 'name@version':
73
51
  return (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].read(file, pathDef), ts_belt_1.R.getWithDefault([]));
@@ -80,7 +58,6 @@ var PackageJsonFile = /** @class */ (function () {
80
58
  default:
81
59
  return (0, path_strategy_1.exhaustiveCheck)(strategyName);
82
60
  }
83
- };
84
- return PackageJsonFile;
85
- }());
61
+ }
62
+ }
86
63
  exports.PackageJsonFile = PackageJsonFile;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Instance = void 0;
4
- var ts_belt_1 = require("@mobily/ts-belt");
5
- var _R_1 = require("../../$R");
6
- var path_strategy_1 = require("../../get-config/path-strategy");
7
- var Instance = /** @class */ (function () {
8
- function Instance(pathDef, name, packageJsonFile, version) {
4
+ const ts_belt_1 = require("@mobily/ts-belt");
5
+ const _R_1 = require("../../$R");
6
+ const path_strategy_1 = require("../../get-config/path-strategy");
7
+ class Instance {
8
+ constructor(pathDef, name, packageJsonFile, version) {
9
9
  this.pathDef = pathDef;
10
10
  this.name = name;
11
11
  this.packageJsonFile = packageJsonFile;
@@ -13,17 +13,17 @@ var Instance = /** @class */ (function () {
13
13
  this.version = version;
14
14
  }
15
15
  /** Is this instance the package.json file of this package developed in this repo? */
16
- Instance.prototype.isWorkspace = function () {
16
+ isWorkspace() {
17
17
  return this.pathDef.name === 'workspace';
18
- };
18
+ }
19
19
  /**
20
20
  * In the case of banned dependencies, their version is set to `undefined`,
21
21
  * which causes them to be removed by `JSON.stringify`.
22
22
  */
23
- Instance.prototype.setVersion = function (version) {
24
- var strategyName = this.pathDef.strategy;
25
- var entry = [this.name, version];
26
- var file = this.packageJsonFile;
23
+ setVersion(version) {
24
+ const strategyName = this.pathDef.strategy;
25
+ const entry = [this.name, version];
26
+ const file = this.packageJsonFile;
27
27
  switch (strategyName) {
28
28
  case 'name@version':
29
29
  (0, ts_belt_1.pipe)(path_strategy_1.strategyByName[strategyName].write(file, this.pathDef, entry), _R_1.$R.tapErrVerbose);
@@ -40,7 +40,6 @@ var Instance = /** @class */ (function () {
40
40
  default:
41
41
  return (0, path_strategy_1.exhaustiveCheck)(strategyName);
42
42
  }
43
- };
44
- return Instance;
45
- }());
43
+ }
44
+ }
46
45
  exports.Instance = Instance;