@codefast/cli 0.7.0 → 0.8.1

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 (222) hide show
  1. package/README.md +152 -37
  2. package/dist/arrange/analyze.js +3 -2
  3. package/dist/arrange/cli-schema.js +7 -2
  4. package/dist/arrange/command.js +3 -2
  5. package/dist/arrange/domain/analyze-service.js +3 -2
  6. package/dist/arrange/domain/ast/ast-node.js +35 -2
  7. package/dist/arrange/domain/ast/collectors-cn.js +9 -2
  8. package/dist/arrange/domain/ast/collectors-jsx.js +3 -2
  9. package/dist/arrange/domain/ast/collectors-tv.js +11 -2
  10. package/dist/arrange/domain/ast/helpers.js +5 -2
  11. package/dist/arrange/domain/ast/simplify-targets.js +1 -2
  12. package/dist/arrange/domain/ast/targets.js +7 -2
  13. package/dist/arrange/domain/constants.js +1 -2
  14. package/dist/arrange/domain/grouping-service.js +15 -2
  15. package/dist/arrange/domain/grouping.js +3 -2
  16. package/dist/arrange/domain/imports.js +3 -2
  17. package/dist/arrange/domain/source-text-formatters.js +9 -2
  18. package/dist/arrange/domain/tailwind-token.js +3 -2
  19. package/dist/arrange/domain/token-classifier.js +5 -2
  20. package/dist/arrange/domain/types.js +1 -2
  21. package/dist/arrange/output.js +9 -2
  22. package/dist/arrange/process-file.js +3 -2
  23. package/dist/arrange/resolve-target.js +3 -2
  24. package/dist/arrange/scan-target.js +3 -2
  25. package/dist/arrange/simplify-process-file.js +3 -2
  26. package/dist/arrange/simplify-sync.js +3 -2
  27. package/dist/arrange/source-parse.js +3 -2
  28. package/dist/arrange/suggest.js +3 -2
  29. package/dist/arrange/sync.js +3 -2
  30. package/dist/arrange/typescript-ast-translator.js +3 -2
  31. package/dist/arrange/workspace.js +3 -2
  32. package/dist/audit/cli-schema.js +14 -4
  33. package/dist/audit/command.js +45 -6
  34. package/dist/audit/domain/audit-file.js +4 -5
  35. package/dist/audit/domain/comment-content.js +1 -2
  36. package/dist/audit/domain/comment-dividers.js +1 -2
  37. package/dist/audit/domain/link-references.js +1 -2
  38. package/dist/audit/domain/mappings.js +10 -9
  39. package/dist/audit/domain/markdown-links.js +1 -2
  40. package/dist/audit/domain/react-imports.js +91 -0
  41. package/dist/audit/domain/since-versions.js +85 -0
  42. package/dist/audit/domain/tokenize.js +7 -6
  43. package/dist/audit/domain/tsdoc-syntax.js +1 -2
  44. package/dist/audit/domain/types.js +1 -2
  45. package/dist/audit/output.js +45 -5
  46. package/dist/audit/prepare.js +33 -3
  47. package/dist/audit/run-comments.js +26 -2
  48. package/dist/audit/run-links.js +1 -2
  49. package/dist/audit/run-react.js +55 -0
  50. package/dist/audit/run.js +2 -3
  51. package/dist/bin.js +1 -2
  52. package/dist/cli.js +5 -2
  53. package/dist/core/cli/format-error.js +3 -2
  54. package/dist/core/cli/global-options.js +1 -2
  55. package/dist/core/cli/positional.js +1 -2
  56. package/dist/core/cli/result-handle.js +5 -20
  57. package/dist/core/config/loader.js +3 -2
  58. package/dist/core/config/schema.js +27 -9
  59. package/dist/core/config/warnings.js +3 -2
  60. package/dist/core/config.js +3 -2
  61. package/dist/core/errors.js +3 -2
  62. package/dist/core/exit-codes.js +5 -2
  63. package/dist/core/filesystem/node.js +3 -2
  64. package/dist/core/filesystem/port.js +1 -2
  65. package/dist/core/glob.js +1 -2
  66. package/dist/core/logger.js +3 -2
  67. package/dist/core/result.js +5 -2
  68. package/dist/core/schema-parse.js +3 -2
  69. package/dist/core/source-text-edit.js +9 -2
  70. package/dist/core/verbose-diagnostics.js +3 -2
  71. package/dist/core/workspace/markdown-walk.js +1 -2
  72. package/dist/core/workspace/package-version.js +24 -0
  73. package/dist/core/workspace/resolver.js +3 -2
  74. package/dist/core/workspace/skip-directories.js +3 -2
  75. package/dist/core/workspace/source-walk.js +1 -2
  76. package/dist/core/workspace/typescript-walk.js +3 -2
  77. package/dist/mirror/cli-result.js +5 -2
  78. package/dist/mirror/cli-schema.js +3 -2
  79. package/dist/mirror/command.js +3 -2
  80. package/dist/mirror/dist-filesystem-impl.js +3 -2
  81. package/dist/mirror/domain/constants.js +11 -2
  82. package/dist/mirror/domain/dirent-guard.js +1 -2
  83. package/dist/mirror/domain/dist-filesystem.js +1 -2
  84. package/dist/mirror/domain/errors.js +5 -2
  85. package/dist/mirror/domain/exports.js +5 -2
  86. package/dist/mirror/domain/package-display-name.js +1 -2
  87. package/dist/mirror/domain/path-normalizer.js +3 -2
  88. package/dist/mirror/domain/types.js +1 -2
  89. package/dist/mirror/output.js +3 -2
  90. package/dist/mirror/package-path.js +5 -2
  91. package/dist/mirror/prepare.js +3 -2
  92. package/dist/mirror/supplement-exports.js +3 -2
  93. package/dist/mirror/sync-reporter.js +1 -2
  94. package/dist/mirror/sync-types.js +1 -2
  95. package/dist/mirror/sync-workspace-package.js +3 -2
  96. package/dist/mirror/sync.js +3 -2
  97. package/dist/mirror/write-exports.js +1 -2
  98. package/dist/pack-slim/cli-result.js +23 -0
  99. package/dist/pack-slim/cli-schema.js +11 -0
  100. package/dist/pack-slim/command.js +79 -0
  101. package/dist/pack-slim/domain/transform.js +95 -0
  102. package/dist/pack-slim/domain/types.js +2 -0
  103. package/dist/pack-slim/output.js +53 -0
  104. package/dist/pack-slim/sync.js +151 -0
  105. package/dist/pack-slim/working-tree.js +45 -0
  106. package/dist/tag/cli-result.js +3 -2
  107. package/dist/tag/cli-schema.js +3 -2
  108. package/dist/tag/command.js +3 -2
  109. package/dist/tag/domain/types.js +1 -2
  110. package/dist/tag/output.js +5 -2
  111. package/dist/tag/prepare.js +3 -2
  112. package/dist/tag/resolve-target-path.js +3 -2
  113. package/dist/tag/since-writer.js +3 -2
  114. package/dist/tag/sync.js +3 -2
  115. package/dist/tag/target-candidates.js +3 -2
  116. package/dist/tag/target-runner.js +3 -2
  117. package/dist/tag/version-resolver.js +8 -23
  118. package/package.json +9 -16
  119. package/dist/arrange/analyze.js.map +0 -1
  120. package/dist/arrange/cli-schema.js.map +0 -1
  121. package/dist/arrange/command.js.map +0 -1
  122. package/dist/arrange/domain/analyze-service.js.map +0 -1
  123. package/dist/arrange/domain/ast/ast-node.js.map +0 -1
  124. package/dist/arrange/domain/ast/collectors-cn.js.map +0 -1
  125. package/dist/arrange/domain/ast/collectors-jsx.js.map +0 -1
  126. package/dist/arrange/domain/ast/collectors-tv.js.map +0 -1
  127. package/dist/arrange/domain/ast/helpers.js.map +0 -1
  128. package/dist/arrange/domain/ast/simplify-targets.js.map +0 -1
  129. package/dist/arrange/domain/ast/targets.js.map +0 -1
  130. package/dist/arrange/domain/constants.js.map +0 -1
  131. package/dist/arrange/domain/grouping-service.js.map +0 -1
  132. package/dist/arrange/domain/grouping.js.map +0 -1
  133. package/dist/arrange/domain/imports.js.map +0 -1
  134. package/dist/arrange/domain/source-text-formatters.js.map +0 -1
  135. package/dist/arrange/domain/tailwind-token.js.map +0 -1
  136. package/dist/arrange/domain/token-classifier.js.map +0 -1
  137. package/dist/arrange/domain/types.js.map +0 -1
  138. package/dist/arrange/output.js.map +0 -1
  139. package/dist/arrange/process-file.js.map +0 -1
  140. package/dist/arrange/resolve-target.js.map +0 -1
  141. package/dist/arrange/scan-target.js.map +0 -1
  142. package/dist/arrange/simplify-process-file.js.map +0 -1
  143. package/dist/arrange/simplify-sync.js.map +0 -1
  144. package/dist/arrange/source-parse.js.map +0 -1
  145. package/dist/arrange/suggest.js.map +0 -1
  146. package/dist/arrange/sync.js.map +0 -1
  147. package/dist/arrange/typescript-ast-translator.js.map +0 -1
  148. package/dist/arrange/workspace.js.map +0 -1
  149. package/dist/audit/cli-schema.js.map +0 -1
  150. package/dist/audit/command.js.map +0 -1
  151. package/dist/audit/domain/audit-file.js.map +0 -1
  152. package/dist/audit/domain/comment-content.js.map +0 -1
  153. package/dist/audit/domain/comment-dividers.js.map +0 -1
  154. package/dist/audit/domain/link-references.js.map +0 -1
  155. package/dist/audit/domain/mappings.js.map +0 -1
  156. package/dist/audit/domain/markdown-links.js.map +0 -1
  157. package/dist/audit/domain/tokenize.js.map +0 -1
  158. package/dist/audit/domain/tsdoc-syntax.js.map +0 -1
  159. package/dist/audit/domain/types.js.map +0 -1
  160. package/dist/audit/output.js.map +0 -1
  161. package/dist/audit/prepare.js.map +0 -1
  162. package/dist/audit/run-comments.js.map +0 -1
  163. package/dist/audit/run-links.js.map +0 -1
  164. package/dist/audit/run.js.map +0 -1
  165. package/dist/bin.js.map +0 -1
  166. package/dist/cli.js.map +0 -1
  167. package/dist/core/cli/format-error.js.map +0 -1
  168. package/dist/core/cli/global-options.js.map +0 -1
  169. package/dist/core/cli/positional.js.map +0 -1
  170. package/dist/core/cli/result-handle.js.map +0 -1
  171. package/dist/core/config/loader.js.map +0 -1
  172. package/dist/core/config/schema.js.map +0 -1
  173. package/dist/core/config/warnings.js.map +0 -1
  174. package/dist/core/config.js.map +0 -1
  175. package/dist/core/errors.js.map +0 -1
  176. package/dist/core/exit-codes.js.map +0 -1
  177. package/dist/core/filesystem/node.js.map +0 -1
  178. package/dist/core/filesystem/port.js.map +0 -1
  179. package/dist/core/glob.js.map +0 -1
  180. package/dist/core/logger.js.map +0 -1
  181. package/dist/core/result.js.map +0 -1
  182. package/dist/core/schema-parse.js.map +0 -1
  183. package/dist/core/source-text-edit.js.map +0 -1
  184. package/dist/core/verbose-diagnostics.js.map +0 -1
  185. package/dist/core/workspace/markdown-walk.js.map +0 -1
  186. package/dist/core/workspace/resolver.js.map +0 -1
  187. package/dist/core/workspace/skip-directories.js.map +0 -1
  188. package/dist/core/workspace/source-walk.js.map +0 -1
  189. package/dist/core/workspace/typescript-walk.js.map +0 -1
  190. package/dist/mirror/cli-result.js.map +0 -1
  191. package/dist/mirror/cli-schema.js.map +0 -1
  192. package/dist/mirror/command.js.map +0 -1
  193. package/dist/mirror/dist-filesystem-impl.js.map +0 -1
  194. package/dist/mirror/domain/constants.js.map +0 -1
  195. package/dist/mirror/domain/dirent-guard.js.map +0 -1
  196. package/dist/mirror/domain/dist-filesystem.js.map +0 -1
  197. package/dist/mirror/domain/errors.js.map +0 -1
  198. package/dist/mirror/domain/exports.js.map +0 -1
  199. package/dist/mirror/domain/package-display-name.js.map +0 -1
  200. package/dist/mirror/domain/path-normalizer.js.map +0 -1
  201. package/dist/mirror/domain/types.js.map +0 -1
  202. package/dist/mirror/output.js.map +0 -1
  203. package/dist/mirror/package-path.js.map +0 -1
  204. package/dist/mirror/prepare.js.map +0 -1
  205. package/dist/mirror/supplement-exports.js.map +0 -1
  206. package/dist/mirror/sync-reporter.js.map +0 -1
  207. package/dist/mirror/sync-types.js.map +0 -1
  208. package/dist/mirror/sync-workspace-package.js.map +0 -1
  209. package/dist/mirror/sync.js.map +0 -1
  210. package/dist/mirror/write-exports.js.map +0 -1
  211. package/dist/tag/cli-result.js.map +0 -1
  212. package/dist/tag/cli-schema.js.map +0 -1
  213. package/dist/tag/command.js.map +0 -1
  214. package/dist/tag/domain/types.js.map +0 -1
  215. package/dist/tag/output.js.map +0 -1
  216. package/dist/tag/prepare.js.map +0 -1
  217. package/dist/tag/resolve-target-path.js.map +0 -1
  218. package/dist/tag/since-writer.js.map +0 -1
  219. package/dist/tag/sync.js.map +0 -1
  220. package/dist/tag/target-candidates.js.map +0 -1
  221. package/dist/tag/target-runner.js.map +0 -1
  222. package/dist/tag/version-resolver.js.map +0 -1
