@codefast/cli 0.3.14-canary.1 → 0.3.14

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
@@ -0,0 +1,306 @@
1
+ import { CliFsToken } from "../../core/contracts/tokens.mjs";
2
+ import { codefastConfigSchema } from "./config-schema.adapter.mjs";
3
+ import path from "node:path";
4
+ import { inject, injectable } from "@codefast/di";
5
+ import { ZodError } from "zod";
6
+ import jiti from "jiti";
7
+ //#region src/lib/config/infrastructure/config-loader.adapter.ts
8
+ function toPrimitive(input, hint) {
9
+ if (typeof input !== "object" || input === null) return input;
10
+ var prim = input[Symbol.toPrimitive];
11
+ if (prim !== void 0) {
12
+ var res = prim.call(input, hint || "default");
13
+ if (typeof res !== "object") return res;
14
+ throw new TypeError("@@toPrimitive must return a primitive value.");
15
+ }
16
+ return (hint === "string" ? String : Number)(input);
17
+ }
18
+ function toPropertyKey(arg) {
19
+ var key = toPrimitive(arg, "string");
20
+ return typeof key === "symbol" ? key : String(key);
21
+ }
22
+ function checkInRHS(value) {
23
+ if (Object(value) !== value) throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null"));
24
+ return value;
25
+ }
26
+ function setFunctionName(fn, name, prefix) {
27
+ if (typeof name === "symbol") {
28
+ name = name.description;
29
+ name = name ? "[" + name + "]" : "";
30
+ }
31
+ try {
32
+ Object.defineProperty(fn, "name", {
33
+ configurable: true,
34
+ value: prefix ? prefix + " " + name : name
35
+ });
36
+ } catch (_) {}
37
+ return fn;
38
+ }
39
+ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) {
40
+ var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
41
+ var defineProperty = Object.defineProperty;
42
+ var create = Object.create;
43
+ var metadata;
44
+ var existingNonFields = [create(null), create(null)];
45
+ var hasClassDecs = classDecs.length;
46
+ var _;
47
+ function createRunInitializers(initializers, useStaticThis, hasValue) {
48
+ return function(thisArg, value) {
49
+ if (useStaticThis) {
50
+ value = thisArg;
51
+ thisArg = targetClass;
52
+ }
53
+ for (var i = 0; i < initializers.length; i++) value = initializers[i].apply(thisArg, hasValue ? [value] : []);
54
+ return hasValue ? value : thisArg;
55
+ };
56
+ }
57
+ function assertCallable(fn, hint1, hint2, throwUndefined) {
58
+ if (typeof fn !== "function") {
59
+ if (throwUndefined || fn !== void 0) throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
60
+ }
61
+ return fn;
62
+ }
63
+ function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) {
64
+ function assertInstanceIfPrivate(target) {
65
+ if (!hasPrivateBrand(target)) throw new TypeError("Attempted to access private element on non-instance");
66
+ }
67
+ var decs = [].concat(decInfo[0]);
68
+ var decVal = decInfo[3];
69
+ var isClass = !ret;
70
+ var isAccessor = kind === 1;
71
+ var isGetter = kind === 3;
72
+ var isSetter = kind === 4;
73
+ var isMethod = kind === 2;
74
+ function bindPropCall(name, useStaticThis, before) {
75
+ return function(_this, value) {
76
+ if (useStaticThis) {
77
+ value = _this;
78
+ _this = Class;
79
+ }
80
+ if (before) before(_this);
81
+ return desc[name].call(_this, value);
82
+ };
83
+ }
84
+ var desc1 = {};
85
+ var init = [];
86
+ var key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value";
87
+ if (!isClass) {
88
+ if (isPrivate) {
89
+ if (isField || isAccessor) desc1 = {
90
+ get: setFunctionName(function() {
91
+ return decVal(this);
92
+ }, name, "get"),
93
+ set: function(value) {
94
+ decInfo[4](this, value);
95
+ }
96
+ };
97
+ else desc1[key] = decVal;
98
+ if (!isField) setFunctionName(desc1[key], name, isMethod ? "" : key);
99
+ } else if (!isField) desc1 = Object.getOwnPropertyDescriptor(Class, name);
100
+ if (!isField && !isPrivate) {
101
+ _ = existingNonFields[+isStatic][name];
102
+ if (_ && (_ ^ kind) !== 7) throw new Error("Decorating two elements with the same name (" + desc1[key].name + ") is not supported yet");
103
+ existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind;
104
+ }
105
+ }
106
+ var newValue = Class;
107
+ for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
108
+ var dec = assertCallable(decs[i], "A decorator", "be", true);
109
+ var decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
110
+ var decoratorFinishedRef = {};
111
+ var ctx = {
112
+ kind: [
113
+ "field",
114
+ "accessor",
115
+ "method",
116
+ "getter",
117
+ "setter",
118
+ "class"
119
+ ][kind],
120
+ name,
121
+ metadata,
122
+ addInitializer: (function(decoratorFinishedRef, initializer) {
123
+ if (decoratorFinishedRef.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
124
+ assertCallable(initializer, "An initializer", "be", true);
125
+ initializers.push(initializer);
126
+ }).bind(null, decoratorFinishedRef)
127
+ };
128
+ if (isClass) {
129
+ _ = dec.call(decThis, newValue, ctx);
130
+ decoratorFinishedRef.v = 1;
131
+ if (assertCallable(_, "class decorators", "return")) newValue = _;
132
+ continue;
133
+ }
134
+ ctx.static = isStatic;
135
+ ctx.private = isPrivate;
136
+ _ = ctx.access = { has: isPrivate ? hasPrivateBrand.bind() : function(target) {
137
+ return name in target;
138
+ } };
139
+ if (!isSetter) _.get = isPrivate ? isMethod ? function(_this) {
140
+ assertInstanceIfPrivate(_this);
141
+ return desc1.value;
142
+ } : bindPropCall("get", 0, assertInstanceIfPrivate) : function(target) {
143
+ return target[name];
144
+ };
145
+ if (!isMethod && !isGetter) _.set = isPrivate ? bindPropCall("set", 0, assertInstanceIfPrivate) : function(target, value) {
146
+ target[name] = value;
147
+ };
148
+ newValue = dec.call(decThis, isAccessor ? {
149
+ get: desc1.get,
150
+ set: desc1.set
151
+ } : desc1[key], ctx);
152
+ decoratorFinishedRef.v = 1;
153
+ if (isAccessor) {
154
+ if (typeof newValue === "object" && newValue) {
155
+ if (_ = assertCallable(newValue.get, "accessor.get")) desc1.get = _;
156
+ if (_ = assertCallable(newValue.set, "accessor.set")) desc1.set = _;
157
+ if (_ = assertCallable(newValue.init, "accessor.init")) init.unshift(_);
158
+ } else if (newValue !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
159
+ } else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) if (isField) init.unshift(newValue);
160
+ else desc1[key] = newValue;
161
+ }
162
+ if (kind < 2) ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0));
163
+ if (!isField && !isClass) if (isPrivate) if (isAccessor) ret.splice(-1, 0, bindPropCall("get", isStatic), bindPropCall("set", isStatic));
164
+ else ret.push(isMethod ? desc1[key] : assertCallable.call.bind(desc1[key]));
165
+ else defineProperty(Class, name, desc1);
166
+ return newValue;
167
+ }
168
+ function applyMemberDecs() {
169
+ var ret = [];
170
+ var protoInitializers;
171
+ var staticInitializers;
172
+ var pushInitializers = function(initializers) {
173
+ if (initializers) ret.push(createRunInitializers(initializers));
174
+ };
175
+ var applyMemberDecsOfKind = function(isStatic, isField) {
176
+ for (var i = 0; i < memberDecs.length; i++) {
177
+ var decInfo = memberDecs[i];
178
+ var kind = decInfo[1];
179
+ var kindOnly = kind & 7;
180
+ if ((kind & 8) == isStatic && !kindOnly == isField) {
181
+ var name = decInfo[2];
182
+ var isPrivate = !!decInfo[3];
183
+ var decoratorsHaveThis = kind & 16;
184
+ 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(_) {
185
+ return checkInRHS(_) === targetClass;
186
+ } : instanceBrand);
187
+ }
188
+ }
189
+ };
190
+ applyMemberDecsOfKind(8, 0);
191
+ applyMemberDecsOfKind(0, 0);
192
+ applyMemberDecsOfKind(8, 1);
193
+ applyMemberDecsOfKind(0, 1);
194
+ pushInitializers(protoInitializers);
195
+ pushInitializers(staticInitializers);
196
+ return ret;
197
+ }
198
+ function defineMetadata(Class) {
199
+ return defineProperty(Class, symbolMetadata, {
200
+ configurable: true,
201
+ enumerable: true,
202
+ value: metadata
203
+ });
204
+ }
205
+ if (parentClass !== void 0) metadata = parentClass[symbolMetadata];
206
+ metadata = create(metadata == null ? null : metadata);
207
+ _ = applyMemberDecs();
208
+ if (!hasClassDecs) defineMetadata(targetClass);
209
+ return {
210
+ e: _,
211
+ get c() {
212
+ var initializers = [];
213
+ return hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)];
214
+ }
215
+ };
216
+ }
217
+ let _dec, _initClass;
218
+ const CONFIG_JS_PRIORITY = [
219
+ "codefast.config.mjs",
220
+ "codefast.config.js",
221
+ "codefast.config.cjs"
222
+ ];
223
+ const CONFIG_JSON = "codefast.config.json";
224
+ const cachedLoads = /* @__PURE__ */ new Map();
225
+ function formatZodError(error, filePath) {
226
+ const formatted = error.issues.map((issue) => {
227
+ return ` - ${issue.path.length > 0 ? issue.path.join(".") : "<root>"}: ${issue.message}`;
228
+ }).join("\n");
229
+ return `Invalid config schema in ${path.basename(filePath)}:\n${formatted}`;
230
+ }
231
+ function parseLoadedConfig(raw, filePath) {
232
+ try {
233
+ return codefastConfigSchema.parse(raw);
234
+ } catch (caughtError) {
235
+ if (caughtError instanceof ZodError) throw new Error(formatZodError(caughtError, filePath));
236
+ throw caughtError;
237
+ }
238
+ }
239
+ function listConfigCandidates(startDir, fs) {
240
+ const candidates = [];
241
+ let current = path.resolve(startDir);
242
+ while (true) {
243
+ for (const name of CONFIG_JS_PRIORITY) {
244
+ const candidate = path.join(current, name);
245
+ if (fs.existsSync(candidate)) candidates.push(candidate);
246
+ }
247
+ const jsonCandidate = path.join(current, CONFIG_JSON);
248
+ if (fs.existsSync(jsonCandidate)) candidates.push(jsonCandidate);
249
+ const parent = path.dirname(current);
250
+ if (parent === current) break;
251
+ current = parent;
252
+ }
253
+ return candidates;
254
+ }
255
+ async function readConfigFromPath(filePath, fs, jitiBaseDir) {
256
+ if (path.extname(filePath) === ".json") {
257
+ const content = await fs.readFile(filePath, "utf8");
258
+ return parseLoadedConfig(JSON.parse(content), filePath);
259
+ }
260
+ const moduleConfig = jiti(jitiBaseDir, {
261
+ interopDefault: true,
262
+ moduleCache: false
263
+ })(filePath);
264
+ return parseLoadedConfig(typeof moduleConfig === "object" && moduleConfig !== null && "default" in moduleConfig ? moduleConfig.default : moduleConfig, filePath);
265
+ }
266
+ async function loadOnce(fs, startDir) {
267
+ const warnings = [];
268
+ const configPaths = listConfigCandidates(startDir, fs);
269
+ if (configPaths.length === 0) return {
270
+ config: {},
271
+ warnings
272
+ };
273
+ const configPath = configPaths[0];
274
+ if (configPath === void 0) return {
275
+ config: {},
276
+ warnings
277
+ };
278
+ return {
279
+ config: await readConfigFromPath(configPath, fs, startDir),
280
+ warnings,
281
+ configPath
282
+ };
283
+ }
284
+ _dec = injectable([inject(CliFsToken)]);
285
+ let _ConfigLoaderAdapterImpl;
286
+ (class {
287
+ fs;
288
+ static {
289
+ ({c: [_ConfigLoaderAdapterImpl, _initClass]} = _apply_decs_2311(this, [_dec], []));
290
+ }
291
+ constructor(fs) {
292
+ this.fs = fs;
293
+ }
294
+ async loadConfig(startDir) {
295
+ const cacheKey = path.resolve(startDir);
296
+ if (!cachedLoads.has(cacheKey)) cachedLoads.set(cacheKey, loadOnce(this.fs, cacheKey));
297
+ const cached = cachedLoads.get(cacheKey);
298
+ if (cached === void 0) throw new Error("config loader cache invariant violated");
299
+ return cached;
300
+ }
301
+ static {
302
+ _initClass();
303
+ }
304
+ });
305
+ //#endregion
306
+ export { _ConfigLoaderAdapterImpl as ConfigLoaderAdapterImpl };
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- //#region src/lib/config/infra/config-schema.adapter.ts
2
+ //#region src/lib/config/infrastructure/config-schema.adapter.ts
3
3
  const hookSchema = z.custom((value) => typeof value === "function", { message: "Expected a function" });
