@codefast/cli 0.8.0 → 0.9.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 (230) hide show
  1. package/CHANGELOG.md +568 -0
  2. package/LICENSE +1 -1
  3. package/README.md +150 -50
  4. package/dist/arrange/analyze.js +1 -2
  5. package/dist/arrange/cli-schema.js +1 -2
  6. package/dist/arrange/command.js +1 -2
  7. package/dist/arrange/domain/analyze-service.js +1 -2
  8. package/dist/arrange/domain/ast/ast-node.js +1 -2
  9. package/dist/arrange/domain/ast/collectors-cn.js +1 -2
  10. package/dist/arrange/domain/ast/collectors-jsx.js +1 -2
  11. package/dist/arrange/domain/ast/collectors-tv.js +1 -2
  12. package/dist/arrange/domain/ast/helpers.js +1 -2
  13. package/dist/arrange/domain/ast/simplify-targets.js +1 -2
  14. package/dist/arrange/domain/ast/targets.js +1 -2
  15. package/dist/arrange/domain/constants.js +1 -2
  16. package/dist/arrange/domain/grouping-service.js +1 -2
  17. package/dist/arrange/domain/grouping.js +1 -2
  18. package/dist/arrange/domain/imports.js +1 -2
  19. package/dist/arrange/domain/source-text-formatters.js +1 -2
  20. package/dist/arrange/domain/tailwind-token.js +1 -2
  21. package/dist/arrange/domain/token-classifier.js +1 -2
  22. package/dist/arrange/domain/types.js +1 -2
  23. package/dist/arrange/output.js +1 -2
  24. package/dist/arrange/process-file.js +1 -2
  25. package/dist/arrange/resolve-target.js +1 -2
  26. package/dist/arrange/scan-target.js +1 -2
  27. package/dist/arrange/simplify-process-file.js +1 -2
  28. package/dist/arrange/simplify-sync.js +1 -2
  29. package/dist/arrange/source-parse.js +1 -2
  30. package/dist/arrange/suggest.js +1 -2
  31. package/dist/arrange/sync.js +1 -2
  32. package/dist/arrange/typescript-ast-translator.js +1 -2
  33. package/dist/arrange/workspace.js +1 -2
  34. package/dist/audit/cli-schema.js +12 -2
  35. package/dist/audit/command.js +44 -5
  36. package/dist/audit/domain/audit-file.js +2 -3
  37. package/dist/audit/domain/comment-content.js +1 -2
  38. package/dist/audit/domain/comment-dividers.js +49 -22
  39. package/dist/audit/domain/display-names.js +71 -0
  40. package/dist/audit/domain/link-references.js +1 -2
  41. package/dist/audit/domain/mappings.js +1 -2
  42. package/dist/audit/domain/markdown-links.js +1 -2
  43. package/dist/audit/domain/react-imports.js +1 -2
  44. package/dist/audit/domain/since-versions.js +1 -2
  45. package/dist/audit/domain/tokenize.js +2 -3
  46. package/dist/audit/domain/tsdoc-syntax.js +1 -2
  47. package/dist/audit/domain/types.js +1 -2
  48. package/dist/audit/output.js +41 -1
  49. package/dist/audit/prepare.js +31 -1
  50. package/dist/audit/run-comments.js +23 -20
  51. package/dist/audit/run-display-names.js +60 -0
  52. package/dist/audit/run-links.js +1 -2
  53. package/dist/audit/run-react.js +1 -2
  54. package/dist/audit/run.js +1 -2
  55. package/dist/bin.js +1 -2
  56. package/dist/cli.js +3 -2
  57. package/dist/core/cli/format-error.js +1 -2
  58. package/dist/core/cli/global-options.js +1 -2
  59. package/dist/core/cli/positional.js +1 -2
  60. package/dist/core/cli/result-handle.js +1 -22
  61. package/dist/core/config/loader.js +1 -2
  62. package/dist/core/config/schema.js +19 -10
  63. package/dist/core/config/warnings.js +1 -2
  64. package/dist/core/config.js +1 -2
  65. package/dist/core/errors.js +1 -2
  66. package/dist/core/exit-codes.js +1 -2
  67. package/dist/core/filesystem/node.js +1 -2
  68. package/dist/core/filesystem/port.js +1 -2
  69. package/dist/core/glob.js +1 -2
  70. package/dist/core/logger.js +1 -2
  71. package/dist/core/result.js +1 -2
  72. package/dist/core/schema-parse.js +1 -2
  73. package/dist/core/source-text-edit.js +1 -2
  74. package/dist/core/verbose-diagnostics.js +1 -2
  75. package/dist/core/workspace/markdown-walk.js +1 -2
  76. package/dist/core/workspace/package-version.js +1 -2
  77. package/dist/core/workspace/resolver.js +1 -2
  78. package/dist/core/workspace/skip-directories.js +1 -2
  79. package/dist/core/workspace/source-walk.js +14 -4
  80. package/dist/core/workspace/typescript-walk.js +1 -2
  81. package/dist/mirror/cli-result.js +1 -2
  82. package/dist/mirror/cli-schema.js +1 -2
  83. package/dist/mirror/command.js +1 -2
  84. package/dist/mirror/dist-filesystem-impl.js +1 -2
  85. package/dist/mirror/domain/constants.js +1 -2
  86. package/dist/mirror/domain/dirent-guard.js +1 -2
  87. package/dist/mirror/domain/dist-filesystem.js +1 -2
  88. package/dist/mirror/domain/errors.js +1 -2
  89. package/dist/mirror/domain/exports.js +1 -2
  90. package/dist/mirror/domain/package-display-name.js +1 -2
  91. package/dist/mirror/domain/path-normalizer.js +1 -2
  92. package/dist/mirror/domain/types.js +1 -2
  93. package/dist/mirror/output.js +1 -2
  94. package/dist/mirror/package-path.js +1 -2
  95. package/dist/mirror/prepare.js +1 -2
  96. package/dist/mirror/supplement-exports.js +1 -2
  97. package/dist/mirror/sync-reporter.js +1 -2
  98. package/dist/mirror/sync-types.js +1 -2
  99. package/dist/mirror/sync-workspace-package.js +1 -2
  100. package/dist/mirror/sync.js +1 -2
  101. package/dist/mirror/write-exports.js +1 -2
  102. package/dist/pack-slim/cli-result.js +23 -0
  103. package/dist/pack-slim/cli-schema.js +11 -0
  104. package/dist/pack-slim/command.js +80 -0
  105. package/dist/pack-slim/domain/transform.js +221 -0
  106. package/dist/pack-slim/domain/types.js +2 -0
  107. package/dist/pack-slim/output.js +62 -0
  108. package/dist/pack-slim/sync.js +157 -0
  109. package/dist/pack-slim/working-tree.js +45 -0
  110. package/dist/tag/cli-result.js +1 -2
  111. package/dist/tag/cli-schema.js +1 -2
  112. package/dist/tag/command.js +1 -2
  113. package/dist/tag/domain/types.js +1 -2
  114. package/dist/tag/output.js +1 -2
  115. package/dist/tag/prepare.js +1 -2
  116. package/dist/tag/resolve-target-path.js +1 -2
  117. package/dist/tag/since-writer.js +1 -2
  118. package/dist/tag/sync.js +1 -2
  119. package/dist/tag/target-candidates.js +1 -2
  120. package/dist/tag/target-runner.js +1 -2
  121. package/dist/tag/version-resolver.js +1 -2
  122. package/package.json +8 -43
  123. package/dist/arrange/analyze.js.map +0 -1
  124. package/dist/arrange/cli-schema.js.map +0 -1
  125. package/dist/arrange/command.js.map +0 -1
  126. package/dist/arrange/domain/analyze-service.js.map +0 -1
  127. package/dist/arrange/domain/ast/ast-node.js.map +0 -1
  128. package/dist/arrange/domain/ast/collectors-cn.js.map +0 -1
  129. package/dist/arrange/domain/ast/collectors-jsx.js.map +0 -1
  130. package/dist/arrange/domain/ast/collectors-tv.js.map +0 -1
  131. package/dist/arrange/domain/ast/helpers.js.map +0 -1
  132. package/dist/arrange/domain/ast/simplify-targets.js.map +0 -1
  133. package/dist/arrange/domain/ast/targets.js.map +0 -1
  134. package/dist/arrange/domain/constants.js.map +0 -1
  135. package/dist/arrange/domain/grouping-service.js.map +0 -1
  136. package/dist/arrange/domain/grouping.js.map +0 -1
  137. package/dist/arrange/domain/imports.js.map +0 -1
  138. package/dist/arrange/domain/source-text-formatters.js.map +0 -1
  139. package/dist/arrange/domain/tailwind-token.js.map +0 -1
  140. package/dist/arrange/domain/token-classifier.js.map +0 -1
  141. package/dist/arrange/domain/types.js.map +0 -1
  142. package/dist/arrange/output.js.map +0 -1
  143. package/dist/arrange/process-file.js.map +0 -1
  144. package/dist/arrange/resolve-target.js.map +0 -1
  145. package/dist/arrange/scan-target.js.map +0 -1
  146. package/dist/arrange/simplify-process-file.js.map +0 -1
  147. package/dist/arrange/simplify-sync.js.map +0 -1
  148. package/dist/arrange/source-parse.js.map +0 -1
  149. package/dist/arrange/suggest.js.map +0 -1
  150. package/dist/arrange/sync.js.map +0 -1
  151. package/dist/arrange/typescript-ast-translator.js.map +0 -1
  152. package/dist/arrange/workspace.js.map +0 -1
  153. package/dist/audit/cli-schema.js.map +0 -1
  154. package/dist/audit/command.js.map +0 -1
  155. package/dist/audit/domain/audit-file.js.map +0 -1
  156. package/dist/audit/domain/comment-content.js.map +0 -1
  157. package/dist/audit/domain/comment-dividers.js.map +0 -1
  158. package/dist/audit/domain/link-references.js.map +0 -1
  159. package/dist/audit/domain/mappings.js.map +0 -1
  160. package/dist/audit/domain/markdown-links.js.map +0 -1
  161. package/dist/audit/domain/react-imports.js.map +0 -1
  162. package/dist/audit/domain/since-versions.js.map +0 -1
  163. package/dist/audit/domain/tokenize.js.map +0 -1
  164. package/dist/audit/domain/tsdoc-syntax.js.map +0 -1
  165. package/dist/audit/domain/types.js.map +0 -1
  166. package/dist/audit/output.js.map +0 -1
  167. package/dist/audit/prepare.js.map +0 -1
  168. package/dist/audit/run-comments.js.map +0 -1
  169. package/dist/audit/run-links.js.map +0 -1
  170. package/dist/audit/run-react.js.map +0 -1
  171. package/dist/audit/run.js.map +0 -1
  172. package/dist/bin.js.map +0 -1
  173. package/dist/cli.js.map +0 -1
  174. package/dist/core/cli/format-error.js.map +0 -1
  175. package/dist/core/cli/global-options.js.map +0 -1
  176. package/dist/core/cli/positional.js.map +0 -1
  177. package/dist/core/cli/result-handle.js.map +0 -1
  178. package/dist/core/config/loader.js.map +0 -1
  179. package/dist/core/config/schema.js.map +0 -1
  180. package/dist/core/config/warnings.js.map +0 -1
  181. package/dist/core/config.js.map +0 -1
  182. package/dist/core/errors.js.map +0 -1
  183. package/dist/core/exit-codes.js.map +0 -1
  184. package/dist/core/filesystem/node.js.map +0 -1
  185. package/dist/core/filesystem/port.js.map +0 -1
  186. package/dist/core/glob.js.map +0 -1
  187. package/dist/core/logger.js.map +0 -1
  188. package/dist/core/result.js.map +0 -1
  189. package/dist/core/schema-parse.js.map +0 -1
  190. package/dist/core/source-text-edit.js.map +0 -1
  191. package/dist/core/verbose-diagnostics.js.map +0 -1
  192. package/dist/core/workspace/markdown-walk.js.map +0 -1
  193. package/dist/core/workspace/package-version.js.map +0 -1
  194. package/dist/core/workspace/resolver.js.map +0 -1
  195. package/dist/core/workspace/skip-directories.js.map +0 -1
  196. package/dist/core/workspace/source-walk.js.map +0 -1
  197. package/dist/core/workspace/typescript-walk.js.map +0 -1
  198. package/dist/mirror/cli-result.js.map +0 -1
  199. package/dist/mirror/cli-schema.js.map +0 -1
  200. package/dist/mirror/command.js.map +0 -1
  201. package/dist/mirror/dist-filesystem-impl.js.map +0 -1
  202. package/dist/mirror/domain/constants.js.map +0 -1
  203. package/dist/mirror/domain/dirent-guard.js.map +0 -1
  204. package/dist/mirror/domain/dist-filesystem.js.map +0 -1
  205. package/dist/mirror/domain/errors.js.map +0 -1
  206. package/dist/mirror/domain/exports.js.map +0 -1
  207. package/dist/mirror/domain/package-display-name.js.map +0 -1
  208. package/dist/mirror/domain/path-normalizer.js.map +0 -1
  209. package/dist/mirror/domain/types.js.map +0 -1
  210. package/dist/mirror/output.js.map +0 -1
  211. package/dist/mirror/package-path.js.map +0 -1
  212. package/dist/mirror/prepare.js.map +0 -1
  213. package/dist/mirror/supplement-exports.js.map +0 -1
  214. package/dist/mirror/sync-reporter.js.map +0 -1
  215. package/dist/mirror/sync-types.js.map +0 -1
  216. package/dist/mirror/sync-workspace-package.js.map +0 -1
  217. package/dist/mirror/sync.js.map +0 -1
  218. package/dist/mirror/write-exports.js.map +0 -1
  219. package/dist/tag/cli-result.js.map +0 -1
  220. package/dist/tag/cli-schema.js.map +0 -1
  221. package/dist/tag/command.js.map +0 -1
  222. package/dist/tag/domain/types.js.map +0 -1
  223. package/dist/tag/output.js.map +0 -1
  224. package/dist/tag/prepare.js.map +0 -1
  225. package/dist/tag/resolve-target-path.js.map +0 -1
  226. package/dist/tag/since-writer.js.map +0 -1
  227. package/dist/tag/sync.js.map +0 -1
  228. package/dist/tag/target-candidates.js.map +0 -1
  229. package/dist/tag/target-runner.js.map +0 -1
  230. package/dist/tag/version-resolver.js.map +0 -1
