syncpack 13.0.1 → 14.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +0 -3
  2. package/index.js +48 -0
  3. package/package.json +16 -73
  4. package/schema.json +917 -0
  5. package/syncpack.d.ts +122 -0
  6. package/LICENSE +0 -20
  7. package/dist/bin-fix-mismatches/fix-mismatches.d.ts +0 -16
  8. package/dist/bin-fix-mismatches/fix-mismatches.js +0 -115
  9. package/dist/bin-fix-mismatches/index.d.ts +0 -2
  10. package/dist/bin-fix-mismatches/index.js +0 -33
  11. package/dist/bin-format/format.d.ts +0 -13
  12. package/dist/bin-format/format.js +0 -92
  13. package/dist/bin-format/index.d.ts +0 -2
  14. package/dist/bin-format/index.js +0 -28
  15. package/dist/bin-lint/index.d.ts +0 -2
  16. package/dist/bin-lint/index.js +0 -17
  17. package/dist/bin-lint/lint.d.ts +0 -11
  18. package/dist/bin-lint/lint.js +0 -52
  19. package/dist/bin-lint-semver-ranges/index.d.ts +0 -2
  20. package/dist/bin-lint-semver-ranges/index.js +0 -30
  21. package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +0 -16
  22. package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +0 -92
  23. package/dist/bin-list/index.d.ts +0 -2
  24. package/dist/bin-list/index.js +0 -27
  25. package/dist/bin-list/list.d.ts +0 -14
  26. package/dist/bin-list/list.js +0 -151
  27. package/dist/bin-list-mismatches/index.d.ts +0 -2
  28. package/dist/bin-list-mismatches/index.js +0 -29
  29. package/dist/bin-list-mismatches/list-mismatches.d.ts +0 -18
  30. package/dist/bin-list-mismatches/list-mismatches.js +0 -224
  31. package/dist/bin-prompt/index.d.ts +0 -2
  32. package/dist/bin-prompt/index.js +0 -29
  33. package/dist/bin-prompt/prompt.d.ts +0 -11
  34. package/dist/bin-prompt/prompt.js +0 -95
  35. package/dist/bin-set-semver-ranges/index.d.ts +0 -2
  36. package/dist/bin-set-semver-ranges/index.js +0 -32
  37. package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +0 -11
  38. package/dist/bin-set-semver-ranges/set-semver-ranges.js +0 -61
  39. package/dist/bin-update/effects.d.ts +0 -52
  40. package/dist/bin-update/effects.js +0 -282
  41. package/dist/bin-update/index.d.ts +0 -2
  42. package/dist/bin-update/index.js +0 -24
  43. package/dist/bin-update/update.d.ts +0 -6
  44. package/dist/bin-update/update.js +0 -59
  45. package/dist/bin.d.ts +0 -2
  46. package/dist/bin.js +0 -37
  47. package/dist/config/get-custom-types.d.ts +0 -19
  48. package/dist/config/get-custom-types.js +0 -57
  49. package/dist/config/get-enabled-types.d.ts +0 -17
  50. package/dist/config/get-enabled-types.js +0 -109
  51. package/dist/config/get-filter.d.ts +0 -2
  52. package/dist/config/get-filter.js +0 -10
  53. package/dist/config/get-indent.d.ts +0 -2
  54. package/dist/config/get-indent.js +0 -9
  55. package/dist/config/get-sort-az.d.ts +0 -2
  56. package/dist/config/get-sort-az.js +0 -8
  57. package/dist/config/get-sort-exports.d.ts +0 -2
  58. package/dist/config/get-sort-exports.js +0 -9
  59. package/dist/config/get-sort-first.d.ts +0 -2
  60. package/dist/config/get-sort-first.js +0 -8
  61. package/dist/config/get-source.d.ts +0 -2
  62. package/dist/config/get-source.js +0 -8
  63. package/dist/config/tag.d.ts +0 -3
  64. package/dist/config/tag.js +0 -2
  65. package/dist/config/types.d.ts +0 -134
  66. package/dist/config/types.js +0 -1
  67. package/dist/constants.d.ts +0 -106
  68. package/dist/constants.js +0 -103
  69. package/dist/error-handlers/default-error-handlers.d.ts +0 -25
  70. package/dist/error-handlers/default-error-handlers.js +0 -80
  71. package/dist/get-context/index.d.ts +0 -23
  72. package/dist/get-context/index.js +0 -18
  73. package/dist/get-context/lib/key-by.d.ts +0 -6
  74. package/dist/get-context/lib/key-by.js +0 -12
  75. package/dist/get-instances/index.d.ts +0 -14
  76. package/dist/get-instances/index.js +0 -42
  77. package/dist/get-instances/instance.d.ts +0 -26
  78. package/dist/get-instances/instance.js +0 -35
  79. package/dist/get-package-json-files/get-file-paths.d.ts +0 -21
  80. package/dist/get-package-json-files/get-file-paths.js +0 -22
  81. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +0 -3
  82. package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +0 -12
  83. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +0 -3
  84. package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +0 -14
  85. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +0 -3
  86. package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +0 -16
  87. package/dist/get-package-json-files/get-patterns/index.d.ts +0 -8
  88. package/dist/get-package-json-files/get-patterns/index.js +0 -23
  89. package/dist/get-package-json-files/index.d.ts +0 -10
  90. package/dist/get-package-json-files/index.js +0 -8
  91. package/dist/get-package-json-files/package-json-file.d.ts +0 -54
  92. package/dist/get-package-json-files/package-json-file.js +0 -44
  93. package/dist/guards/can-add-to-group.d.ts +0 -5
  94. package/dist/guards/can-add-to-group.js +0 -58
  95. package/dist/guards/is-semver.d.ts +0 -2
  96. package/dist/guards/is-semver.js +0 -15
  97. package/dist/guards/is-valid-semver-range.d.ts +0 -3
  98. package/dist/guards/is-valid-semver-range.js +0 -14
  99. package/dist/index.d.ts +0 -2
  100. package/dist/index.js +0 -1
  101. package/dist/io/ask-for-choice.d.ts +0 -14
  102. package/dist/io/ask-for-choice.js +0 -17
  103. package/dist/io/ask-for-input.d.ts +0 -13
  104. package/dist/io/ask-for-input.js +0 -14
  105. package/dist/io/exit-if-invalid.d.ts +0 -4
  106. package/dist/io/exit-if-invalid.js +0 -9
  107. package/dist/io/glob-sync.d.ts +0 -11
  108. package/dist/io/glob-sync.js +0 -14
  109. package/dist/io/index.d.ts +0 -27
  110. package/dist/io/index.js +0 -26
  111. package/dist/io/read-config-file.d.ts +0 -7
  112. package/dist/io/read-config-file.js +0 -24
  113. package/dist/io/read-file-sync.d.ts +0 -12
  114. package/dist/io/read-file-sync.js +0 -9
  115. package/dist/io/read-json-file-sync.d.ts +0 -31
  116. package/dist/io/read-json-file-sync.js +0 -23
  117. package/dist/io/read-yaml-file-sync.d.ts +0 -12
  118. package/dist/io/read-yaml-file-sync.js +0 -9
  119. package/dist/io/to-formatted-json.d.ts +0 -9
  120. package/dist/io/to-formatted-json.js +0 -32
  121. package/dist/io/write-file-sync.d.ts +0 -12
  122. package/dist/io/write-file-sync.js +0 -10
  123. package/dist/io/write-if-changed.d.ts +0 -5
  124. package/dist/io/write-if-changed.js +0 -9
  125. package/dist/lib/format-repository-url.d.ts +0 -1
  126. package/dist/lib/format-repository-url.js +0 -40
  127. package/dist/lib/get-group-header.d.ts +0 -10
  128. package/dist/lib/get-group-header.js +0 -25
  129. package/dist/lib/get.d.ts +0 -11
  130. package/dist/lib/get.js +0 -44
  131. package/dist/lib/pad-start.d.ts +0 -1
  132. package/dist/lib/pad-start.js +0 -3
  133. package/dist/lib/ring-buffer.d.ts +0 -10
  134. package/dist/lib/ring-buffer.js +0 -20
  135. package/dist/lib/set-semver-range.d.ts +0 -3
  136. package/dist/lib/set-semver-range.js +0 -24
  137. package/dist/lib/show-help-on-error.d.ts +0 -2
  138. package/dist/lib/show-help-on-error.js +0 -32
  139. package/dist/lib/sort-by-name.d.ts +0 -5
  140. package/dist/lib/sort-by-name.js +0 -9
  141. package/dist/lib/with-logger.d.ts +0 -2
  142. package/dist/lib/with-logger.js +0 -28
  143. package/dist/option.d.ts +0 -10
  144. package/dist/option.js +0 -30
  145. package/dist/report.d.ts +0 -131
  146. package/dist/report.js +0 -129
  147. package/dist/schema.json +0 -614
  148. package/dist/semver-group/create-semver-groups.d.ts +0 -4
  149. package/dist/semver-group/create-semver-groups.js +0 -83
  150. package/dist/semver-group/disabled.d.ts +0 -26
  151. package/dist/semver-group/disabled.js +0 -28
  152. package/dist/semver-group/filtered-out.d.ts +0 -27
  153. package/dist/semver-group/filtered-out.js +0 -34
  154. package/dist/semver-group/ignored.d.ts +0 -22
  155. package/dist/semver-group/ignored.js +0 -24
  156. package/dist/semver-group/index.d.ts +0 -20
  157. package/dist/semver-group/index.js +0 -7
  158. package/dist/semver-group/with-range.d.ts +0 -22
  159. package/dist/semver-group/with-range.js +0 -45
  160. package/dist/specifier/alias.d.ts +0 -17
  161. package/dist/specifier/alias.js +0 -21
  162. package/dist/specifier/base.d.ts +0 -41
  163. package/dist/specifier/base.js +0 -54
  164. package/dist/specifier/delete.d.ts +0 -17
  165. package/dist/specifier/delete.js +0 -16
  166. package/dist/specifier/exact.d.ts +0 -20
  167. package/dist/specifier/exact.js +0 -21
  168. package/dist/specifier/file.d.ts +0 -8
  169. package/dist/specifier/file.js +0 -7
  170. package/dist/specifier/hosted-git.d.ts +0 -15
  171. package/dist/specifier/hosted-git.js +0 -24
  172. package/dist/specifier/index.d.ts +0 -28
  173. package/dist/specifier/index.js +0 -75
  174. package/dist/specifier/latest.d.ts +0 -19
  175. package/dist/specifier/latest.js +0 -20
  176. package/dist/specifier/lib/non-semver-error.d.ts +0 -11
  177. package/dist/specifier/lib/non-semver-error.js +0 -6
  178. package/dist/specifier/lib/parse-specifier.d.ts +0 -14
  179. package/dist/specifier/lib/parse-specifier.js +0 -18
  180. package/dist/specifier/lib/specific-registry-result.d.ts +0 -9
  181. package/dist/specifier/lib/specific-registry-result.js +0 -1
  182. package/dist/specifier/range.d.ts +0 -19
  183. package/dist/specifier/range.js +0 -20
  184. package/dist/specifier/tag.d.ts +0 -11
  185. package/dist/specifier/tag.js +0 -10
  186. package/dist/specifier/unsupported.d.ts +0 -7
  187. package/dist/specifier/unsupported.js +0 -7
  188. package/dist/specifier/url.d.ts +0 -8
  189. package/dist/specifier/url.js +0 -7
  190. package/dist/specifier/workspace-protocol.d.ts +0 -19
  191. package/dist/specifier/workspace-protocol.js +0 -35
  192. package/dist/strategy/lib/get-non-empty-string-prop.d.ts +0 -3
  193. package/dist/strategy/lib/get-non-empty-string-prop.js +0 -7
  194. package/dist/strategy/name-and-version-props.d.ts +0 -12
  195. package/dist/strategy/name-and-version-props.js +0 -60
  196. package/dist/strategy/named-version-string.d.ts +0 -11
  197. package/dist/strategy/named-version-string.js +0 -52
  198. package/dist/strategy/unnamed-version-string.d.ts +0 -11
  199. package/dist/strategy/unnamed-version-string.js +0 -45
  200. package/dist/strategy/versions-by-name.d.ts +0 -11
  201. package/dist/strategy/versions-by-name.js +0 -27
  202. package/dist/version-group/banned.d.ts +0 -17
  203. package/dist/version-group/banned.js +0 -26
  204. package/dist/version-group/create-version-groups.d.ts +0 -4
  205. package/dist/version-group/create-version-groups.js +0 -118
  206. package/dist/version-group/filtered-out.d.ts +0 -19
  207. package/dist/version-group/filtered-out.js +0 -30
  208. package/dist/version-group/ignored.d.ts +0 -17
  209. package/dist/version-group/ignored.js +0 -23
  210. package/dist/version-group/index.d.ts +0 -26
  211. package/dist/version-group/index.js +0 -7
  212. package/dist/version-group/lib/clean.d.ts +0 -2
  213. package/dist/version-group/lib/clean.js +0 -6
  214. package/dist/version-group/lib/delete.d.ts +0 -2
  215. package/dist/version-group/lib/delete.js +0 -1
  216. package/dist/version-group/lib/get-highest-version.d.ts +0 -6
  217. package/dist/version-group/lib/get-highest-version.js +0 -8
  218. package/dist/version-group/lib/get-lowest-version.d.ts +0 -6
  219. package/dist/version-group/lib/get-lowest-version.js +0 -8
  220. package/dist/version-group/lib/get-preferred-version.d.ts +0 -5
  221. package/dist/version-group/lib/get-preferred-version.js +0 -53
  222. package/dist/version-group/lib/get-range-score.d.ts +0 -2
  223. package/dist/version-group/lib/get-range-score.js +0 -20
  224. package/dist/version-group/lib/group-by.d.ts +0 -5
  225. package/dist/version-group/lib/group-by.js +0 -11
  226. package/dist/version-group/pinned.d.ts +0 -17
  227. package/dist/version-group/pinned.js +0 -26
  228. package/dist/version-group/same-range.d.ts +0 -19
  229. package/dist/version-group/same-range.js +0 -96
  230. package/dist/version-group/snapped-to.d.ts +0 -17
  231. package/dist/version-group/snapped-to.js +0 -71
  232. package/dist/version-group/standard.d.ts +0 -18
  233. package/dist/version-group/standard.js +0 -119
