@codefast/cli 0.3.14-canary.0 → 0.3.14-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/{commands/arrange.mjs → lib/arrange/adapters/primary/cli/arrange.command.mjs} +32 -33
  2. package/dist/lib/arrange/adapters/primary/cli/arrange.presentation.module.mjs +14 -0
  3. package/dist/lib/arrange/adapters/primary/cli/presentation.tokens.mjs +5 -0
  4. package/dist/lib/arrange/{infra → adapters/secondary}/domain-source-parser.adapter.mjs +5 -8
  5. package/dist/lib/arrange/{infra → adapters/secondary}/file-walker.adapter.mjs +11 -9
  6. package/dist/lib/arrange/adapters/secondary/workspace-resolver.adapter.mjs +233 -0
  7. package/dist/lib/arrange/application/services/arrange-file-processor.service.mjs +37 -12
  8. package/dist/lib/arrange/application/services/arrange-target-path-resolver.service.mjs +21 -0
  9. package/dist/lib/arrange/application/services/arrange-target-scanner.service.mjs +10 -4
  10. package/dist/lib/arrange/application/use-cases/analyze-directory.use-case.mjs +7 -10
  11. package/dist/lib/arrange/{presentation/prepare-arrange.orchestrator.mjs → application/use-cases/prepare-arrange-workspace.use-case.mjs} +25 -20
  12. package/dist/lib/arrange/application/use-cases/run-arrange-sync.use-case.mjs +10 -19
  13. package/dist/lib/arrange/application/use-cases/suggest-cn-groups.use-case.mjs +9 -5
  14. package/dist/lib/arrange/arrange.module.mjs +17 -13
  15. package/dist/lib/arrange/contracts/tokens.mjs +6 -5
  16. package/dist/lib/arrange/domain/arrange-analyze.service.mjs +1 -1
  17. package/dist/lib/arrange/domain/ast/ast-helpers.helper.mjs +1 -1
  18. package/dist/lib/arrange/domain/ast/ast-node.model.mjs +1 -21
  19. package/dist/lib/arrange/domain/ast/collectors-tv.collector.mjs +2 -2
  20. package/dist/lib/arrange/domain/ast/targets.model.mjs +6 -6
  21. package/dist/lib/arrange/domain/grouping.domain.mjs +3 -2
  22. package/dist/lib/arrange/domain/imports.domain.mjs +1 -1
  23. package/dist/lib/arrange/domain/source-text-formatters.formatter.mjs +19 -2
  24. package/dist/lib/{tag/presentation/create-tag-progress-listener.presenter.mjs → arrange/domain/tailwind-grouping.service.mjs} +10 -7
  25. package/dist/lib/arrange/domain/{tokenizer.util.mjs → tailwind-token-classifier.domain-service.mjs} +3 -29
  26. package/dist/lib/arrange/domain/tailwind-token.value-object.mjs +31 -0
  27. package/dist/lib/arrange/{infra/ts-ast-translator.adapter.mjs → infrastructure/typescript-ast-translator.adapter.mjs} +2 -2
  28. package/dist/lib/arrange/presentation/arrange-analyze.presenter.mjs +259 -0
  29. package/dist/lib/arrange/presentation/arrange-cli.schema.mjs +18 -0
  30. package/dist/lib/arrange/presentation/arrange-sync.presenter.mjs +23 -2
  31. package/dist/lib/arrange/presentation/group-file-preview.presenter.mjs +10 -14
  32. package/dist/lib/bootstrap/composition-root.mjs +33 -0
  33. package/dist/lib/config/application/services/load-config.service.mjs +17 -0
  34. package/dist/lib/config/contracts/tokens.mjs +2 -1
  35. package/dist/lib/config/infrastructure/config-loader.adapter.mjs +306 -0
  36. package/dist/lib/config/{infra → infrastructure}/config-schema.adapter.mjs +2 -2
  37. package/dist/lib/{arrange/presentation/present-analyze-report.presenter.mjs → config/infrastructure/config-warning-reporter.adapter.mjs} +9 -8
  38. package/dist/lib/core/{presentation/try-load-codefast-config.presenter.mjs → application/load-codefast-config.use-case.mjs} +22 -22
  39. package/dist/lib/core/{presentation/global-cli-options.presenter.mjs → application/services/global-cli-options-parser.service.mjs} +3 -3
  40. package/dist/lib/core/application/services/schema-validator.service.mjs +17 -0
  41. package/dist/lib/core/contracts/tokens.mjs +7 -2
  42. package/dist/lib/core/core.module.mjs +3 -3
  43. package/dist/lib/core/{application/utils/caught-unknown-message.util.mjs → domain/caught-unknown-message.value-object.mjs} +1 -1
  44. package/dist/lib/core/domain/errors.domain.mjs +13 -12
  45. package/dist/lib/core/domain/result.model.mjs +1 -7
  46. package/dist/lib/core/infrastructure/infrastructure.module.mjs +30 -0
  47. package/dist/lib/core/infrastructure/path.adapter.mjs +246 -0
  48. package/dist/lib/core/{infra/logging-decorator.adapter.mjs → infrastructure/port-telemetry.decorator.mjs} +1 -1
  49. package/dist/lib/core/infrastructure/repo-root-resolver.adapter.mjs +233 -0
  50. package/dist/lib/core/{application/utils/verbose-diagnostics.util.mjs → infrastructure/verbose-diagnostics.policy.mjs} +1 -1
  51. package/dist/lib/core/presentation/cli-executor.presenter.mjs +3 -18
  52. package/dist/lib/core/presentation/cli-schema.parser.mjs +7 -0
  53. package/dist/lib/core/presentation/presentation.module.mjs +1 -7
  54. package/dist/lib/{infra → infrastructure}/node-io.adapter.mjs +22 -3
  55. package/dist/lib/{infra/workspace/repo-root.adapter.mjs → infrastructure/workspace/repo-root-resolver.service.mjs} +1 -1
  56. package/dist/lib/kernel/contracts/tokens.mjs +5 -0
  57. package/dist/{commands/mirror.mjs → lib/mirror/adapters/primary/cli/mirror.command.mjs} +17 -12
  58. package/dist/lib/mirror/{infra → adapters/secondary}/file-system-service.adapter.mjs +14 -9
  59. package/dist/lib/mirror/{infra → adapters/secondary}/mirror-sync-reporter.adapter.mjs +12 -5
  60. package/dist/lib/mirror/{infra → adapters/secondary}/package-repository.adapter.mjs +12 -6
  61. package/dist/lib/mirror/{application/services/sync-workspace-package.service.mjs → adapters/secondary/sync-workspace-package.adapter.mjs} +29 -29
  62. package/dist/lib/mirror/{infra → adapters/secondary}/workspace-service.adapter.mjs +12 -7
  63. package/dist/lib/mirror/application/{use-cases/generate-mirror-exports.use-case.mjs → services/generate-mirror-exports.service.mjs} +7 -7
  64. package/dist/lib/mirror/{presentation/resolve-mirror-package-arg.presenter.mjs → application/services/mirror-package-arg-resolver.service.mjs} +4 -4
  65. package/dist/lib/mirror/{presentation/prepare-mirror.orchestrator.mjs → application/use-cases/prepare-mirror-sync.use-case.mjs} +23 -22
  66. package/dist/lib/mirror/application/use-cases/run-mirror-sync.use-case.mjs +12 -12
  67. package/dist/lib/mirror/contracts/tokens.mjs +3 -3
  68. package/dist/lib/mirror/domain/package-display-name.policy.mjs +9 -0
  69. package/dist/lib/mirror/{infra/path-normalizer.adapter.mjs → domain/path-normalizer.value-object.mjs} +1 -1
  70. package/dist/lib/mirror/{infra/dirent-list.adapter.mjs → infrastructure/dirent-list.guard.mjs} +1 -1
  71. package/dist/lib/mirror/infrastructure/mirror-console-reporter.presenter.mjs +99 -0
  72. package/dist/lib/mirror/{infra/package-filter.adapter.mjs → infrastructure/package-filter-resolver.service.mjs} +2 -2
  73. package/dist/lib/mirror/{infra/update-pkg.adapter.mjs → infrastructure/package-json-exports.repository.mjs} +4 -19
  74. package/dist/lib/mirror/{infra/workspace-packages.adapter.mjs → infrastructure/workspace-packages.service.mjs} +4 -4
  75. package/dist/lib/mirror/mirror.module.mjs +17 -15
  76. package/dist/lib/mirror/presentation/{mirror-cli-schema.presenter.mjs → mirror-cli.schema.mjs} +1 -1
  77. package/dist/lib/shared/source-code/domain/text-edit.model.mjs +32 -5
  78. package/dist/lib/shared/source-code/{infra/tsx-file-walk.adapter.mjs → infrastructure/typescript-source-file-walker.service.mjs} +2 -2
  79. package/dist/lib/tag/adapters/primary/cli/presentation.tokens.mjs +6 -0
  80. package/dist/{commands/tag.mjs → lib/tag/adapters/primary/cli/tag.command.mjs} +23 -21
  81. package/dist/lib/tag/adapters/primary/cli/tag.presentation.module.mjs +13 -0
  82. package/dist/lib/tag/{infra → adapters/secondary}/tag-since-writer.adapter.mjs +12 -7
  83. package/dist/lib/tag/{infra → adapters/secondary}/tag-target-resolver.adapter.mjs +12 -5
  84. package/dist/lib/tag/{infra → adapters/secondary}/tag-version-resolver.adapter.mjs +10 -8
  85. package/dist/lib/tag/{infra → adapters/secondary}/typescript-tree-walk.adapter.mjs +12 -5
  86. package/dist/lib/tag/{presentation/resolve-tag-cli-target.presenter.mjs → application/services/tag-cli-target-path-resolver.service.mjs} +1 -1
  87. package/dist/lib/tag/application/services/tag-target-runner.service.mjs +21 -0
  88. package/dist/lib/tag/{presentation/prepare-tag.orchestrator.mjs → application/use-cases/prepare-tag-sync.use-case.mjs} +23 -23
  89. package/dist/lib/tag/application/use-cases/run-tag-sync.use-case.mjs +14 -31
  90. package/dist/lib/tag/contracts/tokens.mjs +2 -4
  91. package/dist/lib/tag/{infra → infrastructure}/tag-target-candidates.adapter.mjs +4 -4
  92. package/dist/lib/tag/presentation/present-tag-sync-result.presenter.mjs +1 -1
  93. package/dist/lib/tag/presentation/{tag-cli-schema.presenter.mjs → tag-cli.schema.mjs} +1 -1
  94. package/dist/lib/tag/presentation/tag-sync-progress-listener.presenter.mjs +243 -0
  95. package/dist/lib/tag/presentation/tag-sync.presenter.mjs +6 -23
  96. package/dist/lib/tag/tag.module.mjs +15 -13
  97. package/dist/program.mjs +2 -2
  98. package/package.json +16 -9
  99. package/dist/lib/arrange/application/arrange-analyze-json.format.mjs +0 -10
  100. package/dist/lib/arrange/application/arrange-group-json.format.mjs +0 -11
  101. package/dist/lib/arrange/application/arrange-sync-cli-result.mjs +0 -7
  102. package/dist/lib/arrange/application/arrange-sync-json.format.mjs +0 -12
  103. package/dist/lib/arrange/application/use-cases/group-file.use-case.mjs +0 -35
  104. package/dist/lib/arrange/arrange.feature.module.mjs +0 -19
  105. package/dist/lib/arrange/arrange.presentation.module.mjs +0 -13
  106. package/dist/lib/arrange/domain/errors.domain.mjs +0 -18
  107. package/dist/lib/arrange/infra/ensure-cn-import.adapter.mjs +0 -10
  108. package/dist/lib/arrange/infra/merge-cn-literal-pool-for-test.test-helper.mjs +0 -18
  109. package/dist/lib/arrange/presentation/arrange-cli-schema.presenter.mjs +0 -29
  110. package/dist/lib/arrange/presentation/formatters.presenter.mjs +0 -2
  111. package/dist/lib/arrange/presentation/present-analyze-cli.presenter.mjs +0 -7
  112. package/dist/lib/arrange/presentation/report.presenter.mjs +0 -24
  113. package/dist/lib/arrange/presentation/resolve-arrange-cli-target.presenter.mjs +0 -21
  114. package/dist/lib/config/application/use-cases/load-config.use-case.mjs +0 -17
  115. package/dist/lib/config/infra/loader.adapter.mjs +0 -84
  116. package/dist/lib/core/application/schema-parse.util.mjs +0 -17
  117. package/dist/lib/core/infra/composition-root.mjs +0 -21
  118. package/dist/lib/core/infra/infra.module.mjs +0 -23
  119. package/dist/lib/core/infra/path.adapter.mjs +0 -13
  120. package/dist/lib/core/operational/contracts/tokens.mjs +0 -7
  121. package/dist/lib/core/presentation/load-codefast-config.presenter.mjs +0 -18
  122. package/dist/lib/core/presentation/parse-cli-schema.presenter.mjs +0 -7
  123. package/dist/lib/infra/config-reporter.adapter.mjs +0 -11
  124. package/dist/lib/kernel/di/command.token.mjs +0 -5
  125. package/dist/lib/mirror/contracts/use-cases.contract.mjs +0 -1
  126. package/dist/lib/mirror/infra/mirror-sync-cli-options.adapter.mjs +0 -1
  127. package/dist/lib/mirror/mirror.feature.module.mjs +0 -19
  128. package/dist/lib/mirror/mirror.presentation.module.mjs +0 -11
  129. package/dist/lib/mirror/presentation/reporter.presenter.mjs +0 -111
  130. package/dist/lib/tag/contracts/presentation.contract.mjs +0 -1
  131. package/dist/lib/tag/contracts/use-cases.contract.mjs +0 -1
  132. package/dist/lib/tag/infra/tag-sync-cli-options.adapter.mjs +0 -1
  133. package/dist/lib/tag/presentation/resolve-tag-workspace-root.presenter.mjs +0 -12
  134. package/dist/lib/tag/tag.feature.module.mjs +0 -19
  135. package/dist/lib/tag/tag.presentation.module.mjs +0 -15
  136. /package/dist/lib/arrange/{contracts/presentation.contract.mjs → application/ports/workspace-resolver.port.mjs} +0 -0
  137. /package/dist/lib/arrange/contracts/{use-cases.contract.mjs → analyze-report-presenter.contract.mjs} +0 -0
  138. /package/dist/lib/{arrange/infra/arrange-sync-cli-options.adapter.mjs → config/application/ports/config-warning-reporter.port.mjs} +0 -0
  139. /package/dist/lib/core/{contracts/presentation.contract.mjs → application/ports/repo-root-resolver.port.mjs} +0 -0
  140. /package/dist/lib/core/{presentation/command.interface.mjs → application/ports/runtime.port.mjs} +0 -0
  141. /package/dist/lib/{infra/fs-contract.port.mjs → kernel/contracts/cli-command.contract.mjs} +0 -0
  142. /package/dist/lib/{mirror/contracts/presentation.contract.mjs → tag/contracts/tag-sync-result-presenter.contract.mjs} +0 -0