@@ -17,26 +17,6 @@ function exitCodeForAppError(error) {
17
17
  }
18
18
  }
19
19
  }
20
- /**
21
- * Narrows a `Result` by invoking `onSuccess` on success, or reporting the error and setting the exit code.
22
- *
23
- * @since 0.3.16-canary.0
24
- */
25
- export function handleResult(outcome, onSuccess) {
26
- if (!outcome.ok) {
27
- logger.err(formatAppError(outcome.error));
28
- if (isVerboseCliDiagnostics() &&
29
- outcome.error.code === "INFRA_FAILURE" &&
30
- outcome.error.cause instanceof Error &&
31
- outcome.error.cause.stack !== undefined) {
32
- logger.err(outcome.error.cause.stack);
33
- }
34
- process.exitCode = exitCodeForAppError(outcome.error);
35
- return false;
36
- }
37
- onSuccess(outcome.value);
38
- return true;
39
- }
40
20
  /**
41
21
  * Narrows a `Result`, reporting a failure and setting the exit code, or logging an optional success message.
42
22
  *
@@ -71,5 +51,4 @@ export async function runCliResultAsync(outcomePromise, onSuccess) {
71
51
  }
72
52
  const exit = await onSuccess(outcome.value);
73
53
  process.exitCode = exit === undefined ? 0 : exit;
74
- }
75
- //# sourceMappingURL=result-handle.js.map
54
+ }
@@ -86,5 +86,4 @@ export function loadConfigPayload(startDir, fs) {
86
86
  throw new Error("config loader cache invariant violated");
87
87
  }
88
88
  return cached;
89
- }
90
- //# 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. */
@@ -53,7 +53,7 @@ export const mirrorConfigSchema = z.record(z.string(), z.union([z.literal(false)
53
53
  *
54
54
  * @since 0.3.16-canary.0
55
55
  */
56
- export const codefastTagConfigSchema = z
56
+ const codefastTagConfigSchema = z
57
57
  .object({
58
58
  skipPackages: z.array(z.string()).optional(),
59
59
  onAfterWrite: afterWriteHookSchema.optional(),
@@ -64,7 +64,7 @@ export const codefastTagConfigSchema = z
64
64
  *
65
65
  * @since 0.3.16-canary.0
66
66
  */
67
- export const codefastArrangeConfigSchema = z
67
+ const codefastArrangeConfigSchema = z
68
68
  .object({
69
69
  onAfterWrite: afterWriteHookSchema.optional(),
70
70
  })
@@ -74,7 +74,7 @@ export const codefastArrangeConfigSchema = z
74
74
  *
75
75
  * @since 0.3.16-canary.0
76
76
  */
77
- export const codefastAuditRtlConfigSchema = z
77
+ const codefastAuditRtlConfigSchema = z
78
78
  .object({
79
79
  /** Directory or file to scan when no CLI target is passed. */
80
80
  target: z.string().optional(),
@@ -87,7 +87,7 @@ export const codefastAuditRtlConfigSchema = z
87
87
  *
88
88
  * @since 0.5.0
89
89
  */
90
- export const codefastAuditLinksConfigSchema = z
90
+ const codefastAuditLinksConfigSchema = z
91
91
  .object({
92
92
  /** Bare link targets or `repo/relative/doc.md:target` entries to ignore. */
93
93
  allowlist: z.array(z.string()).optional(),
@@ -98,7 +98,7 @@ export const codefastAuditLinksConfigSchema = z
98
98
  *
99
99
  * @since 0.6.0
100
100
  */
101
- export const codefastAuditCommentsConfigSchema = z
101
+ const codefastAuditCommentsConfigSchema = z
102
102
  .object({
103
103
  /** Divider lines as written, or `repo/relative/path.ts:<divider>` entries, to ignore. */
104
104
  allowlist: z.array(z.string()).optional(),
@@ -110,23 +110,33 @@ export const codefastAuditCommentsConfigSchema = z
110
110
  *
111
111
  * @since 0.8.0
112
112
  */
113
- export const codefastAuditReactConfigSchema = z
113
+ const codefastAuditReactConfigSchema = z
114
114
  .object({
115
115
  /** Offending source text as written, or `repo/relative/path.tsx:<text>` entries, to ignore. */
116
116
  allowlist: z.array(z.string()).optional(),
117
117
  })
118
118
  .strict();
119
+ /**
120
+ * Display-name audit defaults — the scan always starts at the repo root, so only exceptions are configured.
121
+ */
122
+ const codefastAuditDisplayNamesConfigSchema = z
123
+ .object({
124
+ /** Offending calls as written, or `repo/relative/path.ts:<call>` entries, to ignore. */
125
+ allowlist: z.array(z.string()).optional(),
126
+ })
127
+ .strict();
119
128
  /**
120
129
  * Zod schema grouping the per-audit configurations under `audit`.
121
130
  *
122
131
  * @since 0.3.16-canary.0
123
132
  */
124
- export const codefastAuditConfigSchema = z
133
+ const codefastAuditConfigSchema = z
125
134
  .object({
126
135
  rtl: codefastAuditRtlConfigSchema.optional(),
127
136
  links: codefastAuditLinksConfigSchema.optional(),
128
137
  comments: codefastAuditCommentsConfigSchema.optional(),
129
138
  react: codefastAuditReactConfigSchema.optional(),
139
+ displayNames: codefastAuditDisplayNamesConfigSchema.optional(),
130
140
  })
131
141
  .strict();
132
142
  /**
@@ -141,5 +151,4 @@ export const codefastConfigRootSchema = z
141
151
  arrange: codefastArrangeConfigSchema.optional(),
142
152
  audit: codefastAuditConfigSchema.optional(),
143
153
  })
144
- .strict();
145
- //# sourceMappingURL=schema.js.map
154
+ .strict();
@@ -10,5 +10,4 @@ export function reportSchemaWarnings(warnings) {
10
10
  for (const warningMessage of warnings) {
11
11
  logger.out(`${yellowAnsi}⚠ ${warningMessage}${resetAnsi}`);
12
12
  }
13
- }
14
- //# sourceMappingURL=warnings.js.map
13
+ }
@@ -16,5 +16,4 @@ export async function loadCodefastConfig(rootDir, fs) {
16
16
  catch (caughtError) {
17
17
  return err(new AppError("INFRA_FAILURE", messageFrom(caughtError), caughtError));
18
18
  }
19
- }
20
- //# sourceMappingURL=config.js.map
19
+ }
@@ -56,5 +56,4 @@ export function messageFrom(value) {
56
56
  // Circular structure, BigInt in tree, etc.
57
57
  }
58
58
  return "[unserializable non-Error value]";
59
- }
60
- //# sourceMappingURL=errors.js.map
59
+ }
@@ -15,5 +15,4 @@ export const CLI_EXIT_GENERAL_ERROR = 1;
15
15
  *
16
16
  * @since 0.3.16-canary.0
17
17
  */
18
- export const CLI_EXIT_USAGE = 2;
19
- //# sourceMappingURL=exit-codes.js.map
18
+ export const CLI_EXIT_USAGE = 2;
@@ -31,5 +31,4 @@ export const nodeFilesystem = {
31
31
  },
32
32
  rename: (oldPath, newPath) => fsPromises.rename(oldPath, newPath),
33
33
  unlink: (filePath) => fsPromises.unlink(filePath),
34
- };
35
- //# 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
+ }
@@ -11,5 +11,4 @@ export const logger = {
11
11
  err(line) {
12
12
  process.stderr.write(`${line}\n`);
13
13
  },
14
- };
15
- //# sourceMappingURL=logger.js.map
14
+ };
@@ -16,5 +16,4 @@ export function ok(value) {
16
16
  */
17
17
  export function err(error) {
18
18
  return { ok: false, error };
19
- }
20
- //# sourceMappingURL=result.js.map
19
+ }
@@ -19,5 +19,4 @@ export function parseWithSchema(schema, input) {
19
19
  return err(new AppError("VALIDATION_ERROR", formatSchemaIssues(parsed.error.issues)));
20
20
  }
21
21
  return ok(parsed.data);
22
- }
23
- //# sourceMappingURL=schema-parse.js.map
22
+ }
@@ -66,5 +66,4 @@ export function applyEditsDescending(sourceText, edits) {
66
66
  out = out.slice(0, edit.start) + edit.replacement + out.slice(edit.end);
67
67
  }
68
68
  return out;
69
- }
70
- //# sourceMappingURL=source-text-edit.js.map
69
+ }
@@ -7,5 +7,4 @@ import process from "node:process";
7
7
  export function isVerboseCliDiagnostics() {
8
8
  const raw = process.env.CODEFAST_VERBOSE;
9
9
  return raw === "1" || raw === "true";
10
- }
11
- //# 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
+ }
@@ -21,5 +21,4 @@ function findNearestPackageVersion(fs, targetPath) {
21
21
  current = parent;
22
22
  }
23
23
  }
24
- export { findNearestPackageVersion };
25
- //# sourceMappingURL=package-version.js.map
24
+ export { findNearestPackageVersion };
@@ -206,5 +206,4 @@ export async function listWorkspacePackageDirectories(rootDirectoryPathAbsolute,
206
206
  layoutSource,
207
207
  hasPnpmWorkspaceYamlFile,
208
208
  };
209
- }
210
- //# sourceMappingURL=resolver.js.map
209
+ }
@@ -17,5 +17,4 @@ export const defaultSkipDirectoryNames = new Set([
17
17
  ".output",
18
18
  ".tanstack",
19
19
  ".nitro",
20
- ]);
21
- //# sourceMappingURL=skip-directories.js.map
20
+ ]);
@@ -1,7 +1,15 @@
1
1
  import path from "node:path";