package/syncpack.d.ts ADDED
@@ -0,0 +1,122 @@
1
+ export interface RcFile {
2
+ /** @see https://jamiemason.github.io/syncpack/integrations/json-schema */
3
+ $schema?: string;
4
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types */
5
+ customTypes?: Record<string, CustomType.Any>;
6
+ /** @see https://jamiemason.github.io/syncpack/config/format-bugs */
7
+ formatBugs?: boolean;
8
+ /** @see https://jamiemason.github.io/syncpack/config/format-repository */
9
+ formatRepository?: boolean;
10
+ /** @see https://jamiemason.github.io/syncpack/config/indent */
11
+ indent?: string;
12
+ /** @see https://jamiemason.github.io/syncpack/config/semver-groups */
13
+ semverGroups?: SemverGroup.Any[];
14
+ /** @see https://jamiemason.github.io/syncpack/config/sort-az */
15
+ sortAz?: string[];
16
+ /** @see https://jamiemason.github.io/syncpack/config/sort-exports */
17
+ sortExports?: string[];
18
+ /** @see https://jamiemason.github.io/syncpack/config/sort-first */
19
+ sortFirst?: string[];
20
+ /** @see https://jamiemason.github.io/syncpack/config/sort-packages */
21
+ sortPackages?: boolean;
22
+ /** @see https://jamiemason.github.io/syncpack/config/source */
23
+ source?: string[];
24
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups */
25
+ versionGroups?: VersionGroup.Any[];
26
+ /** @deprecated */
27
+ dependencyTypes?: never;
28
+ /** @deprecated */
29
+ filter?: never;
30
+ /** @deprecated */
31
+ lintFormatting?: never;
32
+ /** @deprecated */
33
+ lintSemverRanges?: never;
34
+ /** @deprecated */
35
+ lintVersions?: never;
36
+ /** @deprecated */
37
+ specifierTypes?: never;
38
+ }
39
+ export interface DependencyGroup {
40
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/standard/#dependencies */
41
+ dependencies?: string[];
42
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/standard/#dependencytypes */
43
+ dependencyTypes?: DependencyType[];
44
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/standard/#label */
45
+ label?: string;
46
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/standard/#packages */
47
+ packages?: string[];
48
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/standard/#specifiertypes */
49
+ specifierTypes?: SpecifierType[];
50
+ }
51
+ declare namespace SemverGroup {
52
+ interface Ignored extends DependencyGroup {
53
+ /** @see https://jamiemason.github.io/syncpack/config/semver-groups/ignored/#isignored */
54
+ isIgnored: true;
55
+ }
56
+ interface WithRange extends DependencyGroup {
57
+ /** @see https://jamiemason.github.io/syncpack/config/semver-groups/with-range/#range */
58
+ range: SemverRange;
59
+ }
60
+ type Any = Ignored | WithRange;
61
+ }
62
+ declare namespace VersionGroup {
63
+ interface Banned extends DependencyGroup {
64
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/banned/#isbanned */
65
+ isBanned: true;
66
+ }
67
+ interface Ignored extends DependencyGroup {
68
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/ignored/#isignored */
69
+ isIgnored: true;
70
+ }
71
+ interface Pinned extends DependencyGroup {
72
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/pinned/#pinversion */
73
+ pinVersion: string;
74
+ }
75
+ interface SnappedTo extends DependencyGroup {
76
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/snapped-to/#snapto */
77
+ snapTo: string[];
78
+ }
79
+ interface SameRange extends DependencyGroup {
80
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/same-range/#policy */
81
+ policy: "sameRange";
82
+ }
83
+ interface Standard extends DependencyGroup {
84
+ /** @see https://jamiemason.github.io/syncpack/config/version-groups/lowest-version/#preferversion */
85
+ preferVersion?: "highestSemver" | "lowestSemver";
86
+ }
87
+ type Any = Banned | Ignored | Pinned | SameRange | SnappedTo | Standard;
88
+ }
89
+ declare namespace CustomType {
90
+ interface NameAndVersionProps {
91
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types/#namepath */
92
+ namePath: string;
93
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types/#name */
94
+ path: string;
95
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types/#namestrategy */
96
+ strategy: "name~version";
97
+ }
98
+ interface NamedVersionString {
99
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types/#name */
100
+ path: string;
101
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types/#namestrategy */
102
+ strategy: "name@version";
103
+ }
104
+ interface UnnamedVersionString {
105
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types/#name */
106
+ path: string;
107
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types/#namestrategy */
108
+ strategy: "version";
109
+ }
110
+ interface VersionsByName {
111
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types/#name */
112
+ path: string;
113
+ /** @see https://jamiemason.github.io/syncpack/config/custom-types/#namestrategy */
114
+ strategy: "versionsByName";
115
+ }
116
+ type Any = NameAndVersionProps | NamedVersionString | UnnamedVersionString | VersionsByName;
117
+ }
118
+ type SemverRange = "" | "*" | ">" | ">=" | ".x" | "<" | "<=" | "^" | "~";
119
+ type DependencyType = "dev" | "local" | "overrides" | "peer" | "pnpmOverrides" | "prod" | "resolutions" | AnyString;
120
+ type SpecifierType = "alias" | "exact" | "file" | "git" | "latest" | "major" | "minor" | "missing" | "range" | "range-complex" | "range-major" | "range-minor" | "tag" | "unsupported" | "url" | "workspace-protocol" | AnyString;
121
+ type AnyString = string & {};
122
+ export {};
package/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2017-2023 Jamie Mason
4
-
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
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
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, 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,16 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { CliConfig } from '../config/types.js';
3
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
4
- import type { Io } from '../io/index.js';
5
- import type { Report } from '../report.js';
6
- interface Input {
7
- io: Io;
8
- cli: Partial<CliConfig>;
9
- errorHandlers?: ErrorHandlers;
10
- }
11
- export declare function fixMismatches({ io, cli, errorHandlers, }: Input): Effect.Effect<unknown, never, never>;
12
- export declare function fixMismatch(report: Report.Version.Fixable.Any): Effect.Effect<import("../get-package-json-files/package-json-file.js").PackageJsonFile, never, never>;
13
- export declare function logAlreadyValidSize(amount: number): Effect.Effect<void, never, never>;
14
- export declare function logFixedSize(amount: number): Effect.Effect<void, never, never>;
15
- export declare function logUnfixableSize(amount: number): Effect.Effect<void, never, never>;
16
- export {};
@@ -1,115 +0,0 @@
1
- import chalk from 'chalk-template';
2
- import { Context, Effect, flow, pipe } from 'effect';
3
- import { isObject } from 'tightrope/guard/is-object.js';
4
- import { isUndefined } from 'tightrope/guard/is-undefined.js';
5
- import { logIgnoredSize } from '../bin-lint-semver-ranges/lint-semver-ranges.js';
6
- import { logMissingLocalVersion, logMissingSnappedToMismatch, logSameRangeMismatch, logUnsupportedMismatch, } from '../bin-list-mismatches/list-mismatches.js';
7
- import { CliConfigTag } from '../config/tag.js';
8
- import { ICON } from '../constants.js';
9
- import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
10
- import { getContext } from '../get-context/index.js';
11
- import { getInstances } from '../get-instances/index.js';
12
- import { exitIfInvalid } from '../io/exit-if-invalid.js';
13
- import { IoTag } from '../io/index.js';
14
- import { writeIfChanged } from '../io/write-if-changed.js';
15
- import { getVersionGroupHeader } from '../lib/get-group-header.js';
16
- import { padStart } from '../lib/pad-start.js';
17
- import { withLogger } from '../lib/with-logger.js';
18
- import { DELETE } from '../version-group/lib/delete.js';
19
- export function fixMismatches({ io, cli, errorHandlers = defaultErrorHandlers, }) {
20
- return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(ctx => pipe(Effect.gen(function* ($) {
21
- const { versionGroups } = yield* $(getInstances(ctx, io, errorHandlers));
22
- let index = 0;
23
- for (const group of versionGroups) {
24
- const groupSize = group.instances.length;
25
- let fixedCount = 0;
26
- let unfixableCount = 0;
27
- let validCount = 0;
28
- if (group._tag === 'FilteredOut') {
29
- index++;
30
- continue;
31
- }
32
- yield* $(Effect.logInfo(getVersionGroupHeader({ group, index })));
33
- if (group._tag === 'Ignored') {
34
- yield* $(logIgnoredSize(groupSize));
35
- index++;
36
- continue;
37
- }
38
- for (const groupReport of yield* $(group.inspectAll())) {
39
- for (const report of groupReport.reports) {
40
- if (report._tagGroup === 'Valid') {
41
- validCount++;
42
- }
43
- else if (report._tagGroup === 'Fixable') {
44
- fixedCount++;
45
- yield* $(fixMismatch(report));
46
- }
47
- else if (report._tagGroup === 'Unfixable') {
48
- ctx.isInvalid = true;
49
- unfixableCount++;
50
- }
51
- if (report._tag === 'MissingLocalVersion') {
52
- yield* $(logMissingLocalVersion(report));
53
- }
54
- else if (report._tag === 'MissingSnappedToMismatch') {
55
- yield* $(logMissingSnappedToMismatch(report));
56
- }
57
- else if (report._tag === 'UnsupportedMismatch') {
58
- yield* $(logUnsupportedMismatch(report));
59
- }
60
- else if (report._tag === 'SameRangeMismatch') {
61
- yield* $(logSameRangeMismatch(report));
62
- }
63
- }
64
- }
65
- if (validCount) {
66
- yield* $(logAlreadyValidSize(validCount));
67
- }
68
- if (fixedCount) {
69
- yield* $(logFixedSize(fixedCount));
70
- }
71
- if (unfixableCount) {
72
- yield* $(logUnfixableSize(unfixableCount));
73
- }
74
- index++;
75
- }
76
- yield* $(removeEmptyObjects(ctx));
77
- return ctx;
78
- }), Effect.flatMap(writeIfChanged), Effect.catchTags({
79
- WriteFileError: flow(errorHandlers.WriteFileError, Effect.map(() => {
80
- ctx.isInvalid = true;
81
- return ctx;
82
- })),
83
- }), Effect.flatMap(exitIfInvalid))), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
84
- }
85
- export function fixMismatch(report) {
86
- return report.fixable.instance.write(report._tag === 'Banned' ? DELETE : report.fixable.raw);
87
- }
88
- /** Remove empty objects such as `{"dependencies": {}}` left after deleting */
89
- function removeEmptyObjects(ctx) {
90
- return Effect.sync(() => {
91
- ctx.packageJsonFiles.forEach(file => {
92
- const contents = file.jsonFile.contents;
93
- Object.keys(contents).forEach(key => {
94
- const value = contents[key];
95
- if (isObject(value) &&
96
- value &&
97
- Object.values(value).every(isUndefined)) {
98
- delete contents[key];
99
- }
100
- });
101
- });
102
- });
103
- }
104
- export function logAlreadyValidSize(amount) {
105
- const msg = chalk `${padStart(amount)} {green ${ICON.tick}} already valid`;
106
- return Effect.logInfo(msg);
107
- }
108
- export function logFixedSize(amount) {
109
- const msg = chalk `${padStart(amount)} {green ${ICON.tick}} fixed`;
110
- return Effect.logInfo(msg);
111
- }
112
- export function logUnfixableSize(amount) {
113
- const msg = chalk `{red ${padStart(amount)} ${ICON.panic} can be fixed manually using} {blue syncpack prompt}`;
114
- return Effect.logInfo(msg);
115
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env node
2
- import chalk from 'chalk-template';
3
- import { program } from 'commander';
4
- import { Effect } from 'effect';
5
- import { io } from '../io/index.js';
6
- import { showHelpOnError } from '../lib/show-help-on-error.js';
7
- import { option } from '../option.js';
8
- import { fixMismatches } from './fix-mismatches.js';
9
- program.description(chalk `
10
- Ensure that multiple packages requiring the same dependency define the same
11
- version, so that every package requires eg. {yellow react@16.4.2}, instead of a
12
- combination of {yellow react@16.4.2}, {yellow react@0.15.9}, and {yellow react@16.0.0}.`.replace(/^\n/, ''));
13
- program.on('--help', () => { });
14
- showHelpOnError(program);
15
- program
16
- .option(...option.source)
17
- .option(...option.filter)
18
- .option(...option.specs)
19
- .option(...option.types)
20
- .option(...option.config)
21
- .option(...option.indent)
22
- .parse(process.argv);
23
- Effect.runPromise(fixMismatches({
24
- io,
25
- cli: {
26
- configPath: program.opts().config,
27
- filter: program.opts().filter,
28
- indent: program.opts().indent,
29
- source: program.opts().source,
30
- specs: program.opts().specs,
31
- types: program.opts().types,
32
- },
33
- }));
@@ -1,13 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { CliConfig } from '../config/types.js';
3
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
4
- import type { Ctx } from '../get-context/index.js';
5
- import type { Io } from '../io/index.js';
6
- interface Input {
7
- io: Io;
8
- cli: Partial<CliConfig>;
9
- errorHandlers?: ErrorHandlers;
10
- }
11
- export declare function format({ io, cli, errorHandlers, }: Input): Effect.Effect<unknown, never, never>;
12
- export declare function pipeline(ctx: Ctx): Effect.Effect<Ctx>;
13
- export {};
@@ -1,92 +0,0 @@
1
- import { Context, Effect, flow, pipe } from 'effect';
2
- import { isArray } from 'tightrope/guard/is-array.js';
3
- import { isNonEmptyString } from 'tightrope/guard/is-non-empty-string.js';
4
- import { isObject } from 'tightrope/guard/is-object.js';
5
- import { getSortAz } from '../config/get-sort-az.js';
6
- import { getSortExports } from '../config/get-sort-exports.js';
7
- import { getSortFirst } from '../config/get-sort-first.js';
8
- import { CliConfigTag } from '../config/tag.js';
9
- import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
10
- import { getContext } from '../get-context/index.js';
11
- import { exitIfInvalid } from '../io/exit-if-invalid.js';
12
- import { IoTag } from '../io/index.js';
13
- import { toFormattedJson } from '../io/to-formatted-json.js';
14
- import { writeIfChanged } from '../io/write-if-changed.js';
15
- import { withLogger } from '../lib/with-logger.js';
16
- export function format({ io, cli, errorHandlers = defaultErrorHandlers, }) {
17
- return pipe(getContext({ io, cli, errorHandlers }), Effect.flatMap(pipeline), Effect.flatMap(ctx => pipe(writeIfChanged(ctx), Effect.catchTags({
18
- WriteFileError: flow(errorHandlers.WriteFileError, Effect.map(() => {
19
- ctx.isInvalid = true;
20
- return ctx;
21
- })),
22
- }))), Effect.flatMap(exitIfInvalid), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
23
- }
24
- export function pipeline(ctx) {
25
- const { config, packageJsonFiles } = ctx;
26
- const sortAz = getSortAz(config);
27
- const sortExports = getSortExports(config);
28
- const sortFirst = getSortFirst(config);
29
- const sortPackages = config.rcFile.sortPackages !== false;
30
- const formatBugs = config.rcFile.formatBugs !== false;
31
- const formatRepository = config.rcFile.formatRepository !== false;
32
- packageJsonFiles.forEach(file => {
33
- const { contents } = file.jsonFile;
34
- const chain = contents;
35
- if (formatBugs) {
36
- const bugsUrl = chain?.bugs?.url;
37
- if (bugsUrl) {
38
- contents.bugs = bugsUrl;
39
- }
40
- }
41
- if (formatRepository) {
42
- const repoUrl = chain?.repository?.url;
43
- const repoDir = chain?.repository?.directory;
44
- if (isNonEmptyString(repoUrl) && !isNonEmptyString(repoDir)) {
45
- contents.repository = repoUrl.includes('github.com')
46
- ? repoUrl.replace(/^.+github\.com\//, '')
47
- : repoUrl;
48
- }
49
- }
50
- if (sortExports.length > 0) {
51
- visitExports(sortExports, contents.exports);
52
- }
53
- if (sortAz.length > 0) {
54
- sortAz.forEach(key => sortAlphabetically(contents[key]));
55
- }
56
- if (sortPackages) {
57
- const sortedKeys = Object.keys(contents).sort();
58
- sortObject(sortedKeys, contents);
59
- }
60
- if (sortFirst.length > 0) {
61
- const otherKeys = Object.keys(contents);
62
- const sortedKeys = new Set([...sortFirst, ...otherKeys]);
63
- sortObject(sortedKeys, contents);
64
- }
65
- file.nextJson = toFormattedJson(ctx, file);
66
- });
67
- return Effect.succeed(ctx);
68
- }
69
- function visitExports(sortExports, value) {
70
- if (isObject(value)) {
71
- const otherKeys = Object.keys(value);
72
- const sortedKeys = new Set([...sortExports, ...otherKeys]);
73
- sortObject(sortedKeys, value);
74
- Object.values(value).forEach(nextValue => visitExports(sortExports, nextValue));
75
- }
76
- }
77
- function sortObject(sortedKeys, obj) {
78
- sortedKeys.forEach((key) => {
79
- const value = obj[key];
80
- delete obj[key];
81
- obj[key] = value;
82
- });
83
- }
84
- function sortAlphabetically(value) {
85
- const localeComparison = (a, b) => a.localeCompare(b);
86
- if (isArray(value)) {
87
- value.sort(localeComparison);
88
- }
89
- else if (isObject(value)) {
90
- sortObject(Object.keys(value).sort(localeComparison), value);
91
- }
92
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env node
2
- import chalk from 'chalk-template';
3
- import { program } from 'commander';
4
- import { Effect } from 'effect';
5
- import { io } from '../io/index.js';
6
- import { showHelpOnError } from '../lib/show-help-on-error.js';
7
- import { option } from '../option.js';
8
- import { format } from './format.js';
9
- program.description(chalk `
10
- Organise package.json files according to a conventional format, where fields
11
- appear in a predictable order and nested fields are ordered alphabetically.
12
- Shorthand properties are used where available, such as the {yellow repository} and
13
- {yellow bugs} fields.`.replace(/^\n/, ''));
14
- program.on('--help', () => { });
15
- showHelpOnError(program);
16
- program
17
- .option(...option.source)
18
- .option(...option.config)
19
- .option(...option.indent)
20
- .parse(process.argv);
21
- Effect.runPromise(format({
22
- io,
23
- cli: {
24
- configPath: program.opts().config,
25
- indent: program.opts().indent,
26
- source: program.opts().source,
27
- },
28
- }));
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import { Effect } from 'effect';
4
- import { io } from '../io/index.js';
5
- import { showHelpOnError } from '../lib/show-help-on-error.js';
6
- import { option } from '../option.js';
7
- import { lint } from './lint.js';
8
- program.description(' lint all versions and ranges');
9
- program.on('--help', () => { });
10
- showHelpOnError(program);
11
- program.option(...option.config).parse(process.argv);
12
- Effect.runPromise(lint({
13
- io,
14
- cli: {
15
- configPath: program.opts().config,
16
- },
17
- }));
@@ -1,11 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { CliConfig } from '../config/types.js';
3
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
4
- import type { Io } from '../io/index.js';
5
- interface Input {
6
- io: Io;
7
- cli: Partial<CliConfig>;
8
- errorHandlers?: ErrorHandlers;
9
- }
10
- export declare function lint({ io, cli, errorHandlers }: Input): Effect.Effect<unknown, never, never>;
11
- export {};
@@ -1,52 +0,0 @@
1
- import chalk from 'chalk-template';
2
- import { Context, Effect, pipe } from 'effect';
3
- import { pipeline as format } from '../bin-format/format.js';
4
- import { pipeline as lintSemverRanges } from '../bin-lint-semver-ranges/lint-semver-ranges.js';
5
- import { pipeline as listMismatches } from '../bin-list-mismatches/list-mismatches.js';
6
- import { CliConfigTag } from '../config/tag.js';
7
- import { ICON } from '../constants.js';
8
- import { defaultErrorHandlers } from '../error-handlers/default-error-handlers.js';
9
- import { getContext } from '../get-context/index.js';
10
- import { exitIfInvalid } from '../io/exit-if-invalid.js';
11
- import { IoTag } from '../io/index.js';
12
- import { toFormattedJson } from '../io/to-formatted-json.js';
13
- import { withLogger } from '../lib/with-logger.js';
14
- export function lint({ io, cli, errorHandlers = defaultErrorHandlers }) {
15
- return pipe(getContext({ io, cli, errorHandlers }),
16
- // Formatting
17
- Effect.flatMap(ctx => Effect.gen(function* ($) {
18
- if (ctx.config.rcFile.lintFormatting !== false) {
19
- yield* $(Effect.logInfo(chalk `{yellow Formatting}`));
20
- yield* $(format(ctx));
21
- for (const file of ctx.packageJsonFiles) {
22
- const shortPath = file.jsonFile.shortPath;
23
- const formattedJson = toFormattedJson(ctx, file);
24
- const isFormatted = file.jsonFile.json === formattedJson;
25
- if (isFormatted) {
26
- yield* $(Effect.logInfo(chalk `{green ${ICON.tick}} ${shortPath}`));
27
- }
28
- else {
29
- ctx.isInvalid = true;
30
- yield* $(Effect.logInfo(chalk `{red ${ICON.cross}} ${shortPath}`));
31
- }
32
- }
33
- }
34
- return ctx;
35
- })),
36
- // Versions
37
- Effect.flatMap(ctx => Effect.gen(function* ($) {
38
- if (ctx.config.rcFile.lintVersions !== false) {
39
- yield* $(Effect.logInfo(chalk `{yellow Versions}`));
40
- yield* $(listMismatches(ctx, io, errorHandlers));
41
- }
42
- return ctx;
43
- })),
44
- // Semver Ranges
45
- Effect.flatMap(ctx => Effect.gen(function* ($) {
46
- if (ctx.config.rcFile.lintSemverRanges !== false) {
47
- yield* $(Effect.logInfo(chalk `{yellow Semver Ranges}`));
48
- yield* $(lintSemverRanges(ctx, io, errorHandlers));
49
- }
50
- return ctx;
51
- })), Effect.flatMap(exitIfInvalid), Effect.provide(pipe(Context.empty(), Context.add(CliConfigTag, cli), Context.add(IoTag, io))), withLogger);
52
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env node
2
- import chalk from 'chalk-template';
3
- import { program } from 'commander';
4
- import { Effect } from 'effect';
5
- import { io } from '../io/index.js';
6
- import { showHelpOnError } from '../lib/show-help-on-error.js';
7
- import { option } from '../option.js';
8
- import { lintSemverRanges } from './lint-semver-ranges.js';
9
- program.description(chalk `
10
- Check dependency versions within {yellow dependencies}, {yellow devDependencies},
11
- {yellow peerDependencies}, {yellow overrides}, and {yellow resolutions} follow a consistent format.`.replace(/^\n/, ''));
12
- program.on('--help', () => { });
13
- showHelpOnError(program);
14
- program
15
- .option(...option.source)
16
- .option(...option.filter)
17
- .option(...option.config)
18
- .option(...option.specs)
19
- .option(...option.types)
20
- .parse(process.argv);
21
- Effect.runPromise(lintSemverRanges({
22
- io,
23
- cli: {
24
- configPath: program.opts().config,
25
- filter: program.opts().filter,
26
- source: program.opts().source,
27
- specs: program.opts().specs,
28
- types: program.opts().types,
29
- },
30
- }));
@@ -1,16 +0,0 @@
1
- import { Effect } from 'effect';
2
- import type { CliConfig } from '../config/types.js';
3
- import type { ErrorHandlers } from '../error-handlers/default-error-handlers.js';
4
- import type { Ctx } from '../get-context/index.js';
5
- import type { Io } from '../io/index.js';
6
- interface Input {
7
- io: Io;
8
- cli: Partial<CliConfig>;
9
- errorHandlers?: ErrorHandlers;
10
- }
11
- export declare function lintSemverRanges({ io, cli, errorHandlers, }: Input): Effect.Effect<unknown, never, never>;
12
- /** Exported to be reused by `syncpack lint` */
13
- export declare function pipeline(ctx: Ctx, io: Io, errorHandlers: ErrorHandlers): Effect.Effect<Ctx>;
14
- export declare function logSemverGroupsDisabledWarning(): Effect.Effect<void, never, never>;
15
- export declare function logIgnoredSize(amount: number): Effect.Effect<void, never, never>;
16
- export {};