@codefast/cli 0.3.14-canary.2 → 0.3.15

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 (205) hide show
  1. package/README.md +8 -3
  2. package/dist/bootstrap/cli-application.module.mjs +18 -0
  3. package/dist/bootstrap/composition-root.mjs +14 -0
  4. package/dist/bootstrap/register-cli-command-trees.mjs +7 -0
  5. package/dist/{lib → domains}/arrange/application/use-cases/analyze-directory.use-case.mjs +12 -12
  6. package/dist/{lib → domains}/arrange/application/use-cases/prepare-arrange-workspace.use-case.mjs +19 -18
  7. package/dist/{lib → domains}/arrange/application/use-cases/run-arrange-sync.use-case.mjs +18 -18
  8. package/dist/{lib → domains}/arrange/application/use-cases/suggest-cn-groups.use-case.mjs +5 -5
  9. package/dist/domains/arrange/arrange.module.mjs +38 -0
  10. package/dist/domains/arrange/composition/tokens.mjs +17 -0
  11. package/dist/{lib/arrange/domain/arrange-analyze.service.mjs → domains/arrange/domain/arrange-analyze.domain-service.mjs} +1 -1
  12. package/dist/{lib/arrange/domain/arrange-grouping.service.mjs → domains/arrange/domain/arrange-grouping.domain-service.mjs} +2 -2
  13. package/dist/{lib → domains}/arrange/domain/ast/ast-helpers.helper.mjs +2 -2
  14. package/dist/{lib → domains}/arrange/domain/ast/ast-node.model.mjs +1 -1
  15. package/dist/{lib → domains}/arrange/domain/ast/collectors-cn.collector.mjs +1 -1
  16. package/dist/{lib → domains}/arrange/domain/ast/collectors-jsx.collector.mjs +1 -1
  17. package/dist/{lib → domains}/arrange/domain/ast/collectors-tv.collector.mjs +1 -1
  18. package/dist/{lib → domains}/arrange/domain/ast/targets.model.mjs +2 -2
  19. package/dist/{lib → domains}/arrange/domain/constants.domain.mjs +1 -1
  20. package/dist/{lib → domains}/arrange/domain/grouping.domain.mjs +1 -1
  21. package/dist/{lib → domains}/arrange/domain/imports.domain.mjs +1 -1
  22. package/dist/{lib → domains}/arrange/domain/source-text-formatters.formatter.mjs +2 -2
  23. package/dist/{lib/arrange/domain/tailwind-grouping.service.mjs → domains/arrange/domain/tailwind-grouping.domain-service.mjs} +5 -5
  24. package/dist/{lib → domains}/arrange/domain/tailwind-token-classifier.domain-service.mjs +1 -1
  25. package/dist/{lib → domains}/arrange/domain/tailwind-token.value-object.mjs +1 -1
  26. package/dist/{lib/arrange/application/services/arrange-file-processor.service.mjs → domains/arrange/infrastructure/adapters/arrange-file-processor.adapter.mjs} +8 -8
  27. package/dist/domains/arrange/infrastructure/adapters/arrange-target-path-resolver.adapter.mjs +247 -0
  28. package/dist/{lib/arrange/application/services/arrange-target-scanner.service.mjs → domains/arrange/infrastructure/adapters/arrange-target-scanner.adapter.mjs} +8 -8
  29. package/dist/{lib/arrange/adapters/secondary → domains/arrange/infrastructure/adapters}/domain-source-parser.adapter.mjs +10 -8
  30. package/dist/{lib/arrange/adapters/secondary → domains/arrange/infrastructure/adapters}/file-walker.adapter.mjs +8 -9
  31. package/dist/domains/arrange/infrastructure/typescript-ast-translator.mjs +580 -0
  32. package/dist/{lib/arrange/adapters/primary → domains/arrange/presentation}/cli/arrange.command.mjs +195 -54
  33. package/dist/{lib/arrange/presentation → domains/arrange/presentation/presenters}/arrange-analyze.presenter.mjs +26 -33
  34. package/dist/{lib/arrange/presentation → domains/arrange/presentation/presenters}/arrange-cli.schema.mjs +1 -1
  35. package/dist/{lib/tag/presentation/present-tag-sync-result.presenter.mjs → domains/arrange/presentation/presenters/arrange-sync.presenter.mjs} +12 -9
  36. package/dist/{lib/arrange/presentation → domains/arrange/presentation/presenters}/group-file-preview.presenter.mjs +46 -46
  37. package/dist/domains/config/composition/tokens.mjs +7 -0
  38. package/dist/{lib/config/infrastructure/config-schema.adapter.mjs → domains/config/domain/codefast-config.schema.mjs} +6 -6
  39. package/dist/{lib/config/infrastructure → domains/config/infrastructure/adapters}/config-loader.adapter.mjs +76 -77
  40. package/dist/{lib/config/infrastructure → domains/config/infrastructure/adapters}/config-warning-reporter.adapter.mjs +6 -6
  41. package/dist/domains/config/infrastructure/adapters/zod-codefast-config-schema.adapter.mjs +236 -0
  42. package/dist/domains/mirror/application/mirror-sync-cli-result.mjs +15 -0
  43. package/dist/{lib → domains}/mirror/application/use-cases/prepare-mirror-sync.use-case.mjs +14 -15
  44. package/dist/{lib → domains}/mirror/application/use-cases/run-mirror-sync.use-case.mjs +69 -54
  45. package/dist/{lib/mirror/contracts → domains/mirror/composition}/tokens.mjs +4 -3
  46. package/dist/{lib → domains}/mirror/domain/constants.domain.mjs +1 -1
  47. package/dist/{lib → domains}/mirror/domain/errors.domain.mjs +1 -1
  48. package/dist/{lib/mirror/application/services/generate-mirror-exports.service.mjs → domains/mirror/domain/generate-mirror-exports.domain-service.mjs} +2 -2
  49. package/dist/{lib → domains}/mirror/domain/package-display-name.policy.mjs +1 -1
  50. package/dist/{lib → domains}/mirror/domain/path-normalizer.value-object.mjs +1 -1
  51. package/dist/{lib/mirror/adapters/secondary → domains/mirror/infrastructure/adapters}/file-system-service.adapter.mjs +8 -8
  52. package/dist/domains/mirror/infrastructure/adapters/mirror-package-path-resolver.adapter.mjs +252 -0
  53. package/dist/{lib/mirror/adapters/secondary → domains/mirror/infrastructure/adapters}/mirror-sync-reporter.adapter.mjs +94 -15
  54. package/dist/{lib/mirror/adapters/secondary → domains/mirror/infrastructure/adapters}/package-repository.adapter.mjs +4 -4
  55. package/dist/{lib/mirror/adapters/secondary → domains/mirror/infrastructure/adapters}/sync-workspace-package.adapter.mjs +23 -46
  56. package/dist/{lib/mirror/infrastructure → domains/mirror/infrastructure/guards}/dirent-list.guard.mjs +1 -1
  57. package/dist/{lib → domains}/mirror/infrastructure/package-json-exports.repository.mjs +27 -27
  58. package/dist/domains/mirror/mirror.module.mjs +26 -0
  59. package/dist/{lib/mirror/adapters/primary → domains/mirror/presentation}/cli/mirror.command.mjs +83 -27
  60. package/dist/{lib/mirror/presentation → domains/mirror/presentation/presenters}/mirror-cli.schema.mjs +1 -4
  61. package/dist/domains/mirror/presentation/presenters/present-mirror-sync-progress.presenter.mjs +265 -0
  62. package/dist/domains/tag/application/ports/outbound/tag-eligible-workspace-paths.port.mjs +1 -0
  63. package/dist/domains/tag/application/ports/outbound/tag-since-writer.port.mjs +1 -0
  64. package/dist/domains/tag/application/ports/outbound/tag-target-path-resolver.port.mjs +1 -0
  65. package/dist/domains/tag/application/ports/outbound/tag-target-runner.port.mjs +1 -0
  66. package/dist/domains/tag/application/ports/outbound/tag-version-resolver.port.mjs +1 -0
  67. package/dist/domains/tag/application/ports/presenting/present-tag-sync-progress.presenter.mjs +1 -0
  68. package/dist/domains/tag/application/ports/presenting/present-tag-sync-result.presenter.mjs +1 -0
  69. package/dist/domains/tag/application/requests/tag-sync-execution-input.mjs +1 -0
  70. package/dist/domains/tag/application/requests/tag-sync.request.mjs +1 -0
  71. package/dist/{lib → domains}/tag/application/tag-sync-cli-result.mjs +3 -3
  72. package/dist/{lib → domains}/tag/application/use-cases/prepare-tag-sync.use-case.mjs +20 -24
  73. package/dist/{lib → domains}/tag/application/use-cases/run-tag-sync.use-case.mjs +123 -129
  74. package/dist/domains/tag/composition/tokens.mjs +13 -0
  75. package/dist/domains/tag/contracts/models.mjs +1 -0
  76. package/dist/domains/tag/domain/types.domain.mjs +1 -0
  77. package/dist/{lib/tag/adapters/secondary → domains/tag/infrastructure/adapters}/tag-since-writer.adapter.mjs +105 -105
  78. package/dist/{lib/tag/adapters/secondary/typescript-tree-walk.adapter.mjs → domains/tag/infrastructure/adapters/tag-target-path-resolver.adapter.mjs} +11 -9
  79. package/dist/domains/tag/infrastructure/adapters/tag-target-resolver.adapter.mjs +302 -0
  80. package/dist/domains/tag/infrastructure/adapters/tag-target-runner.adapter.mjs +259 -0
  81. package/dist/{lib/tag/adapters/secondary → domains/tag/infrastructure/adapters}/tag-version-resolver.adapter.mjs +6 -6
  82. package/dist/{lib/tag/adapters/primary → domains/tag/presentation}/cli/tag.command.mjs +67 -27
  83. package/dist/{lib/tag/presentation/tag-sync-progress-listener.presenter.mjs → domains/tag/presentation/presenters/present-tag-sync-progress.presenter.mjs} +14 -9
  84. package/dist/domains/tag/presentation/presenters/present-tag-sync-result.presenter.mjs +290 -0
  85. package/dist/{lib/tag/presentation → domains/tag/presentation/presenters}/tag-cli.schema.mjs +1 -1
  86. package/dist/domains/tag/tag.module.mjs +28 -0
  87. package/dist/program.mjs +3 -2
  88. package/dist/shell/application/cli-runtime.tokens.mjs +18 -0
  89. package/dist/shell/application/coordination/cli-executor.coordination.mjs +1 -0
  90. package/dist/shell/application/coordination/cli-schema-parsing.coordination.mjs +1 -0
  91. package/dist/shell/application/global-cli-options.model.mjs +5 -0
  92. package/dist/shell/application/ports/inbound/load-codefast-config.port.mjs +1 -0
  93. package/dist/shell/application/ports/outbound/cli-fs.port.mjs +1 -0
  94. package/dist/shell/application/ports/outbound/cli-logger.port.mjs +1 -0
  95. package/dist/shell/application/ports/outbound/cli-path.port.mjs +1 -0
  96. package/dist/shell/application/ports/outbound/cli-runtime.port.mjs +1 -0
  97. package/dist/shell/application/ports/outbound/cli-telemetry.port.mjs +1 -0
  98. package/dist/shell/application/ports/outbound/cli-verbose-diagnostics.port.mjs +1 -0
  99. package/dist/shell/application/ports/outbound/format-app-error.port.mjs +1 -0
  100. package/dist/shell/application/ports/outbound/global-cli-options-parse.port.mjs +1 -0
  101. package/dist/shell/application/ports/outbound/repo-root-resolver.port.mjs +1 -0
  102. package/dist/shell/application/ports/outbound/typescript-source-file-walker.port.mjs +1 -0
  103. package/dist/shell/application/ports/outbound/workspace-package-layout.port.mjs +1 -0
  104. package/dist/shell/application/ports/primary/command.port.mjs +1 -0
  105. package/dist/shell/application/services/cli-executor.service.mjs +267 -0
  106. package/dist/shell/application/services/schema-validator.service.mjs +236 -0
  107. package/dist/{lib/core/application → shell/application/use-cases}/load-codefast-config.use-case.mjs +11 -13
  108. package/dist/shell/composition/tokens.mjs +5 -0
  109. package/dist/shell/contracts/cli-command-slots.mjs +11 -0
  110. package/dist/{lib/core → shell}/domain/caught-unknown-message.value-object.mjs +1 -1
  111. package/dist/{lib/core → shell}/domain/cli-exit-codes.domain.mjs +1 -1
  112. package/dist/shell/domain/cli-positional-arg.value-object.mjs +6 -0
  113. package/dist/{lib/core → shell}/domain/errors.domain.mjs +1 -1
  114. package/dist/{lib/core → shell}/domain/result.model.mjs +1 -1
  115. package/dist/{lib/shared/source-code/domain/text-edit.model.mjs → shell/domain/source-text-edit.support.mjs} +2 -2
  116. package/dist/shell/infrastructure/adapters/cli-verbose-diagnostics.adapter.mjs +228 -0
  117. package/dist/{lib/tag/adapters/secondary/tag-target-resolver.adapter.mjs → shell/infrastructure/adapters/format-app-error.adapter.mjs} +16 -13
  118. package/dist/shell/infrastructure/adapters/global-cli-options-parser.adapter.mjs +233 -0
  119. package/dist/{lib/mirror/adapters/secondary/workspace-service.adapter.mjs → shell/infrastructure/adapters/repo-root-resolver.adapter.mjs} +20 -13
  120. package/dist/shell/infrastructure/adapters/typescript-source-file-walker.adapter.mjs +259 -0
  121. package/dist/shell/infrastructure/commander/commander-cli-host.adapter.mjs +69 -0
  122. package/dist/{lib/infrastructure/node-io.adapter.mjs → shell/infrastructure/node/node-cli-fs.adapter.mjs} +11 -47
  123. package/dist/{lib/arrange/adapters/secondary/workspace-resolver.adapter.mjs → shell/infrastructure/node/node-cli-logger.adapter.mjs} +11 -13
  124. package/dist/{lib/core/infrastructure/path.adapter.mjs → shell/infrastructure/node/node-cli-path.adapter.mjs} +1 -1
  125. package/dist/{lib/core/infrastructure/repo-root-resolver.adapter.mjs → shell/infrastructure/node/node-cli-runtime.adapter.mjs} +14 -13
  126. package/dist/shell/infrastructure/telemetry/cli-telemetry.adapter.mjs +280 -0
  127. package/dist/shell/infrastructure/workspace/node-pnpm-workspace-package-layout.adapter.mjs +385 -0
  128. package/dist/shell/shell.module.mjs +43 -0
  129. package/dist/shell/wiring/optional-cli-port-telemetry-activation.mjs +13 -0
  130. package/package.json +9 -7
  131. package/dist/lib/arrange/adapters/primary/cli/arrange.presentation.module.mjs +0 -14
  132. package/dist/lib/arrange/adapters/primary/cli/presentation.tokens.mjs +0 -5
  133. package/dist/lib/arrange/application/services/arrange-target-path-resolver.service.mjs +0 -21
  134. package/dist/lib/arrange/arrange.module.mjs +0 -31
  135. package/dist/lib/arrange/contracts/tokens.mjs +0 -15
  136. package/dist/lib/arrange/infrastructure/typescript-ast-translator.adapter.mjs +0 -355
  137. package/dist/lib/arrange/presentation/arrange-sync.presenter.mjs +0 -33
  138. package/dist/lib/bootstrap/composition-root.mjs +0 -33
  139. package/dist/lib/config/application/services/load-config.service.mjs +0 -17
  140. package/dist/lib/config/contracts/tokens.mjs +0 -6
  141. package/dist/lib/core/application/services/global-cli-options-parser.service.mjs +0 -9
  142. package/dist/lib/core/application/services/schema-validator.service.mjs +0 -17
  143. package/dist/lib/core/contracts/tokens.mjs +0 -10
  144. package/dist/lib/core/core.module.mjs +0 -9
  145. package/dist/lib/core/infrastructure/infrastructure.module.mjs +0 -30
  146. package/dist/lib/core/infrastructure/port-telemetry.decorator.mjs +0 -62
  147. package/dist/lib/core/infrastructure/verbose-diagnostics.policy.mjs +0 -9
  148. package/dist/lib/core/presentation/cli-executor.presenter.mjs +0 -42
  149. package/dist/lib/core/presentation/cli-schema.parser.mjs +0 -7
  150. package/dist/lib/core/presentation/format-app-error.presenter.mjs +0 -17
  151. package/dist/lib/core/presentation/presentation.module.mjs +0 -5
  152. package/dist/lib/infrastructure/workspace/repo-root-resolver.service.mjs +0 -21
  153. package/dist/lib/kernel/contracts/tokens.mjs +0 -5
  154. package/dist/lib/mirror/application/mirror-sync-json.format.mjs +0 -12
  155. package/dist/lib/mirror/application/services/mirror-package-arg-resolver.service.mjs +0 -20
  156. package/dist/lib/mirror/infrastructure/mirror-console-reporter.presenter.mjs +0 -99
  157. package/dist/lib/mirror/infrastructure/package-filter-resolver.service.mjs +0 -25
  158. package/dist/lib/mirror/infrastructure/workspace-packages.service.mjs +0 -158
  159. package/dist/lib/mirror/mirror.module.mjs +0 -25
  160. package/dist/lib/shared/source-code/infrastructure/typescript-source-file-walker.service.mjs +0 -33
  161. package/dist/lib/tag/adapters/primary/cli/presentation.tokens.mjs +0 -6
  162. package/dist/lib/tag/adapters/primary/cli/tag.presentation.module.mjs +0 -13
  163. package/dist/lib/tag/application/services/tag-cli-target-path-resolver.service.mjs +0 -9
  164. package/dist/lib/tag/application/services/tag-target-runner.service.mjs +0 -21
  165. package/dist/lib/tag/application/tag-sync-json.format.mjs +0 -14
  166. package/dist/lib/tag/contracts/tokens.mjs +0 -10
  167. package/dist/lib/tag/infrastructure/tag-target-candidates.adapter.mjs +0 -170
  168. package/dist/lib/tag/presentation/colors.presenter.mjs +0 -12
  169. package/dist/lib/tag/presentation/tag-sync.presenter.mjs +0 -61
  170. package/dist/lib/tag/tag.module.mjs +0 -23
  171. /package/dist/{lib/arrange/application/ports/domain-source-parser.port.mjs → domains/arrange/application/ports/inbound/analyze-directory.port.mjs} +0 -0
  172. /package/dist/{lib/arrange/application/ports/file-walker.port.mjs → domains/arrange/application/ports/inbound/prepare-arrange-workspace.port.mjs} +0 -0
  173. /package/dist/{lib/arrange/application/ports/group-file-preview.port.mjs → domains/arrange/application/ports/inbound/run-arrange-sync.port.mjs} +0 -0
  174. /package/dist/{lib/arrange/application/ports/workspace-resolver.port.mjs → domains/arrange/application/ports/inbound/suggest-cn-groups.port.mjs} +0 -0
  175. /package/dist/{lib/arrange/application/requests/analyze-directory.request.mjs → domains/arrange/application/ports/outbound/arrange-file-processor.port.mjs} +0 -0
  176. /package/dist/{lib/arrange/application/requests/arrange-sync.request.mjs → domains/arrange/application/ports/outbound/arrange-target-path-resolver.port.mjs} +0 -0
  177. /package/dist/{lib/arrange/application/requests/suggest-groups.request.mjs → domains/arrange/application/ports/outbound/arrange-target-scanner.port.mjs} +0 -0
  178. /package/dist/{lib/arrange/contracts/analyze-report-presenter.contract.mjs → domains/arrange/application/ports/outbound/domain-source-parser.port.mjs} +0 -0
  179. /package/dist/{lib/arrange/contracts/models.mjs → domains/arrange/application/ports/outbound/file-walker.port.mjs} +0 -0
  180. /package/dist/{lib/arrange/contracts/services.contract.mjs → domains/arrange/application/ports/presenting/present-analyze-report.presenter.mjs} +0 -0
  181. /package/dist/{lib/arrange/domain/types.domain.mjs → domains/arrange/application/ports/presenting/present-arrange-sync-result.presenter.mjs} +0 -0
  182. /package/dist/{lib/config/application/ports/config-loader.port.mjs → domains/arrange/application/ports/presenting/present-group-file-preview.presenter.mjs} +0 -0
  183. /package/dist/{lib/config/application/ports/config-warning-reporter.port.mjs → domains/arrange/application/requests/analyze-directory.request.mjs} +0 -0
  184. /package/dist/{lib/config/domain/schema.domain.mjs → domains/arrange/application/requests/arrange-sync.request.mjs} +0 -0
  185. /package/dist/{lib/core/application/ports/cli-io.port.mjs → domains/arrange/application/requests/suggest-groups.request.mjs} +0 -0
  186. /package/dist/{lib/mirror → domains/arrange}/contracts/models.mjs +0 -0
  187. /package/dist/{lib/mirror → domains/arrange}/domain/types.domain.mjs +0 -0
  188. /package/dist/{lib/core/application/ports/path.port.mjs → domains/config/application/ports/outbound/codefast-config-schema.port.mjs} +0 -0
  189. /package/dist/{lib/core/application/ports/repo-root-resolver.port.mjs → domains/config/application/ports/outbound/config-loader.port.mjs} +0 -0
  190. /package/dist/{lib/core/application/ports/runtime.port.mjs → domains/config/application/ports/outbound/config-warning-reporter.port.mjs} +0 -0
  191. /package/dist/{lib/kernel/contracts/cli-command.contract.mjs → domains/config/domain/schema.domain.mjs} +0 -0
  192. /package/dist/{lib/mirror/application/ports/file-system-service.port.mjs → domains/mirror/application/ports/inbound/prepare-mirror-sync.port.mjs} +0 -0
  193. /package/dist/{lib/mirror/application/ports/mirror-sync-reporter.port.mjs → domains/mirror/application/ports/inbound/run-mirror-sync.port.mjs} +0 -0
  194. /package/dist/{lib/mirror/application/ports/package-repository.port.mjs → domains/mirror/application/ports/outbound/file-system-service.port.mjs} +0 -0
  195. /package/dist/{lib/mirror/application/ports/sync-workspace-package.port.mjs → domains/mirror/application/ports/outbound/mirror-package-path.port.mjs} +0 -0
  196. /package/dist/{lib/mirror/application/ports/workspace-service.port.mjs → domains/mirror/application/ports/outbound/mirror-sync-reporter.port.mjs} +0 -0
  197. /package/dist/{lib/mirror/application/requests/mirror-sync.request.mjs → domains/mirror/application/ports/outbound/package-repository.port.mjs} +0 -0
  198. /package/dist/{lib/tag/application/ports/tag-since-writer.port.mjs → domains/mirror/application/ports/outbound/sync-workspace-package.port.mjs} +0 -0
  199. /package/dist/{lib/tag/application/ports/tag-version-resolver.port.mjs → domains/mirror/application/ports/presenting/present-mirror-sync-progress.presenter.mjs} +0 -0
  200. /package/dist/{lib/tag/application/ports/target-resolver.port.mjs → domains/mirror/application/requests/mirror-sync-execution-input.mjs} +0 -0
  201. /package/dist/{lib/tag/application/ports/typescript-tree-walk.port.mjs → domains/mirror/application/requests/mirror-sync.request.mjs} +0 -0
  202. /package/dist/{lib/tag → domains/mirror}/contracts/models.mjs +0 -0
  203. /package/dist/{lib/tag → domains/mirror}/domain/types.domain.mjs +0 -0
  204. /package/dist/{lib/tag/application/requests/tag-sync.request.mjs → domains/tag/application/ports/inbound/prepare-tag-sync.port.mjs} +0 -0
  205. /package/dist/{lib/tag/contracts/tag-sync-result-presenter.contract.mjs → domains/tag/application/ports/inbound/run-tag-sync.port.mjs} +0 -0
