@codefast/cli 0.5.0-canary.5 → 0.5.0-canary.6

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 (274) hide show
  1. package/README.md +106 -480
  2. package/dist/arrange/analyze.js +25 -0
  3. package/dist/arrange/analyze.js.map +1 -0
  4. package/dist/arrange/cli-schema.js +29 -0
  5. package/dist/arrange/cli-schema.js.map +1 -0
  6. package/dist/arrange/command.js +170 -0
  7. package/dist/arrange/command.js.map +1 -0
  8. package/dist/arrange/domain/analyze-service.js +122 -0
  9. package/dist/arrange/domain/analyze-service.js.map +1 -0
  10. package/dist/arrange/domain/ast/ast-node.js +240 -0
  11. package/dist/arrange/domain/ast/ast-node.js.map +1 -0
  12. package/dist/arrange/domain/ast/collectors-cn.js +81 -0
  13. package/dist/arrange/domain/ast/collectors-cn.js.map +1 -0
  14. package/dist/arrange/domain/ast/collectors-jsx.js +24 -0
  15. package/dist/arrange/domain/ast/collectors-jsx.js.map +1 -0
  16. package/dist/arrange/domain/ast/collectors-tv.js +319 -0
  17. package/dist/arrange/domain/ast/collectors-tv.js.map +1 -0
  18. package/dist/arrange/domain/ast/helpers.js +151 -0
  19. package/dist/arrange/domain/ast/helpers.js.map +1 -0
  20. package/dist/arrange/domain/ast/simplify-targets.js +161 -0
  21. package/dist/arrange/domain/ast/simplify-targets.js.map +1 -0
  22. package/dist/arrange/domain/ast/targets.js +182 -0
  23. package/dist/arrange/domain/ast/targets.js.map +1 -0
  24. package/dist/arrange/domain/constants.js +225 -0
  25. package/dist/arrange/domain/constants.js.map +1 -0
  26. package/dist/arrange/domain/grouping-service.js +128 -0
  27. package/dist/arrange/domain/grouping-service.js.map +1 -0
  28. package/dist/arrange/domain/grouping.js +435 -0
  29. package/dist/arrange/domain/grouping.js.map +1 -0
  30. package/dist/arrange/domain/imports.js +160 -0
  31. package/dist/arrange/domain/imports.js.map +1 -0
  32. package/dist/arrange/domain/source-text-formatters.js +100 -0
  33. package/dist/arrange/domain/source-text-formatters.js.map +1 -0
  34. package/dist/arrange/domain/tailwind-token.js +50 -0
  35. package/dist/arrange/domain/tailwind-token.js.map +1 -0
  36. package/dist/arrange/domain/token-classifier.js +448 -0
  37. package/dist/arrange/domain/token-classifier.js.map +1 -0
  38. package/dist/arrange/domain/types.js +11 -0
  39. package/dist/arrange/domain/types.js.map +1 -0
  40. package/dist/arrange/output.js +120 -0
  41. package/dist/arrange/output.js.map +1 -0
  42. package/dist/arrange/process-file.js +44 -0
  43. package/dist/arrange/process-file.js.map +1 -0
  44. package/dist/arrange/resolve-target.js +33 -0
  45. package/dist/arrange/resolve-target.js.map +1 -0
  46. package/dist/arrange/scan-target.js +30 -0
  47. package/dist/arrange/scan-target.js.map +1 -0
  48. package/dist/arrange/simplify-process-file.js +29 -0
  49. package/dist/arrange/simplify-process-file.js.map +1 -0
  50. package/dist/arrange/simplify-sync.js +29 -0
  51. package/dist/arrange/simplify-sync.js.map +1 -0
  52. package/dist/arrange/source-parse.js +17 -0
  53. package/dist/arrange/source-parse.js.map +1 -0
  54. package/dist/arrange/suggest.js +14 -0
  55. package/dist/arrange/suggest.js.map +1 -0
  56. package/dist/arrange/sync.js +48 -0
  57. package/dist/arrange/sync.js.map +1 -0
  58. package/dist/arrange/typescript-ast-translator.js +455 -0
  59. package/dist/arrange/typescript-ast-translator.js.map +1 -0
  60. package/dist/arrange/workspace.js +31 -0
  61. package/dist/arrange/workspace.js.map +1 -0
  62. package/dist/audit/cli-schema.js +22 -0
  63. package/dist/audit/cli-schema.js.map +1 -0
  64. package/dist/audit/command.js +60 -0
  65. package/dist/audit/command.js.map +1 -0
  66. package/dist/audit/domain/audit-file.js +101 -0
  67. package/dist/audit/domain/audit-file.js.map +1 -0
  68. package/dist/audit/domain/mappings.js +103 -0
  69. package/dist/audit/domain/mappings.js.map +1 -0
  70. package/dist/audit/domain/tokenize.js +83 -0
  71. package/dist/audit/domain/tokenize.js.map +1 -0
  72. package/dist/audit/domain/types.js +2 -0
  73. package/dist/audit/domain/types.js.map +1 -0
  74. package/dist/audit/output.js +44 -0
  75. package/dist/audit/output.js.map +1 -0
  76. package/dist/audit/prepare.js +42 -0
  77. package/dist/audit/prepare.js.map +1 -0
  78. package/dist/audit/run.js +57 -0
  79. package/dist/audit/run.js.map +1 -0
  80. package/dist/{bin.mjs → bin.js} +2 -4
  81. package/dist/bin.js.map +1 -0
  82. package/dist/cli.js +45 -0
  83. package/dist/cli.js.map +1 -0
  84. package/dist/core/cli/format-error.js +19 -0
  85. package/dist/core/cli/format-error.js.map +1 -0
  86. package/dist/core/cli/global-options.js +10 -0
  87. package/dist/core/cli/global-options.js.map +1 -0
  88. package/dist/core/cli/positional.js +9 -0
  89. package/dist/core/cli/positional.js.map +1 -0
  90. package/dist/core/cli/result-handle.js +69 -0
  91. package/dist/core/cli/result-handle.js.map +1 -0
  92. package/dist/core/config/loader.js +88 -0
  93. package/dist/core/config/loader.js.map +1 -0
  94. package/dist/core/config/schema.js +97 -0
  95. package/dist/core/config/schema.js.map +1 -0
  96. package/dist/core/config/warnings.js +12 -0
  97. package/dist/core/config/warnings.js.map +1 -0
  98. package/dist/core/config.js +18 -0
  99. package/dist/core/config.js.map +1 -0
  100. package/dist/core/errors.js +58 -0
  101. package/dist/core/errors.js.map +1 -0
  102. package/dist/core/exit-codes.js +15 -0
  103. package/dist/core/exit-codes.js.map +1 -0
  104. package/dist/core/filesystem/node.js +33 -0
  105. package/dist/core/filesystem/node.js.map +1 -0
  106. package/dist/core/filesystem/port.js +2 -0
  107. package/dist/core/filesystem/port.js.map +1 -0
  108. package/dist/core/glob.js +20 -0
  109. package/dist/core/glob.js.map +1 -0
  110. package/dist/core/logger.js +13 -0
  111. package/dist/core/logger.js.map +1 -0
  112. package/dist/core/result.js +16 -0
  113. package/dist/core/result.js.map +1 -0
  114. package/dist/core/schema-parse.js +21 -0
  115. package/dist/core/schema-parse.js.map +1 -0
  116. package/dist/core/source-text-edit.js +62 -0
  117. package/dist/core/source-text-edit.js.map +1 -0
  118. package/dist/core/verbose-diagnostics.js +9 -0
  119. package/dist/core/verbose-diagnostics.js.map +1 -0
  120. package/dist/core/workspace/resolver.js +208 -0
  121. package/dist/core/workspace/resolver.js.map +1 -0
  122. package/dist/core/workspace/typescript-walk.js +41 -0
  123. package/dist/core/workspace/typescript-walk.js.map +1 -0
  124. package/dist/mirror/cli-result.js +20 -0
  125. package/dist/mirror/cli-result.js.map +1 -0
  126. package/dist/mirror/cli-schema.js +11 -0
  127. package/dist/mirror/cli-schema.js.map +1 -0
  128. package/dist/mirror/command.js +73 -0
  129. package/dist/mirror/command.js.map +1 -0
  130. package/dist/mirror/dist-filesystem-impl.js +53 -0
  131. package/dist/mirror/dist-filesystem-impl.js.map +1 -0
  132. package/dist/mirror/domain/constants.js +21 -0
  133. package/dist/mirror/domain/constants.js.map +1 -0
  134. package/dist/mirror/domain/dirent-guard.js +16 -0
  135. package/dist/mirror/domain/dirent-guard.js.map +1 -0
  136. package/dist/mirror/domain/dist-filesystem.js +2 -0
  137. package/dist/mirror/domain/dist-filesystem.js.map +1 -0
  138. package/dist/mirror/domain/errors.js +19 -0
  139. package/dist/mirror/domain/errors.js.map +1 -0
  140. package/dist/mirror/domain/exports.js +284 -0
  141. package/dist/mirror/domain/exports.js.map +1 -0
  142. package/dist/mirror/domain/package-display-name.js +10 -0
  143. package/dist/mirror/domain/package-display-name.js.map +1 -0
  144. package/dist/mirror/domain/path-normalizer.js +8 -0
  145. package/dist/mirror/domain/path-normalizer.js.map +1 -0
  146. package/dist/mirror/domain/types.js +2 -0
  147. package/dist/mirror/domain/types.js.map +1 -0
  148. package/dist/mirror/output.js +47 -0
  149. package/dist/mirror/output.js.map +1 -0
  150. package/dist/mirror/package-path.js +40 -0
  151. package/dist/mirror/package-path.js.map +1 -0
  152. package/dist/mirror/prepare.js +37 -0
  153. package/dist/mirror/prepare.js.map +1 -0
  154. package/dist/mirror/supplement-exports.js +157 -0
  155. package/dist/mirror/supplement-exports.js.map +1 -0
  156. package/dist/mirror/sync-reporter.js +125 -0
  157. package/dist/mirror/sync-reporter.js.map +1 -0
  158. package/dist/mirror/sync-types.js +2 -0
  159. package/dist/mirror/sync-types.js.map +1 -0
  160. package/dist/mirror/sync-workspace-package.js +117 -0
  161. package/dist/mirror/sync-workspace-package.js.map +1 -0
  162. package/dist/mirror/sync.js +90 -0
  163. package/dist/mirror/sync.js.map +1 -0
  164. package/dist/mirror/write-exports.js +145 -0
  165. package/dist/mirror/write-exports.js.map +1 -0
  166. package/dist/tag/cli-result.js +12 -0
  167. package/dist/tag/cli-result.js.map +1 -0
  168. package/dist/tag/cli-schema.js +13 -0
  169. package/dist/tag/cli-schema.js.map +1 -0
  170. package/dist/tag/command.js +69 -0
  171. package/dist/tag/command.js.map +1 -0
  172. package/dist/tag/domain/types.js +2 -0
  173. package/dist/tag/domain/types.js.map +1 -0
  174. package/dist/tag/output.js +101 -0
  175. package/dist/tag/output.js.map +1 -0
  176. package/dist/tag/prepare.js +30 -0
  177. package/dist/tag/prepare.js.map +1 -0
  178. package/dist/tag/resolve-target-path.js +14 -0
  179. package/dist/tag/resolve-target-path.js.map +1 -0
  180. package/dist/tag/since-writer.js +231 -0
  181. package/dist/tag/since-writer.js.map +1 -0
  182. package/dist/tag/sync.js +166 -0
  183. package/dist/tag/sync.js.map +1 -0
  184. package/dist/tag/target-candidates.js +79 -0
  185. package/dist/tag/target-candidates.js.map +1 -0
  186. package/dist/tag/target-runner.js +25 -0
  187. package/dist/tag/target-runner.js.map +1 -0
  188. package/dist/tag/version-resolver.js +28 -0
  189. package/dist/tag/version-resolver.js.map +1 -0
  190. package/package.json +25 -20
  191. package/dist/arrange/analyze.mjs +0 -24
  192. package/dist/arrange/cli-schema.mjs +0 -27
  193. package/dist/arrange/command.mjs +0 -130
  194. package/dist/arrange/domain/analyze-service.mjs +0 -102
  195. package/dist/arrange/domain/ast/ast-node.mjs +0 -215
  196. package/dist/arrange/domain/ast/collectors-cn.mjs +0 -64
  197. package/dist/arrange/domain/ast/collectors-jsx.mjs +0 -23
  198. package/dist/arrange/domain/ast/collectors-tv.mjs +0 -189
  199. package/dist/arrange/domain/ast/helpers.mjs +0 -108
  200. package/dist/arrange/domain/ast/simplify-targets.mjs +0 -109
  201. package/dist/arrange/domain/ast/targets.mjs +0 -134
  202. package/dist/arrange/domain/constants.mjs +0 -213
  203. package/dist/arrange/domain/grouping-service.mjs +0 -121
  204. package/dist/arrange/domain/grouping.mjs +0 -338
  205. package/dist/arrange/domain/imports.mjs +0 -107
  206. package/dist/arrange/domain/source-text-formatters.mjs +0 -88
  207. package/dist/arrange/domain/tailwind-token.mjs +0 -40
  208. package/dist/arrange/domain/token-classifier.mjs +0 -218
  209. package/dist/arrange/domain/types.mjs +0 -1
  210. package/dist/arrange/output.mjs +0 -87
  211. package/dist/arrange/process-file.mjs +0 -42
  212. package/dist/arrange/resolve-target.mjs +0 -24
  213. package/dist/arrange/scan-target.mjs +0 -29
  214. package/dist/arrange/simplify-process-file.mjs +0 -35
  215. package/dist/arrange/simplify-sync.mjs +0 -32
  216. package/dist/arrange/source-parse.mjs +0 -18
  217. package/dist/arrange/suggest.mjs +0 -15
  218. package/dist/arrange/sync.mjs +0 -51
  219. package/dist/arrange/typescript-ast-translator.mjs +0 -354
  220. package/dist/arrange/workspace.mjs +0 -31
  221. package/dist/cli.mjs +0 -34
  222. package/dist/core/cli/format-error.mjs +0 -15
  223. package/dist/core/cli/global-options.mjs +0 -10
  224. package/dist/core/cli/positional.mjs +0 -11
  225. package/dist/core/cli/result-handle.mjs +0 -51
  226. package/dist/core/config/loader.mjs +0 -79
  227. package/dist/core/config/schema.mjs +0 -60
  228. package/dist/core/config/warnings.mjs +0 -12
  229. package/dist/core/config.mjs +0 -19
  230. package/dist/core/errors.mjs +0 -35
  231. package/dist/core/exit-codes.mjs +0 -17
  232. package/dist/core/filesystem/node.mjs +0 -32
  233. package/dist/core/filesystem/port.mjs +0 -1
  234. package/dist/core/glob.mjs +0 -20
  235. package/dist/core/logger.mjs +0 -15
  236. package/dist/core/result.mjs +0 -21
  237. package/dist/core/schema-parse.mjs +0 -18
  238. package/dist/core/source-text-edit.mjs +0 -56
  239. package/dist/core/verbose-diagnostics.mjs +0 -11
  240. package/dist/core/workspace/resolver.mjs +0 -177
  241. package/dist/core/workspace/typescript-walk.mjs +0 -36
  242. package/dist/mirror/cli-result.mjs +0 -22
  243. package/dist/mirror/cli-schema.mjs +0 -13
  244. package/dist/mirror/command.mjs +0 -58
  245. package/dist/mirror/dist-filesystem-impl.mjs +0 -42
  246. package/dist/mirror/domain/constants.mjs +0 -31
  247. package/dist/mirror/domain/dirent-guard.mjs +0 -16
  248. package/dist/mirror/domain/dist-filesystem.mjs +0 -1
  249. package/dist/mirror/domain/errors.mjs +0 -21
  250. package/dist/mirror/domain/exports.mjs +0 -226
  251. package/dist/mirror/domain/package-display-name.mjs +0 -12
  252. package/dist/mirror/domain/path-normalizer.mjs +0 -10
  253. package/dist/mirror/domain/types.mjs +0 -1
  254. package/dist/mirror/output.mjs +0 -48
  255. package/dist/mirror/package-path.mjs +0 -32
  256. package/dist/mirror/prepare.mjs +0 -33
  257. package/dist/mirror/supplement-exports.mjs +0 -114
  258. package/dist/mirror/sync-reporter.mjs +0 -107
  259. package/dist/mirror/sync-types.mjs +0 -1
  260. package/dist/mirror/sync-workspace-package.mjs +0 -109
  261. package/dist/mirror/sync.mjs +0 -88
  262. package/dist/mirror/write-exports.mjs +0 -94
  263. package/dist/tag/cli-result.mjs +0 -11
  264. package/dist/tag/cli-schema.mjs +0 -15
  265. package/dist/tag/command.mjs +0 -56
  266. package/dist/tag/domain/types.mjs +0 -1
  267. package/dist/tag/output.mjs +0 -87
  268. package/dist/tag/prepare.mjs +0 -29
  269. package/dist/tag/resolve-target-path.mjs +0 -12
  270. package/dist/tag/since-writer.mjs +0 -131
  271. package/dist/tag/sync.mjs +0 -149
  272. package/dist/tag/target-candidates.mjs +0 -68
  273. package/dist/tag/target-runner.mjs +0 -26
  274. package/dist/tag/version-resolver.mjs +0 -25