@@ -18,24 +18,8 @@ function exitCodeForAppError(error) {
18
18
  }
19
19
  }
20
20
  /**
21
- * @since 0.3.16-canary.0
22
- */
23
- export function handleResult(outcome, onSuccess) {
24
- if (!outcome.ok) {
25
- logger.err(formatAppError(outcome.error));
26
- if (isVerboseCliDiagnostics() &&
27
- outcome.error.code === "INFRA_FAILURE" &&
28
- outcome.error.cause instanceof Error &&
29
- outcome.error.cause.stack !== undefined) {
30
- logger.err(outcome.error.cause.stack);
31
- }
32
- process.exitCode = exitCodeForAppError(outcome.error);
33
- return false;
34
- }
35
- onSuccess(outcome.value);
36
- return true;
37
- }
38
- /**
21
+ * Narrows a `Result`, reporting a failure and setting the exit code, or logging an optional success message.
22
+ *
39
23
  * @since 0.3.16-canary.0
40
24
  */
41
25
  export function consumeCliAppError(outcome, options) {
@@ -56,6 +40,8 @@ export function consumeCliAppError(outcome, options) {
56
40
  return true;
57
41
  }
58
42
  /**
43
+ * Awaits a `Result`, hands a success to `onSuccess`, and records the returned exit code on the process.
44
+ *
59
45
  * @since 0.3.16-canary.0
60
46
  */
61
47
  export async function runCliResultAsync(outcomePromise, onSuccess) {
@@ -65,5 +51,4 @@ export async function runCliResultAsync(outcomePromise, onSuccess) {
65
51
  }
66
52
  const exit = await onSuccess(outcome.value);
67
53
  process.exitCode = exit === undefined ? 0 : exit;
68
- }
69
- //# sourceMappingURL=result-handle.js.map
54
+ }
@@ -72,6 +72,8 @@ async function loadOnce(startDir, fs) {
72
72
  return { config, warnings, configPath };
73
73
  }