@@ -0,0 +1,280 @@
1
+ import { injectable } from "@codefast/di";
2
+ //#region src/shell/infrastructure/telemetry/cli-telemetry.adapter.ts
3
+ function toPrimitive(input, hint) {
4
+ if (typeof input !== "object" || input === null) return input;
5
+ var prim = input[Symbol.toPrimitive];
6
+ if (prim !== void 0) {
7
+ var res = prim.call(input, hint || "default");
8
+ if (typeof res !== "object") return res;
9
+ throw new TypeError("@@toPrimitive must return a primitive value.");
10
+ }
11
+ return (hint === "string" ? String : Number)(input);
12
+ }
13
+ function toPropertyKey(arg) {
14
+ var key = toPrimitive(arg, "string");
15
+ return typeof key === "symbol" ? key : String(key);
16
+ }
17
+ function checkInRHS(value) {
18
+ if (Object(value) !== value) throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null"));
19
+ return value;
20
+ }
21
+ function setFunctionName(fn, name, prefix) {
22
+ if (typeof name === "symbol") {
23
+ name = name.description;
24
+ name = name ? "[" + name + "]" : "";
25
+ }
26
+ try {
27
+ Object.defineProperty(fn, "name", {
28
+ configurable: true,
29
+ value: prefix ? prefix + " " + name : name
30
+ });
31
+ } catch (_) {}
32
+ return fn;
33
+ }
34
+ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) {
35
+ var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
36
+ var defineProperty = Object.defineProperty;
37
+ var create = Object.create;
38
+ var metadata;
39
+ var existingNonFields = [create(null), create(null)];
40
+ var hasClassDecs = classDecs.length;
41
+ var _;
42
+ function createRunInitializers(initializers, useStaticThis, hasValue) {
43
+ return function(thisArg, value) {
44
+ if (useStaticThis) {
45
+ value = thisArg;
46
+ thisArg = targetClass;
47
+ }
48
+ for (var i = 0; i < initializers.length; i++) value = initializers[i].apply(thisArg, hasValue ? [value] : []);
49
+ return hasValue ? value : thisArg;
50
+ };
51
+ }
52
+ function assertCallable(fn, hint1, hint2, throwUndefined) {
53
+ if (typeof fn !== "function") {
54
+ if (throwUndefined || fn !== void 0) throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
55
+ }
56
+ return fn;
57
+ }
58
+ function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) {
59
+ function assertInstanceIfPrivate(target) {
60
+ if (!hasPrivateBrand(target)) throw new TypeError("Attempted to access private element on non-instance");
61
+ }
62
+ var decs = [].concat(decInfo[0]);
63
+ var decVal = decInfo[3];
64
+ var isClass = !ret;
65
+ var isAccessor = kind === 1;
66
+ var isGetter = kind === 3;
67
+ var isSetter = kind === 4;
68
+ var isMethod = kind === 2;
69
+ function bindPropCall(name, useStaticThis, before) {
70
+ return function(_this, value) {
71
+ if (useStaticThis) {
72
+ value = _this;
73
+ _this = Class;
74
+ }
75
+ if (before) before(_this);
76
+ return desc[name].call(_this, value);
77
+ };
78
+ }
79
+ var desc1 = {};
80
+ var init = [];
81
+ var key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value";
82
+ if (!isClass) {
83
+ if (isPrivate) {
84
+ if (isField || isAccessor) desc1 = {
85
+ get: setFunctionName(function() {
86
+ return decVal(this);
87
+ }, name, "get"),
88
+ set: function(value) {
89
+ decInfo[4](this, value);
90
+ }
91
+ };
92
+ else desc1[key] = decVal;
93
+ if (!isField) setFunctionName(desc1[key], name, isMethod ? "" : key);
94
+ } else if (!isField) desc1 = Object.getOwnPropertyDescriptor(Class, name);
95
+ if (!isField && !isPrivate) {
96
+ _ = existingNonFields[+isStatic][name];
97
+ if (_ && (_ ^ kind) !== 7) throw new Error("Decorating two elements with the same name (" + desc1[key].name + ") is not supported yet");
98
+ existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind;
99
+ }
100
+ }
101
+ var newValue = Class;
102
+ for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
103
+ var dec = assertCallable(decs[i], "A decorator", "be", true);
104
+ var decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
105
+ var decoratorFinishedRef = {};
106
+ var ctx = {
107
+ kind: [
108
+ "field",
109
+ "accessor",
110
+ "method",
111
+ "getter",
112
+ "setter",
113
+ "class"
114
+ ][kind],
115
+ name,
116
+ metadata,
117
+ addInitializer: (function(decoratorFinishedRef, initializer) {
118
+ if (decoratorFinishedRef.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
119
+ assertCallable(initializer, "An initializer", "be", true);
120
+ initializers.push(initializer);
121
+ }).bind(null, decoratorFinishedRef)
122
+ };
123
+ if (isClass) {
124
+ _ = dec.call(decThis, newValue, ctx);
125
+ decoratorFinishedRef.v = 1;
126
+ if (assertCallable(_, "class decorators", "return")) newValue = _;
127
+ continue;
128
+ }
129
+ ctx.static = isStatic;
130
+ ctx.private = isPrivate;
131
+ _ = ctx.access = { has: isPrivate ? hasPrivateBrand.bind() : function(target) {
132
+ return name in target;
133
+ } };
134
+ if (!isSetter) _.get = isPrivate ? isMethod ? function(_this) {
135
+ assertInstanceIfPrivate(_this);
136
+ return desc1.value;
137
+ } : bindPropCall("get", 0, assertInstanceIfPrivate) : function(target) {
138
+ return target[name];
139
+ };
140
+ if (!isMethod && !isGetter) _.set = isPrivate ? bindPropCall("set", 0, assertInstanceIfPrivate) : function(target, value) {
141
+ target[name] = value;
142
+ };
143
+ newValue = dec.call(decThis, isAccessor ? {
144
+ get: desc1.get,
145
+ set: desc1.set
146
+ } : desc1[key], ctx);
147
+ decoratorFinishedRef.v = 1;
148
+ if (isAccessor) {
149
+ if (typeof newValue === "object" && newValue) {
150
+ if (_ = assertCallable(newValue.get, "accessor.get")) desc1.get = _;
151
+ if (_ = assertCallable(newValue.set, "accessor.set")) desc1.set = _;
152
+ if (_ = assertCallable(newValue.init, "accessor.init")) init.unshift(_);
153
+ } else if (newValue !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
154
+ } else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) if (isField) init.unshift(newValue);
155
+ else desc1[key] = newValue;
156
+ }
157
+ if (kind < 2) ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0));
158
+ if (!isField && !isClass) if (isPrivate) if (isAccessor) ret.splice(-1, 0, bindPropCall("get", isStatic), bindPropCall("set", isStatic));
159
+ else ret.push(isMethod ? desc1[key] : assertCallable.call.bind(desc1[key]));
160
+ else defineProperty(Class, name, desc1);
161
+ return newValue;
162
+ }
163
+ function applyMemberDecs() {
164
+ var ret = [];
165
+ var protoInitializers;
166
+ var staticInitializers;
167
+ var pushInitializers = function(initializers) {
168
+ if (initializers) ret.push(createRunInitializers(initializers));
169
+ };
170
+ var applyMemberDecsOfKind = function(isStatic, isField) {
171
+ for (var i = 0; i < memberDecs.length; i++) {
172
+ var decInfo = memberDecs[i];
173
+ var kind = decInfo[1];
174
+ var kindOnly = kind & 7;
175
+ if ((kind & 8) == isStatic && !kindOnly == isField) {
176
+ var name = decInfo[2];
177
+ var isPrivate = !!decInfo[3];
178
+ var decoratorsHaveThis = kind & 16;
179
+ 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(_) {
180
+ return checkInRHS(_) === targetClass;
181
+ } : instanceBrand);
182
+ }
183
+ }
184
+ };
185
+ applyMemberDecsOfKind(8, 0);
186
+ applyMemberDecsOfKind(0, 0);
187
+ applyMemberDecsOfKind(8, 1);
188
+ applyMemberDecsOfKind(0, 1);
189
+ pushInitializers(protoInitializers);
190
+ pushInitializers(staticInitializers);
191
+ return ret;
192
+ }
193
+ function defineMetadata(Class) {
194
+ return defineProperty(Class, symbolMetadata, {
195
+ configurable: true,
196
+ enumerable: true,
197
+ value: metadata
198
+ });
199
+ }
200
+ if (parentClass !== void 0) metadata = parentClass[symbolMetadata];
201
+ metadata = create(metadata == null ? null : metadata);
202
+ _ = applyMemberDecs();
203
+ if (!hasClassDecs) defineMetadata(targetClass);
204
+ return {
205
+ e: _,
206
+ get c() {
207
+ var initializers = [];
208
+ return hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)];
209
+ }
210
+ };
211
+ }
212
+ let _dec, _initClass;
213
+ _dec = injectable([]);
214
+ let _CliTelemetryAdapter;
215
+ (class {
216
+ static {
217
+ ({c: [_CliTelemetryAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
218
+ }
219
+ isCliTelemetryEnabled() {
220
+ const raw = process.env.ENABLE_TELEMETRY;
221
+ return raw === "1" || raw === "true";
222
+ }
223
+ withCliPortTelemetry(args) {
224
+ const { portName, implementation, logger } = args;
225
+ return new Proxy(implementation, { get: (target, propertyKey, receiver) => {
226
+ if (typeof propertyKey === "symbol") return Reflect.get(target, propertyKey, receiver);
227
+ const propertyName = String(propertyKey);
228
+ const value = Reflect.get(target, propertyKey, receiver);
229
+ if (typeof value !== "function") return value;
230
+ return (...callArgs) => {
231
+ const argSummary = callArgs.map((arg) => this.summarizeTelemetryArg(arg)).join(", ");
232
+ logger.out(`[telemetry:${portName}.${propertyName}] ← (${argSummary})`);
233
+ const startedAt = performance.now();
234
+ try {
235
+ const result = value.apply(target, callArgs);
236
+ if (this.isPromiseLike(result)) return result.then((resolved) => {
237
+ logger.out(`[telemetry:${portName}.${propertyName}] → ok ${(performance.now() - startedAt).toFixed(2)}ms`);
238
+ return resolved;
239
+ }, (rejection) => {
240
+ logger.out(`[telemetry:${portName}.${propertyName}] → err ${(performance.now() - startedAt).toFixed(2)}ms`);
241
+ throw rejection;
242
+ });
243
+ logger.out(`[telemetry:${portName}.${propertyName}] → ${(performance.now() - startedAt).toFixed(2)}ms`);
244
+ return result;
245
+ } catch (caughtSyncError) {
246
+ logger.out(`[telemetry:${portName}.${propertyName}] → err ${(performance.now() - startedAt).toFixed(2)}ms`);
247
+ throw caughtSyncError;
248
+ }
249
+ };
250
+ } });
251
+ }
252
+ withOptionalPortTelemetry(portName, implementation, logger) {
253
+ if (!this.isCliTelemetryEnabled()) return implementation;
254
+ return this.withCliPortTelemetry({
255
+ portName,
256
+ implementation,
257
+ logger
258
+ });
259
+ }
260
+ summarizeTelemetryArg(value, maxLen = 160) {
261
+ if (typeof value === "string") return value.length > maxLen ? `${value.slice(0, maxLen)}…(${value.length} chars)` : value;
262
+ if (value === null || value === void 0) return String(value);
263
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
264
+ if (typeof value === "object") try {
265
+ const json = JSON.stringify(value);
266
+ if (typeof json === "string") return json.length > maxLen ? `${json.slice(0, maxLen)}…` : json;
267
+ } catch {
268
+ return "[object]";
269
+ }
270
+ return "[value]";
271
+ }
272
+ isPromiseLike(value) {
273
+ return value !== null && typeof value === "object" && "then" in value && typeof value.then === "function";
274
+ }
275
+ static {
276
+ _initClass();
277
+ }
278
+ });
279
+ //#endregion
280
+ export { _CliTelemetryAdapter as CliTelemetryAdapter };
@@ -0,0 +1,385 @@
1
+ import { CliFilesystemPortToken, CliLoggerPortToken } from "../../application/cli-runtime.tokens.mjs";
2
+ import { messageFromCaughtUnknown } from "../../domain/caught-unknown-message.value-object.mjs";
3
+ import { globSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { inject, injectable } from "@codefast/di";
6
+ import picomatch from "picomatch";
7
+ import { parse } from "yaml";
8
+ //#region src/shell/infrastructure/workspace/node-pnpm-workspace-package-layout.adapter.ts
9
+ function toPrimitive(input, hint) {
10
+ if (typeof input !== "object" || input === null) return input;
11
+ var prim = input[Symbol.toPrimitive];
12
+ if (prim !== void 0) {
13
+ var res = prim.call(input, hint || "default");
14
+ if (typeof res !== "object") return res;
15
+ throw new TypeError("@@toPrimitive must return a primitive value.");
16
+ }
17
+ return (hint === "string" ? String : Number)(input);
18
+ }
19
+ function toPropertyKey(arg) {
20
+ var key = toPrimitive(arg, "string");
21
+ return typeof key === "symbol" ? key : String(key);
22
+ }
23
+ function checkInRHS(value) {
24
+ if (Object(value) !== value) throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null"));
25
+ return value;
26
+ }
27
+ function setFunctionName(fn, name, prefix) {
28
+ if (typeof name === "symbol") {
29
+ name = name.description;
30
+ name = name ? "[" + name + "]" : "";
31
+ }
32
+ try {
33
+ Object.defineProperty(fn, "name", {
34
+ configurable: true,
35
+ value: prefix ? prefix + " " + name : name
36
+ });
37
+ } catch (_) {}
38
+ return fn;
39
+ }
40
+ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) {
41
+ var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
42
+ var defineProperty = Object.defineProperty;
43
+ var create = Object.create;
44
+ var metadata;
45
+ var existingNonFields = [create(null), create(null)];
46
+ var hasClassDecs = classDecs.length;
47
+ var _;
48
+ function createRunInitializers(initializers, useStaticThis, hasValue) {
49
+ return function(thisArg, value) {
50
+ if (useStaticThis) {
51
+ value = thisArg;
52
+ thisArg = targetClass;
53
+ }
54
+ for (var i = 0; i < initializers.length; i++) value = initializers[i].apply(thisArg, hasValue ? [value] : []);
55
+ return hasValue ? value : thisArg;
56
+ };
57
+ }
58
+ function assertCallable(fn, hint1, hint2, throwUndefined) {
59
+ if (typeof fn !== "function") {
60
+ if (throwUndefined || fn !== void 0) throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
61
+ }
62
+ return fn;
63
+ }
64
+ function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) {
65
+ function assertInstanceIfPrivate(target) {
66
+ if (!hasPrivateBrand(target)) throw new TypeError("Attempted to access private element on non-instance");
67
+ }
68
+ var decs = [].concat(decInfo[0]);
69
+ var decVal = decInfo[3];
70
+ var isClass = !ret;
71
+ var isAccessor = kind === 1;
72
+ var isGetter = kind === 3;
73
+ var isSetter = kind === 4;
74
+ var isMethod = kind === 2;
75
+ function bindPropCall(name, useStaticThis, before) {
76
+ return function(_this, value) {
77
+ if (useStaticThis) {
78
+ value = _this;
79
+ _this = Class;
80
+ }
81
+ if (before) before(_this);
82
+ return desc[name].call(_this, value);
83
+ };
84
+ }
85
+ var desc1 = {};
86
+ var init = [];
87
+ var key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value";
88
+ if (!isClass) {
89
+ if (isPrivate) {
90
+ if (isField || isAccessor) desc1 = {
91
+ get: setFunctionName(function() {
92
+ return decVal(this);
93
+ }, name, "get"),
94
+ set: function(value) {
95
+ decInfo[4](this, value);
96
+ }
97
+ };
98
+ else desc1[key] = decVal;
99
+ if (!isField) setFunctionName(desc1[key], name, isMethod ? "" : key);
100
+ } else if (!isField) desc1 = Object.getOwnPropertyDescriptor(Class, name);
101
+ if (!isField && !isPrivate) {
102
+ _ = existingNonFields[+isStatic][name];
103
+ if (_ && (_ ^ kind) !== 7) throw new Error("Decorating two elements with the same name (" + desc1[key].name + ") is not supported yet");
104
+ existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind;
105
+ }
106
+ }
107
+ var newValue = Class;
108
+ for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
109
+ var dec = assertCallable(decs[i], "A decorator", "be", true);
110
+ var decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
111
+ var decoratorFinishedRef = {};
112
+ var ctx = {
113
+ kind: [
114
+ "field",
115
+ "accessor",
116
+ "method",
117
+ "getter",
118
+ "setter",
119
+ "class"
120
+ ][kind],
121
+ name,
122
+ metadata,
123
+ addInitializer: (function(decoratorFinishedRef, initializer) {
124
+ if (decoratorFinishedRef.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
125
+ assertCallable(initializer, "An initializer", "be", true);
126
+ initializers.push(initializer);
127
+ }).bind(null, decoratorFinishedRef)
128
+ };
129
+ if (isClass) {
130
+ _ = dec.call(decThis, newValue, ctx);
131
+ decoratorFinishedRef.v = 1;
132
+ if (assertCallable(_, "class decorators", "return")) newValue = _;
133
+ continue;
134
+ }
135
+ ctx.static = isStatic;
136
+ ctx.private = isPrivate;
137
+ _ = ctx.access = { has: isPrivate ? hasPrivateBrand.bind() : function(target) {
138
+ return name in target;
139
+ } };
140
+ if (!isSetter) _.get = isPrivate ? isMethod ? function(_this) {
141
+ assertInstanceIfPrivate(_this);
142
+ return desc1.value;
143
+ } : bindPropCall("get", 0, assertInstanceIfPrivate) : function(target) {
144
+ return target[name];
145
+ };
146
+ if (!isMethod && !isGetter) _.set = isPrivate ? bindPropCall("set", 0, assertInstanceIfPrivate) : function(target, value) {
147
+ target[name] = value;
148
+ };
149
+ newValue = dec.call(decThis, isAccessor ? {
150
+ get: desc1.get,
151
+ set: desc1.set
152
+ } : desc1[key], ctx);
153
+ decoratorFinishedRef.v = 1;
154
+ if (isAccessor) {
155
+ if (typeof newValue === "object" && newValue) {
156
+ if (_ = assertCallable(newValue.get, "accessor.get")) desc1.get = _;
157
+ if (_ = assertCallable(newValue.set, "accessor.set")) desc1.set = _;
158
+ if (_ = assertCallable(newValue.init, "accessor.init")) init.unshift(_);
159
+ } else if (newValue !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
160
+ } else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) if (isField) init.unshift(newValue);
161
+ else desc1[key] = newValue;
162
+ }
163
+ if (kind < 2) ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0));
164
+ if (!isField && !isClass) if (isPrivate) if (isAccessor) ret.splice(-1, 0, bindPropCall("get", isStatic), bindPropCall("set", isStatic));
165
+ else ret.push(isMethod ? desc1[key] : assertCallable.call.bind(desc1[key]));
166
+ else defineProperty(Class, name, desc1);
167
+ return newValue;
168
+ }
169
+ function applyMemberDecs() {
170
+ var ret = [];
171
+ var protoInitializers;
172
+ var staticInitializers;
173
+ var pushInitializers = function(initializers) {
174
+ if (initializers) ret.push(createRunInitializers(initializers));
175
+ };
176
+ var applyMemberDecsOfKind = function(isStatic, isField) {
177
+ for (var i = 0; i < memberDecs.length; i++) {
178
+ var decInfo = memberDecs[i];
179
+ var kind = decInfo[1];
180
+ var kindOnly = kind & 7;
181
+ if ((kind & 8) == isStatic && !kindOnly == isField) {
182
+ var name = decInfo[2];
183
+ var isPrivate = !!decInfo[3];
184
+ var decoratorsHaveThis = kind & 16;
185
+ 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(_) {
186
+ return checkInRHS(_) === targetClass;
187
+ } : instanceBrand);
188
+ }
189
+ }
190
+ };
191
+ applyMemberDecsOfKind(8, 0);
192
+ applyMemberDecsOfKind(0, 0);
193
+ applyMemberDecsOfKind(8, 1);
194
+ applyMemberDecsOfKind(0, 1);
195
+ pushInitializers(protoInitializers);
196
+ pushInitializers(staticInitializers);
197
+ return ret;
198
+ }
199
+ function defineMetadata(Class) {
200
+ return defineProperty(Class, symbolMetadata, {
201
+ configurable: true,
202
+ enumerable: true,
203
+ value: metadata
204
+ });
205
+ }
206
+ if (parentClass !== void 0) metadata = parentClass[symbolMetadata];
207
+ metadata = create(metadata == null ? null : metadata);
208
+ _ = applyMemberDecs();
209
+ if (!hasClassDecs) defineMetadata(targetClass);
210
+ return {
211
+ e: _,
212
+ get c() {
213
+ var initializers = [];
214
+ return hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)];
215
+ }
216
+ };
217
+ }
218
+ let _dec, _initClass;
219
+ _dec = injectable([inject(CliFilesystemPortToken), inject(CliLoggerPortToken)]);
220
+ let _NodePnpmWorkspacePackageLayoutAdapter;
221
+ (class {
222
+ fs;
223
+ logger;
224
+ static {
225
+ ({c: [_NodePnpmWorkspacePackageLayoutAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
226
+ }
227
+ constructor(fs, logger) {
228
+ this.fs = fs;
229
+ this.logger = logger;
230
+ }
231
+ workspaceYamlFileName = "pnpm-workspace.yaml";
232
+ defaultIncludePatterns = ["packages/*"];
233
+ packageJsonFileName = "package.json";
234
+ async listPackageDirectoryPathsAbsolute(rootDirectoryPathAbsolute, suppressGlobPermissionDiagnostics) {
235
+ return this.collectPackageDirectoryPathsAbsolute(rootDirectoryPathAbsolute, !!suppressGlobPermissionDiagnostics);
236
+ }
237
+ toPosix(filePath) {
238
+ return filePath.split(path.sep).join("/");
239
+ }
240
+ isGlobPermissionError(caughtError) {
241
+ if (typeof caughtError !== "object" || caughtError === null || !("code" in caughtError)) return false;
242
+ const code = caughtError.code;
243
+ return code === "EACCES" || code === "EPERM";
244
+ }
245
+ workspacePatternToPackageJsonGlob(pattern) {
246
+ const normalizedPattern = this.toPosix(pattern.trim()).replace(/\/+$/, "");
247
+ if (!normalizedPattern) return `**/${this.packageJsonFileName}`;
248
+ return `${normalizedPattern}/${this.packageJsonFileName}`;
249
+ }
250
+ splitPnpmWorkspacePackagesArray(raw) {
251
+ const include = [];
252
+ const exclude = [];
253
+ if (!Array.isArray(raw)) return {
254
+ include,
255
+ exclude
256
+ };
257
+ for (const entry of raw) {
258
+ if (typeof entry !== "string") continue;
259
+ const trimmed = entry.trim();
260
+ if (!trimmed) continue;
261
+ if (trimmed.startsWith("!")) exclude.push(trimmed.slice(1).trim());
262
+ else include.push(trimmed);
263
+ }
264
+ return {
265
+ include,
266
+ exclude
267
+ };
268
+ }
269
+ parsePnpmWorkspaceDocument(doc) {
270
+ const wf = this.workspaceYamlFileName;
271
+ if (doc === null || doc === void 0) throw new Error(`${wf} root document must be an object (got empty or null)`);
272
+ if (typeof doc !== "object" || Array.isArray(doc)) throw new Error(`${wf} root must be a mapping, not an array or scalar`);
273
+ const parsedDoc = doc;
274
+ if (!Object.prototype.hasOwnProperty.call(parsedDoc, "packages")) return {
275
+ include: [],
276
+ exclude: [],
277
+ hasPackagesKey: false,
278
+ isEmptyPackagesArray: false
279
+ };
280
+ const pkgs = parsedDoc.packages;
281
+ if (!Array.isArray(pkgs)) throw new Error(`${wf} field "packages" must be an array`);
282
+ if (pkgs.length === 0) return {
283
+ include: [],
284
+ exclude: [],
285
+ hasPackagesKey: true,
286
+ isEmptyPackagesArray: true
287
+ };
288
+ return {
289
+ ...this.splitPnpmWorkspacePackagesArray(pkgs),
290
+ hasPackagesKey: true,
291
+ isEmptyPackagesArray: false
292
+ };
293
+ }
294
+ async readWorkspaceYaml(rootDir) {
295
+ const wf = this.workspaceYamlFileName;
296
+ const workspaceYamlPath = path.join(rootDir, wf);
297
+ if (!this.fs.existsSync(workspaceYamlPath)) return { exists: false };
298
+ let raw;
299
+ try {
300
+ raw = await this.fs.readFile(workspaceYamlPath, "utf8");
301
+ } catch (caughtReadError) {
302
+ throw new Error(`Failed to read ${wf}: ${messageFromCaughtUnknown(caughtReadError)}`);
303
+ }
304
+ let doc;
305
+ try {
306
+ doc = parse(raw);
307
+ } catch (caughtYamlParseError) {
308
+ throw new Error(`Failed to parse ${wf}: ${messageFromCaughtUnknown(caughtYamlParseError)}`);
309
+ }
310
+ if (doc === null || doc === void 0) throw new Error(`${wf} must define a mapping at the document root`);
311
+ return {
312
+ exists: true,
313
+ doc
314
+ };
315
+ }
316
+ async collectPackageDirectoryPathsAbsolute(rootDir, suppressGlobPermissionDiagnostics) {
317
+ const workspaceYaml = await this.readWorkspaceYaml(rootDir);
318
+ const defInc = this.defaultIncludePatterns;
319
+ let include;
320
+ let exclude;
321
+ let layoutSource;
322
+ const hasPnpmWorkspaceYamlFile = workspaceYaml.exists;
323
+ if (!workspaceYaml.exists) {
324
+ include = [...defInc];
325
+ exclude = [];
326
+ layoutSource = "default-patterns";
327
+ } else {
328
+ const parsed = this.parsePnpmWorkspaceDocument(workspaceYaml.doc);
329
+ if (!parsed.hasPackagesKey) {
330
+ include = [...defInc];
331
+ exclude = [];
332
+ layoutSource = "default-patterns";
333
+ } else if (parsed.isEmptyPackagesArray) return {
334
+ packageDirectoryPathsAbsolute: [],
335
+ layoutSource: "declared-empty",
336
+ hasPnpmWorkspaceYamlFile: true
337
+ };
338
+ else {
339
+ include = parsed.include;
340
+ exclude = parsed.exclude;
341
+ layoutSource = "pnpm-workspace-yaml";
342
+ }
343
+ }
344
+ const foundRelativePosixPackageRoots = /* @__PURE__ */ new Set();
345
+ const globOpts = {
346
+ cwd: rootDir,
347
+ posix: true,
348
+ ...path.sep === "\\" ? { windowsPathsNoEscape: true } : {}
349
+ };
350
+ for (const pattern of include) {
351
+ const globPat = this.workspacePatternToPackageJsonGlob(pattern);
352
+ let matches;
353
+ try {
354
+ matches = globSync(globPat, globOpts);
355
+ } catch (caughtGlobError) {
356
+ if (this.isGlobPermissionError(caughtGlobError)) {
357
+ if (!suppressGlobPermissionDiagnostics) this.logger.out(`⚠ Skipping workspace glob "${pattern}" (${messageFromCaughtUnknown(caughtGlobError)})`);
358
+ continue;
359
+ }
360
+ throw new Error(`Invalid workspace glob "${pattern}": ${messageFromCaughtUnknown(caughtGlobError)}`);
361
+ }
362
+ for (const matchedPath of matches) {
363
+ const posix = this.toPosix(matchedPath);
364
+ const suffix = `/${this.packageJsonFileName}`;
365
+ if (!posix.endsWith(suffix)) continue;
366
+ const rel = posix.slice(0, -suffix.length);
367
+ if (!rel) continue;
368
+ foundRelativePosixPackageRoots.add(rel);
369
+ }
370
+ }
371
+ const excludeMatchers = exclude.map((pat) => picomatch(pat, { dot: true }));
372
+ const filteredRelative = [...foundRelativePosixPackageRoots].filter((rel) => !excludeMatchers.some((isMatch) => isMatch(rel)));
373
+ filteredRelative.sort((a, b) => a.localeCompare(b));
374
+ return {
375
+ packageDirectoryPathsAbsolute: filteredRelative.map((rel) => path.resolve(rootDir, rel.split("/").join(path.sep))),
376
+ layoutSource,
377
+ hasPnpmWorkspaceYamlFile
378
+ };
379
+ }
380
+ static {
381
+ _initClass();
382
+ }
383
+ });
384
+ //#endregion
385
+ export { _NodePnpmWorkspacePackageLayoutAdapter as NodePnpmWorkspacePackageLayoutAdapter };