4
4
  const mirrorConfigSchema = z.object({
5
5
  skipPackages: z.array(z.string()).optional(),
@@ -22,4 +22,4 @@ const codefastConfigSchema = z.object({
22
22
  arrange: codefastArrangeConfigSchema.optional()
23
23
  }).strict();
24
24
  //#endregion
25
- export { codefastArrangeConfigSchema, codefastConfigSchema, codefastTagConfigSchema, hookSchema, mirrorConfigSchema };
25
+ export { codefastConfigSchema };
@@ -1,7 +1,6 @@
1
- import { CliLoggerToken } from "../../core/operational/contracts/tokens.mjs";
2
- import { presentAnalyzeCliReport } from "./present-analyze-cli.presenter.mjs";
1
+ import { CliLoggerToken } from "../../core/contracts/tokens.mjs";
3
2
  import { inject, injectable } from "@codefast/di";
4
- //#region src/lib/arrange/presentation/present-analyze-report.presenter.ts
3
+ //#region src/lib/config/infrastructure/config-warning-reporter.adapter.ts
5
4
  function toPrimitive(input, hint) {
6
5
  if (typeof input !== "object" || input === null) return input;
7
6
  var prim = input[Symbol.toPrimitive];
@@ -212,22 +211,24 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
212
211
  };
213
212
  }
214
213
  let _dec, _initClass;
214
+ const YELLOW = "\x1B[33m";
215
+ const RESET = "\x1B[0m";
215
216
  _dec = injectable([inject(CliLoggerToken)]);
216
- let _PresentAnalyzeReportPresenterImpl;
217
+ let _ConfigWarningReporterAdapter;
217
218
  (class {
218
219
  logger;
219
220
  static {
220
- ({c: [_PresentAnalyzeReportPresenterImpl, _initClass]} = _apply_decs_2311(this, [_dec], []));
221
+ ({c: [_ConfigWarningReporterAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
221
222
  }
222
223
  constructor(logger) {
223
224
  this.logger = logger;
224
225
  }
225
- present(resolvedTargetPath, report) {
226
- presentAnalyzeCliReport(this.logger, resolvedTargetPath, report);
226
+ reportSchemaWarnings(warnings) {
227
+ for (const warningMessage of warnings) this.logger.out(`${YELLOW}⚠ ${warningMessage}${RESET}`);
227
228
  }
228
229
  static {
229
230
  _initClass();
230
231
  }
231
232
  });
232
233
  //#endregion
233
- export { _PresentAnalyzeReportPresenterImpl as PresentAnalyzeReportPresenterImpl };
234
+ export { _ConfigWarningReporterAdapter as ConfigWarningReporterAdapter };
@@ -1,8 +1,10 @@
1
- import { CliFsToken, CliLoggerToken } from "../operational/contracts/tokens.mjs";
2
- import { ConfigLoaderPortToken } from "../../config/contracts/tokens.mjs";
3
- import { tryLoadCodefastConfig } from "./load-codefast-config.presenter.mjs";
1
+ import { AppError } from "../domain/errors.domain.mjs";
2
+ import { err, ok } from "../domain/result.model.mjs";
3
+ import { messageFromCaughtUnknown } from "../domain/caught-unknown-message.value-object.mjs";
4
+ import { ConfigLoaderPortToken, ConfigWarningReporterPortToken } from "../../config/contracts/tokens.mjs";
5
+ import { loadCodefastConfig } from "../../config/application/services/load-config.service.mjs";
4
6
  import { inject, injectable } from "@codefast/di";
5
- //#region src/lib/core/presentation/try-load-codefast-config.presenter.ts
7
+ //#region src/lib/core/application/load-codefast-config.use-case.ts
6
8
  function toPrimitive(input, hint) {
7
9
  if (typeof input !== "object" || input === null) return input;
8
10
  var prim = input[Symbol.toPrimitive];
@@ -213,33 +215,31 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
213
215
  };
214
216
  }
215
217
  let _dec, _initClass;
216
- _dec = injectable([
217
- inject(CliFsToken),
218
- inject(CliLoggerToken),
219
- inject(ConfigLoaderPortToken)
220
- ]);
221
- let _TryLoadCodefastConfigPresenterImpl;
218
+ _dec = injectable([inject(ConfigLoaderPortToken), inject(ConfigWarningReporterPortToken)]);
219
+ let _LoadCodefastConfigUseCaseImpl;
222
220
  (class {
223
- fs;
224
- logger;
225
221
  configLoader;
222
+ warningReporter;
226
223
  static {
227
- ({c: [_TryLoadCodefastConfigPresenterImpl, _initClass]} = _apply_decs_2311(this, [_dec], []));
224
+ ({c: [_LoadCodefastConfigUseCaseImpl, _initClass]} = _apply_decs_2311(this, [_dec], []));
228
225
  }
229
- constructor(fs, logger, configLoader) {
230
- this.fs = fs;
231
- this.logger = logger;
226
+ constructor(configLoader, warningReporter) {
232
227
  this.configLoader = configLoader;
228
+ this.warningReporter = warningReporter;
233
229
  }
234
- execute(rootDir) {
235
- return tryLoadCodefastConfig({
236
- fs: this.fs,
237
- logger: this.logger
238
- }, this.configLoader, rootDir);
230
+ async execute(rootDir) {
231
+ try {
232
+ const loadedConfig = await loadCodefastConfig(this.configLoader, rootDir);
233
+ if (!loadedConfig.ok) return loadedConfig;
234
+ this.warningReporter.reportSchemaWarnings(loadedConfig.value.warnings);
235
+ return ok({ config: loadedConfig.value.config });
236
+ } catch (caughtError) {
237
+ return err(new AppError("INFRA_FAILURE", messageFromCaughtUnknown(caughtError), caughtError));
238
+ }
239
239
  }
240
240
  static {
241
241
  _initClass();
242
242
  }
243
243
  });
244
244
  //#endregion
245
- export { _TryLoadCodefastConfigPresenterImpl as TryLoadCodefastConfigPresenterImpl };
245
+ export { _LoadCodefastConfigUseCaseImpl as LoadCodefastConfigUseCaseImpl };
@@ -1,9 +1,9 @@
1
- import { parseWithSchema } from "../application/schema-parse.util.mjs";
1
+ import { parseWithSchema } from "./schema-validator.service.mjs";
2
2
  import { z } from "zod";
3
- //#region src/lib/core/presentation/global-cli-options.presenter.ts
3
+ //#region src/lib/core/application/services/global-cli-options-parser.service.ts
4
4
  const globalCliOptionsSchema = z.object({ color: z.boolean().optional() });
5
5
  function parseGlobalCliOptions(raw) {
6
6
  return parseWithSchema(globalCliOptionsSchema, raw);
7
7
  }
8
8
  //#endregion
9
- export { globalCliOptionsSchema, parseGlobalCliOptions };
9
+ export { parseGlobalCliOptions };
@@ -0,0 +1,17 @@
1
+ import { AppError } from "../../domain/errors.domain.mjs";
2
+ import { err, ok } from "../../domain/result.model.mjs";
3
+ //#region src/lib/core/application/services/schema-validator.service.ts
4
+ function formatSchemaIssues(issues) {
5
+ return issues.map((issue) => {
6
+ return `${issue.path.length > 0 ? `${issue.path.join(".")}: ` : ""}${issue.message}`;
7
+ }).join("; ");
8
+ }
9
+ /**
10
+ * Validates `input` with `schema`, returning {@link AppError} (code `VALIDATION_ERROR`) on failure.
11
+ */ function parseWithSchema(schema, input) {
12
+ const parsed = schema.safeParse(input);
13
+ if (!parsed.success) return err(new AppError("VALIDATION_ERROR", formatSchemaIssues(parsed.error.issues)));
14
+ return ok(parsed.data);
15
+ }
16
+ //#endregion
17
+ export { parseWithSchema };
@@ -1,5 +1,10 @@
1
1
  import { token } from "@codefast/di";
2
2
  //#region src/lib/core/contracts/tokens.ts
3
- const TryLoadCodefastConfigPresenterToken = token("TryLoadCodefastConfigPresenter");
3
+ const CliFsToken = token("CliFs");
4
+ const CliLoggerToken = token("CliLogger");
5
+ const CliPathToken = token("CliPath");
6
+ const RepoRootResolverPortToken = token("RepoRootResolverPort");
7
+ const CliRuntimeToken = token("CliRuntime");
8
+ const LoadCodefastConfigUseCaseToken = token("LoadCodefastConfigUseCase");
4
9
  //#endregion
5
- export { TryLoadCodefastConfigPresenterToken };
10
+ export { CliFsToken, CliLoggerToken, CliPathToken, CliRuntimeToken, LoadCodefastConfigUseCaseToken, RepoRootResolverPortToken };
@@ -1,9 +1,9 @@
1
- import { CliPathToken } from "./operational/contracts/tokens.mjs";
2
- import { nodeCliPath } from "./infra/path.adapter.mjs";
1
+ import { CliPathToken } from "./contracts/tokens.mjs";
2
+ import { NodeCliPathAdapter as _NodeCliPathAdapter } from "./infrastructure/path.adapter.mjs";
3
3
  import { Module } from "@codefast/di";
4
4
  //#region src/lib/core/core.module.ts
5
5
  const CoreModule = Module.create("cli-core", (moduleBuilder) => {
6
- moduleBuilder.bind(CliPathToken).toConstantValue(nodeCliPath);
6
+ moduleBuilder.bind(CliPathToken).to(_NodeCliPathAdapter).singleton();
7
7
  });
8
8
  //#endregion
9
9
  export { CoreModule };
@@ -1,4 +1,4 @@
1
- //#region src/lib/core/application/utils/caught-unknown-message.util.ts
1
+ //#region src/lib/core/domain/caught-unknown-message.value-object.ts
2
2
  /**
3
3
  * Stable, user-facing text for values caught as `unknown`.
4
4
  * Avoids `String(unknown)` / `[object Object]` and satisfies strict `no-base-to-string`.
@@ -1,16 +1,17 @@
1
1
  //#region src/lib/core/domain/errors.domain.ts
2
2
  /**
3
3
  * Cross-context application errors for Result-based use cases (CLI orchestration).
4
- */ function appError(code, message, cause) {
5
- if (cause === void 0) return {
6
- code,
7
- message
8
- };
9
- return {
10
- code,
11
- message,
12
- cause
13
- };
14
- }
4
+ * Does not extend the global `Error` type — instances are carried in `Result` values, not thrown.
5
+ */ var AppError = class {
6
+ name = "AppError";
7
+ code;
8
+ message;
9
+ cause;
10
+ constructor(code, message, cause) {
11
+ this.code = code;
12
+ this.message = message;
13
+ if (cause !== void 0) this.cause = cause;
14
+ }
15
+ };
15
16
  //#endregion
16
- export { appError };
17
+ export { AppError };
@@ -13,11 +13,5 @@ function err(error) {
13
13
  error
14
14
  };
15
15
  }
16
- function isOk(result) {
17
- return result.ok === true;
18
- }
19
- function isErr(result) {
20
- return result.ok === false;
21
- }
22
16
  //#endregion
23
- export { err, isErr, isOk, ok };
17
+ export { err, ok };
@@ -0,0 +1,30 @@
1
+ import { CliFsToken, CliLoggerToken, CliRuntimeToken, LoadCodefastConfigUseCaseToken, RepoRootResolverPortToken } from "../contracts/tokens.mjs";
2
+ import { ConfigLoaderPortToken, ConfigWarningReporterPortToken } from "../../config/contracts/tokens.mjs";
3
+ import { ConfigLoaderAdapterImpl as _ConfigLoaderAdapterImpl } from "../../config/infrastructure/config-loader.adapter.mjs";
4
+ import { ConfigWarningReporterAdapter as _ConfigWarningReporterAdapter } from "../../config/infrastructure/config-warning-reporter.adapter.mjs";
5
+ import { LoadCodefastConfigUseCaseImpl as _LoadCodefastConfigUseCaseImpl } from "../application/load-codefast-config.use-case.mjs";
6
+ import { CoreModule } from "../core.module.mjs";
7
+ import { isCliTelemetryEnabled, withCliPortTelemetry } from "./port-telemetry.decorator.mjs";
8
+ import { RepoRootResolverAdapter as _RepoRootResolverAdapter } from "./repo-root-resolver.adapter.mjs";
9
+ import { NodeCliFsAdapter as _NodeCliFsAdapter, NodeCliLoggerAdapter as _NodeCliLoggerAdapter, NodeCliRuntimeAdapter as _NodeCliRuntimeAdapter } from "../../infrastructure/node-io.adapter.mjs";
10
+ import { Module } from "@codefast/di";
11
+ //#region src/lib/core/infrastructure/infrastructure.module.ts
12
+ const InfrastructureModule = Module.create("cli-infrastructure", (moduleBuilder) => {
13
+ moduleBuilder.import(CoreModule);
14
+ moduleBuilder.bind(CliLoggerToken).to(_NodeCliLoggerAdapter).singleton();
15
+ moduleBuilder.bind(CliRuntimeToken).to(_NodeCliRuntimeAdapter).singleton();
16
+ moduleBuilder.bind(RepoRootResolverPortToken).to(_RepoRootResolverAdapter).singleton();
17
+ moduleBuilder.bind(CliFsToken).to(_NodeCliFsAdapter).singleton().onActivation((ctx, rawFs) => {
18
+ if (!isCliTelemetryEnabled()) return rawFs;
19
+ return withCliPortTelemetry({
20
+ portName: "CliFs",
21
+ implementation: rawFs,
22
+ logger: ctx.resolve(CliLoggerToken)
23
+ });
24
+ });
25
+ moduleBuilder.bind(ConfigLoaderPortToken).to(_ConfigLoaderAdapterImpl).singleton();
26
+ moduleBuilder.bind(ConfigWarningReporterPortToken).to(_ConfigWarningReporterAdapter).singleton();
27
+ moduleBuilder.bind(LoadCodefastConfigUseCaseToken).to(_LoadCodefastConfigUseCaseImpl).singleton();
28
+ });
29
+ //#endregion
30
+ export { InfrastructureModule };