74
74
  /**
75
+ * Loads and caches the config payload for a directory, sharing one load per resolved path.
76
+ *
75
77
  * @since 0.3.16-canary.0
76
78
  */
77
79
  export function loadConfigPayload(startDir, fs) {
@@ -84,5 +86,4 @@ export function loadConfigPayload(startDir, fs) {
84
86
  throw new Error("config loader cache invariant violated");
85
87
  }
86
88
  return cached;
87
- }
88
- //# sourceMappingURL=loader.js.map
89
+ }
@@ -23,7 +23,7 @@ const mirrorCssConfigSchema = z.union([
23
23
  *
24
24
  * @since 0.3.16-canary.0
25
25
  */
26
- export const mirrorPackageConfigSchema = z
26
+ const mirrorPackageConfigSchema = z
27
27
  .object({
28
28
  /** Preserve the existing `package.json#exports` map and only add missing conditions
29
29
  * (`source`, `types`, `import`). No dist/ scan is performed. */
@@ -49,18 +49,22 @@ export const mirrorPackageConfigSchema = z
49
49
  */
50
50
  export const mirrorConfigSchema = z.record(z.string(), z.union([z.literal(false), mirrorPackageConfigSchema]));
51
51
  /**
52
+ * Zod schema for the `tag` command's configuration.
53
+ *
52
54
  * @since 0.3.16-canary.0
53
55
  */
54
- export const codefastTagConfigSchema = z
56
+ const codefastTagConfigSchema = z
55
57
  .object({
56
58
  skipPackages: z.array(z.string()).optional(),
57
59
  onAfterWrite: afterWriteHookSchema.optional(),
58
60
  })
59
61
  .strict();
60
62
  /**
63
+ * Zod schema for the `arrange` command's configuration.
64
+ *
61
65
  * @since 0.3.16-canary.0
62
66
  */
63
- export const codefastArrangeConfigSchema = z
67
+ const codefastArrangeConfigSchema = z
64
68
  .object({
65
69
  onAfterWrite: afterWriteHookSchema.optional(),
66
70
  })
@@ -70,7 +74,7 @@ export const codefastArrangeConfigSchema = z
70
74
  *
71
75
  * @since 0.3.16-canary.0
72
76
  */
73
- export const codefastAuditRtlConfigSchema = z
77
+ const codefastAuditRtlConfigSchema = z
74
78
  .object({
75
79
  /** Directory or file to scan when no CLI target is passed. */
76
80
  target: z.string().optional(),
@@ -83,7 +87,7 @@ export const codefastAuditRtlConfigSchema = z
83
87
  *
84
88
  * @since 0.5.0
85
89
  */
86
- export const codefastAuditLinksConfigSchema = z
90
+ const codefastAuditLinksConfigSchema = z
87
91
  .object({
88
92
  /** Bare link targets or `repo/relative/doc.md:target` entries to ignore. */
89
93
  allowlist: z.array(z.string()).optional(),
@@ -94,20 +98,35 @@ export const codefastAuditLinksConfigSchema = z
94
98
  *
95
99
  * @since 0.6.0
96
100
  */
97
- export const codefastAuditCommentsConfigSchema = z
101
+ const codefastAuditCommentsConfigSchema = z
98
102
  .object({
99
103
  /** Divider lines as written, or `repo/relative/path.ts:<divider>` entries, to ignore. */
100
104
  allowlist: z.array(z.string()).optional(),
101
105
  })
102
106
  .strict();
103
107
  /**
108
+ * React import-policy audit defaults — the scan always starts at the repo root, so only
109
+ * exceptions are configured.
110
+ *
111
+ * @since 0.8.0
112
+ */
113
+ const codefastAuditReactConfigSchema = z
114
+ .object({
115
+ /** Offending source text as written, or `repo/relative/path.tsx:<text>` entries, to ignore. */
116
+ allowlist: z.array(z.string()).optional(),
117
+ })
118
+ .strict();
119
+ /**
120
+ * Zod schema grouping the per-audit configurations under `audit`.
121
+ *
104
122
  * @since 0.3.16-canary.0
105
123
  */
106
- export const codefastAuditConfigSchema = z
124
+ const codefastAuditConfigSchema = z
107
125
  .object({
108
126
  rtl: codefastAuditRtlConfigSchema.optional(),
109
127
  links: codefastAuditLinksConfigSchema.optional(),
110
128
  comments: codefastAuditCommentsConfigSchema.optional(),
129
+ react: codefastAuditReactConfigSchema.optional(),
111
130
  })
112
131
  .strict();
113
132
  /**
@@ -122,5 +141,4 @@ export const codefastConfigRootSchema = z
122
141
  arrange: codefastArrangeConfigSchema.optional(),
123
142
  audit: codefastAuditConfigSchema.optional(),
124
143
  })
125
- .strict();
126
- //# sourceMappingURL=schema.js.map
144
+ .strict();
@@ -2,11 +2,12 @@ import { logger } from "#/core/logger";
2
2
  const yellowAnsi = "\x1b[33m";
3
3
  const resetAnsi = "\x1b[0m";
4
4
  /**
5
+ * Prints each config schema warning as a highlighted line.
6
+ *
5
7
  * @since 0.3.16-canary.0
6
8
  */
7
9
  export function reportSchemaWarnings(warnings) {
8
10
  for (const warningMessage of warnings) {
9
11
  logger.out(`${yellowAnsi}⚠ ${warningMessage}${resetAnsi}`);
10
12
  }
11
- }
12
- //# sourceMappingURL=warnings.js.map
13
+ }
@@ -3,6 +3,8 @@ import { reportSchemaWarnings } from "#/core/config/warnings";
3
3
  import { AppError, messageFrom } from "#/core/errors";
4
4
  import { err, ok } from "#/core/result";
5
5
  /**
6
+ * Loads the `codefast.config.js` for a workspace root, reporting schema warnings along the way.
7
+ *
6
8
  * @since 0.3.16-canary.0
7
9
  */
8
10
  export async function loadCodefastConfig(rootDir, fs) {
@@ -14,5 +16,4 @@ export async function loadCodefastConfig(rootDir, fs) {
14
16
  catch (caughtError) {
15
17
  return err(new AppError("INFRA_FAILURE", messageFrom(caughtError), caughtError));
16
18
  }
17
- }
18
- //# sourceMappingURL=config.js.map
19
+ }
@@ -5,6 +5,8 @@
5
5
  * @since 0.3.16-canary.0
6
6
  */
7
7
  /**
8
+ * A coded application error carried in `Result` values rather than thrown.
9
+ *
8
10
  * @since 0.3.16-canary.0
9
11
  */
10
12
  export class AppError {
@@ -54,5 +56,4 @@ export function messageFrom(value) {
54
56
  // Circular structure, BigInt in tree, etc.
55
57
  }
56
58
  return "[unserializable non-Error value]";
57
- }
58
- //# sourceMappingURL=errors.js.map
59
+ }
@@ -5,11 +5,14 @@
5
5
  */
6
6
  export const CLI_EXIT_SUCCESS = 0;
7
7
  /**
8
+ * The exit code for a run that failed for any reason other than bad usage.
9
+ *
8
10
  * @since 0.3.16-canary.0
9
11
  */
10
12
  export const CLI_EXIT_GENERAL_ERROR = 1;
11
13
  /**
14
+ * The exit code for invalid arguments or configuration.
15
+ *
12
16
  * @since 0.3.16-canary.0
13
17
  */
14
- export const CLI_EXIT_USAGE = 2;
15
- //# sourceMappingURL=exit-codes.js.map
18
+ export const CLI_EXIT_USAGE = 2;
@@ -2,6 +2,8 @@ import fsSync from "node:fs";
2
2
  import fsPromises from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  /**
5
+ * The `FilesystemPort` implementation backed by Node's real filesystem.
6
+ *
5
7
  * @since 0.3.16-canary.0
6
8
  */
7
9
  export const nodeFilesystem = {
@@ -29,5 +31,4 @@ export const nodeFilesystem = {
29
31
  },
30
32
  rename: (oldPath, newPath) => fsPromises.rename(oldPath, newPath),
31
33
  unlink: (filePath) => fsPromises.unlink(filePath),
32
- };
33
- //# sourceMappingURL=node.js.map
34
+ };
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=port.js.map
1
+ export {};
package/dist/core/glob.js CHANGED
@@ -16,5 +16,4 @@ export function createAnyGlobMatcher(patterns, options) {
16
16
  }
17
17
  const matchers = patterns.map((pattern) => picomatch(pattern, options));
18
18
  return (value) => matchers.some((isMatch) => isMatch(value));
19
- }
20
- //# sourceMappingURL=glob.js.map
19
+ }
@@ -1,5 +1,7 @@
1
1
  import process from "node:process";
2
2
  /**
3
+ * The CLI's line-oriented writer for stdout and stderr.
4
+ *
3
5
  * @since 0.3.16-canary.0
4
6
  */
5
7
  export const logger = {
@@ -9,5 +11,4 @@ export const logger = {
9
11
  err(line) {
10
12
  process.stderr.write(`${line}\n`);
11
13
  },
12
- };
13
- //# sourceMappingURL=logger.js.map
14
+ };
@@ -2,15 +2,18 @@
2
2
  * Lightweight functional Result type for CLI boundaries.
3
3
  */
4
4
  /**
5
+ * Wraps a value in a success `Result`.
6
+ *
5
7
  * @since 0.3.16-canary.0
6
8
  */
7
9
  export function ok(value) {
8
10
  return { ok: true, value };
9
11
  }
10
12
  /**
13
+ * Wraps an error in a failure `Result`.
14
+ *
11
15
  * @since 0.3.16-canary.0
12
16
  */
13
17
  export function err(error) {
14
18
  return { ok: false, error };
15
- }
16
- //# sourceMappingURL=result.js.map
19
+ }
@@ -9,6 +9,8 @@ function formatSchemaIssues(issues) {
9
9
  .join("; ");
10
10
  }
11
11
  /**
12
+ * Parses an input against a Zod schema and returns a `Result` with the value or a validation `AppError`.
13
+ *
12
14
  * @since 0.3.16-canary.0
13
15
  */
14
16
  export function parseWithSchema(schema, input) {
@@ -17,5 +19,4 @@ export function parseWithSchema(schema, input) {
17
19
  return err(new AppError("VALIDATION_ERROR", formatSchemaIssues(parsed.error.issues)));
18
20
  }
19
21
  return ok(parsed.data);
20
- }
21
- //# sourceMappingURL=schema-parse.js.map
22
+ }
@@ -7,6 +7,8 @@ function lineStartIndexContaining(source, pos) {
7
7
  return prevLineBreak === -1 ? 0 : prevLineBreak + 1;
8
8
  }
9
9
  /**
10
+ * Returns the leading whitespace of the line containing a position.
11
+ *
10
12
  * @since 0.3.16-canary.0
11
13
  */
12
14
  export function indentOfLineContaining(source, pos) {
@@ -24,6 +26,8 @@ export function indentOfLineContaining(source, pos) {
24
26
  return indentMatch?.[0] ?? "";
25
27
  }
26
28
  /**
29
+ * Returns the text from the start of a position's line up to that position.
30
+ *
27
31
  * @since 0.3.16-canary.0
28
32
  */
29
33
  export function textPrefixFromLineStartToPosition(source, pos) {
@@ -31,6 +35,8 @@ export function textPrefixFromLineStartToPosition(source, pos) {
31
35
  return source.slice(lineStartIndexContaining(source, searchPos), searchPos);
32
36
  }
33
37
  /**
38
+ * Extends a token's end position past any whitespace-separated trailing comma.
39
+ *
34
40
  * @since 0.3.16-canary.0
35
41
  */
36
42
  export function endAfterOptionalCommaFollowingInSource(source, tokenEnd) {
@@ -49,6 +55,8 @@ export function endAfterOptionalCommaFollowingInSource(source, tokenEnd) {
49
55
  return tokenEnd;
50
56
  }
51
57
  /**
58
+ * Applies non-overlapping text edits from the highest offset down and returns the edited source.
59
+ *
52
60
  * @since 0.3.16-canary.0
53
61
  */
54
62
  export function applyEditsDescending(sourceText, edits) {
@@ -58,5 +66,4 @@ export function applyEditsDescending(sourceText, edits) {
58
66
  out = out.slice(0, edit.start) + edit.replacement + out.slice(edit.end);
59
67
  }
60
68
  return out;
61
- }
62
- //# sourceMappingURL=source-text-edit.js.map
69
+ }
@@ -1,9 +1,10 @@
1
1
  import process from "node:process";
2
2
  /**
3
+ * Reports whether the `CODEFAST_VERBOSE` environment variable enables verbose diagnostics.
4
+ *
3
5
  * @since 0.3.16-canary.0
4
6
  */
5
7
  export function isVerboseCliDiagnostics() {
6
8
  const raw = process.env.CODEFAST_VERBOSE;
7
9
  return raw === "1" || raw === "true";
8
- }
9
- //# sourceMappingURL=verbose-diagnostics.js.map
10
+ }
@@ -24,5 +24,4 @@ function visitMarkdownPaths(result, entryPath, fs) {
24
24
  if (entryPath.endsWith(".md")) {
25
25
  result.push(entryPath);
26
26
  }
27
- }
28
- //# sourceMappingURL=markdown-walk.js.map
27
+ }
@@ -0,0 +1,24 @@
1
+ import path from "node:path";
2
+ /**
3
+ * Finds the `version` of the nearest enclosing `package.json`, or null when the first
4
+ * one found declares none (the private workspace root is version-less by design).
5
+ *
6
+ * @since 0.8.0
7
+ */
8
+ function findNearestPackageVersion(fs, targetPath) {
9
+ const resolved = path.resolve(targetPath);
10
+ let current = fs.statSync(resolved).isDirectory() ? resolved : path.dirname(resolved);
11
+ while (true) {
12
+ const packageJsonPath = path.join(current, "package.json");
13
+ if (fs.existsSync(packageJsonPath)) {
14
+ const version = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).version;
15
+ return typeof version === "string" && version.length > 0 ? version : null;
16
+ }
17
+ const parent = path.dirname(current);
18
+ if (parent === current) {
19
+ return null;
20
+ }
21
+ current = parent;
22
+ }
23
+ }
24
+ export { findNearestPackageVersion };
@@ -125,6 +125,8 @@ async function readWorkspaceYaml(rootDir, fs) {
125
125
  return { exists: true, doc };
126
126
  }
