syncpack 9.8.6 → 10.0.0

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 (184) hide show
  1. package/README.md +17 -19
  2. package/dist/bin-fix-mismatches/fix-mismatches-cli.d.ts +2 -2
  3. package/dist/bin-fix-mismatches/fix-mismatches-cli.js +3 -1
  4. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +2 -2
  5. package/dist/bin-fix-mismatches/fix-mismatches.js +42 -24
  6. package/dist/bin-format/format-cli.d.ts +2 -2
  7. package/dist/bin-format/format-cli.js +2 -1
  8. package/dist/bin-format/format.d.ts +2 -2
  9. package/dist/bin-format/format.js +4 -1
  10. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.d.ts +2 -2
  11. package/dist/bin-lint-semver-ranges/lint-semver-ranges-cli.js +2 -1
  12. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +2 -2
  13. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +29 -25
  14. package/dist/bin-list/list-cli.d.ts +2 -2
  15. package/dist/bin-list/list-cli.js +2 -1
  16. package/dist/bin-list/list.d.ts +2 -2
  17. package/dist/bin-list/list.js +58 -54
  18. package/dist/bin-list-mismatches/list-mismatches-cli.d.ts +2 -2
  19. package/dist/bin-list-mismatches/list-mismatches-cli.js +2 -1
  20. package/dist/bin-list-mismatches/list-mismatches.d.ts +2 -2
  21. package/dist/bin-list-mismatches/list-mismatches.js +72 -106
  22. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.d.ts +2 -2
  23. package/dist/bin-set-semver-ranges/set-semver-ranges-cli.js +2 -1
  24. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +2 -2
  25. package/dist/bin-set-semver-ranges/set-semver-ranges.js +17 -3
  26. package/dist/config/get-custom-types.d.ts +9 -0
  27. package/dist/config/get-custom-types.js +49 -0
  28. package/dist/config/get-enabled-types.d.ts +3 -0
  29. package/dist/config/get-enabled-types.js +48 -0
  30. package/dist/config/get-filter.d.ts +2 -0
  31. package/dist/config/get-filter.js +13 -0
  32. package/dist/config/get-indent.d.ts +2 -0
  33. package/dist/config/get-indent.js +12 -0
  34. package/dist/config/get-semver-range.d.ts +3 -0
  35. package/dist/config/get-semver-range.js +12 -0
  36. package/dist/config/get-sort-az.d.ts +2 -0
  37. package/dist/config/get-sort-az.js +18 -0
  38. package/dist/config/get-sort-first.d.ts +2 -0
  39. package/dist/config/get-sort-first.js +10 -0
  40. package/dist/config/get-source.d.ts +2 -0
  41. package/dist/config/get-source.js +13 -0
  42. package/dist/config/types.d.ts +106 -0
  43. package/dist/constants.d.ts +1 -0
  44. package/dist/constants.js +1 -0
  45. package/dist/get-context/index.d.ts +8 -16
  46. package/dist/get-context/index.js +7 -33
  47. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.d.ts +3 -3
  48. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-file-paths.js +4 -4
  49. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-lerna-patterns.d.ts +1 -1
  50. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-lerna-patterns.js +1 -1
  51. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-pnpm-patterns.d.ts +1 -1
  52. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-pnpm-patterns.js +1 -1
  53. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-yarn-patterns.d.ts +1 -1
  54. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/get-yarn-patterns.js +1 -1
  55. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.d.ts +3 -3
  56. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/index.js +4 -3
  57. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-json-safe.d.ts +1 -1
  58. package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-yaml-safe.d.ts +1 -1
  59. package/dist/{get-context/get-package-json-files → get-package-json-files}/index.d.ts +3 -3
  60. package/dist/{get-context/get-package-json-files → get-package-json-files}/index.js +1 -1
  61. package/dist/{get-context/get-package-json-files/package-json-file → get-package-json-files}/instance.d.ts +6 -8
  62. package/dist/get-package-json-files/instance.js +23 -0
  63. package/dist/{get-context/get-package-json-files/package-json-file/index.d.ts → get-package-json-files/package-json-file.d.ts} +7 -9
  64. package/dist/get-package-json-files/package-json-file.js +45 -0
  65. package/dist/get-semver-groups/catch-all.d.ts +4 -0
  66. package/dist/get-semver-groups/catch-all.js +11 -0
  67. package/dist/get-semver-groups/filtered-out.d.ts +13 -0
  68. package/dist/get-semver-groups/filtered-out.js +29 -0
  69. package/dist/get-semver-groups/ignored.d.ts +11 -0
  70. package/dist/get-semver-groups/ignored.js +22 -0
  71. package/dist/get-semver-groups/index.d.ts +32 -0
  72. package/dist/get-semver-groups/index.js +90 -0
  73. package/dist/get-semver-groups/with-range.d.ts +11 -0
  74. package/dist/get-semver-groups/with-range.js +55 -0
  75. package/dist/get-version-groups/banned.d.ts +11 -0
  76. package/dist/get-version-groups/banned.js +24 -0
  77. package/dist/get-version-groups/catch-all.d.ts +4 -0
  78. package/dist/get-version-groups/catch-all.js +11 -0
  79. package/dist/get-version-groups/filtered-out.d.ts +13 -0
  80. package/dist/get-version-groups/filtered-out.js +31 -0
  81. package/dist/get-version-groups/ignored.d.ts +11 -0
  82. package/dist/get-version-groups/ignored.js +24 -0
  83. package/dist/get-version-groups/index.d.ts +57 -0
  84. package/dist/get-version-groups/index.js +119 -0
  85. package/dist/get-version-groups/lib/delete.d.ts +2 -0
  86. package/dist/get-version-groups/lib/delete.js +4 -0
  87. package/dist/get-version-groups/lib/get-highest-version.js +13 -0
  88. package/dist/get-version-groups/lib/get-lowest-version.js +13 -0
  89. package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.js +3 -2
  90. package/dist/get-version-groups/lib/get-unique-versions.d.ts +2 -0
  91. package/dist/get-version-groups/lib/get-unique-versions.js +8 -0
  92. package/dist/get-version-groups/lib/group-by.d.ts +1 -0
  93. package/dist/get-version-groups/lib/group-by.js +11 -0
  94. package/dist/get-version-groups/lib/sort.d.ts +1 -0
  95. package/dist/get-version-groups/lib/sort.js +44 -0
  96. package/dist/get-version-groups/pinned.d.ts +11 -0
  97. package/dist/get-version-groups/pinned.js +43 -0
  98. package/dist/get-version-groups/snapped-to.d.ts +11 -0
  99. package/dist/get-version-groups/snapped-to.js +52 -0
  100. package/dist/get-version-groups/standard.d.ts +11 -0
  101. package/dist/get-version-groups/standard.js +95 -0
  102. package/dist/index.d.ts +2 -0
  103. package/dist/{get-context → lib}/$R.d.ts +2 -2
  104. package/dist/{get-context → lib}/$R.js +3 -4
  105. package/dist/lib/disk.d.ts +3 -2
  106. package/dist/lib/exit-if-invalid.d.ts +2 -2
  107. package/dist/lib/is-semver.d.ts +5 -3
  108. package/dist/lib/is-semver.js +17 -3
  109. package/dist/lib/log.d.ts +4 -8
  110. package/dist/lib/log.js +3 -29
  111. package/dist/lib/set-semver-range.d.ts +2 -2
  112. package/dist/lib/write-if-changed.d.ts +2 -2
  113. package/dist/lib/write-if-changed.js +6 -25
  114. package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.d.ts +1 -1
  115. package/dist/{get-context/get-config/path-strategy → strategy}/lib/get-non-empty-string-prop.js +1 -2
  116. package/dist/strategy/name-and-version-props.d.ts +12 -0
  117. package/dist/strategy/name-and-version-props.js +50 -0
  118. package/dist/strategy/named-version-string.d.ts +11 -0
  119. package/dist/{get-context/get-config/path-strategy/name-and-version-string.js → strategy/named-version-string.js} +26 -22
  120. package/dist/strategy/unnamed-version-string.d.ts +11 -0
  121. package/dist/strategy/unnamed-version-string.js +48 -0
  122. package/dist/strategy/versions-by-name.d.ts +11 -0
  123. package/dist/strategy/versions-by-name.js +29 -0
  124. package/package.json +8 -4
  125. package/dist/get-context/get-config/get-core-types.d.ts +0 -36
  126. package/dist/get-context/get-config/get-core-types.js +0 -38
  127. package/dist/get-context/get-config/get-custom-types.d.ts +0 -4
  128. package/dist/get-context/get-config/get-custom-types.js +0 -16
  129. package/dist/get-context/get-config/get-enabled-types.d.ts +0 -4
  130. package/dist/get-context/get-config/get-enabled-types.js +0 -17
  131. package/dist/get-context/get-config/index.d.ts +0 -8
  132. package/dist/get-context/get-config/index.js +0 -98
  133. package/dist/get-context/get-config/path-strategy/index.d.ts +0 -8
  134. package/dist/get-context/get-config/path-strategy/index.js +0 -18
  135. package/dist/get-context/get-config/path-strategy/name-and-version-props.d.ts +0 -2
  136. package/dist/get-context/get-config/path-strategy/name-and-version-props.js +0 -44
  137. package/dist/get-context/get-config/path-strategy/name-and-version-string.d.ts +0 -2
  138. package/dist/get-context/get-config/path-strategy/types.d.ts +0 -14
  139. package/dist/get-context/get-config/path-strategy/version-string.d.ts +0 -2
  140. package/dist/get-context/get-config/path-strategy/version-string.js +0 -49
  141. package/dist/get-context/get-config/path-strategy/versions-by-name.d.ts +0 -2
  142. package/dist/get-context/get-config/path-strategy/versions-by-name.js +0 -21
  143. package/dist/get-context/get-config/schema/base-group.d.ts +0 -7
  144. package/dist/get-context/get-config/schema/base-group.js +0 -10
  145. package/dist/get-context/get-config/schema/index.d.ts +0 -1540
  146. package/dist/get-context/get-config/schema/index.js +0 -81
  147. package/dist/get-context/get-config/schema/lib/non-empty-string.d.ts +0 -2
  148. package/dist/get-context/get-config/schema/lib/non-empty-string.js +0 -5
  149. package/dist/get-context/get-config/schema/paths.d.ts +0 -89
  150. package/dist/get-context/get-config/schema/paths.js +0 -33
  151. package/dist/get-context/get-config/schema/semver-group.d.ts +0 -119
  152. package/dist/get-context/get-config/schema/semver-group.js +0 -43
  153. package/dist/get-context/get-config/schema/semver-range.d.ts +0 -2
  154. package/dist/get-context/get-config/schema/semver-range.js +0 -16
  155. package/dist/get-context/get-config/schema/version-group.d.ts +0 -230
  156. package/dist/get-context/get-config/schema/version-group.js +0 -36
  157. package/dist/get-context/get-groups/base-group.d.ts +0 -22
  158. package/dist/get-context/get-groups/base-group.js +0 -39
  159. package/dist/get-context/get-groups/index.d.ts +0 -11
  160. package/dist/get-context/get-groups/index.js +0 -53
  161. package/dist/get-context/get-groups/semver-group.d.ts +0 -15
  162. package/dist/get-context/get-groups/semver-group.js +0 -46
  163. package/dist/get-context/get-groups/version-group/index.d.ts +0 -15
  164. package/dist/get-context/get-groups/version-group/index.js +0 -40
  165. package/dist/get-context/get-groups/version-group/instance-group/get-highest-version.js +0 -42
  166. package/dist/get-context/get-groups/version-group/instance-group/get-lowest-version.js +0 -44
  167. package/dist/get-context/get-groups/version-group/instance-group/index.d.ts +0 -34
  168. package/dist/get-context/get-groups/version-group/instance-group/index.js +0 -103
  169. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.d.ts +0 -4
  170. package/dist/get-context/get-groups/version-group/instance-group/lib/compare-semver.js +0 -38
  171. package/dist/get-context/get-package-json-files/package-json-file/index.js +0 -65
  172. package/dist/get-context/get-package-json-files/package-json-file/instance.js +0 -46
  173. package/dist/lib/error.d.ts +0 -12
  174. package/dist/lib/error.js +0 -25
  175. package/dist/types.d.ts +0 -90
  176. /package/dist/{get-context/get-config/path-strategy → config}/types.js +0 -0
  177. /package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-json-safe.js +0 -0
  178. /package/dist/{get-context/get-package-json-files → get-package-json-files}/get-patterns/read-yaml-safe.js +0 -0
  179. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.d.ts +0 -0
  180. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/clean.js +0 -0
  181. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups/lib}/get-highest-version.d.ts +0 -0
  182. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups/lib}/get-lowest-version.d.ts +0 -0
  183. /package/dist/{get-context/get-groups/version-group/instance-group → get-version-groups}/lib/get-range-score.d.ts +0 -0
  184. /package/dist/{types.js → index.js} +0 -0
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandardVersionGroup = void 0;
4
+ const unwrap_1 = require("tightrope/result/unwrap");
5
+ const is_semver_1 = require("../lib/is-semver");
6
+ const get_highest_version_1 = require("./lib/get-highest-version");
7
+ const get_lowest_version_1 = require("./lib/get-lowest-version");
8
+ const get_unique_versions_1 = require("./lib/get-unique-versions");
9
+ const group_by_1 = require("./lib/group-by");
10
+ class StandardVersionGroup {
11
+ constructor(config) {
12
+ this._tag = 'Standard';
13
+ this.config = config;
14
+ this.instances = [];
15
+ }
16
+ canAdd(_) {
17
+ return true;
18
+ }
19
+ inspect() {
20
+ const report = [];
21
+ const instancesByName = (0, group_by_1.groupBy)('name', this.instances);
22
+ Object.entries(instancesByName).forEach(([name, instances]) => {
23
+ if (!hasMismatch(instances)) {
24
+ return report.push({
25
+ status: 'VALID',
26
+ instances,
27
+ isValid: true,
28
+ name,
29
+ });
30
+ }
31
+ const wsInstance = getWorkspaceInstance(instances);
32
+ const wsFile = wsInstance?.packageJsonFile;
33
+ const wsVersion = wsFile?.contents?.version;
34
+ const isWorkspacePackage = wsInstance && wsVersion;
35
+ if (isWorkspacePackage) {
36
+ const nonWsInstances = getNonWorkspaceInstances(instances);
37
+ if (!hasMismatch(nonWsInstances)) {
38
+ return report.push({
39
+ status: 'VALID',
40
+ instances,
41
+ isValid: true,
42
+ name,
43
+ });
44
+ }
45
+ return report.push({
46
+ status: 'WORKSPACE_MISMATCH',
47
+ expectedVersion: wsVersion,
48
+ instances,
49
+ isValid: false,
50
+ name,
51
+ workspaceInstance: wsInstance,
52
+ });
53
+ }
54
+ if (hasUnsupported(instances)) {
55
+ return report.push({
56
+ status: 'UNSUPPORTED_MISMATCH',
57
+ instances,
58
+ isValid: false,
59
+ name,
60
+ });
61
+ }
62
+ const preferVersion = this.config.preferVersion;
63
+ const expectedVersion = getExpectedVersion(preferVersion, instances);
64
+ return report.push({
65
+ status: preferVersion === 'highestSemver'
66
+ ? 'HIGHEST_SEMVER_MISMATCH'
67
+ : 'LOWEST_SEMVER_MISMATCH',
68
+ expectedVersion,
69
+ instances,
70
+ isValid: false,
71
+ name,
72
+ });
73
+ });
74
+ return report;
75
+ }
76
+ }
77
+ exports.StandardVersionGroup = StandardVersionGroup;
78
+ function getExpectedVersion(preferVersion, instances) {
79
+ const versions = (0, get_unique_versions_1.getUniqueVersions)(instances);
80
+ return (0, unwrap_1.unwrap)(preferVersion === 'highestSemver'
81
+ ? (0, get_highest_version_1.getHighestVersion)(versions)
82
+ : (0, get_lowest_version_1.getLowestVersion)(versions));
83
+ }
84
+ function hasMismatch(instances) {
85
+ return (0, get_unique_versions_1.getUniqueVersions)(instances).length > 1;
86
+ }
87
+ function hasUnsupported(instances) {
88
+ return instances.some((instance) => !(0, is_semver_1.isSupported)(instance.version));
89
+ }
90
+ function getWorkspaceInstance(instances) {
91
+ return instances.find((instance) => instance.strategy.name === 'workspace');
92
+ }
93
+ function getNonWorkspaceInstances(instances) {
94
+ return instances.filter((instance) => instance.strategy.name !== 'workspace');
95
+ }
@@ -0,0 +1,2 @@
1
+ import type { RcConfig } from './config/types';
2
+ export type RcFile = Partial<RcConfig>;
@@ -4,9 +4,9 @@ export declare const $R: {
4
4
  /**
5
5
  * Return a single `Ok<output[]>` containing an array of the output of every
6
6
  * `Result` returned by `getResult(input)` which succeeded, or a single
7
- * `Err<BaseError>` if none succeeded.
7
+ * `Err<Error>` if none succeeded.
8
8
  */
9
- onlyOk<Input, Output = Input>(getResult: (value: Input) => Result<Output, unknown>): (inputs: Input[]) => Result<Output[], unknown>;
9
+ onlyOk<Input, Output = Input>(getResult: (value: Input) => Result<Output>): (inputs: Input[]) => Result<Output[]>;
10
10
  /** Log verbose only when Result is an Err */
11
11
  tapErrVerbose<T extends AnyResult>(result: T): T;
12
12
  };
