@codefast/cli 0.3.14 → 0.3.16-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/README.md +8 -3
  2. package/dist/arrange/analyze.mjs +24 -0
  3. package/dist/{lib/arrange/presentation/arrange-cli.schema.mjs → arrange/cli-schema.mjs} +10 -1
  4. package/dist/arrange/command.mjs +106 -0
  5. package/dist/{lib/arrange/domain/arrange-analyze.service.mjs → arrange/domain/analyze-service.mjs} +17 -10
  6. package/dist/{lib/arrange/domain/ast/ast-node.model.mjs → arrange/domain/ast/ast-node.mjs} +57 -3
  7. package/dist/{lib/arrange/domain/ast/collectors-cn.collector.mjs → arrange/domain/ast/collectors-cn.mjs} +21 -9
  8. package/dist/{lib/arrange/domain/ast/collectors-jsx.collector.mjs → arrange/domain/ast/collectors-jsx.mjs} +5 -2
  9. package/dist/{lib/arrange/domain/ast/collectors-tv.collector.mjs → arrange/domain/ast/collectors-tv.mjs} +21 -6
  10. package/dist/{lib/arrange/domain/ast/ast-helpers.helper.mjs → arrange/domain/ast/helpers.mjs} +26 -9
  11. package/dist/{lib/arrange/domain/ast/targets.model.mjs → arrange/domain/ast/targets.mjs} +19 -10
  12. package/dist/{lib/arrange/domain/constants.domain.mjs → arrange/domain/constants.mjs} +63 -18
  13. package/dist/{lib/arrange/domain/arrange-grouping.service.mjs → arrange/domain/grouping-service.mjs} +31 -10
  14. package/dist/{lib/arrange/domain/grouping.domain.mjs → arrange/domain/grouping.mjs} +39 -18
  15. package/dist/{lib/arrange/domain/imports.domain.mjs → arrange/domain/imports.mjs} +7 -3
  16. package/dist/{lib/arrange/domain/source-text-formatters.formatter.mjs → arrange/domain/source-text-formatters.mjs} +22 -5
  17. package/dist/{lib/arrange/domain/tailwind-token.value-object.mjs → arrange/domain/tailwind-token.mjs} +12 -3
  18. package/dist/{lib/arrange/domain/tailwind-token-classifier.domain-service.mjs → arrange/domain/token-classifier.mjs} +40 -15
  19. package/dist/arrange/output.mjs +79 -0
  20. package/dist/arrange/process-file.mjs +42 -0
  21. package/dist/arrange/resolve-target.mjs +24 -0
  22. package/dist/arrange/scan-target.mjs +20 -0
  23. package/dist/arrange/source-parse.mjs +18 -0
  24. package/dist/arrange/suggest.mjs +15 -0
  25. package/dist/arrange/sync.mjs +51 -0
  26. package/dist/arrange/typescript-ast-translator.mjs +354 -0
  27. package/dist/arrange/workspace.mjs +31 -0
  28. package/dist/bin.mjs +1 -1
  29. package/dist/{program.mjs → cli.mjs} +14 -19
  30. package/dist/core/cli/format-error.mjs +15 -0
  31. package/dist/core/cli/global-options.mjs +10 -0
  32. package/dist/core/cli/positional.mjs +11 -0
  33. package/dist/core/cli/result-handle.mjs +51 -0
  34. package/dist/core/config/loader.mjs +79 -0
  35. package/dist/{lib/config/infrastructure/config-schema.adapter.mjs → core/config/schema.mjs} +20 -6
  36. package/dist/core/config/warnings.mjs +12 -0
  37. package/dist/core/config.mjs +19 -0
  38. package/dist/{lib/core/domain/caught-unknown-message.value-object.mjs → core/errors.mjs} +20 -4
  39. package/dist/core/exit-codes.mjs +17 -0
  40. package/dist/core/filesystem/node.mjs +32 -0
  41. package/dist/core/logger.mjs +15 -0
  42. package/dist/{lib/core/domain/result.model.mjs → core/result.mjs} +7 -3
  43. package/dist/{lib/core/application/services/schema-validator.service.mjs → core/schema-parse.mjs} +6 -5
  44. package/dist/{lib/shared/source-code/domain/text-edit.model.mjs → core/source-text-edit.mjs} +15 -14
  45. package/dist/core/verbose-diagnostics.mjs +11 -0
  46. package/dist/core/workspace/resolver.mjs +177 -0
  47. package/dist/core/workspace/typescript-walk.mjs +36 -0
  48. package/dist/mirror/cli-result.mjs +21 -0
  49. package/dist/{lib/mirror/presentation/mirror-cli.schema.mjs → mirror/cli-schema.mjs} +4 -4
  50. package/dist/mirror/command.mjs +57 -0
  51. package/dist/mirror/dist-filesystem-impl.mjs +42 -0
  52. package/dist/{lib/mirror/domain/constants.domain.mjs → mirror/domain/constants.mjs} +16 -1
  53. package/dist/{lib/mirror/infrastructure/dirent-list.guard.mjs → mirror/domain/dirent-guard.mjs} +5 -2
  54. package/dist/{lib/mirror/domain/errors.domain.mjs → mirror/domain/errors.mjs} +7 -1
  55. package/dist/{lib/mirror/application/services/generate-mirror-exports.service.mjs → mirror/domain/exports.mjs} +17 -10
  56. package/dist/{lib/mirror/domain/package-display-name.policy.mjs → mirror/domain/package-display-name.mjs} +5 -2
  57. package/dist/{lib/mirror/domain/path-normalizer.value-object.mjs → mirror/domain/path-normalizer.mjs} +4 -1
  58. package/dist/mirror/output.mjs +45 -0
  59. package/dist/mirror/package-path.mjs +32 -0
  60. package/dist/mirror/prepare.mjs +33 -0
  61. package/dist/mirror/sync-reporter.mjs +104 -0
  62. package/dist/mirror/sync-workspace-package.mjs +103 -0
  63. package/dist/mirror/sync.mjs +87 -0
  64. package/dist/{lib/mirror/infrastructure/package-json-exports.repository.mjs → mirror/write-exports.mjs} +35 -31
  65. package/dist/tag/cli-result.mjs +11 -0
  66. package/dist/{lib/tag/presentation/tag-cli.schema.mjs → tag/cli-schema.mjs} +4 -1
  67. package/dist/tag/command.mjs +56 -0
  68. package/dist/{lib/tag/presentation/tag-sync.presenter.mjs → tag/output.mjs} +54 -28
  69. package/dist/tag/prepare.mjs +29 -0
  70. package/dist/tag/resolve-target-path.mjs +12 -0
  71. package/dist/tag/since-writer.mjs +130 -0
  72. package/dist/tag/sync.mjs +141 -0
  73. package/dist/tag/target-candidates.mjs +68 -0
  74. package/dist/tag/target-runner.mjs +26 -0
  75. package/dist/tag/version-resolver.mjs +25 -0
  76. package/package.json +8 -9
  77. package/dist/lib/arrange/adapters/primary/cli/arrange.command.mjs +0 -324
  78. package/dist/lib/arrange/adapters/primary/cli/arrange.presentation.module.mjs +0 -14
  79. package/dist/lib/arrange/adapters/primary/cli/presentation.tokens.mjs +0 -5
  80. package/dist/lib/arrange/adapters/secondary/domain-source-parser.adapter.mjs +0 -239
  81. package/dist/lib/arrange/adapters/secondary/file-walker.adapter.mjs +0 -241
  82. package/dist/lib/arrange/adapters/secondary/workspace-resolver.adapter.mjs +0 -233
  83. package/dist/lib/arrange/application/requests/suggest-groups.request.mjs +0 -1
  84. package/dist/lib/arrange/application/services/arrange-file-processor.service.mjs +0 -267
  85. package/dist/lib/arrange/application/services/arrange-target-path-resolver.service.mjs +0 -21
  86. package/dist/lib/arrange/application/services/arrange-target-scanner.service.mjs +0 -243
  87. package/dist/lib/arrange/application/use-cases/analyze-directory.use-case.mjs +0 -255
  88. package/dist/lib/arrange/application/use-cases/prepare-arrange-workspace.use-case.mjs +0 -263
  89. package/dist/lib/arrange/application/use-cases/run-arrange-sync.use-case.mjs +0 -274
  90. package/dist/lib/arrange/application/use-cases/suggest-cn-groups.use-case.mjs +0 -237
  91. package/dist/lib/arrange/arrange.module.mjs +0 -31
  92. package/dist/lib/arrange/contracts/analyze-report-presenter.contract.mjs +0 -1
  93. package/dist/lib/arrange/contracts/models.mjs +0 -1
  94. package/dist/lib/arrange/contracts/services.contract.mjs +0 -1
  95. package/dist/lib/arrange/contracts/tokens.mjs +0 -15
  96. package/dist/lib/arrange/domain/tailwind-grouping.service.mjs +0 -231
  97. package/dist/lib/arrange/domain/types.domain.mjs +0 -1
  98. package/dist/lib/arrange/infrastructure/typescript-ast-translator.adapter.mjs +0 -355
  99. package/dist/lib/arrange/presentation/arrange-analyze.presenter.mjs +0 -259
  100. package/dist/lib/arrange/presentation/arrange-sync.presenter.mjs +0 -33
  101. package/dist/lib/arrange/presentation/group-file-preview.presenter.mjs +0 -271
  102. package/dist/lib/bootstrap/composition-root.mjs +0 -33
  103. package/dist/lib/config/application/ports/config-loader.port.mjs +0 -1
  104. package/dist/lib/config/application/ports/config-warning-reporter.port.mjs +0 -1
  105. package/dist/lib/config/application/services/load-config.service.mjs +0 -17
  106. package/dist/lib/config/contracts/tokens.mjs +0 -6
  107. package/dist/lib/config/domain/schema.domain.mjs +0 -1
  108. package/dist/lib/config/infrastructure/config-loader.adapter.mjs +0 -306
  109. package/dist/lib/config/infrastructure/config-warning-reporter.adapter.mjs +0 -234
  110. package/dist/lib/core/application/load-codefast-config.use-case.mjs +0 -245
  111. package/dist/lib/core/application/ports/cli-io.port.mjs +0 -1
  112. package/dist/lib/core/application/ports/path.port.mjs +0 -1
  113. package/dist/lib/core/application/ports/repo-root-resolver.port.mjs +0 -1
  114. package/dist/lib/core/application/ports/runtime.port.mjs +0 -1
  115. package/dist/lib/core/application/services/global-cli-options-parser.service.mjs +0 -9
  116. package/dist/lib/core/contracts/tokens.mjs +0 -10
  117. package/dist/lib/core/core.module.mjs +0 -9
  118. package/dist/lib/core/domain/cli-exit-codes.domain.mjs +0 -11
  119. package/dist/lib/core/domain/errors.domain.mjs +0 -17
  120. package/dist/lib/core/infrastructure/infrastructure.module.mjs +0 -30
  121. package/dist/lib/core/infrastructure/path.adapter.mjs +0 -246
  122. package/dist/lib/core/infrastructure/port-telemetry.decorator.mjs +0 -62
  123. package/dist/lib/core/infrastructure/repo-root-resolver.adapter.mjs +0 -233
  124. package/dist/lib/core/infrastructure/verbose-diagnostics.policy.mjs +0 -9
  125. package/dist/lib/core/presentation/cli-executor.presenter.mjs +0 -42
  126. package/dist/lib/core/presentation/cli-schema.parser.mjs +0 -7
  127. package/dist/lib/core/presentation/format-app-error.presenter.mjs +0 -17
  128. package/dist/lib/core/presentation/presentation.module.mjs +0 -5
  129. package/dist/lib/infrastructure/node-io.adapter.mjs +0 -285
  130. package/dist/lib/infrastructure/workspace/repo-root-resolver.service.mjs +0 -21
  131. package/dist/lib/kernel/contracts/cli-command.contract.mjs +0 -1
  132. package/dist/lib/kernel/contracts/tokens.mjs +0 -5
  133. package/dist/lib/mirror/adapters/primary/cli/mirror.command.mjs +0 -272
  134. package/dist/lib/mirror/adapters/secondary/file-system-service.adapter.mjs +0 -261
  135. package/dist/lib/mirror/adapters/secondary/mirror-sync-reporter.adapter.mjs +0 -243
  136. package/dist/lib/mirror/adapters/secondary/package-repository.adapter.mjs +0 -241
  137. package/dist/lib/mirror/adapters/secondary/sync-workspace-package.adapter.mjs +0 -351
  138. package/dist/lib/mirror/adapters/secondary/workspace-service.adapter.mjs +0 -237
  139. package/dist/lib/mirror/application/mirror-sync-json.format.mjs +0 -12
  140. package/dist/lib/mirror/application/ports/file-system-service.port.mjs +0 -1
  141. package/dist/lib/mirror/application/ports/mirror-sync-reporter.port.mjs +0 -1
  142. package/dist/lib/mirror/application/ports/package-repository.port.mjs +0 -1
  143. package/dist/lib/mirror/application/ports/sync-workspace-package.port.mjs +0 -1
  144. package/dist/lib/mirror/application/ports/workspace-service.port.mjs +0 -1
  145. package/dist/lib/mirror/application/requests/mirror-sync.request.mjs +0 -1
  146. package/dist/lib/mirror/application/services/mirror-package-arg-resolver.service.mjs +0 -20
  147. package/dist/lib/mirror/application/use-cases/prepare-mirror-sync.use-case.mjs +0 -264
  148. package/dist/lib/mirror/application/use-cases/run-mirror-sync.use-case.mjs +0 -302
  149. package/dist/lib/mirror/contracts/models.mjs +0 -1
  150. package/dist/lib/mirror/contracts/tokens.mjs +0 -11
  151. package/dist/lib/mirror/domain/types.domain.mjs +0 -1
  152. package/dist/lib/mirror/infrastructure/mirror-console-reporter.presenter.mjs +0 -99
  153. package/dist/lib/mirror/infrastructure/package-filter-resolver.service.mjs +0 -25
  154. package/dist/lib/mirror/infrastructure/workspace-packages.service.mjs +0 -158
  155. package/dist/lib/mirror/mirror.module.mjs +0 -25
  156. package/dist/lib/shared/source-code/infrastructure/typescript-source-file-walker.service.mjs +0 -33
  157. package/dist/lib/tag/adapters/primary/cli/presentation.tokens.mjs +0 -6
  158. package/dist/lib/tag/adapters/primary/cli/tag.command.mjs +0 -285
  159. package/dist/lib/tag/adapters/primary/cli/tag.presentation.module.mjs +0 -13
  160. package/dist/lib/tag/adapters/secondary/tag-since-writer.adapter.mjs +0 -348
  161. package/dist/lib/tag/adapters/secondary/tag-target-resolver.adapter.mjs +0 -233
  162. package/dist/lib/tag/adapters/secondary/tag-version-resolver.adapter.mjs +0 -249
  163. package/dist/lib/tag/adapters/secondary/typescript-tree-walk.adapter.mjs +0 -233
  164. package/dist/lib/tag/application/ports/tag-since-writer.port.mjs +0 -1
  165. package/dist/lib/tag/application/ports/tag-version-resolver.port.mjs +0 -1
  166. package/dist/lib/tag/application/ports/target-resolver.port.mjs +0 -1
  167. package/dist/lib/tag/application/ports/typescript-tree-walk.port.mjs +0 -1
  168. package/dist/lib/tag/application/requests/tag-sync.request.mjs +0 -1
  169. package/dist/lib/tag/application/services/tag-cli-target-path-resolver.service.mjs +0 -9
  170. package/dist/lib/tag/application/services/tag-target-runner.service.mjs +0 -21
  171. package/dist/lib/tag/application/tag-sync-cli-result.mjs +0 -11
  172. package/dist/lib/tag/application/tag-sync-json.format.mjs +0 -14
  173. package/dist/lib/tag/application/use-cases/prepare-tag-sync.use-case.mjs +0 -264
  174. package/dist/lib/tag/application/use-cases/run-tag-sync.use-case.mjs +0 -381
  175. package/dist/lib/tag/contracts/models.mjs +0 -1
  176. package/dist/lib/tag/contracts/tag-sync-result-presenter.contract.mjs +0 -1
  177. package/dist/lib/tag/contracts/tokens.mjs +0 -10
  178. package/dist/lib/tag/domain/types.domain.mjs +0 -1
  179. package/dist/lib/tag/infrastructure/tag-target-candidates.adapter.mjs +0 -170
  180. package/dist/lib/tag/presentation/colors.presenter.mjs +0 -12
  181. package/dist/lib/tag/presentation/present-tag-sync-result.presenter.mjs +0 -233
  182. package/dist/lib/tag/presentation/tag-sync-progress-listener.presenter.mjs +0 -243
  183. package/dist/lib/tag/tag.module.mjs +0 -23
  184. /package/dist/{lib/arrange/application/ports/domain-source-parser.port.mjs → arrange/domain/types.mjs} +0 -0
  185. /package/dist/{lib/arrange/application/ports/file-walker.port.mjs → core/filesystem/port.mjs} +0 -0
  186. /package/dist/{lib/arrange/application/ports/group-file-preview.port.mjs → mirror/domain/dist-filesystem.mjs} +0 -0
  187. /package/dist/{lib/arrange/application/ports/workspace-resolver.port.mjs → mirror/domain/types.mjs} +0 -0
  188. /package/dist/{lib/arrange/application/requests/analyze-directory.request.mjs → mirror/sync-types.mjs} +0 -0
  189. /package/dist/{lib/arrange/application/requests/arrange-sync.request.mjs → tag/domain/types.mjs} +0 -0