127
127
  /**
128
+ * Lists the workspace's package directories per `pnpm-workspace.yaml`, falling back to default patterns.
129
+ *
128
130
  * @since 0.3.16-canary.0
129
131
  */
130
132
  export async function listWorkspacePackageDirectories(rootDirectoryPathAbsolute, fs, suppressGlobPermissionDiagnostics) {
@@ -204,5 +206,4 @@ export async function listWorkspacePackageDirectories(rootDirectoryPathAbsolute,
204
206
  layoutSource,
205
207
  hasPnpmWorkspaceYamlFile,
206
208
  };
207
- }
208
- //# sourceMappingURL=resolver.js.map
209
+ }
@@ -15,5 +15,6 @@ export const defaultSkipDirectoryNames = new Set([
15
15
  "coverage",
16
16
  ".vercel",
17
17
  ".output",
18
- ]);
19
- //# sourceMappingURL=skip-directories.js.map
18
+ ".tanstack",
19
+ ".nitro",
20
+ ]);
@@ -41,5 +41,4 @@ function visitSourcePaths(result, entryPath, fs) {
41
41
  if (sourceCommentLanguage(entryPath) !== null) {
42
42
  result.push(entryPath);
43
43
  }
44
- }
45
- //# sourceMappingURL=source-walk.js.map
44
+ }
@@ -1,6 +1,8 @@
1
1
  import path from "node:path";