@@ -4,13 +4,12 @@ exports.$R = void 0;
4
4
  const result_1 = require("tightrope/result");
5
5
  const is_err_1 = require("tightrope/result/is-err");
6
6
  const unwrap_1 = require("tightrope/result/unwrap");
7
- const error_1 = require("../lib/error");
8
- const log_1 = require("../lib/log");
7
+ const log_1 = require("./log");
9
8
  exports.$R = {
10
9
  /**
11
10
  * Return a single `Ok<output[]>` containing an array of the output of every
12
11
  * `Result` returned by `getResult(input)` which succeeded, or a single
13
- * `Err<BaseError>` if none succeeded.
12
+ * `Err<Error>` if none succeeded.
14
13
  */
15
14
  onlyOk(getResult) {
16
15
  return (inputs) => {
@@ -23,7 +22,7 @@ exports.$R = {
23
22
  }
24
23
  return outputs.length > 0
25
24
  ? new result_1.Ok(outputs)
26
- : new result_1.Err(new error_1.BaseError('No Ok() returned by $R.onlyOk'));
25
+ : new result_1.Err(new Error('No Ok() returned by $R.onlyOk'));
27
26
  };
28
27
  },
29
28
  /** Log verbose only when Result is an Err */
@@ -1,10 +1,11 @@
1
- import type { Syncpack } from '../types';
1
+ import type { O } from 'ts-toolbelt';
2
+ import type { RcConfig } from '../config/types';
2
3
  export type Disk = {
3
4
  process: {
4
5
  exit: (code: number) => void;
5
6
  };
6
7
  globSync: (pattern: string) => string[];
7
- readConfigFileSync: (configPath?: string) => Partial<Syncpack.Config.SyncpackRc>;
8
+ readConfigFileSync: (configPath?: string) => O.Partial<RcConfig, 'deep'>;
8
9
  readFileSync: (filePath: string) => string;
9
10
  readYamlFileSync: <T = unknown>(filePath: string) => T;
10
11
  removeSync: (filePath: string) => void;
@@ -1,2 +1,2 @@
1
- import type { Syncpack } from '../types';
2
- export declare function exitIfInvalid(ctx: Syncpack.Ctx): Syncpack.Ctx;
1
+ import type { Context } from '../get-context';
2
+ export declare function exitIfInvalid(ctx: Context): Context;
@@ -1,4 +1,6 @@
1
- import type { Syncpack } from '../types';
2
- export declare function isValidSemverRange(value: unknown): value is Syncpack.Config.SemverRange.Value;
3
- export declare function isSemver(version: unknown): version is string;
1
+ import type { SemverRange } from '../config/types';
2
+ export declare function isValidSemverRange(value: unknown): value is SemverRange;
3
+ export declare function isSupported(version: unknown): version is string;
4
+ export declare function isWorkspaceProtocol(version: unknown): boolean;
5
+ export declare function isSemver(version: unknown): boolean;
4
6
  export declare function isLooseSemver(version: unknown): boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLooseSemver = exports.isSemver = exports.isValidSemverRange = void 0;
3
+ exports.isLooseSemver = exports.isSemver = exports.isWorkspaceProtocol = exports.isSupported = exports.isValidSemverRange = void 0;
4
4
  const is_string_1 = require("tightrope/guard/is-string");
5
5
  const constants_1 = require("../constants");
6
6
  function isValidSemverRange(value) {
@@ -12,9 +12,23 @@ function isValidSemverRange(value) {
12
12
  value === constants_1.RANGE.LT ||
13
13
  value === constants_1.RANGE.LTE ||
14
14
  value === constants_1.RANGE.MINOR ||
15
- value === constants_1.RANGE.PATCH);
15
+ value === constants_1.RANGE.PATCH ||
16
+ value === constants_1.RANGE.WORKSPACE);
16
17
  }
17
18
  exports.isValidSemverRange = isValidSemverRange;
19
+ function isSupported(version) {
20
+ return version === '*' || isSemver(version) || isWorkspaceProtocol(version);
21
+ }
22
+ exports.isSupported = isSupported;
23
+ function isWorkspaceProtocol(version) {
24
+ if (!(0, is_string_1.isString)(version))
25
+ return false;
26
+ if (!version.startsWith('workspace:'))
27
+ return false;
28
+ const value = version.replace(/^workspace:/, '');
29
+ return value === '*' || isSemver(value);
30
+ }
31
+ exports.isWorkspaceProtocol = isWorkspaceProtocol;
18
32
  function isSemver(version) {
19
33
  const range = '(~|\\^|>=|>|<=|<)?';
20
34
  const ints = '[0-9]+';
@@ -30,6 +44,6 @@ function isSemver(version) {
30
44
  }
31
45
  exports.isSemver = isSemver;
32
46
  function isLooseSemver(version) {
33
- return isSemver(version) && version.search(/\.x(\.|$)/) !== -1;
47
+ return ((0, is_string_1.isString)(version) && isSemver(version) && version.search(/\.x(\.|$)/) !== -1);
34
48
  }
35
49
  exports.isLooseSemver = isLooseSemver;
package/dist/lib/log.d.ts CHANGED
@@ -1,9 +1,5 @@
1
- import type { SemverGroup } from '../get-context/get-groups/semver-group';
2
- import type { VersionGroup } from '../get-context/get-groups/version-group';
1
+ import type { AnySemverGroup } from '../get-semver-groups';
2
+ import type { AnyVersionGroup } from '../get-version-groups';
3
3
  export declare function verbose(...values: unknown[]): void;
4
- export declare function fixed(message: string): void;
5
- export declare function skip(message: string): void;
6
- export declare function valid(message: string, comment?: string): void;
7
- export declare function invalid(message: string, comment?: string): void;
8
- export declare function semverGroupHeader(group: SemverGroup, i: number): void;
9
- export declare function versionGroupHeader(group: VersionGroup, i: number): void;
4
+ export declare function semverGroupHeader(group: AnySemverGroup, i: number): void;
5
+ export declare function versionGroupHeader(group: AnyVersionGroup, i: number): void;
package/dist/lib/log.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.versionGroupHeader = exports.semverGroupHeader = exports.invalid = exports.valid = exports.skip = exports.fixed = exports.verbose = void 0;
6
+ exports.versionGroupHeader = exports.semverGroupHeader = exports.verbose = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const is_string_1 = require("tightrope/guard/is-string");
9
9
  const util_1 = require("util");
@@ -22,32 +22,6 @@ function verbose(...values) {
22
22
  }
23
23
  }
24
24
  exports.verbose = verbose;
25
- function fixed(message) {
26
- console.log((0, chalk_1.default) `{green ${constants_1.ICON.tick}}`, message);
27
- }
28
- exports.fixed = fixed;
29
- function skip(message) {
30
- console.log(chalk_1.default.dim(constants_1.ICON.skip), chalk_1.default.dim(message));
31
- }
32
- exports.skip = skip;
33
- function valid(message, comment) {
34
- if (comment) {
35
- console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip}} ${message} {dim ${comment}}`);
36
- }
37
- else {
38
- console.log((0, chalk_1.default) `{dim ${constants_1.ICON.skip}} ${message}`);
39
- }
40
- }
41
- exports.valid = valid;
42
- function invalid(message, comment) {
43
- if (comment) {
44
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross}} ${message} {dim ${comment}}`);
45
- }
46
- else {
47
- console.log((0, chalk_1.default) `{red ${constants_1.ICON.cross}} ${message}`);
48
- }
49
- }
50
- exports.invalid = invalid;
51
25
  function semverGroupHeader(group, i) {
52
26
  logHeader(group, 'Semver', i);
53
27
  }