@@ -1,7 +1,7 @@
1
- import { messageFromCaughtUnknown } from "../../core/application/utils/caught-unknown-message.util.mjs";
2
- import { PACKAGE_JSON_EXPORT } from "../domain/constants.domain.mjs";
1
+ import { messageFromCaughtUnknown } from "../../core/domain/caught-unknown-message.value-object.mjs";
3
2
  import { MirrorError, MirrorErrorCode } from "../domain/errors.domain.mjs";
4
- //#region src/lib/mirror/infra/update-pkg.adapter.ts
3
+ import { PACKAGE_JSON_EXPORT } from "../domain/constants.domain.mjs";
4
+ //#region src/lib/mirror/infrastructure/package-json-exports.repository.ts
5
5
  function containsDistTarget(value) {
6
6
  if (typeof value === "string") return value.startsWith("./dist/");
7
7
  if (Array.isArray(value)) return value.some((entryValue) => containsDistTarget(entryValue));
@@ -28,21 +28,6 @@ function compareExportSpecifiers(leftSpecifier, rightSpecifier, originalPathBySp
28
28
  return leftSpecifier.localeCompare(rightSpecifier);
29
29
  }
30
30
  /**
31
- * Shared rule: show `package.json#name` when it is a non-empty string; else folder basename.
32
- */ function resolvePackageDisplayName(packageJson, folderBasename) {
33
- const declaredName = packageJson.name;
34
- return typeof declaredName === "string" && declaredName.length > 0 ? declaredName : folderBasename;
35
- }
36
- async function readPackageJsonDisplayName(fs, packageJsonPath, folderBasename) {
37
- if (!fs.existsSync(packageJsonPath)) return folderBasename;
38
- try {
39
- const raw = await fs.readFile(packageJsonPath, "utf8");
40
- return resolvePackageDisplayName(JSON.parse(raw), folderBasename);
41
- } catch {
42
- return folderBasename;
43
- }
44
- }
45
- /**
46
31
  * Writes `exports` into `package.json` via a temp file + rename (atomic on same volume).
47
32
  * Preserves a trailing newline after JSON.
48
33
  */ async function writePackageJsonExportsAtomic(fs, packageJsonPath, mergeInput) {
@@ -101,4 +86,4 @@ async function readPackageJsonDisplayName(fs, packageJsonPath, folderBasename) {
101
86
  return { prunedKeys };
102
87
  }
103
88
  //#endregion
104
- export { readPackageJsonDisplayName, resolvePackageDisplayName, writePackageJsonExportsAtomic };
89
+ export { writePackageJsonExportsAtomic };
@@ -1,10 +1,10 @@
1
- import { messageFromCaughtUnknown } from "../../core/application/utils/caught-unknown-message.util.mjs";
2
- import { normalizePath } from "./path-normalizer.adapter.mjs";
1
+ import { messageFromCaughtUnknown } from "../../core/domain/caught-unknown-message.value-object.mjs";
2
+ import { normalizePath } from "../domain/path-normalizer.value-object.mjs";
3
3
  import { globSync } from "node:fs";
4
4
  import path from "node:path";
5
5
  import picomatch from "picomatch";
6
6
  import { parse } from "yaml";
7
- //#region src/lib/mirror/infra/workspace-packages.adapter.ts
7
+ //#region src/lib/mirror/infrastructure/workspace-packages.service.ts
8
8
  const PNPM_WORKSPACE = "pnpm-workspace.yaml";
9
9
  /**
10
10
  * Default when the workspace file is missing or has no `packages` key.
@@ -155,4 +155,4 @@ async function readWorkspaceYaml(rootDir, fs) {
155
155
  };
156
156
  }
157
157
  //#endregion
158
- export { findWorkspacePackageRelPaths, parsePnpmWorkspaceDocument, splitWorkspacePackageEntries, workspacePatternToPackageJsonGlob };
158
+ export { findWorkspacePackageRelPaths };
@@ -1,22 +1,24 @@
1
- import { CliLoggerToken } from "../core/operational/contracts/tokens.mjs";
2
- import { withOptionalPortTelemetry } from "../core/infra/logging-decorator.adapter.mjs";
3
- import { InfraModule } from "../core/infra/infra.module.mjs";
4
- import { FileSystemServicePortToken, MirrorSyncReporterPortToken, PackageRepositoryPortToken, RunMirrorSyncUseCaseToken, SyncWorkspacePackageServiceToken, WorkspaceServicePortToken } from "./contracts/tokens.mjs";
5
- import { SyncWorkspacePackageServiceImpl as _SyncWorkspacePackageServiceImpl } from "./application/services/sync-workspace-package.service.mjs";
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";
6
11
  import { RunMirrorSyncUseCaseImpl as _RunMirrorSyncUseCaseImpl } from "./application/use-cases/run-mirror-sync.use-case.mjs";
7
- import { FileSystemServiceAdapter as _FileSystemServiceAdapter } from "./infra/file-system-service.adapter.mjs";
8
- import { MirrorSyncReporterAdapter as _MirrorSyncReporterAdapter } from "./infra/mirror-sync-reporter.adapter.mjs";
9
- import { PackageRepositoryAdapter as _PackageRepositoryAdapter } from "./infra/package-repository.adapter.mjs";
10
- import { WorkspaceServiceAdapter as _WorkspaceServiceAdapter } from "./infra/workspace-service.adapter.mjs";
11
12
  import { Module } from "@codefast/di";
12
13
  //#region src/lib/mirror/mirror.module.ts
13
14
  const MirrorModule = Module.create("cli-mirror", (moduleBuilder) => {
14
- moduleBuilder.import(InfraModule);
15
- moduleBuilder.bind(WorkspaceServicePortToken).to(_WorkspaceServiceAdapter).onActivation((ctx, implementation) => withOptionalPortTelemetry("WorkspaceServicePort", implementation, ctx.resolve(CliLoggerToken))).singleton();
16
- moduleBuilder.bind(PackageRepositoryPortToken).to(_PackageRepositoryAdapter).onActivation((ctx, implementation) => withOptionalPortTelemetry("PackageRepositoryPort", implementation, ctx.resolve(CliLoggerToken))).singleton();
17
- moduleBuilder.bind(FileSystemServicePortToken).to(_FileSystemServiceAdapter).onActivation((ctx, implementation) => withOptionalPortTelemetry("FileSystemServicePort", implementation, ctx.resolve(CliLoggerToken))).singleton();
18
- moduleBuilder.bind(MirrorSyncReporterPortToken).to(_MirrorSyncReporterAdapter).onActivation((ctx, implementation) => withOptionalPortTelemetry("MirrorSyncReporterPort", implementation, ctx.resolve(CliLoggerToken))).singleton();
19
- moduleBuilder.bind(SyncWorkspacePackageServiceToken).to(_SyncWorkspacePackageServiceImpl).singleton();
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();
20
22
  moduleBuilder.bind(RunMirrorSyncUseCaseToken).to(_RunMirrorSyncUseCaseImpl).singleton();
21
23
  });
22
24
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- //#region src/lib/mirror/presentation/mirror-cli-schema.presenter.ts
2
+ //#region src/lib/mirror/presentation/mirror-cli.schema.ts
3
3
  const mirrorSyncRunRequestSchema = z.object({
4
4
  rootDir: z.string().min(1),
5
5
  verbose: z.boolean().optional(),
@@ -1,12 +1,15 @@
1
1
  //#region src/lib/shared/source-code/domain/text-edit.model.ts
2
2
  /**
3
3
  * Pure string utilities for applying non-overlapping text edits and reading line indentation.
4
- */ /**
5
- * Returns only the leading whitespace (tabs / spaces) of the line containing `pos`.
6
- */ function indentOfLineContaining(source, pos) {
4
+ */ function lineStartIndexContaining(source, pos) {
7
5
  const searchPos = Math.max(0, Math.min(pos, source.length));
8
6
  const prevLineBreak = Math.max(source.lastIndexOf("\n", searchPos - 1), source.lastIndexOf("\r", searchPos - 1));
9
- const lineStart = prevLineBreak === -1 ? 0 : prevLineBreak + 1;
7
+ return prevLineBreak === -1 ? 0 : prevLineBreak + 1;
8
+ }
9
+ /**
10
+ * Returns only the leading whitespace (tabs / spaces) of the line containing `pos`.
11
+ */ function indentOfLineContaining(source, pos) {
12
+ const lineStart = lineStartIndexContaining(source, pos);
10
13
  let lineEnd = source.length;
11
14
  for (let i = lineStart; i < source.length; i++) {
12
15
  const ch = source[i];
@@ -18,6 +21,30 @@
18
21
  const line = source.slice(lineStart, lineEnd);
19
22
  return /^[\t ]*/.exec(line)?.[0] ?? "";
20
23
  }
24
+ /**
25
+ * Source slice `[lineStart, pos)` for the line containing `pos`. Aligns continuation lines with
26
+ * a token not at column 0 (e.g. `base: ["foo"` → prefix before the opening `"` of `"foo"`).
27
+ */ function textPrefixFromLineStartToPosition(source, pos) {
28
+ const searchPos = Math.max(0, Math.min(pos, source.length));
29
+ return source.slice(lineStartIndexContaining(source, pos), searchPos);
30
+ }
31
+ /**
32
+ * If `tokenEnd` is followed by optional ASCII whitespace then `,`, returns the index after that
33
+ * comma. Otherwise returns `tokenEnd`. Useful when a replacement already ends with `,` and the
34
+ * following source comma must be absorbed.
35
+ */ function endAfterOptionalCommaFollowingInSource(source, tokenEnd) {
36
+ let index = tokenEnd;
37
+ while (index < source.length) {
38
+ const ch = source[index];
39
+ if (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
40
+ index += 1;
41
+ continue;
42
+ }
43
+ if (ch === ",") return index + 1;
44
+ break;
45
+ }
46
+ return tokenEnd;
47
+ }
21
48
  function applyEditsDescending(sourceText, edits) {
22
49
  const sorted = [...edits].sort((editA, editB) => editB.start - editA.start);
23
50
  let out = sourceText;
@@ -25,4 +52,4 @@ function applyEditsDescending(sourceText, edits) {
25
52
  return out;
26
53
  }
27
54
  //#endregion
28
- export { applyEditsDescending, indentOfLineContaining };
55
+ export { applyEditsDescending, endAfterOptionalCommaFollowingInSource, indentOfLineContaining, textPrefixFromLineStartToPosition };
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- //#region src/lib/shared/source-code/infra/tsx-file-walk.adapter.ts
2
+ //#region src/lib/shared/source-code/infrastructure/typescript-source-file-walker.service.ts
3
3
  const DEFAULT_SKIP_DIRS = new Set([
4
4
  "node_modules",
5
5
  "dist",
@@ -30,4 +30,4 @@ function walkTsxFiles(rootDirectoryPath, fs) {
30
30
  return result;
31
31
  }
32
32
  //#endregion
33
- export { DEFAULT_SKIP_DIRS, walkTsxFiles };
33
+ export { walkTsxFiles };
@@ -0,0 +1,6 @@
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,13 +1,13 @@
1
- import { CliLoggerToken } from "../lib/core/operational/contracts/tokens.mjs";
2
- import { parseWithCliSchema } from "../lib/core/presentation/parse-cli-schema.presenter.mjs";
3
- import { consumeCliAppError } from "../lib/core/presentation/cli-executor.presenter.mjs";
4
- import { exitCodeForTagSyncResult } from "../lib/tag/application/tag-sync-cli-result.mjs";
5
- import { formatTagSyncJsonOutput } from "../lib/tag/application/tag-sync-json.format.mjs";
6
- import { CreateTagProgressListenerPresenterToken, PrepareTagOrchestratorToken, PresentTagSyncResultPresenterToken, RunTagSyncUseCaseToken } from "../lib/tag/contracts/tokens.mjs";
7
- import { tagSyncRunRequestSchema } from "../lib/tag/presentation/tag-cli-schema.presenter.mjs";
8
- import process from "node:process";
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
9
  import { inject, injectable } from "@codefast/di";
10
- //#region src/commands/tag.ts
10
+ //#region src/lib/tag/adapters/primary/cli/tag.command.ts
11
11
  function toPrimitive(input, hint) {
12
12
  if (typeof input !== "object" || input === null) return input;
13
13
  var prim = input[Symbol.toPrimitive];
@@ -220,26 +220,29 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
220
220
  let _dec, _initClass;
221
221
  _dec = injectable([
222
222
  inject(CliLoggerToken),
223
- inject(PrepareTagOrchestratorToken),
223
+ inject(CliRuntimeToken),
224
+ inject(PrepareTagSyncUseCaseToken),
224
225
  inject(RunTagSyncUseCaseToken),
225
- inject(CreateTagProgressListenerPresenterToken),
226
+ inject(TagSyncProgressListenerToken),
226
227
  inject(PresentTagSyncResultPresenterToken)
227
228
  ]);
228
229
  let _TagCommand;
229
230
  (class {
230
231
  logger;
232
+ runtime;
231
233
  prepareTagSync;
232
234
  runTagSync;
233
- createProgressListener;
235
+ tagProgressListener;
234
236
  presentSyncCliResult;
235
237
  static {
236
238
  ({c: [_TagCommand, _initClass]} = _apply_decs_2311(this, [_dec], []));
237
239
  }
238
- constructor(logger, prepareTagSync, runTagSync, createProgressListener, presentSyncCliResult) {
240
+ constructor(logger, runtime, prepareTagSync, runTagSync, tagProgressListener, presentSyncCliResult) {
239
241
  this.logger = logger;
242
+ this.runtime = runtime;
240
243
  this.prepareTagSync = prepareTagSync;
241
244
  this.runTagSync = runTagSync;
242
- this.createProgressListener = createProgressListener;
245
+ this.tagProgressListener = tagProgressListener;
243
246
  this.presentSyncCliResult = presentSyncCliResult;
244
247
  }
245
248
  name = "tag";
@@ -247,11 +250,10 @@ let _TagCommand;
247
250
  register(program) {
248
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));
249
252
  }
250
- async execute(target, options, command) {
253
+ async execute(target, options, _command) {
251
254
  const prelude = await this.prepareTagSync.execute({
252
- currentWorkingDirectory: process.cwd(),
253
- rawTarget: target,
254
- globalCliRaw: command.optsWithGlobals()
255
+ currentWorkingDirectory: this.runtime.cwd(),
256
+ rawTarget: target
255
257
  });
256
258
  if (!consumeCliAppError(this.logger, prelude)) return;
257
259
  const { rootDir, config, resolvedTargetPath } = prelude.value;
@@ -267,13 +269,13 @@ let _TagCommand;
267
269
  if (!consumeCliAppError(this.logger, parsed)) return;
268
270
  const tagOutcome = await this.runTagSync.execute({
269
271
  ...parsed.value,
270
- listener: parsed.value.json ? void 0 : this.createProgressListener.create((line) => this.logger.out(line))
272
+ listener: parsed.value.json ? void 0 : this.tagProgressListener
271
273
  });
272
274
  if (!consumeCliAppError(this.logger, tagOutcome)) return;
273
275
  if (parsed.value.json) {
274
276
  this.logger.out(formatTagSyncJsonOutput(tagOutcome.value, rootDir));
275
- process.exitCode = exitCodeForTagSyncResult(tagOutcome.value);
276
- } else process.exitCode = this.presentSyncCliResult.present(tagOutcome.value, rootDir);
277
+ this.runtime.setExitCode(exitCodeForTagSyncResult(tagOutcome.value));
278
+ } else this.runtime.setExitCode(this.presentSyncCliResult.present(tagOutcome.value, rootDir));
277
279
  }
278
280
  static {
279
281
  _initClass();
@@ -0,0 +1,13 @@
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 };
@@ -1,7 +1,8 @@
1
- import { applyEditsDescending, indentOfLineContaining } from "../../shared/source-code/domain/text-edit.model.mjs";
2
- import { injectable } from "@codefast/di";
1
+ import { CliFsToken } from "../../../core/contracts/tokens.mjs";
2
+ import { applyEditsDescending, indentOfLineContaining } from "../../../shared/source-code/domain/text-edit.model.mjs";
3
+ import { inject, injectable } from "@codefast/di";
3
4
  import ts from "typescript";
4
- //#region src/lib/tag/infra/tag-since-writer.adapter.ts
5
+ //#region src/lib/tag/adapters/secondary/tag-since-writer.adapter.ts
5
6
  function toPrimitive(input, hint) {
6
7
  if (typeof input !== "object" || input === null) return input;
7
8
  var prim = input[Symbol.toPrimitive];
@@ -311,14 +312,18 @@ function makeDeclarationSinceLine(declaration, sf, sourceText, version) {
311
312
  replacement: `${indent}${makeSinceOnlyJSDocBlock(indent, version)}\n${indent}`
312
313
  };
313
314
  }
314
- _dec = injectable([]);
315
+ _dec = injectable([inject(CliFsToken)]);
315
316
  let _TagSinceWriterAdapter;
316
317
  (class {
318
+ fs;
317
319
  static {
318
320
  ({c: [_TagSinceWriterAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
319
321
  }
320
- applySinceTagsToFile(filePath, version, fs, write) {
321
- const sourceText = fs.readFileSync(filePath, "utf8");
322
+ constructor(fs) {
323
+ this.fs = fs;
324
+ }
325
+ applySinceTagsToFile(filePath, version, write) {
326
+ const sourceText = this.fs.readFileSync(filePath, "utf8");
322
327
  const sf = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
323
328
  const edits = [];
324
329
  for (const declaration of collectExportedDeclarations(sf)) {
@@ -327,7 +332,7 @@ let _TagSinceWriterAdapter;
327
332
  }
328
333
  if (edits.length > 0 && write) {
329
334
  const updated = applyEditsDescending(sourceText, edits);
330
- fs.writeFileSync(filePath, updated, "utf8");
335
+ this.fs.writeFileSync(filePath, updated, "utf8");
331
336
  }
332
337
  return {
333
338
  filePath,
@@ -1,6 +1,7 @@
1
- import { resolveTagTargetCandidates } from "./tag-target-candidates.adapter.mjs";
2
- import { injectable } from "@codefast/di";
3
- //#region src/lib/tag/infra/tag-target-resolver.adapter.ts
1
+ import { CliFsToken } from "../../../core/contracts/tokens.mjs";
2
+ import { resolveTagTargetCandidates } from "../../infrastructure/tag-target-candidates.adapter.mjs";
3
+ import { inject, injectable } from "@codefast/di";
4
+ //#region src/lib/tag/adapters/secondary/tag-target-resolver.adapter.ts
4
5
  function toPrimitive(input, hint) {
5
6
  if (typeof input !== "object" || input === null) return input;
6
7
  var prim = input[Symbol.toPrimitive];
@@ -211,13 +212,19 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
211
212
  };
212
213
  }
213
214
  let _dec, _initClass;
214
- _dec = injectable([]);
215
+ _dec = injectable([inject(CliFsToken)]);
215
216
  let _TagTargetResolverAdapter;
216
217
  (class {
218
+ fs;
217
219
  static {
218
220
  ({c: [_TagTargetResolverAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
219
221
  }
220
- resolveTagTargetCandidates = resolveTagTargetCandidates;
222
+ constructor(fs) {
223
+ this.fs = fs;
224
+ }
225
+ resolveTagTargetCandidates(rootDir, explicitTarget) {
226
+ return resolveTagTargetCandidates(rootDir, explicitTarget, this.fs);
227
+ }
221
228
  static {
222
229
  _initClass();
223
230
  }
@@ -1,6 +1,6 @@
1
- import { CliPathToken } from "../../core/operational/contracts/tokens.mjs";
1
+ import { CliFsToken, CliPathToken } from "../../../core/contracts/tokens.mjs";
2
2
  import { inject, injectable } from "@codefast/di";
3
- //#region src/lib/tag/infra/tag-version-resolver.adapter.ts
3
+ //#region src/lib/tag/adapters/secondary/tag-version-resolver.adapter.ts
4
4
  function toPrimitive(input, hint) {
5
5
  if (typeof input !== "object" || input === null) return input;
6
6
  var prim = input[Symbol.toPrimitive];
@@ -212,23 +212,25 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
212
212
  }
213
213
  let _dec, _initClass;
214
214
  const PACKAGE_JSON = "package.json";
215
- _dec = injectable([inject(CliPathToken)]);
215
+ _dec = injectable([inject(CliPathToken), inject(CliFsToken)]);
216
216
  let _TagVersionResolverAdapter;
217
217
  (class {
218
218
  path;
219
+ fs;
219
220
  static {
220
221
  ({c: [_TagVersionResolverAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
221
222
  }
222
- constructor(path) {
223
+ constructor(path, fs) {
223
224
  this.path = path;
225
+ this.fs = fs;
224
226
  }
225
- resolveNearestPackageVersion(targetPath, fs) {
227
+ resolveNearestPackageVersion(targetPath) {
226
228
  const resolved = this.path.resolve(targetPath);
227
- let current = fs.statSync(resolved).isDirectory() ? resolved : this.path.dirname(resolved);
229
+ let current = this.fs.statSync(resolved).isDirectory() ? resolved : this.path.dirname(resolved);
228
230
  while (true) {
229
231
  const packageJsonPath = this.path.join(current, PACKAGE_JSON);
230
- if (fs.existsSync(packageJsonPath)) {
231
- const raw = fs.readFileSync(packageJsonPath, "utf8");
232
+ if (this.fs.existsSync(packageJsonPath)) {
233
+ const raw = this.fs.readFileSync(packageJsonPath, "utf8");
232
234
  const version = JSON.parse(raw).version;
233
235
  if (typeof version === "string" && version.length > 0) return version;
234
236
  throw new Error(`Missing or invalid version in ${packageJsonPath}`);
@@ -1,6 +1,7 @@
1
- import { walkTsxFiles } from "../../shared/source-code/infra/tsx-file-walk.adapter.mjs";
2
- import { injectable } from "@codefast/di";
3
- //#region src/lib/tag/infra/typescript-tree-walk.adapter.ts
1
+ import { CliFsToken } from "../../../core/contracts/tokens.mjs";
2
+ import { walkTsxFiles } from "../../../shared/source-code/infrastructure/typescript-source-file-walker.service.mjs";
3
+ import { inject, injectable } from "@codefast/di";
4
+ //#region src/lib/tag/adapters/secondary/typescript-tree-walk.adapter.ts
4
5
  function toPrimitive(input, hint) {
5
6
  if (typeof input !== "object" || input === null) return input;
6
7
  var prim = input[Symbol.toPrimitive];
@@ -211,13 +212,19 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
211
212
  };
212
213
  }
213
214
  let _dec, _initClass;
214
- _dec = injectable([]);
215
+ _dec = injectable([inject(CliFsToken)]);
215
216
  let _TypeScriptTreeWalkAdapter;
216
217
  (class {
218
+ fs;
217
219
  static {
218
220
  ({c: [_TypeScriptTreeWalkAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
219
221
  }
220
- walkTsxFiles = walkTsxFiles;
222
+ constructor(fs) {
223
+ this.fs = fs;
224
+ }
225
+ walkTsxFiles(rootDirectoryPath) {
226
+ return walkTsxFiles(rootDirectoryPath, this.fs);
227
+ }
221
228
  static {
222
229
  _initClass();
223
230
  }
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- //#region src/lib/tag/presentation/resolve-tag-cli-target.presenter.ts
2
+ //#region src/lib/tag/application/services/tag-cli-target-path-resolver.service.ts
3
3
  function resolveTagCliTargetPath(input) {
4
4
  if (input.rawTarget === void 0) return;
5
5
  const candidate = path.isAbsolute(input.rawTarget) ? path.resolve(input.rawTarget) : path.resolve(input.currentWorkingDirectory, input.rawTarget);
@@ -0,0 +1,21 @@
1
+ //#region src/lib/tag/application/services/tag-target-runner.service.ts
2
+ function resolveNearestPackageVersion(targetPath, versionResolver) {
3
+ return versionResolver.resolveNearestPackageVersion(targetPath);
4
+ }
5
+ function runTagOnTarget(targetPath, opts, fs, pathService, versionResolver, sinceWriter, typeScriptTreeWalk) {
6
+ const resolvedTarget = pathService.resolve(targetPath);
7
+ const version = resolveNearestPackageVersion(resolvedTarget, versionResolver);
8
+ const tsFiles = (fs.statSync(resolvedTarget).isDirectory() ? typeScriptTreeWalk.walkTsxFiles(resolvedTarget) : [resolvedTarget]).filter((filePath) => filePath.endsWith(".ts") || filePath.endsWith(".tsx"));
9
+ const fileResults = tsFiles.map((filePath) => sinceWriter.applySinceTagsToFile(filePath, version, opts.write));
10
+ const filesChanged = fileResults.filter((result) => result.changed).length;
11
+ const taggedDeclarations = fileResults.reduce((sum, result) => sum + result.taggedDeclarations, 0);
12
+ return {
13
+ version,
14
+ filesScanned: tsFiles.length,
15
+ filesChanged,
16
+ taggedDeclarations,
17
+ fileResults
18
+ };
19
+ }
20
+ //#endregion
21
+ export { runTagOnTarget };
@@ -1,12 +1,8 @@
1
- import { CliFsToken, CliLoggerToken } from "../../core/operational/contracts/tokens.mjs";
2
- import { ok } from "../../core/domain/result.model.mjs";
3
- import { findRepoRoot } from "../../infra/workspace/repo-root.adapter.mjs";
4
- import { TryLoadCodefastConfigPresenterToken } from "../../core/contracts/tokens.mjs";
5
- import { parseGlobalCliOptions } from "../../core/presentation/global-cli-options.presenter.mjs";
6
- import { resolveTagCliTargetPath } from "./resolve-tag-cli-target.presenter.mjs";
7
- import { resolveTagWorkspaceRootPath } from "./resolve-tag-workspace-root.presenter.mjs";
1
+ import { CliFsToken, LoadCodefastConfigUseCaseToken, RepoRootResolverPortToken } from "../../../core/contracts/tokens.mjs";
2
+ import { ok } from "../../../core/domain/result.model.mjs";
3
+ import { resolveTagCliTargetPath } from "../services/tag-cli-target-path-resolver.service.mjs";
8
4
  import { inject, injectable } from "@codefast/di";
9
- //#region src/lib/tag/presentation/prepare-tag.orchestrator.ts
5
+ //#region src/lib/tag/application/use-cases/prepare-tag-sync.use-case.ts
10
6
  function toPrimitive(input, hint) {
11
7
  if (typeof input !== "object" || input === null) return input;
12
8
  var prim = input[Symbol.toPrimitive];
@@ -217,33 +213,37 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
217
213
  };
218
214
  }
219
215
  let _dec, _initClass;
216
+ function resolveTagWorkspaceRootPath(args) {
217
+ try {
218
+ return args.repoRootResolver.findRepoRoot(args.currentWorkingDirectory);
219
+ } catch {
220
+ return args.currentWorkingDirectory;
221
+ }
222
+ }
220
223
  _dec = injectable([
221
224
  inject(CliFsToken),
222
- inject(CliLoggerToken),
223
- inject(TryLoadCodefastConfigPresenterToken)
225
+ inject(RepoRootResolverPortToken),
226
+ inject(LoadCodefastConfigUseCaseToken)
224
227
  ]);
225
- let _PrepareTagOrchestrator;
228
+ let _PrepareTagSyncUseCaseImpl;
226
229
  (class {
227
230
  fs;
228
- logger;
229
- tryLoadCodefastConfig;
231
+ repoRootResolver;
232
+ loadCodefastConfig;
230
233
  static {
231
- ({c: [_PrepareTagOrchestrator, _initClass]} = _apply_decs_2311(this, [_dec], []));
234
+ ({c: [_PrepareTagSyncUseCaseImpl, _initClass]} = _apply_decs_2311(this, [_dec], []));
232
235
  }
233
- constructor(fs, logger, tryLoadCodefastConfig) {
236
+ constructor(fs, repoRootResolver, loadCodefastConfig) {
234
237
  this.fs = fs;
235
- this.logger = logger;
236
- this.tryLoadCodefastConfig = tryLoadCodefastConfig;
238
+ this.repoRootResolver = repoRootResolver;
239
+ this.loadCodefastConfig = loadCodefastConfig;
237
240
  }
238
241
  async execute(args) {
239
- const globalsOutcome = parseGlobalCliOptions(args.globalCliRaw);
240
- if (!globalsOutcome.ok) return globalsOutcome;
241
242
  const rootDir = resolveTagWorkspaceRootPath({
242
- resolveStrictRepoRoot: () => findRepoRoot(this.fs, args.currentWorkingDirectory),
243
- logger: this.logger,
243
+ repoRootResolver: this.repoRootResolver,
244
244
  currentWorkingDirectory: args.currentWorkingDirectory
245
245
  });
246
- const loadedOutcome = await this.tryLoadCodefastConfig.execute(rootDir);
246
+ const loadedOutcome = await this.loadCodefastConfig.execute(rootDir);
247
247
  if (!loadedOutcome.ok) return loadedOutcome;
248
248
  const resolvedTargetPath = resolveTagCliTargetPath({
249
249
  fs: this.fs,
@@ -261,4 +261,4 @@ let _PrepareTagOrchestrator;
261
261
  }
262
262
  });
263
263
  //#endregion
264
- export { _PrepareTagOrchestrator as PrepareTagOrchestrator };
264
+ export { _PrepareTagSyncUseCaseImpl as PrepareTagSyncUseCaseImpl };
@@ -1,9 +1,10 @@
1
- import { CliFsToken, CliPathToken } from "../../../core/operational/contracts/tokens.mjs";
2
- import { appError } from "../../../core/domain/errors.domain.mjs";
1
+ import { CliFsToken, CliPathToken } from "../../../core/contracts/tokens.mjs";
2
+ import { AppError } from "../../../core/domain/errors.domain.mjs";
3
3
  import { err, ok } from "../../../core/domain/result.model.mjs";
4
- import { messageFromCaughtUnknown } from "../../../core/application/utils/caught-unknown-message.util.mjs";
4
+ import { messageFromCaughtUnknown } from "../../../core/domain/caught-unknown-message.value-object.mjs";
5
5
  import { TagSinceWriterPortToken, TagTargetResolverPortToken, TagVersionResolverPortToken, TypeScriptTreeWalkPortToken } from "../../contracts/tokens.mjs";
6
- import { injectable } from "@codefast/di";
6
+ import { runTagOnTarget } from "../services/tag-target-runner.service.mjs";
7
+ import { inject, injectable } from "@codefast/di";
7
8
  //#region src/lib/tag/application/use-cases/run-tag-sync.use-case.ts
8
9
  function toPrimitive(input, hint) {
9
10
  if (typeof input !== "object" || input === null) return input;
@@ -215,24 +216,6 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
215
216
  };
216
217
  }
217
218
  let _dec, _initClass;
218
- function resolveNearestPackageVersion(targetPath, fs, versionResolver) {
219
- return versionResolver.resolveNearestPackageVersion(targetPath, fs);
220
- }
221
- function runTagOnTarget(targetPath, opts, fs, pathService, versionResolver, sinceWriter, typeScriptTreeWalk) {
222
- const resolvedTarget = pathService.resolve(targetPath);
223
- const version = resolveNearestPackageVersion(resolvedTarget, fs, versionResolver);
224
- const tsFiles = (fs.statSync(resolvedTarget).isDirectory() ? typeScriptTreeWalk.walkTsxFiles(resolvedTarget, fs) : [resolvedTarget]).filter((filePath) => filePath.endsWith(".ts") || filePath.endsWith(".tsx"));
225
- const fileResults = tsFiles.map((filePath) => sinceWriter.applySinceTagsToFile(filePath, version, fs, opts.write));
226
- const filesChanged = fileResults.filter((result) => result.changed).length;
227
- const taggedDeclarations = fileResults.reduce((sum, result) => sum + result.taggedDeclarations, 0);
228
- return {
229
- version,
230
- filesScanned: tsFiles.length,
231
- filesChanged,
232
- taggedDeclarations,
233
- fileResults
234
- };
235
- }
236
219
  async function runTagOnAfterWriteHook(hook, modifiedFiles) {
237
220
  if (!hook || modifiedFiles.length === 0) return null;
238
221
  try {
@@ -333,12 +316,12 @@ async function runOnResolvedTarget(resolvedTarget, write, fs, pathService, versi
333
316
  }
334
317
  }
335
318
  _dec = injectable([
336
- CliFsToken,
337
- CliPathToken,
338
- TagTargetResolverPortToken,
339
- TypeScriptTreeWalkPortToken,
340
- TagVersionResolverPortToken,
341
- TagSinceWriterPortToken
319
+ inject(CliFsToken),
320
+ inject(CliPathToken),
321
+ inject(TagTargetResolverPortToken),
322
+ inject(TypeScriptTreeWalkPortToken),
323
+ inject(TagVersionResolverPortToken),
324
+ inject(TagSinceWriterPortToken)
342
325
  ]);
343
326
  let _RunTagSyncUseCaseImpl;
344
327
  (class {
@@ -362,7 +345,7 @@ let _RunTagSyncUseCaseImpl;
362
345
  async execute(input) {
363
346
  try {
364
347
  const tagConfig = input.config;
365
- const { includedCandidates, skippedPackages } = filterSkippedCandidates(await this.targetResolver.resolveTagTargetCandidates(input.rootDir, input.targetPath, this.fs), input.skipPackages);
348
+ const { includedCandidates, skippedPackages } = filterSkippedCandidates(await this.targetResolver.resolveTagTargetCandidates(input.rootDir, input.targetPath), input.skipPackages);
366
349
  const selectedTargets = includedCandidates.map((candidate) => resolveTargetSelection(candidate, input.rootDir, this.path, this.fs));
367
350
  const targetExecutionResults = await Promise.all(selectedTargets.map((resolvedTarget) => runOnResolvedTarget(resolvedTarget, input.write, this.fs, this.path, this.versionResolver, this.sinceWriter, this.typeScriptTreeWalk, input.listener)));
368
351
  const allFileResults = targetExecutionResults.flatMap((targetResult) => targetResult.result?.fileResults ?? []);
@@ -387,7 +370,7 @@ let _RunTagSyncUseCaseImpl;
387
370
  hookError
388
371
  });
389
372
  } catch (caughtError) {
390
- return err(appError("INFRA_FAILURE", messageFromCaughtUnknown(caughtError), caughtError));
373
+ return err(new AppError("INFRA_FAILURE", messageFromCaughtUnknown(caughtError), caughtError));
391
374
  }
392
375
  }
393
376
  static {
@@ -395,4 +378,4 @@ let _RunTagSyncUseCaseImpl;
395
378
  }
396
379
  });
397
380
  //#endregion
398
- export { _RunTagSyncUseCaseImpl as RunTagSyncUseCaseImpl, resolveNearestPackageVersion, runTagOnTarget };
381
+ export { _RunTagSyncUseCaseImpl as RunTagSyncUseCaseImpl };