2
2
  import { defaultSkipDirectoryNames } from "#/core/workspace/skip-directories";
3
+ // Ignore files carry the divider convention over `#` comments — the content rules stay code-only.
4
+ const ignoreFileNames = new Set([
5
+ ".gitignore",
6
+ ".dockerignore",
7
+ ".npmignore",
8
+ ".prettierignore",
9
+ ".eslintignore",
10
+ ]);
3
11
  /**
4
- * Every hand-written source file a comment convention applies to — `.ts`, `.tsx`, and `.css`.
12
+ * Every hand-written source file a comment convention applies to — `.ts`, `.tsx`, `.css`, and ignore files.
5
13
  *
6
14
  * @remarks Emitted declarations are excluded: they carry whatever the compiler copied over,
7
15
  * and rewriting them would be undone by the next build.
@@ -25,7 +33,10 @@ export function sourceCommentLanguage(filePath) {
25
33
  if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) {
26
34
  return "js";
27
35
  }
28
- return filePath.endsWith(".css") ? "css" : null;
36
+ if (filePath.endsWith(".css")) {
37
+ return "css";
38
+ }
39
+ return ignoreFileNames.has(path.basename(filePath)) ? "ignore" : null;
29
40
  }
30
41
  function visitSourcePaths(result, entryPath, fs) {
31
42
  const entryStats = fs.statSync(entryPath);
@@ -41,5 +52,4 @@ function visitSourcePaths(result, entryPath, fs) {
41
52
  if (sourceCommentLanguage(entryPath) !== null) {
42
53
  result.push(entryPath);
43
54
  }
44
- }
45
- //# sourceMappingURL=source-walk.js.map
55
+ }
@@ -27,5 +27,4 @@ function visitTsxPaths(result, entryPath, fs) {
27
27
  if (entryPath.endsWith(".tsx") || entryPath.endsWith(".ts")) {
28
28
  result.push(entryPath);
29
29
  }
30
- }
31
- //# sourceMappingURL=typescript-walk.js.map
30
+ }
@@ -20,5 +20,4 @@ export function formatMirrorSyncJsonOutput(stats, elapsedSeconds, write = true)
20
20
  elapsedSeconds,
21
21
  stats,
22
22
  });
23
- }
24
- //# sourceMappingURL=cli-result.js.map
23
+ }
@@ -9,5 +9,4 @@ export const mirrorSyncRunRequestSchema = z.object({
9
9
  packageFilter: z.string().optional(),
10
10
  config: z.unknown().optional(),
11
11
  write: z.boolean().optional(),
12
- });
13
- //# sourceMappingURL=cli-schema.js.map
12
+ });
@@ -71,5 +71,4 @@ export function createMirrorCommand() {
71
71
  process.exitCode = exitCodeForMirrorSyncResult(outcome.value);
72
72
  });
73
73
  return cmd;
74
- }
75
- //# sourceMappingURL=command.js.map
74
+ }
@@ -51,5 +51,4 @@ function isKnownReadDirError(caughtError) {
51
51
  caughtError !== null &&
52
52
  "code" in caughtError &&
53
53
  (caughtError.code === "ENOENT" || caughtError.code === "EACCES"));
54
- }
55
- //# sourceMappingURL=dist-filesystem-impl.js.map
54
+ }
@@ -27,5 +27,4 @@ export const VALID_DTS_EXTENSIONS = new Set([".d.ts", ".d.mts", ".d.cts"]);
27
27
  *
28
28
  * @since 0.3.16-canary.0
29
29
  */