@@ -1,306 +0,0 @@
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,234 +0,0 @@
1
- import { CliLoggerToken } from "../../core/contracts/tokens.mjs";
2
- import { inject, injectable } from "@codefast/di";
3
- //#region src/lib/config/infrastructure/config-warning-reporter.adapter.ts
4
- function toPrimitive(input, hint) {
5
- if (typeof input !== "object" || input === null) return input;
6
- var prim = input[Symbol.toPrimitive];
7
- if (prim !== void 0) {
8
- var res = prim.call(input, hint || "default");
9
- if (typeof res !== "object") return res;
10
- throw new TypeError("@@toPrimitive must return a primitive value.");
11
- }
12
- return (hint === "string" ? String : Number)(input);
13
- }
14
- function toPropertyKey(arg) {
15
- var key = toPrimitive(arg, "string");
16
- return typeof key === "symbol" ? key : String(key);
17
- }
18
- function checkInRHS(value) {
19
- if (Object(value) !== value) throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null"));
20
- return value;
21
- }
22
- function setFunctionName(fn, name, prefix) {
23
- if (typeof name === "symbol") {
24
- name = name.description;
25
- name = name ? "[" + name + "]" : "";
26
- }
27
- try {
28
- Object.defineProperty(fn, "name", {
29
- configurable: true,
30
- value: prefix ? prefix + " " + name : name
31
- });
32
- } catch (_) {}
33
- return fn;
34
- }
35
- function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) {
36
- var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
37
- var defineProperty = Object.defineProperty;
38
- var create = Object.create;
39
- var metadata;
40
- var existingNonFields = [create(null), create(null)];
41
- var hasClassDecs = classDecs.length;
42
- var _;
43
- function createRunInitializers(initializers, useStaticThis, hasValue) {
44
- return function(thisArg, value) {
45
- if (useStaticThis) {
46
- value = thisArg;
47
- thisArg = targetClass;
48
- }
49
- for (var i = 0; i < initializers.length; i++) value = initializers[i].apply(thisArg, hasValue ? [value] : []);
50
- return hasValue ? value : thisArg;
51
- };
52
- }
53
- function assertCallable(fn, hint1, hint2, throwUndefined) {
54
- if (typeof fn !== "function") {
55
- if (throwUndefined || fn !== void 0) throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
56
- }
57
- return fn;
58
- }
59
- function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) {
60
- function assertInstanceIfPrivate(target) {
61
- if (!hasPrivateBrand(target)) throw new TypeError("Attempted to access private element on non-instance");
62
- }
63
- var decs = [].concat(decInfo[0]);
64
- var decVal = decInfo[3];
65
- var isClass = !ret;
66
- var isAccessor = kind === 1;
67
- var isGetter = kind === 3;
68
- var isSetter = kind === 4;
69
- var isMethod = kind === 2;
70
- function bindPropCall(name, useStaticThis, before) {
71
- return function(_this, value) {
72
- if (useStaticThis) {
73
- value = _this;
74
- _this = Class;
75
- }
76
- if (before) before(_this);
77
- return desc[name].call(_this, value);
78
- };
79
- }
80
- var desc1 = {};
81
- var init = [];
82
- var key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value";
83
- if (!isClass) {
84
- if (isPrivate) {
85
- if (isField || isAccessor) desc1 = {
86
- get: setFunctionName(function() {
87
- return decVal(this);
88
- }, name, "get"),
89
- set: function(value) {
90
- decInfo[4](this, value);
91
- }
92
- };
93
- else desc1[key] = decVal;
94
- if (!isField) setFunctionName(desc1[key], name, isMethod ? "" : key);
95
- } else if (!isField) desc1 = Object.getOwnPropertyDescriptor(Class, name);
96
- if (!isField && !isPrivate) {
97
- _ = existingNonFields[+isStatic][name];
98
- if (_ && (_ ^ kind) !== 7) throw new Error("Decorating two elements with the same name (" + desc1[key].name + ") is not supported yet");
99
- existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind;
100
- }
101
- }
102
- var newValue = Class;
103
- for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
104
- var dec = assertCallable(decs[i], "A decorator", "be", true);
105
- var decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
106
- var decoratorFinishedRef = {};
107
- var ctx = {
108
- kind: [
109
- "field",
110
- "accessor",
111
- "method",
112
- "getter",
113
- "setter",
114
- "class"
115
- ][kind],
116
- name,
117
- metadata,
118
- addInitializer: (function(decoratorFinishedRef, initializer) {
119
- if (decoratorFinishedRef.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
120
- assertCallable(initializer, "An initializer", "be", true);
121
- initializers.push(initializer);
122
- }).bind(null, decoratorFinishedRef)
123
- };
124
- if (isClass) {
125
- _ = dec.call(decThis, newValue, ctx);
126
- decoratorFinishedRef.v = 1;
127
- if (assertCallable(_, "class decorators", "return")) newValue = _;
128
- continue;
129
- }
130
- ctx.static = isStatic;
131
- ctx.private = isPrivate;
132
- _ = ctx.access = { has: isPrivate ? hasPrivateBrand.bind() : function(target) {
133
- return name in target;
134
- } };
135
- if (!isSetter) _.get = isPrivate ? isMethod ? function(_this) {
136
- assertInstanceIfPrivate(_this);
137
- return desc1.value;
138
- } : bindPropCall("get", 0, assertInstanceIfPrivate) : function(target) {
139
- return target[name];
140
- };
141
- if (!isMethod && !isGetter) _.set = isPrivate ? bindPropCall("set", 0, assertInstanceIfPrivate) : function(target, value) {
142
- target[name] = value;
143
- };
144
- newValue = dec.call(decThis, isAccessor ? {
145
- get: desc1.get,
146
- set: desc1.set
147
- } : desc1[key], ctx);
148
- decoratorFinishedRef.v = 1;
149
- if (isAccessor) {
150
- if (typeof newValue === "object" && newValue) {
151
- if (_ = assertCallable(newValue.get, "accessor.get")) desc1.get = _;
152
- if (_ = assertCallable(newValue.set, "accessor.set")) desc1.set = _;
153
- if (_ = assertCallable(newValue.init, "accessor.init")) init.unshift(_);
154
- } else if (newValue !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
155
- } else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) if (isField) init.unshift(newValue);
156
- else desc1[key] = newValue;
157
- }
158
- if (kind < 2) ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0));
159
- if (!isField && !isClass) if (isPrivate) if (isAccessor) ret.splice(-1, 0, bindPropCall("get", isStatic), bindPropCall("set", isStatic));
160
- else ret.push(isMethod ? desc1[key] : assertCallable.call.bind(desc1[key]));
161
- else defineProperty(Class, name, desc1);
162
- return newValue;
163
- }
164
- function applyMemberDecs() {
165
- var ret = [];
166
- var protoInitializers;
167
- var staticInitializers;
168
- var pushInitializers = function(initializers) {
169
- if (initializers) ret.push(createRunInitializers(initializers));
170
- };
171
- var applyMemberDecsOfKind = function(isStatic, isField) {
172
- for (var i = 0; i < memberDecs.length; i++) {
173
- var decInfo = memberDecs[i];
174
- var kind = decInfo[1];
175
- var kindOnly = kind & 7;
176
- if ((kind & 8) == isStatic && !kindOnly == isField) {
177
- var name = decInfo[2];
178
- var isPrivate = !!decInfo[3];
179
- var decoratorsHaveThis = kind & 16;
180
- 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(_) {
181
- return checkInRHS(_) === targetClass;
182
- } : instanceBrand);
183
- }
184
- }
185
- };
186
- applyMemberDecsOfKind(8, 0);
187
- applyMemberDecsOfKind(0, 0);
188
- applyMemberDecsOfKind(8, 1);
189
- applyMemberDecsOfKind(0, 1);
190
- pushInitializers(protoInitializers);
191
- pushInitializers(staticInitializers);
192
- return ret;
193
- }
194
- function defineMetadata(Class) {
195
- return defineProperty(Class, symbolMetadata, {
196
- configurable: true,
197
- enumerable: true,
198
- value: metadata
199
- });
200
- }
201
- if (parentClass !== void 0) metadata = parentClass[symbolMetadata];
202
- metadata = create(metadata == null ? null : metadata);
203
- _ = applyMemberDecs();
204
- if (!hasClassDecs) defineMetadata(targetClass);
205
- return {
206
- e: _,
207
- get c() {
208
- var initializers = [];
209
- return hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)];
210
- }
211
- };
212
- }
213
- let _dec, _initClass;
214
- const YELLOW = "\x1B[33m";
215
- const RESET = "\x1B[0m";
216
- _dec = injectable([inject(CliLoggerToken)]);
217
- let _ConfigWarningReporterAdapter;
218
- (class {
219
- logger;
220
- static {
221
- ({c: [_ConfigWarningReporterAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
222
- }
223
- constructor(logger) {
224
- this.logger = logger;
225
- }
226
- reportSchemaWarnings(warnings) {
227
- for (const warningMessage of warnings) this.logger.out(`${YELLOW}⚠ ${warningMessage}${RESET}`);
228
- }
229
- static {
230
- _initClass();
231
- }
232
- });
233
- //#endregion
234
- export { _ConfigWarningReporterAdapter as ConfigWarningReporterAdapter };