2
2
  import { defaultSkipDirectoryNames } from "#/core/workspace/skip-directories";
3
3
  /**
4
+ * Recursively collects the `.ts`/`.tsx` file paths under a root, skipping `.d.ts` and skip-listed directories.
5
+ *
4
6
  * @since 0.3.16-canary.0
5
7
  */
6
8
  export function walkTsxFiles(rootDirectoryPath, fs) {
@@ -25,5 +27,4 @@ function visitTsxPaths(result, entryPath, fs) {
25
27
  if (entryPath.endsWith(".tsx") || entryPath.endsWith(".ts")) {
26
28
  result.push(entryPath);
27
29
  }
28
- }
29
- //# sourceMappingURL=typescript-walk.js.map
30
+ }
@@ -1,11 +1,15 @@
1
1
  import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_SUCCESS } from "#/core/exit-codes";
2
2
  /**
3
+ * Maps a mirror run's stats to the process exit code.
4
+ *
3
5
  * @since 0.3.16-canary.0
4
6
  */
5
7
  export function exitCodeForMirrorSyncResult(stats) {
6
8
  return stats.packagesErrored > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
7
9
  }
8
10
  /**
11
+ * Serializes a mirror run's stats as the single-line JSON summary printed under `--json`.
12
+ *
9
13
  * @since 0.3.16-canary.0
10
14
  */