@@ -57,8 +31,8 @@ function versionGroupHeader(group, i) {
57
31
  }
58
32
  exports.versionGroupHeader = versionGroupHeader;
59
33
  function logHeader(group, type, i) {
60
- const customLabel = group.groupConfig.label;
61
- const labelWhenDefault = group.isDefault ? `Default ${type} Group` : '';
34
+ const customLabel = group.config.label;
35
+ const labelWhenDefault = group._tag === 'CatchAll' ? `Default ${type} Group` : '';
62
36
  const anonymousLabel = `${type} Group ${i + 1}`;
63
37
  const label = (customLabel || labelWhenDefault || anonymousLabel).trim();
64
38
  const hasNewLines = label.search(/[\r\n]/) !== -1;
@@ -1,2 +1,2 @@
1
- import type { Syncpack } from '../types';
2
- export declare function setSemverRange(semverRange: Syncpack.Config.SemverRange.Value, version: string): string;
1
+ import type { SemverRange } from '../config/types';
2
+ export declare function setSemverRange(semverRange: SemverRange, version: string): string;
@@ -1,2 +1,2 @@
1
- import type { Syncpack } from '../types';
2
- export declare function writeIfChanged(ctx: Syncpack.Ctx): Syncpack.Ctx;
1
+ import type { Context } from '../get-context';
2
+ export declare function writeIfChanged(ctx: Context): Context;
@@ -1,38 +1,19 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  Object.defineProperty(exports, "__esModule", { value: true });
26
6
  exports.writeIfChanged = void 0;
27
- const log = __importStar(require("./log"));
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const constants_1 = require("../constants");
28
9
  function writeIfChanged(ctx) {
29
10
  ctx.packageJsonFiles.forEach((packageJsonFile) => {
30
11
  if (packageJsonFile.hasChanged()) {
31
12
  packageJsonFile.write();
32
- log.fixed(packageJsonFile.shortPath);
13
+ console.log((0, chalk_1.default) `{green ${constants_1.ICON.tick}}`, packageJsonFile.shortPath);
33
14
  }
34
15
  else {
35
- log.skip(packageJsonFile.shortPath);
16
+ console.log(chalk_1.default.dim(constants_1.ICON.skip), chalk_1.default.dim(packageJsonFile.shortPath));
36
17
  }
37
18
  });
38
19
  return ctx;
@@ -1,3 +1,3 @@
1
1
  import type { Result } from 'tightrope/result';
2
- import type { PackageJsonFile } from '../../../get-package-json-files/package-json-file';
2
+ import type { PackageJsonFile } from '../../get-package-json-files/package-json-file';
3
3
  export declare function getNonEmptyStringProp(propPath: string, file: PackageJsonFile): Result<string>;
@@ -6,8 +6,7 @@ const pipe_1 = require("tightrope/fn/pipe");
6
6
  const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
7
7
  const filter_1 = require("tightrope/result/filter");
8
8
  const map_err_1 = require("tightrope/result/map-err");
9
- const error_1 = require("../../../../lib/error");
10
9
  function getNonEmptyStringProp(propPath, file) {
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
+ 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(`Failed to get ${propPath} in ${file.shortPath}`)));
12
11
  }