30
- export const PACKAGE_JSON_EXPORT = "./package.json";
31
- //# 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 {};
@@ -19,5 +19,4 @@ export class MirrorError extends Error {
19
19
  this.name = "MirrorError";
20
20
  this.code = code;
21
21
  }
22
- }
23
- //# sourceMappingURL=errors.js.map
22
+ }
@@ -320,5 +320,4 @@ export async function generateExports(fileSystemService, distDir, pathTransform,
320
320
  jsCount: Object.keys(moduleExportsBySpecifier).length,
321
321
  cssCount: Object.keys(cssExports).length,
322
322
  };
323
- }
324
- //# 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
+ }
@@ -6,5 +6,4 @@ import path from "node:path";
6
6
  */
7
7
  export function normalizePath(pathString) {
8
8
  return pathString.split(path.sep).join("/").replace(/\\/g, "/");
9
- }
10
- //# sourceMappingURL=path-normalizer.js.map
9
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
1
+ export {};
@@ -45,5 +45,4 @@ export class MirrorSyncProgressPresenter {
45
45
  this.reporter.mirrorSummarySeparator(cliLogger);
46
46
  this.reporter.mirrorSummary(cliLogger, stats, elapsedSeconds);
47
47
  }
48
- }
49
- //# sourceMappingURL=output.js.map
48
+ }
@@ -40,5 +40,4 @@ export function resolvePackageFilterUnderRoot(fs, rootDir, packageFilter) {
40
40
  return err(new AppError("VALIDATION_ERROR", `Package path must be a subdirectory under monorepo root: ${rootDir}`));
41
41
  }