11
15
  export function formatMirrorSyncJsonOutput(stats, elapsedSeconds, write = true) {
@@ -16,5 +20,4 @@ export function formatMirrorSyncJsonOutput(stats, elapsedSeconds, write = true)
16
20
  elapsedSeconds,
17
21
  stats,
18
22
  });
19
- }
20
- //# sourceMappingURL=cli-result.js.map
23
+ }
@@ -1,5 +1,7 @@
1
1
  import { z } from "zod";
2
2
  /**
3
+ * Zod schema validating a `MirrorSyncRunRequest`.
4
+ *
3
5
  * @since 0.3.16-canary.0
4
6
  */
5
7
  export const mirrorSyncRunRequestSchema = z.object({
@@ -7,5 +9,4 @@ export const mirrorSyncRunRequestSchema = z.object({
7
9
  packageFilter: z.string().optional(),
8
10
  config: z.unknown().optional(),
9
11
  write: z.boolean().optional(),
10
- });
11
- //# sourceMappingURL=cli-schema.js.map
12
+ });
@@ -12,6 +12,8 @@ import { MirrorSyncProgressPresenter } from "#/mirror/output";
12
12
  import { prepareMirrorSync } from "#/mirror/prepare";
13
13
  import { runMirrorSync } from "#/mirror/sync";
