@codefast/cli 0.3.14 → 0.3.16-canary.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 (189) hide show
  1. package/README.md +8 -3
  2. package/dist/arrange/analyze.mjs +24 -0
  3. package/dist/{lib/arrange/presentation/arrange-cli.schema.mjs → arrange/cli-schema.mjs} +10 -1
  4. package/dist/arrange/command.mjs +106 -0
  5. package/dist/{lib/arrange/domain/arrange-analyze.service.mjs → arrange/domain/analyze-service.mjs} +17 -10
  6. package/dist/{lib/arrange/domain/ast/ast-node.model.mjs → arrange/domain/ast/ast-node.mjs} +57 -3
  7. package/dist/{lib/arrange/domain/ast/collectors-cn.collector.mjs → arrange/domain/ast/collectors-cn.mjs} +21 -9
  8. package/dist/{lib/arrange/domain/ast/collectors-jsx.collector.mjs → arrange/domain/ast/collectors-jsx.mjs} +5 -2
  9. package/dist/{lib/arrange/domain/ast/collectors-tv.collector.mjs → arrange/domain/ast/collectors-tv.mjs} +21 -6
  10. package/dist/{lib/arrange/domain/ast/ast-helpers.helper.mjs → arrange/domain/ast/helpers.mjs} +26 -9
  11. package/dist/{lib/arrange/domain/ast/targets.model.mjs → arrange/domain/ast/targets.mjs} +19 -10
  12. package/dist/{lib/arrange/domain/constants.domain.mjs → arrange/domain/constants.mjs} +63 -18
  13. package/dist/{lib/arrange/domain/arrange-grouping.service.mjs → arrange/domain/grouping-service.mjs} +31 -10
  14. package/dist/{lib/arrange/domain/grouping.domain.mjs → arrange/domain/grouping.mjs} +39 -18
  15. package/dist/{lib/arrange/domain/imports.domain.mjs → arrange/domain/imports.mjs} +7 -3
  16. package/dist/{lib/arrange/domain/source-text-formatters.formatter.mjs → arrange/domain/source-text-formatters.mjs} +22 -5
  17. package/dist/{lib/arrange/domain/tailwind-token.value-object.mjs → arrange/domain/tailwind-token.mjs} +12 -3
  18. package/dist/{lib/arrange/domain/tailwind-token-classifier.domain-service.mjs → arrange/domain/token-classifier.mjs} +40 -15
  19. package/dist/arrange/output.mjs +79 -0
  20. package/dist/arrange/process-file.mjs +42 -0
  21. package/dist/arrange/resolve-target.mjs +24 -0
  22. package/dist/arrange/scan-target.mjs +20 -0
  23. package/dist/arrange/source-parse.mjs +18 -0
  24. package/dist/arrange/suggest.mjs +15 -0
  25. package/dist/arrange/sync.mjs +51 -0
  26. package/dist/arrange/typescript-ast-translator.mjs +354 -0
  27. package/dist/arrange/workspace.mjs +31 -0
  28. package/dist/bin.mjs +1 -1
  29. package/dist/{program.mjs → cli.mjs} +14 -19
  30. package/dist/core/cli/format-error.mjs +15 -0
  31. package/dist/core/cli/global-options.mjs +10 -0
  32. package/dist/core/cli/positional.mjs +11 -0
  33. package/dist/core/cli/result-handle.mjs +51 -0
  34. package/dist/core/config/loader.mjs +79 -0
  35. package/dist/{lib/config/infrastructure/config-schema.adapter.mjs → core/config/schema.mjs} +20 -6
  36. package/dist/core/config/warnings.mjs +12 -0
  37. package/dist/core/config.mjs +19 -0
  38. package/dist/{lib/core/domain/caught-unknown-message.value-object.mjs → core/errors.mjs} +20 -4
  39. package/dist/core/exit-codes.mjs +17 -0
  40. package/dist/core/filesystem/node.mjs +32 -0
  41. package/dist/core/logger.mjs +15 -0
  42. package/dist/{lib/core/domain/result.model.mjs → core/result.mjs} +7 -3
  43. package/dist/{lib/core/application/services/schema-validator.service.mjs → core/schema-parse.mjs} +6 -5
  44. package/dist/{lib/shared/source-code/domain/text-edit.model.mjs → core/source-text-edit.mjs} +15 -14
  45. package/dist/core/verbose-diagnostics.mjs +11 -0
  46. package/dist/core/workspace/resolver.mjs +177 -0
  47. package/dist/core/workspace/typescript-walk.mjs +36 -0
  48. package/dist/mirror/cli-result.mjs +21 -0
  49. package/dist/{lib/mirror/presentation/mirror-cli.schema.mjs → mirror/cli-schema.mjs} +4 -4
  50. package/dist/mirror/command.mjs +57 -0
  51. package/dist/mirror/dist-filesystem-impl.mjs +42 -0
  52. package/dist/{lib/mirror/domain/constants.domain.mjs → mirror/domain/constants.mjs} +16 -1
  53. package/dist/{lib/mirror/infrastructure/dirent-list.guard.mjs → mirror/domain/dirent-guard.mjs} +5 -2
  54. package/dist/{lib/mirror/domain/errors.domain.mjs → mirror/domain/errors.mjs} +7 -1
  55. package/dist/{lib/mirror/application/services/generate-mirror-exports.service.mjs → mirror/domain/exports.mjs} +17 -10
  56. package/dist/{lib/mirror/domain/package-display-name.policy.mjs → mirror/domain/package-display-name.mjs} +5 -2
  57. package/dist/{lib/mirror/domain/path-normalizer.value-object.mjs → mirror/domain/path-normalizer.mjs} +4 -1
  58. package/dist/mirror/output.mjs +45 -0
  59. package/dist/mirror/package-path.mjs +32 -0
  60. package/dist/mirror/prepare.mjs +33 -0
  61. package/dist/mirror/sync-reporter.mjs +104 -0
  62. package/dist/mirror/sync-workspace-package.mjs +103 -0
  63. package/dist/mirror/sync.mjs +87 -0
  64. package/dist/{lib/mirror/infrastructure/package-json-exports.repository.mjs → mirror/write-exports.mjs} +35 -31
  65. package/dist/tag/cli-result.mjs +11 -0
  66. package/dist/{lib/tag/presentation/tag-cli.schema.mjs → tag/cli-schema.mjs} +4 -1
  67. package/dist/tag/command.mjs +56 -0
  68. package/dist/{lib/tag/presentation/tag-sync.presenter.mjs → tag/output.mjs} +54 -28
  69. package/dist/tag/prepare.mjs +29 -0
  70. package/dist/tag/resolve-target-path.mjs +12 -0
  71. package/dist/tag/since-writer.mjs +130 -0
  72. package/dist/tag/sync.mjs +141 -0
  73. package/dist/tag/target-candidates.mjs +68 -0
  74. package/dist/tag/target-runner.mjs +26 -0
  75. package/dist/tag/version-resolver.mjs +25 -0
  76. package/package.json +8 -9
  77. package/dist/lib/arrange/adapters/primary/cli/arrange.command.mjs +0 -324
  78. package/dist/lib/arrange/adapters/primary/cli/arrange.presentation.module.mjs +0 -14
  79. package/dist/lib/arrange/adapters/primary/cli/presentation.tokens.mjs +0 -5
  80. package/dist/lib/arrange/adapters/secondary/domain-source-parser.adapter.mjs +0 -239
  81. package/dist/lib/arrange/adapters/secondary/file-walker.adapter.mjs +0 -241
  82. package/dist/lib/arrange/adapters/secondary/workspace-resolver.adapter.mjs +0 -233
  83. package/dist/lib/arrange/application/requests/suggest-groups.request.mjs +0 -1
  84. package/dist/lib/arrange/application/services/arrange-file-processor.service.mjs +0 -267
  85. package/dist/lib/arrange/application/services/arrange-target-path-resolver.service.mjs +0 -21
  86. package/dist/lib/arrange/application/services/arrange-target-scanner.service.mjs +0 -243
  87. package/dist/lib/arrange/application/use-cases/analyze-directory.use-case.mjs +0 -255
  88. package/dist/lib/arrange/application/use-cases/prepare-arrange-workspace.use-case.mjs +0 -263
  89. package/dist/lib/arrange/application/use-cases/run-arrange-sync.use-case.mjs +0 -274
  90. package/dist/lib/arrange/application/use-cases/suggest-cn-groups.use-case.mjs +0 -237
  91. package/dist/lib/arrange/arrange.module.mjs +0 -31
  92. package/dist/lib/arrange/contracts/analyze-report-presenter.contract.mjs +0 -1
  93. package/dist/lib/arrange/contracts/models.mjs +0 -1
  94. package/dist/lib/arrange/contracts/services.contract.mjs +0 -1
  95. package/dist/lib/arrange/contracts/tokens.mjs +0 -15
  96. package/dist/lib/arrange/domain/tailwind-grouping.service.mjs +0 -231
  97. package/dist/lib/arrange/domain/types.domain.mjs +0 -1
  98. package/dist/lib/arrange/infrastructure/typescript-ast-translator.adapter.mjs +0 -355
  99. package/dist/lib/arrange/presentation/arrange-analyze.presenter.mjs +0 -259
  100. package/dist/lib/arrange/presentation/arrange-sync.presenter.mjs +0 -33
  101. package/dist/lib/arrange/presentation/group-file-preview.presenter.mjs +0 -271
  102. package/dist/lib/bootstrap/composition-root.mjs +0 -33
  103. package/dist/lib/config/application/ports/config-loader.port.mjs +0 -1
  104. package/dist/lib/config/application/ports/config-warning-reporter.port.mjs +0 -1
  105. package/dist/lib/config/application/services/load-config.service.mjs +0 -17
  106. package/dist/lib/config/contracts/tokens.mjs +0 -6
  107. package/dist/lib/config/domain/schema.domain.mjs +0 -1
  108. package/dist/lib/config/infrastructure/config-loader.adapter.mjs +0 -306
  109. package/dist/lib/config/infrastructure/config-warning-reporter.adapter.mjs +0 -234
  110. package/dist/lib/core/application/load-codefast-config.use-case.mjs +0 -245
  111. package/dist/lib/core/application/ports/cli-io.port.mjs +0 -1
  112. package/dist/lib/core/application/ports/path.port.mjs +0 -1
  113. package/dist/lib/core/application/ports/repo-root-resolver.port.mjs +0 -1
  114. package/dist/lib/core/application/ports/runtime.port.mjs +0 -1
  115. package/dist/lib/core/application/services/global-cli-options-parser.service.mjs +0 -9
  116. package/dist/lib/core/contracts/tokens.mjs +0 -10
  117. package/dist/lib/core/core.module.mjs +0 -9
  118. package/dist/lib/core/domain/cli-exit-codes.domain.mjs +0 -11
  119. package/dist/lib/core/domain/errors.domain.mjs +0 -17
  120. package/dist/lib/core/infrastructure/infrastructure.module.mjs +0 -30
  121. package/dist/lib/core/infrastructure/path.adapter.mjs +0 -246
  122. package/dist/lib/core/infrastructure/port-telemetry.decorator.mjs +0 -62
  123. package/dist/lib/core/infrastructure/repo-root-resolver.adapter.mjs +0 -233
  124. package/dist/lib/core/infrastructure/verbose-diagnostics.policy.mjs +0 -9
  125. package/dist/lib/core/presentation/cli-executor.presenter.mjs +0 -42
  126. package/dist/lib/core/presentation/cli-schema.parser.mjs +0 -7
  127. package/dist/lib/core/presentation/format-app-error.presenter.mjs +0 -17
  128. package/dist/lib/core/presentation/presentation.module.mjs +0 -5
  129. package/dist/lib/infrastructure/node-io.adapter.mjs +0 -285
  130. package/dist/lib/infrastructure/workspace/repo-root-resolver.service.mjs +0 -21
  131. package/dist/lib/kernel/contracts/cli-command.contract.mjs +0 -1
  132. package/dist/lib/kernel/contracts/tokens.mjs +0 -5
  133. package/dist/lib/mirror/adapters/primary/cli/mirror.command.mjs +0 -272
  134. package/dist/lib/mirror/adapters/secondary/file-system-service.adapter.mjs +0 -261
  135. package/dist/lib/mirror/adapters/secondary/mirror-sync-reporter.adapter.mjs +0 -243
  136. package/dist/lib/mirror/adapters/secondary/package-repository.adapter.mjs +0 -241
  137. package/dist/lib/mirror/adapters/secondary/sync-workspace-package.adapter.mjs +0 -351
  138. package/dist/lib/mirror/adapters/secondary/workspace-service.adapter.mjs +0 -237
  139. package/dist/lib/mirror/application/mirror-sync-json.format.mjs +0 -12
  140. package/dist/lib/mirror/application/ports/file-system-service.port.mjs +0 -1
  141. package/dist/lib/mirror/application/ports/mirror-sync-reporter.port.mjs +0 -1
  142. package/dist/lib/mirror/application/ports/package-repository.port.mjs +0 -1
  143. package/dist/lib/mirror/application/ports/sync-workspace-package.port.mjs +0 -1
  144. package/dist/lib/mirror/application/ports/workspace-service.port.mjs +0 -1
  145. package/dist/lib/mirror/application/requests/mirror-sync.request.mjs +0 -1
  146. package/dist/lib/mirror/application/services/mirror-package-arg-resolver.service.mjs +0 -20
  147. package/dist/lib/mirror/application/use-cases/prepare-mirror-sync.use-case.mjs +0 -264
  148. package/dist/lib/mirror/application/use-cases/run-mirror-sync.use-case.mjs +0 -302
  149. package/dist/lib/mirror/contracts/models.mjs +0 -1
  150. package/dist/lib/mirror/contracts/tokens.mjs +0 -11
  151. package/dist/lib/mirror/domain/types.domain.mjs +0 -1
  152. package/dist/lib/mirror/infrastructure/mirror-console-reporter.presenter.mjs +0 -99
  153. package/dist/lib/mirror/infrastructure/package-filter-resolver.service.mjs +0 -25
  154. package/dist/lib/mirror/infrastructure/workspace-packages.service.mjs +0 -158
  155. package/dist/lib/mirror/mirror.module.mjs +0 -25
  156. package/dist/lib/shared/source-code/infrastructure/typescript-source-file-walker.service.mjs +0 -33
  157. package/dist/lib/tag/adapters/primary/cli/presentation.tokens.mjs +0 -6
  158. package/dist/lib/tag/adapters/primary/cli/tag.command.mjs +0 -285
  159. package/dist/lib/tag/adapters/primary/cli/tag.presentation.module.mjs +0 -13
  160. package/dist/lib/tag/adapters/secondary/tag-since-writer.adapter.mjs +0 -348
  161. package/dist/lib/tag/adapters/secondary/tag-target-resolver.adapter.mjs +0 -233
  162. package/dist/lib/tag/adapters/secondary/tag-version-resolver.adapter.mjs +0 -249
  163. package/dist/lib/tag/adapters/secondary/typescript-tree-walk.adapter.mjs +0 -233
  164. package/dist/lib/tag/application/ports/tag-since-writer.port.mjs +0 -1
  165. package/dist/lib/tag/application/ports/tag-version-resolver.port.mjs +0 -1
  166. package/dist/lib/tag/application/ports/target-resolver.port.mjs +0 -1
  167. package/dist/lib/tag/application/ports/typescript-tree-walk.port.mjs +0 -1
  168. package/dist/lib/tag/application/requests/tag-sync.request.mjs +0 -1
  169. package/dist/lib/tag/application/services/tag-cli-target-path-resolver.service.mjs +0 -9
  170. package/dist/lib/tag/application/services/tag-target-runner.service.mjs +0 -21
  171. package/dist/lib/tag/application/tag-sync-cli-result.mjs +0 -11
  172. package/dist/lib/tag/application/tag-sync-json.format.mjs +0 -14
  173. package/dist/lib/tag/application/use-cases/prepare-tag-sync.use-case.mjs +0 -264
  174. package/dist/lib/tag/application/use-cases/run-tag-sync.use-case.mjs +0 -381
  175. package/dist/lib/tag/contracts/models.mjs +0 -1
  176. package/dist/lib/tag/contracts/tag-sync-result-presenter.contract.mjs +0 -1
  177. package/dist/lib/tag/contracts/tokens.mjs +0 -10
  178. package/dist/lib/tag/domain/types.domain.mjs +0 -1
  179. package/dist/lib/tag/infrastructure/tag-target-candidates.adapter.mjs +0 -170
  180. package/dist/lib/tag/presentation/colors.presenter.mjs +0 -12
  181. package/dist/lib/tag/presentation/present-tag-sync-result.presenter.mjs +0 -233
  182. package/dist/lib/tag/presentation/tag-sync-progress-listener.presenter.mjs +0 -243
  183. package/dist/lib/tag/tag.module.mjs +0 -23
  184. /package/dist/{lib/arrange/application/ports/domain-source-parser.port.mjs → arrange/domain/types.mjs} +0 -0
  185. /package/dist/{lib/arrange/application/ports/file-walker.port.mjs → core/filesystem/port.mjs} +0 -0
  186. /package/dist/{lib/arrange/application/ports/group-file-preview.port.mjs → mirror/domain/dist-filesystem.mjs} +0 -0
  187. /package/dist/{lib/arrange/application/ports/workspace-resolver.port.mjs → mirror/domain/types.mjs} +0 -0
  188. /package/dist/{lib/arrange/application/requests/analyze-directory.request.mjs → mirror/sync-types.mjs} +0 -0
  189. /package/dist/{lib/arrange/application/requests/arrange-sync.request.mjs → tag/domain/types.mjs} +0 -0