42
42
  return ok(normalized);
43
- }
44
- //# sourceMappingURL=package-path.js.map
43
+ }
@@ -35,5 +35,4 @@ export async function prepareMirrorSync(fs, args) {
35
35
  config: loadedOutcome.value.config,
36
36
  packageFilter: filterOutcome.value,
37
37
  });
38
- }
39
- //# sourceMappingURL=prepare.js.map
38
+ }
@@ -155,5 +155,4 @@ export function buildSourcePathResolver(fs, packageDir) {
155
155
  const tsxPath = path.join(srcDir, `${modulePath}.tsx`);
156
156
  return fs.existsSync(tsxPath) ? `./src/${modulePath}.tsx` : `./src/${modulePath}.ts`;
157
157
  };
158
- }
159
- //# sourceMappingURL=supplement-exports.js.map
158
+ }
@@ -121,5 +121,4 @@ export class MirrorSyncReporter {
121
121
  }
122
122
  return `${openSequence}${text}${ANSI.reset}`;
123
123
  }
124
- }
125
- //# sourceMappingURL=sync-reporter.js.map
124
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=sync-types.js.map
1
+ export {};
@@ -116,5 +116,4 @@ export async function syncExportsForWorkspacePackage(fs, rootDir, packagePathStr
116
116
  pkgStats.error = messageFrom(caughtError);
117
117
  }