14
14
  /**
15
+ * Creates the `mirror` subcommand, which writes `package.json#exports` from `dist/`.
16
+ *
15
17
  * @since 0.3.16-canary.0
16
18
  */
17
19
  export function createMirrorCommand() {
@@ -69,5 +71,4 @@ export function createMirrorCommand() {
69
71
  process.exitCode = exitCodeForMirrorSyncResult(outcome.value);
70
72
  });
71
73
  return cmd;
72
- }
73
- //# sourceMappingURL=command.js.map
74
+ }
@@ -2,6 +2,8 @@ import path from "node:path";
2
2
  import { isDirentList } from "#/mirror/domain/dirent-guard";
3
3
  import { normalizePath } from "#/mirror/domain/path-normalizer";
4
4
  /**
5
+ * Creates the `DistFilesystem` the mirror scan uses, backed by a `FilesystemPort`.
6
+ *
5
7
  * @since 0.3.16-canary.0
6
8
  */
7
9
  export function createMirrorDistFilesystem(fs) {
@@ -49,5 +51,4 @@ function isKnownReadDirError(caughtError) {
49
51
  caughtError !== null &&
50
52
  "code" in caughtError &&
51
53
  (caughtError.code === "ENOENT" || caughtError.code === "EACCES"));
52
- }
53
- //# sourceMappingURL=dist-filesystem-impl.js.map
54
+ }
@@ -1,21 +1,30 @@
1
1
  /**
2
+ * The build output directory the mirror scan reads.
3
+ *
2
4
  * @since 0.3.16-canary.0
3
5
  */
4
6
  export const DIST_DIR = "dist";