13
12
  exports.getNonEmptyStringProp = getNonEmptyStringProp;
@@ -0,0 +1,12 @@
1
+ import type { Result } from 'tightrope/result';
2
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
3
+ import type { Delete } from '../get-version-groups/lib/delete';
4
+ export declare class NameAndVersionPropsStrategy {
5
+ _tag: string;
6
+ name: string;
7
+ path: string;
8
+ namePath: string;
9
+ constructor(name: string, path: string, namePath: string);
10
+ read(file: PackageJsonFile): Result<[string, string][]>;
11
+ write(file: PackageJsonFile, [, version]: [string, string | Delete]): Result<PackageJsonFile>;
12
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NameAndVersionPropsStrategy = void 0;
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 tap_1 = require("tightrope/result/tap");
10
+ const delete_1 = require("../get-version-groups/lib/delete");
11
+ const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
12
+ class NameAndVersionPropsStrategy {
13
+ constructor(name, path, namePath) {
14
+ this._tag = 'name~version';
15
+ this.name = name;
16
+ this.path = path;
17
+ this.namePath = namePath;
18
+ }
19
+ read(file) {
20
+ const path = this.path;
21
+ const namePath = this.namePath;
22
+ return (0, pipe_1.pipe)(
23
+ // get name prop
24
+ (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(namePath, file),
25
+ // add the version prop
26
+ (0, and_then_1.andThen)((name) => (0, pipe_1.pipe)((0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file), (0, map_1.map)((version) => ({ name, version })))),
27
+ // if both are non empty strings, we can return them
28
+ (0, map_1.map)(({ name, version }) => [[name, version]]));
29
+ }
30
+ write(file, [, version]) {
31
+ const path = this.path;
32
+ const { contents } = file;
33
+ const isNestedPath = path.includes('.');
34
+ const nextValue = version === delete_1.DELETE ? undefined : version;
35
+ if (isNestedPath) {
36
+ const fullPath = path.split('.');
37
+ const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
38
+ const key = fullPath.slice(-1).join('');
39
+ return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
40
+ parent[key] = version;
41
+ }), (0, map_1.map)(() => file));
42
+ }
43
+ else {
44
+ return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
45
+ contents[path] = nextValue;
46
+ }), (0, map_1.map)(() => file));
47
+ }
48
+ }
49
+ }
50
+ exports.NameAndVersionPropsStrategy = NameAndVersionPropsStrategy;
@@ -0,0 +1,11 @@
1
+ import type { Result } from 'tightrope/result';
2
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
3
+ import type { Delete } from '../get-version-groups/lib/delete';
4
+ export declare class NamedVersionStringStrategy {
5
+ _tag: string;
6
+ name: string;
7
+ path: string;
8
+ constructor(name: string, path: string);
9
+ read(file: PackageJsonFile): Result<[string, string][]>;
10
+ write(file: PackageJsonFile, [name, version]: [string, string | Delete]): Result<PackageJsonFile>;
11
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nameAndVersionString = void 0;
3
+ exports.NamedVersionStringStrategy = void 0;
4
4
  const get_1 = require("tightrope/fn/get");
5
5
  const pipe_1 = require("tightrope/fn/pipe");
6
6
  const is_non_empty_string_1 = require("tightrope/guard/is-non-empty-string");
@@ -8,42 +8,46 @@ const result_1 = require("tightrope/result");
8
8
  const and_then_1 = require("tightrope/result/and-then");
9
9
  const from_try_1 = require("tightrope/result/from-try");
10
10
  const map_1 = require("tightrope/result/map");
11
- const map_err_1 = require("tightrope/result/map-err");
12
11
  const tap_1 = require("tightrope/result/tap");
13
- const error_1 = require("../../../lib/error");
12
+ const delete_1 = require("../get-version-groups/lib/delete");
14
13
  const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
15
- exports.nameAndVersionString = {
16
- read(file, pathDef) {
14
+ class NamedVersionStringStrategy {
15
+ constructor(name, path) {
16
+ this._tag = 'name@version';
17
+ this.name = name;
18
+ this.path = path;
19
+ }
20
+ read(file) {
21
+ const path = this.path;
17
22
  return (0, pipe_1.pipe)(
18
23
  // get version prop
19
- (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(pathDef.path, file),
24
+ (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file),
20
25
  // if it is a non empty string, we can read it
21
26
  (0, and_then_1.andThen)((value) => {
22
27
  const [name, version] = value.split('@');
23
28
  return (0, is_non_empty_string_1.isNonEmptyString)(name) && (0, is_non_empty_string_1.isNonEmptyString)(version)
24
29
  ? 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}`));
30
+ : new result_1.Err(new Error(`Strategy<name@version> failed to get ${path} in ${file.shortPath}`));
26
31
  }));
27
- },
28
- write(file, pathDef, [name, version]) {
29
- const { contents, shortPath } = file;
30
- const isNestedPath = pathDef.path.includes('.');
32
+ }
33
+ write(file, [name, version]) {
34
+ const { contents } = file;
35
+ const path = this.path;
36
+ const isNestedPath = path.includes('.');
37
+ const nextValue = version === delete_1.DELETE ? undefined : `${name}@${version}`;
31
38
  if (isNestedPath) {
32
- const fullPath = pathDef.path.split('.');
39
+ const fullPath = path.split('.');
33
40
  const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
34
41
  const key = fullPath.slice(-1).join('');
35
42
  return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
36
- parent[key] = `${name}@${version}`;
37
- }), (0, map_err_1.mapErr)(onError), (0, map_1.map)(() => file));
43
+ parent[key] = nextValue;
44
+ }), (0, map_1.map)(() => file));
38
45
  }
39
46
  else {
40
47
  return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
41
- contents[pathDef.path] = `${name}@${version}`;
42
- }), (0, map_err_1.mapErr)(onError), (0, map_1.map)(() => file));
48
+ contents[path] = nextValue;
49
+ }), (0, map_1.map)(() => file));
43
50
  }
44
- function onError() {
45
- const msg = `Strategy<name@version> failed to set ${pathDef.path} in ${shortPath}`;
46
- return new error_1.BaseError(msg);
47
- }
48
- },
49
- };
51
+ }
52
+ }
53
+ exports.NamedVersionStringStrategy = NamedVersionStringStrategy;
@@ -0,0 +1,11 @@
1
+ import type { Result } from 'tightrope/result';
2
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
3
+ import type { Delete } from '../get-version-groups/lib/delete';
4
+ export declare class UnnamedVersionStringStrategy {
5
+ _tag: string;
6
+ name: string;
7
+ path: string;
8
+ constructor(name: string, path: string);
9
+ read(file: PackageJsonFile): Result<[string, string][]>;
10
+ write(file: PackageJsonFile, [, version]: [string, string | Delete]): Result<PackageJsonFile>;
11
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnnamedVersionStringStrategy = void 0;
4
+ const get_1 = require("tightrope/fn/get");
5
+ const pipe_1 = require("tightrope/fn/pipe");
6
+ const from_try_1 = require("tightrope/result/from-try");
7
+ const map_1 = require("tightrope/result/map");
8
+ const tap_1 = require("tightrope/result/tap");
9
+ const delete_1 = require("../get-version-groups/lib/delete");
10
+ const get_non_empty_string_prop_1 = require("./lib/get-non-empty-string-prop");
11
+ class UnnamedVersionStringStrategy {
12
+ constructor(name, path) {
13
+ this._tag = 'version';
14
+ this.name = name;
15
+ this.path = path;
16
+ }
17
+ read(file) {
18
+ const path = this.path;
19
+ return (0, pipe_1.pipe)(
20
+ // get version prop
21
+ (0, get_non_empty_string_prop_1.getNonEmptyStringProp)(path, file),
22
+ // if it is a non empty string, we can read it
23
+ (0, map_1.map)((version) => {
24
+ const name = path.split('.').slice(-1).join('');
25
+ return [[name, version]];
26
+ }));
27
+ }
28
+ write(file, [, version]) {
29
+ const path = this.path;
30
+ const { contents } = file;
31
+ const isNestedPath = path.includes('.');
32
+ const nextValue = version === delete_1.DELETE ? undefined : version;
33
+ if (isNestedPath) {
34
+ const fullPath = path.split('.');
35
+ const pathToParent = fullPath.slice(0, fullPath.length - 1).join('.');
36
+ const key = fullPath.slice(-1).join('');
37
+ return (0, pipe_1.pipe)((0, get_1.get)(contents, ...pathToParent.split('.')), (0, tap_1.tap)((parent) => {
38
+ parent[key] = nextValue;
39
+ }), (0, map_1.map)(() => file));
40
+ }
41
+ else {
42
+ return (0, pipe_1.pipe)((0, from_try_1.fromTry)(() => {
43
+ contents[path] = nextValue;
44
+ }), (0, map_1.map)(() => file));
45
+ }
46
+ }
47
+ }
48
+ exports.UnnamedVersionStringStrategy = UnnamedVersionStringStrategy;
@@ -0,0 +1,11 @@
1
+ import type { Result } from 'tightrope/result';
2
+ import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
3
+ import type { Delete } from '../get-version-groups/lib/delete';
4
+ export declare class VersionsByNameStrategy {
5
+ _tag: string;
6
+ name: string;
7
+ path: string;
8
+ constructor(name: string, path: string);
9
+ read(file: PackageJsonFile): Result<[string, string][]>;
10
+ write(file: PackageJsonFile, [name, version]: [string, string | Delete]): Result<PackageJsonFile>;
11
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VersionsByNameStrategy = void 0;
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 tap_1 = require("tightrope/result/tap");
10
+ const delete_1 = require("../get-version-groups/lib/delete");
11
+ class VersionsByNameStrategy {
12
+ constructor(name, path) {
13
+ this._tag = 'versionsByName';
14
+ this.name = name;
15
+ this.path = path;
16
+ }
17
+ read(file) {
18
+ const path = this.path;
19
+ return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...path.split('.')), (0, filter_1.filter)((is_non_empty_object_1.isNonEmptyObject), ''), (0, map_1.map)((Object.entries)));
20
+ }
21
+ write(file, [name, version]) {
22
+ const path = this.path;
23
+ const nextValue = version === delete_1.DELETE ? undefined : version;
24
+ return (0, pipe_1.pipe)((0, get_1.get)(file.contents, ...path.split('.')), (0, tap_1.tap)((parent) => {
25
+ parent[name] = nextValue;
26
+ }), (0, map_1.map)(() => file));
27
+ }
28
+ }
29
+ exports.VersionsByNameStrategy = VersionsByNameStrategy;