118
118
  return pkgStats;
119
- }
120
- //# sourceMappingURL=sync-workspace-package.js.map
119
+ }
@@ -88,5 +88,4 @@ function mirrorTargetsFromWorkspaceLayout(rootDir, layoutOutcome) {
88
88
  .filter((relativePath) => relativePath.length > 0);
89
89
  relPaths.sort((left, right) => left.localeCompare(right));
90
90
  return { relPaths, multiSource };
91
- }
92
- //# sourceMappingURL=sync.js.map
91
+ }
@@ -141,5 +141,4 @@ export async function writePackageJsonExportsAtomic(fs, packageJsonPath, mergeIn
141
141
  throw new MirrorError(MirrorErrorCode.PACKAGE_WRITE, `Failed to atomically update ${packageJsonPath}: ${messageFrom(caughtRenameError)}`, caughtRenameError instanceof Error ? { cause: caughtRenameError } : undefined);
142
142
  }
143
143
  return { prunedKeys };
144
- }
145
- //# sourceMappingURL=write-exports.js.map
144
+ }
@@ -0,0 +1,23 @@
1
+ import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_SUCCESS } from "#/core/exit-codes";
2
+ /**
3
+ * Maps a pack-slim run's stats to the process exit code.
4
+ *
5
+ * @since 0.8.1
6
+ */
7
+ export function exitCodeForPackSlimResult(stats) {
8
+ return stats.packagesErrored > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
9
+ }
10
+ /**
11
+ * Serializes a pack-slim run's stats as the single-line JSON summary printed under `--json`.
12
+ *
13
+ * @since 0.8.1
14
+ */
15
+ export function formatPackSlimJsonOutput(stats, elapsedSeconds, write = true) {
16
+ return JSON.stringify({
17
+ schemaVersion: 1,
18
+ ok: stats.packagesErrored === 0,
19
+ write,
20
+ elapsedSeconds,
21
+ stats,
22
+ });
23
+ }
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema validating the serializable inputs of a pack-slim run.
4
+ *
5
+ * @since 0.8.1
6
+ */
7
+ export const packSlimRunRequestSchema = z.object({
8
+ rootDir: z.string().min(1),
9
+ packageFilter: z.string().optional(),
10
+ write: z.boolean().optional(),
11
+ });
@@ -0,0 +1,80 @@
1
+ import process from "node:process";
2
+ import { Command } from "commander";
3
+ import { globalCliCommanderOptionsSchema } from "#/core/cli/global-options";
4
+ import { readOptionalPositionalArg } from "#/core/cli/positional";
5
+ import { consumeCliAppError } from "#/core/cli/result-handle";
6
+ import { AppError, messageFrom } from "#/core/errors";
7
+ import { nodeFilesystem } from "#/core/filesystem/node";
8
+ import { logger } from "#/core/logger";
9
+ import { err } from "#/core/result";
10
+ import { parseWithSchema } from "#/core/schema-parse";
11
+ import { findRepoRoot } from "#/core/workspace/resolver";
12
+ import { exitCodeForPackSlimResult, formatPackSlimJsonOutput } from "#/pack-slim/cli-result";
13
+ import { packSlimRunRequestSchema } from "#/pack-slim/cli-schema";
14
+ import { PackSlimProgressPresenter } from "#/pack-slim/output";
15
+ import { runPackSlim } from "#/pack-slim/sync";
16
+ import { ensureWorkingTreeClean } from "#/pack-slim/working-tree";
17
+ /**
18
+ * Creates the `pack-slim` subcommand, which slims published packages down to what a consumer reads before publish.
19
+ *
20
+ * @since 0.8.1
21
+ */
22
+ export function createPackSlimCommand() {
23
+ const cmd = new Command("pack-slim")
24
+ .description("Strip src, source conditions, unshipped imports, dev-only scripts, devDependencies, and dist source maps from " +
25
+ "published packages before publish")
26
+ .argument("[package]", "Optional package path relative to repo root (e.g. packages/ui)")
27
+ .option("--dry-run", "Report what would change without touching any file", false)
28
+ .option("--force", "Run even if the git working tree has uncommitted tracked changes", false)
29
+ .option("--json", "Print one JSON summary on stdout (suppresses human progress)", false)
30
+ .action(async (packageArg, opts, command) => {
31
+ const globalsOptionCarrier = command.optsWithGlobals?.() ??
32
+ command.opts();
33
+ const globalOptionsOutcome = parseWithSchema(globalCliCommanderOptionsSchema, globalsOptionCarrier);
34
+ if (!consumeCliAppError(globalOptionsOutcome)) {
35
+ return;
36
+ }
37
+ let rootDir;
38
+ try {
39
+ rootDir = findRepoRoot(process.cwd(), nodeFilesystem);
40
+ }
41
+ catch (caughtError) {
42
+ consumeCliAppError(err(new AppError("INFRA_FAILURE", messageFrom(caughtError), caughtError)));
43
+ return;
44
+ }
45
+ const write = !opts.dryRun;
46
+ // A destructive slim must never land on a developer's uncommitted work; --dry-run writes nothing, so it is exempt.
47
+ if (write && !opts.force) {
48
+ const cleanCheck = ensureWorkingTreeClean(rootDir);
49
+ if (!consumeCliAppError(cleanCheck)) {
50
+ return;
51
+ }
52
+ }
53
+ const parsed = parseWithSchema(packSlimRunRequestSchema, {
54
+ rootDir,
55
+ packageFilter: readOptionalPositionalArg(packageArg),
56
+ write,
57
+ });
58
+ if (!consumeCliAppError(parsed)) {
59
+ return;
60
+ }
61
+ const json = !!opts.json;
62
+ const presenter = new PackSlimProgressPresenter();
63
+ if (!json) {
64
+ presenter.configure({ dryRun: !write });
65
+ }
66
+ const startTime = performance.now();
67
+ const outcome = await runPackSlim(nodeFilesystem, {
68
+ ...parsed.value,
69
+ listener: json ? undefined : presenter,
70
+ });
71
+ if (!consumeCliAppError(outcome)) {
72
+ return;
73
+ }
74
+ if (json) {
75
+ logger.out(formatPackSlimJsonOutput(outcome.value, (performance.now() - startTime) / 1000, write));
76
+ }
77
+ process.exitCode = exitCodeForPackSlimResult(outcome.value);
78
+ });
79
+ return cmd;
80
+ }