5
7
  /**
8
+ * The manifest file name the mirror rewrites.
9
+ *
6
10
  * @since 0.3.16-canary.0
7
11
  */
8
12
  export const PACKAGE_JSON = "package.json";
9
13
  /**
14
+ * The JavaScript extensions accepted as runtime entries in `dist/`.
15
+ *
10
16
  * @since 0.3.16-canary.0
11
17
  */
12
18
  export const VALID_JS_EXTENSIONS = new Set([".js", ".mjs", ".cjs"]);
13
19
  /**
20
+ * The declaration-file extensions accepted as type entries in `dist/`.
21
+ *
14
22
  * @since 0.3.16-canary.0
15
23
  */
16
24
  export const VALID_DTS_EXTENSIONS = new Set([".d.ts", ".d.mts", ".d.cts"]);
17
25
  /**
26
+ * The `package.json` self-export specifier every generated map includes.
27
+ *
18
28
  * @since 0.3.16-canary.0
19
29
  */
20
- export const PACKAGE_JSON_EXPORT = "./package.json";
21
- //# sourceMappingURL=constants.js.map
30
+ export const PACKAGE_JSON_EXPORT = "./package.json";
@@ -12,5 +12,4 @@ export function isDirentList(x) {
12
12
  }
13
13
  const first = x[0];
14
14
  return typeof first === "object" && first !== null && "isFile" in first && "isDirectory" in first;
15
- }
16
- //# sourceMappingURL=dirent-guard.js.map
15
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=dist-filesystem.js.map
1
+ export {};
@@ -1,4 +1,6 @@
1
1
  /**
2
+ * The error codes a mirror run can fail with.
3
+ *
2
4
  * @since 0.3.16-canary.0
3
5
  */
4
6
  export const MirrorErrorCode = {
@@ -6,6 +8,8 @@ export const MirrorErrorCode = {
6
8
  PACKAGE_WRITE: "PACKAGE_WRITE",
7
9
  };
8
10
  /**
11
+ * An `Error` carrying a `MirrorErrorCode` for mirror-specific failures.
12
+ *
9
13
  * @since 0.3.16-canary.0
10
14
  */
11
15
  export class MirrorError extends Error {
@@ -15,5 +19,4 @@ export class MirrorError extends Error {
15
19
  this.name = "MirrorError";
16
20
  this.code = code;
17
21
  }
18
- }
19
- //# sourceMappingURL=errors.js.map
22
+ }
@@ -91,6 +91,8 @@ function getExportSortGroup(exportPath, pathTransform) {
91
91
  return [group, subpath, EXPORT_GROUP_ORDER[group] ?? 700, 1];
92
92
  }
93
93
  /**
94
+ * Creates a transform that strips a configured prefix from export paths, or `null` when none is set.
95
+ *
94
96
  * @since 0.3.16-canary.0
95
97
  */
96
98
  export function createPathTransform(strip) {
@@ -217,6 +219,8 @@ function createExcludeMatcher(patterns) {
217
219
  };
218
220
  }
219
221
  /**
222
+ * Generates a package's `package.json#exports` map from its `dist/` contents.
223
+ *
220
224
  * @since 0.5.0-canary.8
221
225
  */
222
226
  export async function generateExports(fileSystemService, distDir, pathTransform, cssConfig, extraExports, options) {
@@ -316,5 +320,4 @@ export async function generateExports(fileSystemService, distDir, pathTransform,
316
320
  jsCount: Object.keys(moduleExportsBySpecifier).length,
317
321
  cssCount: Object.keys(cssExports).length,
318
322
  };
319
- }
320
- //# sourceMappingURL=exports.js.map
323
+ }
@@ -6,5 +6,4 @@
6
6
  export function resolvePackageDisplayName(packageJson, folderBasename) {
7
7
  const declaredName = packageJson.name;
8
8
  return typeof declaredName === "string" && declaredName.length > 0 ? declaredName : folderBasename;
9
- }
10
- //# sourceMappingURL=package-display-name.js.map
9
+ }
@@ -1,8 +1,9 @@
1
1
  import path from "node:path";
2
2
  /**
3
+ * Converts a path's separators to forward slashes.
4
+ *
3
5
  * @since 0.3.16-canary.0
4
6
  */
5
7
  export function normalizePath(pathString) {
6
8
  return pathString.split(path.sep).join("/").replace(/\\/g, "/");
7
- }
8
- //# sourceMappingURL=path-normalizer.js.map
9
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
1
+ export {};
@@ -2,6 +2,8 @@ import { logger } from "#/core/logger";
2
2
  import { MirrorSyncReporter } from "#/mirror/sync-reporter";
3
3
  const cliLogger = logger;
4
4
  /**
5
+ * A progress listener that renders mirror run events through the CLI reporter.
6
+ *
5
7
  * @since 0.3.16-canary.0
6
8
  */
7
9
  export class MirrorSyncProgressPresenter {
@@ -43,5 +45,4 @@ export class MirrorSyncProgressPresenter {
43
45
  this.reporter.mirrorSummarySeparator(cliLogger);
44
46
  this.reporter.mirrorSummary(cliLogger, stats, elapsedSeconds);
45
47
  }
46
- }
47
- //# sourceMappingURL=output.js.map
48
+ }