@@ -1,354 +0,0 @@
1
- import "./domain/ast/ast-node.mjs";
2
- import ts from "typescript";
3
- //#region src/arrange/typescript-ast-translator.ts
4
- /**
5
- * Anti-corruption layer: maps TypeScript compiler AST to arrange domain AST.
6
- * This module is the only place that imports `typescript` for arrange AST translation.
7
- */
8
- /**
9
- * @since 0.3.16-canary.0
10
- */
11
- var TypeScriptAstTranslator = class {
12
- translateSourceFile(filePath, sourceText) {
13
- return this.parseDomainSourceFile(filePath, sourceText);
14
- }
15
- translateUnknown(n, parent, sf) {
16
- const self = {
17
- kind: 1,
18
- pos: n.getStart(sf),
19
- end: n.getEnd(),
20
- parent,
21
- children: []
22
- };
23
- const childList = [];
24
- ts.forEachChild(n, (child) => {
25
- childList.push(this.translateNode(child, self, sf));
26
- });
27
- return {
28
- ...self,
29
- children: childList
30
- };
31
- }
32
- mapBinaryOperator(operatorToken) {
33
- if (operatorToken.kind === ts.SyntaxKind.PlusToken) return 0;
34
- return 1;
35
- }
36
- translateNode(n, parent, sf) {
37
- const pos = n.getStart(sf);
38
- const end = n.getEnd();
39
- switch (n.kind) {
40
- case ts.SyntaxKind.Identifier: return {
41
- kind: 2,
42
- pos,
43
- end,
44
- parent,
45
- text: n.text
46
- };
47
- case ts.SyntaxKind.StringLiteral: return {
48
- kind: 3,
49
- pos,
50
- end,
51
- parent,
52
- text: n.text
53
- };
54
- case ts.SyntaxKind.NoSubstitutionTemplateLiteral: return {
55
- kind: 4,
56
- pos,
57
- end,
58
- parent,
59
- text: n.text
60
- };
61
- case ts.SyntaxKind.ImportDeclaration: {
62
- const decl = n;
63
- const self = {
64
- kind: 5,
65
- pos,
66
- end,
67
- parent,
68
- importClause: void 0,
69
- moduleSpecifier: void 0
70
- };
71
- if (decl.importClause) self.importClause = this.translateNode(decl.importClause, self, sf);
72
- self.moduleSpecifier = this.translateNode(decl.moduleSpecifier, self, sf);
73
- return self;
74
- }
75
- case ts.SyntaxKind.ImportClause: {
76
- const clause = n;
77
- const self = {
78
- kind: 6,
79
- pos,
80
- end,
81
- parent,
82
- isTypeOnly: clause.isTypeOnly,
83
- name: void 0,
84
- namedBindings: void 0
85
- };
86
- if (clause.name) self.name = this.translateNode(clause.name, self, sf);
87
- if (clause.namedBindings) self.namedBindings = this.translateNode(clause.namedBindings, self, sf);
88
- return self;
89
- }
90
- case ts.SyntaxKind.NamedImports: {
91
- const named = n;
92
- const self = {
93
- kind: 7,
94
- pos,
95
- end,
96
- parent,
97
- elements: []
98
- };
99
- const elements = [];
100
- for (const element of named.elements) elements.push(this.translateNode(element, self, sf));
101
- return {
102
- ...self,
103
- elements
104
- };
105
- }
106
- case ts.SyntaxKind.NamespaceImport: {
107
- const ns = n;
108
- const self = {
109
- kind: 8,
110
- pos,
111
- end,
112
- parent,
113
- name: void 0
114
- };
115
- self.name = this.translateNode(ns.name, self, sf);
116
- return self;
117
- }
118
- case ts.SyntaxKind.ImportSpecifier: {
119
- const spec = n;
120
- const self = {
121
- kind: 9,
122
- pos,
123
- end,
124
- parent,
125
- propertyName: void 0,
126
- name: void 0
127
- };
128
- if (spec.propertyName) self.propertyName = this.translateNode(spec.propertyName, self, sf);
129
- self.name = this.translateNode(spec.name, self, sf);
130
- return self;
131
- }
132
- case ts.SyntaxKind.CallExpression: {
133
- const call = n;
134
- const self = {
135
- kind: 10,
136
- pos,
137
- end,
138
- parent,
139
- expression: void 0,
140
- arguments: []
141
- };
142
- self.expression = this.translateNode(call.expression, self, sf);
143
- self.arguments = call.arguments.map((arg) => this.translateNode(arg, self, sf));
144
- return self;
145
- }
146
- case ts.SyntaxKind.PropertyAccessExpression: {
147
- const pa = n;
148
- const self = {
149
- kind: 11,
150
- pos,
151
- end,
152
- parent,
153
- expression: void 0,
154
- name: void 0
155
- };
156
- self.expression = this.translateNode(pa.expression, self, sf);
157
- self.name = this.translateNode(pa.name, self, sf);
158
- return self;
159
- }
160
- case ts.SyntaxKind.ObjectLiteralExpression: {
161
- const obj = n;
162
- const self = {
163
- kind: 12,
164
- pos,
165
- end,
166
- parent,
167
- properties: []
168
- };
169
- const properties = [];
170
- for (const prop of obj.properties) properties.push(this.translateNode(prop, self, sf));
171
- return {
172
- ...self,
173
- properties
174
- };
175
- }
176
- case ts.SyntaxKind.PropertyAssignment: {
177
- const prop = n;
178
- const self = {
179
- kind: 13,
180
- pos,
181
- end,
182
- parent,
183
- name: void 0,
184
- initializer: void 0
185
- };
186
- self.name = this.translateNode(prop.name, self, sf);
187
- self.initializer = this.translateNode(prop.initializer, self, sf);
188
- return self;
189
- }
190
- case ts.SyntaxKind.ArrayLiteralExpression: {
191
- const arr = n;
192
- const self = {
193
- kind: 14,
194
- pos,
195
- end,
196
- parent,
197
- elements: []
198
- };
199
- const elements = [];
200
- for (const element of arr.elements) elements.push(this.translateNode(element, self, sf));
201
- return {
202
- ...self,
203
- elements
204
- };
205
- }
206
- case ts.SyntaxKind.SpreadElement: {
207
- const sp = n;
208
- const self = {
209
- kind: 15,
210
- pos,
211
- end,
212
- parent,
213
- expression: void 0
214
- };
215
- self.expression = this.translateNode(sp.expression, self, sf);
216
- return self;
217
- }
218
- case ts.SyntaxKind.ParenthesizedExpression: {
219
- const pe = n;
220
- const self = {
221
- kind: 16,
222
- pos,
223
- end,
224
- parent,
225
- expression: void 0
226
- };
227
- self.expression = this.translateNode(pe.expression, self, sf);
228
- return self;
229
- }
230
- case ts.SyntaxKind.AsExpression: {
231
- const ae = n;
232
- const self = {
233
- kind: 17,
234
- pos,
235
- end,
236
- parent,
237
- expression: void 0
238
- };
239
- self.expression = this.translateNode(ae.expression, self, sf);
240
- return self;
241
- }
242
- case ts.SyntaxKind.SatisfiesExpression: {
243
- const se = n;
244
- const self = {
245
- kind: 18,
246
- pos,
247
- end,
248
- parent,
249
- expression: void 0
250
- };
251
- self.expression = this.translateNode(se.expression, self, sf);
252
- return self;
253
- }
254
- case ts.SyntaxKind.NonNullExpression: {
255
- const nn = n;
256
- const self = {
257
- kind: 19,
258
- pos,
259
- end,
260
- parent,
261
- expression: void 0
262
- };
263
- self.expression = this.translateNode(nn.expression, self, sf);
264
- return self;
265
- }
266
- case ts.SyntaxKind.ConditionalExpression: {
267
- const ce = n;
268
- const self = {
269
- kind: 20,
270
- pos,
271
- end,
272
- parent,
273
- condition: void 0,
274
- whenTrue: void 0,
275
- whenFalse: void 0
276
- };
277
- self.condition = this.translateNode(ce.condition, self, sf);
278
- self.whenTrue = this.translateNode(ce.whenTrue, self, sf);
279
- self.whenFalse = this.translateNode(ce.whenFalse, self, sf);
280
- return self;
281
- }
282
- case ts.SyntaxKind.BinaryExpression: {
283
- const be = n;
284
- const self = {
285
- kind: 21,
286
- pos,
287
- end,
288
- parent,
289
- left: void 0,
290
- operator: this.mapBinaryOperator(be.operatorToken),
291
- right: void 0
292
- };
293
- self.left = this.translateNode(be.left, self, sf);
294
- self.right = this.translateNode(be.right, self, sf);
295
- return self;
296
- }
297
- case ts.SyntaxKind.ExpressionStatement: {
298
- const es = n;
299
- const self = {
300
- kind: 22,
301
- pos,
302
- end,
303
- parent,
304
- expression: void 0
305
- };
306
- self.expression = this.translateNode(es.expression, self, sf);
307
- return self;
308
- }
309
- case ts.SyntaxKind.JsxAttribute: {
310
- const ja = n;
311
- const self = {
312
- kind: 23,
313
- pos,
314
- end,
315
- parent,
316
- name: void 0,
317
- initializer: void 0
318
- };
319
- self.name = this.translateNode(ja.name, self, sf);
320
- if (ja.initializer) self.initializer = this.translateNode(ja.initializer, self, sf);
321
- return self;
322
- }
323
- case ts.SyntaxKind.JsxExpression: {
324
- const je = n;
325
- const self = {
326
- kind: 24,
327
- pos,
328
- end,
329
- parent,
330
- expression: void 0
331
- };
332
- if (je.expression) self.expression = this.translateNode(je.expression, self, sf);
333
- return self;
334
- }
335
- default: return this.translateUnknown(n, parent, sf);
336
- }
337
- }
338
- translateTypeScriptSourceFile(tsSf) {
339
- const text = tsSf.getFullText();
340
- const statements = tsSf.statements.map((statement) => this.translateNode(statement, null, tsSf));
341
- return {
342
- fileName: tsSf.fileName,
343
- text,
344
- statements
345
- };
346
- }
347
- parseDomainSourceFile(filePath, sourceText) {
348
- const scriptKind = filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
349
- const tsSf = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, scriptKind);
350
- return this.translateTypeScriptSourceFile(tsSf);
351
- }
352
- };
353
- //#endregion
354
- export { TypeScriptAstTranslator };
@@ -1,31 +0,0 @@
1
- import { AppError, messageFrom } from "../core/errors.mjs";
2
- import { err, ok } from "../core/result.mjs";
3
- import { resolveArrangeTargetPath } from "./resolve-target.mjs";
4
- import { loadCodefastConfig } from "../core/config.mjs";
5
- import { findRepoRoot } from "../core/workspace/resolver.mjs";
6
- //#region src/arrange/workspace.ts
7
- /**
8
- * @since 0.3.16-canary.0
9
- */
10
- async function prepareArrangeWorkspace(fs, args) {
11
- const resolvedTarget = resolveArrangeTargetPath(fs, {
12
- currentWorkingDirectory: args.currentWorkingDirectory,
13
- rawTarget: args.rawTarget
14
- });
15
- if (!fs.existsSync(resolvedTarget)) return err(new AppError("NOT_FOUND", `Not found: ${resolvedTarget}`));
16
- let rootDir;
17
- try {
18
- rootDir = findRepoRoot(args.currentWorkingDirectory, fs);
19
- } catch (caughtError) {
20
- return err(new AppError("INFRA_FAILURE", messageFrom(caughtError), caughtError));
21
- }
22
- const loadedOutcome = await loadCodefastConfig(rootDir, fs);
23
- if (!loadedOutcome.ok) return loadedOutcome;
24
- return ok({
25
- resolvedTarget,
26
- rootDir,
27
- config: loadedOutcome.value.config
28
- });
29
- }
30
- //#endregion
31
- export { prepareArrangeWorkspace };
package/dist/cli.mjs DELETED
@@ -1,34 +0,0 @@
1
- import { createArrangeCommand } from "./arrange/command.mjs";
2
- import { createMirrorCommand } from "./mirror/command.mjs";
3
- import { createTagCommand } from "./tag/command.mjs";
4
- import process from "node:process";
5
- import { readFileSync } from "node:fs";
6
- import path from "node:path";
7
- import { fileURLToPath } from "node:url";
8
- import { Command } from "commander";
9
- //#region src/cli.ts
10
- function readVersion() {
11
- try {
12
- const dir = path.dirname(fileURLToPath(import.meta.url));
13
- const raw = readFileSync(path.join(dir, "..", "package.json"), "utf-8");
14
- const pkgVersion = JSON.parse(raw).version;
15
- return typeof pkgVersion === "string" && pkgVersion.length > 0 ? pkgVersion : "unknown";
16
- } catch {
17
- return "unknown";
18
- }
19
- }
20
- /**
21
- * @since 0.3.16-canary.0
22
- */
23
- async function runCli(argv) {
24
- const program = new Command();
25
- program.name("codefast").description("Codefast monorepo developer CLI").version(readVersion()).option("--no-color", "Disable ANSI color output").enablePositionalOptions().configureHelp({ sortSubcommands: true }).showHelpAfterError("(use --help for usage)");
26
- program.addCommand(createArrangeCommand());
27
- program.addCommand(createMirrorCommand());
28
- program.addCommand(createTagCommand());
29
- await program.parseAsync(argv, { from: "node" });
30
- const code = process.exitCode ?? 0;
31
- return typeof code === "number" ? code : Number(code) || 0;
32
- }
33
- //#endregion
34
- export { runCli };
@@ -1,15 +0,0 @@
1
- //#region src/core/cli/format-error.ts
2
- /**
3
- * @since 0.3.16-canary.0
4
- */
5
- function formatAppError(error) {
6
- const { code, message } = error;
7
- switch (code) {
8
- case "NOT_FOUND": return `[NOT_FOUND] ${message}`;
9
- case "VALIDATION_ERROR": return `[VALIDATION_ERROR] ${message}`;
10
- case "INFRA_FAILURE": return `[INFRA_FAILURE] ${message}`;
11
- default: return `Unhandled error code: ${String(code)}`;
12
- }
13
- }
14
- //#endregion
15
- export { formatAppError };
@@ -1,10 +0,0 @@
1
- import { z } from "zod";
2
- //#region src/core/cli/global-options.ts
3
- /**
4
- * Commander global opts shape validated before mirror prelude (`color` from `--no-color`).
5
- *
6
- * @since 0.3.16-canary.0
7
- */
8
- const globalCliCommanderOptionsSchema = z.object({ color: z.boolean().optional() });
9
- //#endregion
10
- export { globalCliCommanderOptionsSchema };
@@ -1,11 +0,0 @@
1
- //#region src/core/cli/positional.ts
2
- /**
3
- * Coerce a raw Commander positional argument to a string, or undefined when absent.
4
- *
5
- * @since 0.3.16-canary.0
6
- */
7
- function readOptionalPositionalArg(candidate) {
8
- return typeof candidate === "string" ? candidate : void 0;
9
- }
10
- //#endregion
11
- export { readOptionalPositionalArg };
@@ -1,51 +0,0 @@
1
- import { logger } from "../logger.mjs";
2
- import { formatAppError } from "./format-error.mjs";
3
- import "../exit-codes.mjs";
4
- import { isVerboseCliDiagnostics } from "../verbose-diagnostics.mjs";
5
- import process from "node:process";
6
- //#region src/core/cli/result-handle.ts
7
- function exitCodeForAppError(error) {
8
- switch (error.code) {
9
- case "NOT_FOUND": return 1;
10
- case "VALIDATION_ERROR": return 2;
11
- case "INFRA_FAILURE": return 1;
12
- default: return error.code;
13
- }
14
- }
15
- /**
16
- * @since 0.3.16-canary.0
17
- */
18
- function handleResult(outcome, onSuccess) {
19
- if (!outcome.ok) {
20
- logger.err(formatAppError(outcome.error));
21
- if (isVerboseCliDiagnostics() && outcome.error.code === "INFRA_FAILURE" && outcome.error.cause instanceof Error && outcome.error.cause.stack !== void 0) logger.err(outcome.error.cause.stack);
22
- process.exitCode = exitCodeForAppError(outcome.error);
23
- return false;
24
- }
25
- onSuccess(outcome.value);
26
- return true;
27
- }
28
- /**
29
- * @since 0.3.16-canary.0
30
- */
31
- function consumeCliAppError(outcome, options) {
32
- if (!outcome.ok) {
33
- logger.err(formatAppError(outcome.error));
34
- if (isVerboseCliDiagnostics() && outcome.error.code === "INFRA_FAILURE" && outcome.error.cause instanceof Error && outcome.error.cause.stack !== void 0) logger.err(outcome.error.cause.stack);
35
- process.exitCode = exitCodeForAppError(outcome.error);
36
- return false;
37
- }
38
- if (options?.successMessage !== void 0) logger.out(options.successMessage);
39
- return true;
40
- }
41
- /**
42
- * @since 0.3.16-canary.0
43
- */
44
- async function runCliResultAsync(outcomePromise, onSuccess) {
45
- const outcome = await outcomePromise;
46
- if (!consumeCliAppError(outcome)) return;
47
- const exit = await onSuccess(outcome.value);
48
- process.exitCode = exit === void 0 ? 0 : exit;
49
- }
50
- //#endregion
51
- export { consumeCliAppError, handleResult, runCliResultAsync };
@@ -1,79 +0,0 @@
1
- import { codefastConfigRootSchema } from "./schema.mjs";
2
- import path from "node:path";
3
- import jiti from "jiti";
4
- //#region src/core/config/loader.ts
5
- function formatZodError(error, filePath) {
6
- const formatted = error.issues.map((issue) => {
7
- return ` - ${issue.path.length > 0 ? issue.path.join(".") : "<root>"}: ${issue.message}`;
8
- }).join("\n");
9
- return `Invalid config schema in ${path.basename(filePath)}:\n${formatted}`;
10
- }
11
- function parseLoadedConfig(raw, filePath) {
12
- const parsed = codefastConfigRootSchema.safeParse(raw);
13
- if (!parsed.success) throw new Error(formatZodError(parsed.error, filePath));
14
- return parsed.data;
15
- }
16
- const configJsPriority = [
17
- "codefast.config.mjs",
18
- "codefast.config.js",
19
- "codefast.config.cjs"
20
- ];
21
- const configJson = "codefast.config.json";
22
- const cachedLoads = /* @__PURE__ */ new Map();
23
- function listConfigCandidates(startDir, fs) {
24
- const candidates = [];
25
- let current = path.resolve(startDir);
26
- while (true) {
27
- for (const name of configJsPriority) {
28
- const candidate = path.join(current, name);
29
- if (fs.existsSync(candidate)) candidates.push(candidate);
30
- }
31
- const jsonCandidate = path.join(current, configJson);
32
- if (fs.existsSync(jsonCandidate)) candidates.push(jsonCandidate);
33
- const parent = path.dirname(current);
34
- if (parent === current) break;
35
- current = parent;
36
- }
37
- return candidates;
38
- }
39
- async function readConfigFromPath(filePath, jitiBaseDir, fs) {
40
- if (path.extname(filePath) === ".json") {
41
- const content = await fs.readFile(filePath, "utf8");
42
- return parseLoadedConfig(JSON.parse(content), filePath);
43
- }
44
- const moduleConfig = jiti(jitiBaseDir, {
45
- interopDefault: true,
46
- moduleCache: false
47
- })(filePath);
48
- return parseLoadedConfig(typeof moduleConfig === "object" && moduleConfig !== null && "default" in moduleConfig ? moduleConfig.default : moduleConfig, filePath);
49
- }
50
- async function loadOnce(startDir, fs) {
51
- const warnings = [];
52
- const configPaths = listConfigCandidates(startDir, fs);
53
- if (configPaths.length === 0) return {
54
- config: {},
55
- warnings
56
- };
57
- const configPath = configPaths[0];
58
- if (configPath === void 0) return {
59
- config: {},
60
- warnings
61
- };
62
- return {
63
- config: await readConfigFromPath(configPath, startDir, fs),
64
- warnings,
65
- configPath
66
- };
67
- }
68
- /**
69
- * @since 0.3.16-canary.0
70
- */
71
- function loadConfigPayload(startDir, fs) {
72
- const cacheKey = path.resolve(startDir);
73
- if (!cachedLoads.has(cacheKey)) cachedLoads.set(cacheKey, loadOnce(cacheKey, fs));
74
- const cached = cachedLoads.get(cacheKey);
75
- if (cached === void 0) throw new Error("config loader cache invariant violated");
76
- return cached;
77
- }
78
- //#endregion
79
- export { loadConfigPayload };
@@ -1,60 +0,0 @@
1
- import { z } from "zod";
2
- //#region src/core/config/schema.ts
3
- const afterWriteHookSchema = z.custom((value) => typeof value === "function", { message: "Expected a function" });
4
- const mirrorCssConfigSchema = z.union([z.boolean(), z.object({
5
- enabled: z.boolean().optional(),
6
- customExports: z.record(z.string(), z.string()).optional(),
7
- forceExportFiles: z.boolean().optional()
8
- }).strict()]);
9
- /**
10
- * Per-package mirror configuration. Setting a package to `false` skips it entirely.
11
- *
12
- * - `source` — include a `source` condition pointing to the original `.ts` file (default `true`).
13
- * Pass a string to override the root-export source path explicitly.
14
- * - `types` — include the `types` condition when `.d.ts` files exist (default `true`).
15
- * - `import` — include the `import` condition (default `true`).
16
- * - `css` — CSS export configuration (wildcard or per-file).
17
- *
18
- * @since 0.3.16-canary.0
19
- */
20
- const mirrorPackageConfigSchema = z.object({
21
- /** Preserve the existing `package.json#exports` map and only add missing conditions
22
- * (`source`, `types`, `import`). No dist/ scan is performed. */
23
- preserve: z.boolean().optional(),
24
- strip: z.string().optional(),
25
- exports: z.record(z.string(), z.string()).optional(),
26
- source: z.union([z.boolean(), z.string()]).default(true),
27
- types: z.boolean().default(true),
28
- import: z.boolean().default(true),
29
- css: mirrorCssConfigSchema.optional()
30
- }).strict();
31
- /**
32
- * Mirror config: a record keyed by package name. Set a package to `false` to skip it;
33
- * omit it entirely to process it with default settings.
34
- *
35
- * @since 0.3.16-canary.0
36
- */
37
- const mirrorConfigSchema = z.record(z.string(), z.union([z.literal(false), mirrorPackageConfigSchema]));
38
- /**
39
- * @since 0.3.16-canary.0
40
- */
41
- const codefastTagConfigSchema = z.object({
42
- skipPackages: z.array(z.string()).optional(),
43
- onAfterWrite: afterWriteHookSchema.optional()
44
- }).strict();
45
- /**
46
- * @since 0.3.16-canary.0
47
- */
48
- const codefastArrangeConfigSchema = z.object({ onAfterWrite: afterWriteHookSchema.optional() }).strict();
49
- /**
50
- * Root `codefast.config` Zod schema — single source of truth for both validation and TS types.
51
- *
52
- * @since 0.3.16-canary.0
53
- */
54
- const codefastConfigRootSchema = z.object({
55
- mirror: mirrorConfigSchema.optional(),
56
- tag: codefastTagConfigSchema.optional(),
57
- arrange: codefastArrangeConfigSchema.optional()
58
- }).strict();
59
- //#endregion
60
- export { codefastArrangeConfigSchema, codefastConfigRootSchema, codefastTagConfigSchema, mirrorConfigSchema, mirrorPackageConfigSchema };
@@ -1,12 +0,0 @@
1
- import { logger } from "../logger.mjs";
2
- //#region src/core/config/warnings.ts
3
- const yellowAnsi = "\x1B[33m";
4
- const resetAnsi = "\x1B[0m";
5
- /**
6
- * @since 0.3.16-canary.0
7
- */
8
- function reportSchemaWarnings(warnings) {
9
- for (const warningMessage of warnings) logger.out(`${yellowAnsi}⚠ ${warningMessage}${resetAnsi}`);
10
- }
11
- //#endregion
12
- export { reportSchemaWarnings };
@@ -1,19 +0,0 @@
1
- import { AppError, messageFrom } from "./errors.mjs";
2
- import { err, ok } from "./result.mjs";
3
- import { loadConfigPayload } from "./config/loader.mjs";
4
- import { reportSchemaWarnings } from "./config/warnings.mjs";
5
- //#region src/core/config.ts
6
- /**
7
- * @since 0.3.16-canary.0
8
- */
9
- async function loadCodefastConfig(rootDir, fs) {
10
- try {
11
- const { config, warnings } = await loadConfigPayload(rootDir, fs);
12
- reportSchemaWarnings(warnings);
13
- return ok({ config });
14
- } catch (caughtError) {
15
- return err(new AppError("INFRA_FAILURE", messageFrom(caughtError), caughtError));
16
- }
17
- }
18
- //#endregion
19
- export { loadCodefastConfig };