@@ -1,25 +0,0 @@
1
- import { normalizePath } from "../domain/path-normalizer.value-object.mjs";
2
- import { realpathSync } from "node:fs";
3
- import path from "node:path";
4
- //#region src/lib/mirror/infrastructure/package-filter-resolver.service.ts
5
- function tryRealpath(entryPath) {
6
- try {
7
- return realpathSync.native(entryPath);
8
- } catch {
9
- return path.resolve(entryPath);
10
- }
11
- }
12
- /**
13
- * Resolve `packageFilter` to a POSIX-ish path relative to `rootDir`, without using
14
- * `process.cwd()`. Use for programmatic `runMirrorSync` calls.
15
- *
16
- * @throws If the resolved path is not a strict subdirectory of `rootDir`.
17
- */ function resolvePackageFilterUnderRoot(rootDir, packageFilter) {
18
- const rootReal = tryRealpath(path.resolve(rootDir));
19
- const resolved = path.isAbsolute(packageFilter) ? tryRealpath(path.resolve(packageFilter)) : tryRealpath(path.join(rootReal, packageFilter));
20
- const normalized = normalizePath(path.relative(rootReal, resolved));
21
- if (normalized.startsWith("..") || path.isAbsolute(normalized) || normalized === "" || normalized === ".") throw new Error(`Package path must be a subdirectory under monorepo root: ${rootDir}`);
22
- return normalized;
23
- }
24
- //#endregion
25
- export { resolvePackageFilterUnderRoot };
@@ -1,158 +0,0 @@
1
- import { messageFromCaughtUnknown } from "../../core/domain/caught-unknown-message.value-object.mjs";
2
- import { normalizePath } from "../domain/path-normalizer.value-object.mjs";
3
- import { globSync } from "node:fs";
4
- import path from "node:path";
5
- import picomatch from "picomatch";
6
- import { parse } from "yaml";
7
- //#region src/lib/mirror/infrastructure/workspace-packages.service.ts
8
- const PNPM_WORKSPACE = "pnpm-workspace.yaml";
9
- /**
10
- * Default when the workspace file is missing or has no `packages` key.
11
- */ const DEFAULT_INCLUDE = ["packages/*"];
12
- function toPosix(filePath) {
13
- return filePath.split(path.sep).join("/");
14
- }
15
- function isGlobPermissionError(caughtError) {
16
- if (typeof caughtError !== "object" || caughtError === null || !("code" in caughtError)) return false;
17
- const code = caughtError.code;
18
- return code === "EACCES" || code === "EPERM";
19
- }
20
- /**
21
- * Turn a pnpm `packages` glob into a `globSync` pattern that finds `package.json` files.
22
- */ function workspacePatternToPackageJsonGlob(pattern) {
23
- const normalizedPattern = toPosix(pattern.trim()).replace(/\/+$/, "");
24
- if (!normalizedPattern) return "**/package.json";
25
- return `${normalizedPattern}/package.json`;
26
- }
27
- function splitWorkspacePackageEntries(raw) {
28
- const include = [];
29
- const exclude = [];
30
- if (!Array.isArray(raw)) return {
31
- include,
32
- exclude
33
- };
34
- for (const entry of raw) {
35
- if (typeof entry !== "string") continue;
36
- const trimmed = entry.trim();
37
- if (!trimmed) continue;
38
- if (trimmed.startsWith("!")) exclude.push(trimmed.slice(1).trim());
39
- else include.push(trimmed);
40
- }
41
- return {
42
- include,
43
- exclude
44
- };
45
- }
46
- /**
47
- * Reads `packages` from a parsed pnpm workspace document.
48
- * @throws If the document is invalid or `packages` is present but not an array.
49
- */ function parsePnpmWorkspaceDocument(doc) {
50
- if (doc === null || doc === void 0) throw new Error(`${PNPM_WORKSPACE} root document must be an object (got empty or null)`);
51
- if (typeof doc !== "object" || Array.isArray(doc)) throw new Error(`${PNPM_WORKSPACE} root must be a mapping, not an array or scalar`);
52
- const parsedDoc = doc;
53
- if (!Object.prototype.hasOwnProperty.call(parsedDoc, "packages")) return {
54
- include: [],
55
- exclude: [],
56
- hasPackagesKey: false,
57
- isEmptyPackagesArray: false
58
- };
59
- const pkgs = parsedDoc.packages;
60
- if (!Array.isArray(pkgs)) throw new Error(`${PNPM_WORKSPACE} field "packages" must be an array`);
61
- if (pkgs.length === 0) return {
62
- include: [],
63
- exclude: [],
64
- hasPackagesKey: true,
65
- isEmptyPackagesArray: true
66
- };
67
- return {
68
- ...splitWorkspacePackageEntries(pkgs),
69
- hasPackagesKey: true,
70
- isEmptyPackagesArray: false
71
- };
72
- }
73
- async function readWorkspaceYaml(rootDir, fs) {
74
- const workspaceYamlPath = path.join(rootDir, PNPM_WORKSPACE);
75
- if (!fs.existsSync(workspaceYamlPath)) return { exists: false };
76
- let raw;
77
- try {
78
- raw = await fs.readFile(workspaceYamlPath, "utf8");
79
- } catch (caughtReadError) {
80
- throw new Error(`Failed to read ${PNPM_WORKSPACE}: ${messageFromCaughtUnknown(caughtReadError)}`);
81
- }
82
- let doc;
83
- try {
84
- doc = parse(raw);
85
- } catch (caughtYamlParseError) {
86
- throw new Error(`Failed to parse ${PNPM_WORKSPACE}: ${messageFromCaughtUnknown(caughtYamlParseError)}`);
87
- }
88
- if (doc === null || doc === void 0) throw new Error(`${PNPM_WORKSPACE} must define a mapping at the document root`);
89
- return {
90
- exists: true,
91
- doc
92
- };
93
- }
94
- /**
95
- * Workspace package directories relative to `rootDir` (POSIX slashes), sorted.
96
- * Reads `pnpm-workspace.yaml` when present; otherwise uses `packages/*`.
97
- * Only paths with a `package.json` are returned (same practical rule as pnpm).
98
- */ async function findWorkspacePackageRelPaths(rootDir, fs, onGlobWarning) {
99
- const workspaceYaml = await readWorkspaceYaml(rootDir, fs);
100
- let include;
101
- let exclude;
102
- let multiSource;
103
- if (!workspaceYaml.exists) {
104
- include = [...DEFAULT_INCLUDE];
105
- exclude = [];
106
- multiSource = "default-patterns";
107
- } else {
108
- const parsed = parsePnpmWorkspaceDocument(workspaceYaml.doc);
109
- if (!parsed.hasPackagesKey) {
110
- include = [...DEFAULT_INCLUDE];
111
- exclude = [];
112
- multiSource = "default-patterns";
113
- } else if (parsed.isEmptyPackagesArray) return {
114
- relPaths: [],
115
- multiSource: "declared-empty"
116
- };
117
- else {
118
- include = parsed.include;
119
- exclude = parsed.exclude;
120
- multiSource = "pnpm-workspace-yaml";
121
- }
122
- }
123
- const found = /* @__PURE__ */ new Set();
124
- const globOpts = {
125
- cwd: rootDir,
126
- posix: true,
127
- ...path.sep === "\\" ? { windowsPathsNoEscape: true } : {}
128
- };
129
- for (const pattern of include) {
130
- const globPat = workspacePatternToPackageJsonGlob(pattern);
131
- let matches;
132
- try {
133
- matches = globSync(globPat, globOpts);
134
- } catch (caughtGlobError) {
135
- if (isGlobPermissionError(caughtGlobError)) {
136
- onGlobWarning(`Skipping workspace glob "${pattern}" (${messageFromCaughtUnknown(caughtGlobError)})`);
137
- continue;
138
- }
139
- throw new Error(`Invalid workspace glob "${pattern}": ${messageFromCaughtUnknown(caughtGlobError)}`);
140
- }
141
- for (const matchedPath of matches) {
142
- const posix = toPosix(matchedPath);
143
- if (!posix.endsWith("/package.json")) continue;
144
- const rel = posix.slice(0, -13);
145
- if (!rel) continue;
146
- found.add(normalizePath(rel));
147
- }
148
- }
149
- const excludeMatchers = exclude.map((pat) => picomatch(pat, { dot: true }));
150
- const relPaths = [...found].filter((rel) => !excludeMatchers.some((isMatch) => isMatch(rel)));
151
- relPaths.sort((a, b) => a.localeCompare(b));
152
- return {
153
- relPaths,
154
- multiSource
155
- };
156
- }
157
- //#endregion
158
- export { findWorkspacePackageRelPaths };
@@ -1,25 +0,0 @@
1
- import { CliLoggerToken } from "../core/contracts/tokens.mjs";
2
- import { withOptionalPortTelemetry } from "../core/infrastructure/port-telemetry.decorator.mjs";
3
- import { InfrastructureModule } from "../core/infrastructure/infrastructure.module.mjs";
4
- import { FileSystemServicePortToken, MirrorSyncReporterPortToken, PackageRepositoryPortToken, PrepareMirrorSyncUseCaseToken, RunMirrorSyncUseCaseToken, SyncWorkspacePackagePortToken, WorkspaceServicePortToken } from "./contracts/tokens.mjs";
5
- import { FileSystemServiceAdapter as _FileSystemServiceAdapter } from "./adapters/secondary/file-system-service.adapter.mjs";
6
- import { MirrorSyncReporterAdapter as _MirrorSyncReporterAdapter } from "./adapters/secondary/mirror-sync-reporter.adapter.mjs";
7
- import { PackageRepositoryAdapter as _PackageRepositoryAdapter } from "./adapters/secondary/package-repository.adapter.mjs";
8
- import { SyncWorkspacePackageAdapter as _SyncWorkspacePackageAdapter } from "./adapters/secondary/sync-workspace-package.adapter.mjs";
9
- import { WorkspaceServiceAdapter as _WorkspaceServiceAdapter } from "./adapters/secondary/workspace-service.adapter.mjs";
10
- import { PrepareMirrorSyncUseCaseImpl as _PrepareMirrorSyncUseCaseImpl } from "./application/use-cases/prepare-mirror-sync.use-case.mjs";
11
- import { RunMirrorSyncUseCaseImpl as _RunMirrorSyncUseCaseImpl } from "./application/use-cases/run-mirror-sync.use-case.mjs";
12
- import { Module } from "@codefast/di";
13
- //#region src/lib/mirror/mirror.module.ts
14
- const MirrorModule = Module.create("cli-mirror", (moduleBuilder) => {
15
- moduleBuilder.import(InfrastructureModule);
16
- moduleBuilder.bind(WorkspaceServicePortToken).to(_WorkspaceServiceAdapter).singleton().onActivation((ctx, implementation) => withOptionalPortTelemetry("WorkspaceServicePort", implementation, ctx.resolve(CliLoggerToken)));
17
- moduleBuilder.bind(PackageRepositoryPortToken).to(_PackageRepositoryAdapter).singleton().onActivation((ctx, implementation) => withOptionalPortTelemetry("PackageRepositoryPort", implementation, ctx.resolve(CliLoggerToken)));
18
- moduleBuilder.bind(FileSystemServicePortToken).to(_FileSystemServiceAdapter).singleton().onActivation((ctx, implementation) => withOptionalPortTelemetry("FileSystemServicePort", implementation, ctx.resolve(CliLoggerToken)));
19
- moduleBuilder.bind(MirrorSyncReporterPortToken).to(_MirrorSyncReporterAdapter).singleton().onActivation((ctx, implementation) => withOptionalPortTelemetry("MirrorSyncReporterPort", implementation, ctx.resolve(CliLoggerToken)));
20
- moduleBuilder.bind(SyncWorkspacePackagePortToken).to(_SyncWorkspacePackageAdapter).singleton();
21
- moduleBuilder.bind(PrepareMirrorSyncUseCaseToken).to(_PrepareMirrorSyncUseCaseImpl).singleton();
22
- moduleBuilder.bind(RunMirrorSyncUseCaseToken).to(_RunMirrorSyncUseCaseImpl).singleton();
23
- });
24
- //#endregion
25
- export { MirrorModule };
@@ -1,33 +0,0 @@
1
- import path from "node:path";
2
- //#region src/lib/shared/source-code/infrastructure/typescript-source-file-walker.service.ts
3
- const DEFAULT_SKIP_DIRS = new Set([
4
- "node_modules",
5
- "dist",
6
- ".git",
7
- ".turbo",
8
- ".next",
9
- ".cache",
10
- "out",
11
- "build",
12
- "coverage",
13
- ".vercel",
14
- ".output"
15
- ]);
16
- function walkTsxFiles(rootDirectoryPath, fs) {
17
- const result = [];
18
- const visit = (entryPath) => {
19
- if (fs.statSync(entryPath).isDirectory()) {
20
- for (const childName of fs.readdirSync(entryPath)) {
21
- if (DEFAULT_SKIP_DIRS.has(childName)) continue;
22
- visit(path.join(entryPath, childName));
23
- }
24
- return;
25
- }
26
- if (entryPath.endsWith(".d.ts")) return;
27
- if (entryPath.endsWith(".tsx") || entryPath.endsWith(".ts")) result.push(entryPath);
28
- };
29
- visit(rootDirectoryPath);
30
- return result;
31
- }
32
- //#endregion
33
- export { walkTsxFiles };
@@ -1,6 +0,0 @@
1
- import { token } from "@codefast/di";
2
- //#region src/lib/tag/adapters/primary/cli/presentation.tokens.ts
3
- const PresentTagSyncResultPresenterToken = token("PresentTagSyncResultPresenter");
4
- const TagSyncProgressListenerToken = token("TagSyncProgressListener");
5
- //#endregion
6
- export { PresentTagSyncResultPresenterToken, TagSyncProgressListenerToken };
@@ -1,285 +0,0 @@
1
- import { CliLoggerToken, CliRuntimeToken } from "../../../../core/contracts/tokens.mjs";
2
- import { parseWithCliSchema } from "../../../../core/presentation/cli-schema.parser.mjs";
3
- import { consumeCliAppError } from "../../../../core/presentation/cli-executor.presenter.mjs";
4
- import { exitCodeForTagSyncResult } from "../../../application/tag-sync-cli-result.mjs";
5
- import { formatTagSyncJsonOutput } from "../../../application/tag-sync-json.format.mjs";
6
- import { PrepareTagSyncUseCaseToken, RunTagSyncUseCaseToken } from "../../../contracts/tokens.mjs";
7
- import { tagSyncRunRequestSchema } from "../../../presentation/tag-cli.schema.mjs";
8
- import { PresentTagSyncResultPresenterToken, TagSyncProgressListenerToken } from "./presentation.tokens.mjs";
9
- import { inject, injectable } from "@codefast/di";
10
- //#region src/lib/tag/adapters/primary/cli/tag.command.ts
11
- function toPrimitive(input, hint) {
12
- if (typeof input !== "object" || input === null) return input;
13
- var prim = input[Symbol.toPrimitive];
14
- if (prim !== void 0) {
15
- var res = prim.call(input, hint || "default");
16
- if (typeof res !== "object") return res;
17
- throw new TypeError("@@toPrimitive must return a primitive value.");
18
- }
19
- return (hint === "string" ? String : Number)(input);
20
- }
21
- function toPropertyKey(arg) {
22
- var key = toPrimitive(arg, "string");
23
- return typeof key === "symbol" ? key : String(key);
24
- }
25
- function checkInRHS(value) {
26
- if (Object(value) !== value) throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null"));
27
- return value;
28
- }
29
- function setFunctionName(fn, name, prefix) {
30
- if (typeof name === "symbol") {
31
- name = name.description;
32
- name = name ? "[" + name + "]" : "";
33
- }
34
- try {
35
- Object.defineProperty(fn, "name", {
36
- configurable: true,
37
- value: prefix ? prefix + " " + name : name
38
- });
39
- } catch (_) {}
40
- return fn;
41
- }
42
- function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) {
43
- var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
44
- var defineProperty = Object.defineProperty;
45
- var create = Object.create;
46
- var metadata;
47
- var existingNonFields = [create(null), create(null)];
48
- var hasClassDecs = classDecs.length;
49
- var _;
50
- function createRunInitializers(initializers, useStaticThis, hasValue) {
51
- return function(thisArg, value) {
52
- if (useStaticThis) {
53
- value = thisArg;
54
- thisArg = targetClass;
55
- }
56
- for (var i = 0; i < initializers.length; i++) value = initializers[i].apply(thisArg, hasValue ? [value] : []);
57
- return hasValue ? value : thisArg;
58
- };
59
- }
60
- function assertCallable(fn, hint1, hint2, throwUndefined) {
61
- if (typeof fn !== "function") {
62
- if (throwUndefined || fn !== void 0) throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
63
- }
64
- return fn;
65
- }
66
- function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) {
67
- function assertInstanceIfPrivate(target) {
68
- if (!hasPrivateBrand(target)) throw new TypeError("Attempted to access private element on non-instance");
69
- }
70
- var decs = [].concat(decInfo[0]);
71
- var decVal = decInfo[3];
72
- var isClass = !ret;
73
- var isAccessor = kind === 1;
74
- var isGetter = kind === 3;
75
- var isSetter = kind === 4;
76
- var isMethod = kind === 2;
77
- function bindPropCall(name, useStaticThis, before) {
78
- return function(_this, value) {
79
- if (useStaticThis) {
80
- value = _this;
81
- _this = Class;
82
- }
83
- if (before) before(_this);
84
- return desc[name].call(_this, value);
85
- };
86
- }
87
- var desc1 = {};
88
- var init = [];
89
- var key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value";
90
- if (!isClass) {
91
- if (isPrivate) {
92
- if (isField || isAccessor) desc1 = {
93
- get: setFunctionName(function() {
94
- return decVal(this);
95
- }, name, "get"),
96
- set: function(value) {
97
- decInfo[4](this, value);
98
- }
99
- };
100
- else desc1[key] = decVal;
101
- if (!isField) setFunctionName(desc1[key], name, isMethod ? "" : key);
102
- } else if (!isField) desc1 = Object.getOwnPropertyDescriptor(Class, name);
103
- if (!isField && !isPrivate) {
104
- _ = existingNonFields[+isStatic][name];
105
- if (_ && (_ ^ kind) !== 7) throw new Error("Decorating two elements with the same name (" + desc1[key].name + ") is not supported yet");
106
- existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind;
107
- }
108
- }
109
- var newValue = Class;
110
- for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
111
- var dec = assertCallable(decs[i], "A decorator", "be", true);
112
- var decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
113
- var decoratorFinishedRef = {};
114
- var ctx = {
115
- kind: [
116
- "field",
117
- "accessor",
118
- "method",
119
- "getter",
120
- "setter",
121
- "class"
122
- ][kind],
123
- name,
124
- metadata,
125
- addInitializer: (function(decoratorFinishedRef, initializer) {
126
- if (decoratorFinishedRef.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
127
- assertCallable(initializer, "An initializer", "be", true);
128
- initializers.push(initializer);
129
- }).bind(null, decoratorFinishedRef)
130
- };
131
- if (isClass) {
132
- _ = dec.call(decThis, newValue, ctx);
133
- decoratorFinishedRef.v = 1;
134
- if (assertCallable(_, "class decorators", "return")) newValue = _;
135
- continue;
136
- }
137
- ctx.static = isStatic;
138
- ctx.private = isPrivate;
139
- _ = ctx.access = { has: isPrivate ? hasPrivateBrand.bind() : function(target) {
140
- return name in target;
141
- } };
142
- if (!isSetter) _.get = isPrivate ? isMethod ? function(_this) {
143
- assertInstanceIfPrivate(_this);
144
- return desc1.value;
145
- } : bindPropCall("get", 0, assertInstanceIfPrivate) : function(target) {
146
- return target[name];
147
- };
148
- if (!isMethod && !isGetter) _.set = isPrivate ? bindPropCall("set", 0, assertInstanceIfPrivate) : function(target, value) {
149
- target[name] = value;
150
- };
151
- newValue = dec.call(decThis, isAccessor ? {
152
- get: desc1.get,
153
- set: desc1.set
154
- } : desc1[key], ctx);
155
- decoratorFinishedRef.v = 1;
156
- if (isAccessor) {
157
- if (typeof newValue === "object" && newValue) {
158
- if (_ = assertCallable(newValue.get, "accessor.get")) desc1.get = _;
159
- if (_ = assertCallable(newValue.set, "accessor.set")) desc1.set = _;
160
- if (_ = assertCallable(newValue.init, "accessor.init")) init.unshift(_);
161
- } else if (newValue !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
162
- } else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) if (isField) init.unshift(newValue);
163
- else desc1[key] = newValue;
164
- }
165
- if (kind < 2) ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0));
166
- if (!isField && !isClass) if (isPrivate) if (isAccessor) ret.splice(-1, 0, bindPropCall("get", isStatic), bindPropCall("set", isStatic));
167
- else ret.push(isMethod ? desc1[key] : assertCallable.call.bind(desc1[key]));
168
- else defineProperty(Class, name, desc1);
169
- return newValue;
170
- }
171
- function applyMemberDecs() {
172
- var ret = [];
173
- var protoInitializers;
174
- var staticInitializers;
175
- var pushInitializers = function(initializers) {
176
- if (initializers) ret.push(createRunInitializers(initializers));
177
- };
178
- var applyMemberDecsOfKind = function(isStatic, isField) {
179
- for (var i = 0; i < memberDecs.length; i++) {
180
- var decInfo = memberDecs[i];
181
- var kind = decInfo[1];
182
- var kindOnly = kind & 7;
183
- if ((kind & 8) == isStatic && !kindOnly == isField) {
184
- var name = decInfo[2];
185
- var isPrivate = !!decInfo[3];
186
- var decoratorsHaveThis = kind & 16;
187
- applyDec(isStatic ? targetClass : targetClass.prototype, decInfo, decoratorsHaveThis, isPrivate ? "#" + name : toPropertyKey(name), kindOnly, kindOnly < 2 ? [] : isStatic ? staticInitializers = staticInitializers || [] : protoInitializers = protoInitializers || [], ret, !!isStatic, isPrivate, isField, isStatic && isPrivate ? function(_) {
188
- return checkInRHS(_) === targetClass;
189
- } : instanceBrand);
190
- }
191
- }
192
- };
193
- applyMemberDecsOfKind(8, 0);
194
- applyMemberDecsOfKind(0, 0);
195
- applyMemberDecsOfKind(8, 1);
196
- applyMemberDecsOfKind(0, 1);
197
- pushInitializers(protoInitializers);
198
- pushInitializers(staticInitializers);
199
- return ret;
200
- }
201
- function defineMetadata(Class) {
202
- return defineProperty(Class, symbolMetadata, {
203
- configurable: true,
204
- enumerable: true,
205
- value: metadata
206
- });
207
- }
208
- if (parentClass !== void 0) metadata = parentClass[symbolMetadata];
209
- metadata = create(metadata == null ? null : metadata);
210
- _ = applyMemberDecs();
211
- if (!hasClassDecs) defineMetadata(targetClass);
212
- return {
213
- e: _,
214
- get c() {
215
- var initializers = [];
216
- return hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)];
217
- }
218
- };
219
- }
220
- let _dec, _initClass;
221
- _dec = injectable([
222
- inject(CliLoggerToken),
223
- inject(CliRuntimeToken),
224
- inject(PrepareTagSyncUseCaseToken),
225
- inject(RunTagSyncUseCaseToken),
226
- inject(TagSyncProgressListenerToken),
227
- inject(PresentTagSyncResultPresenterToken)
228
- ]);
229
- let _TagCommand;
230
- (class {
231
- logger;
232
- runtime;
233
- prepareTagSync;
234
- runTagSync;
235
- tagProgressListener;
236
- presentSyncCliResult;
237
- static {
238
- ({c: [_TagCommand, _initClass]} = _apply_decs_2311(this, [_dec], []));
239
- }
240
- constructor(logger, runtime, prepareTagSync, runTagSync, tagProgressListener, presentSyncCliResult) {
241
- this.logger = logger;
242
- this.runtime = runtime;
243
- this.prepareTagSync = prepareTagSync;
244
- this.runTagSync = runTagSync;
245
- this.tagProgressListener = tagProgressListener;
246
- this.presentSyncCliResult = presentSyncCliResult;
247
- }
248
- name = "tag";
249
- description = "Add @since <version> JSDoc tags to exported declarations";
250
- register(program) {
251
- program.command(this.name).alias("annotate").description(this.description).argument("[target]", "Directory or file to annotate (default: auto-discover workspace packages)").option("--dry-run", "Show summary without writing files", false).option("--json", "Print one JSON summary on stdout (suppresses human progress)", false).action(this.execute.bind(this));
252
- }
253
- async execute(target, options, _command) {
254
- const prelude = await this.prepareTagSync.execute({
255
- currentWorkingDirectory: this.runtime.cwd(),
256
- rawTarget: target
257
- });
258
- if (!consumeCliAppError(this.logger, prelude)) return;
259
- const { rootDir, config, resolvedTargetPath } = prelude.value;
260
- const tagConfig = config.tag ?? {};
261
- const parsed = parseWithCliSchema(tagSyncRunRequestSchema, {
262
- rootDir,
263
- write: !options.dryRun,
264
- json: options.json,
265
- targetPath: resolvedTargetPath,
266
- skipPackages: tagConfig.skipPackages,
267
- config: tagConfig
268
- });
269
- if (!consumeCliAppError(this.logger, parsed)) return;
270
- const tagOutcome = await this.runTagSync.execute({
271
- ...parsed.value,
272
- listener: parsed.value.json ? void 0 : this.tagProgressListener
273
- });
274
- if (!consumeCliAppError(this.logger, tagOutcome)) return;
275
- if (parsed.value.json) {
276
- this.logger.out(formatTagSyncJsonOutput(tagOutcome.value, rootDir));
277
- this.runtime.setExitCode(exitCodeForTagSyncResult(tagOutcome.value));
278
- } else this.runtime.setExitCode(this.presentSyncCliResult.present(tagOutcome.value, rootDir));
279
- }
280
- static {
281
- _initClass();
282
- }
283
- });
284
- //#endregion
285
- export { _TagCommand as TagCommand };
@@ -1,13 +0,0 @@
1
- import { PresentationModule } from "../../../../core/presentation/presentation.module.mjs";
2
- import { PresentTagSyncResultPresenterToken, TagSyncProgressListenerToken } from "./presentation.tokens.mjs";
3
- import { PresentTagSyncResultPresenterImpl as _PresentTagSyncResultPresenterImpl } from "../../../presentation/present-tag-sync-result.presenter.mjs";
4
- import { TagSyncProgressListener as _TagSyncProgressListener } from "../../../presentation/tag-sync-progress-listener.presenter.mjs";
5
- import { Module } from "@codefast/di";
6
- //#region src/lib/tag/adapters/primary/cli/tag.presentation.module.ts
7
- const TagPresentationModule = Module.create("cli-tag-presentation", (moduleBuilder) => {
8
- moduleBuilder.import(PresentationModule);
9
- moduleBuilder.bind(PresentTagSyncResultPresenterToken).to(_PresentTagSyncResultPresenterImpl).singleton();
10
- moduleBuilder.bind(TagSyncProgressListenerToken).to(_TagSyncProgressListener).singleton();
11
- });
12
- //#endregion
13
- export { TagPresentationModule };