@akanjs/devkit 1.0.20 → 2.1.0-rc.1

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 (195) hide show
  1. package/README.ko.md +65 -0
  2. package/README.md +62 -6
  3. package/aiEditor.ts +304 -0
  4. package/akanApp/akanApp.host.ts +393 -0
  5. package/akanApp/index.ts +1 -0
  6. package/akanConfig/akanConfig.test.ts +236 -0
  7. package/akanConfig/akanConfig.ts +384 -0
  8. package/akanConfig/index.ts +2 -0
  9. package/akanConfig/types.ts +23 -0
  10. package/applicationBuildReporter.ts +69 -0
  11. package/applicationBuildRunner.ts +302 -0
  12. package/applicationReleasePackager.ts +206 -0
  13. package/artifact/implicitRootLayout.ts +155 -0
  14. package/artifact/index.ts +1 -0
  15. package/artifact/routeSeedIndex.test.ts +98 -0
  16. package/artifact/routeSeedIndex.ts +130 -0
  17. package/auth.ts +41 -0
  18. package/builder.ts +164 -0
  19. package/capacitor.base.config.ts +88 -0
  20. package/capacitorApp.ts +440 -0
  21. package/commandDecorators/argMeta.ts +102 -0
  22. package/commandDecorators/command.ts +351 -0
  23. package/commandDecorators/commandBuilder.ts +224 -0
  24. package/commandDecorators/commandDecorators.test.ts +212 -0
  25. package/commandDecorators/commandMeta.ts +7 -0
  26. package/commandDecorators/dependencyBuilder.ts +100 -0
  27. package/{esm/src/commandDecorators/helpFormatter.js → commandDecorators/helpFormatter.ts} +100 -47
  28. package/{esm/src/commandDecorators/index.js → commandDecorators/index.ts} +4 -2
  29. package/commandDecorators/targetMeta.ts +31 -0
  30. package/commandDecorators/types.ts +10 -0
  31. package/constants.ts +25 -0
  32. package/createTunnel.ts +36 -0
  33. package/dependencyScanner.ts +357 -0
  34. package/devkitUtils.test.ts +259 -0
  35. package/executors.test.ts +315 -0
  36. package/executors.ts +1390 -0
  37. package/{esm/src/extractDeps.js → extractDeps.ts} +26 -20
  38. package/{esm/src/fileEditor.js → fileEditor.ts} +51 -32
  39. package/fileSys.ts +39 -0
  40. package/frontendBuild/allRoutesBuilder.ts +103 -0
  41. package/frontendBuild/buildRouteClient.test.ts +190 -0
  42. package/frontendBuild/clientBuildTypes.ts +114 -0
  43. package/frontendBuild/clientEntriesBundler.ts +303 -0
  44. package/frontendBuild/clientEntryDiscovery.ts +199 -0
  45. package/frontendBuild/csrArtifactBuilder.ts +237 -0
  46. package/frontendBuild/cssCompiler.ts +286 -0
  47. package/frontendBuild/cssImportResolver.ts +116 -0
  48. package/frontendBuild/fontOptimizer.ts +427 -0
  49. package/frontendBuild/frontendBuild.test.ts +204 -0
  50. package/frontendBuild/hmrChangeClassifier.ts +28 -0
  51. package/frontendBuild/hmrWatcher.ts +102 -0
  52. package/frontendBuild/index.ts +18 -0
  53. package/frontendBuild/pagesBundleBuilder.ts +137 -0
  54. package/frontendBuild/pagesEntrySourceGenerator.ts +37 -0
  55. package/frontendBuild/precompressArtifacts.ts +59 -0
  56. package/frontendBuild/routeClientBuilder.ts +290 -0
  57. package/frontendBuild/routesManifestArtifactSerializer.ts +62 -0
  58. package/frontendBuild/ssrBaseArtifactBuilder.ts +139 -0
  59. package/frontendBuild/vendorSpecifiers.ts +16 -0
  60. package/frontendBuild/watchRootResolver.ts +28 -0
  61. package/getCredentials.ts +19 -0
  62. package/getDirname.ts +3 -0
  63. package/getModelFileData.ts +59 -0
  64. package/getRelatedCnsts.ts +313 -0
  65. package/guideline.ts +19 -0
  66. package/incrementalBuilder/incrementalBuilder.host.test.ts +51 -0
  67. package/incrementalBuilder/incrementalBuilder.host.ts +152 -0
  68. package/incrementalBuilder/incrementalBuilder.proc.ts +331 -0
  69. package/incrementalBuilder/index.ts +1 -0
  70. package/{esm/src/index.js → index.ts} +28 -15
  71. package/lint/no-deep-internal-import.grit +25 -0
  72. package/lint/no-import-client-functions.grit +32 -0
  73. package/lint/no-import-external-library.grit +21 -0
  74. package/lint/no-js-private-class-method.grit +42 -0
  75. package/lint/no-use-client-in-server.grit +7 -0
  76. package/lint/non-scalar-props-restricted.grit +13 -0
  77. package/linter.ts +271 -0
  78. package/mobile/index.ts +1 -0
  79. package/mobile/mobileTarget.test.ts +53 -0
  80. package/mobile/mobileTarget.ts +88 -0
  81. package/package.json +48 -31
  82. package/prompter.ts +72 -0
  83. package/scanInfo.ts +606 -0
  84. package/selectModel.ts +11 -0
  85. package/{esm/src/spinner.js → spinner.ts} +22 -28
  86. package/{esm/src/capacitorApp.js → src/capacitorApp.ts} +82 -81
  87. package/sshTunnel.ts +152 -0
  88. package/{esm/src/streamAi.js → streamAi.ts} +18 -12
  89. package/transforms/barrelAnalyzer.ts +278 -0
  90. package/transforms/barrelImportsPlugin.ts +504 -0
  91. package/transforms/externalizeFrameworkPlugin.ts +185 -0
  92. package/transforms/index.ts +5 -0
  93. package/transforms/rscUseClientTransform.ts +59 -0
  94. package/transforms/transforms.test.ts +208 -0
  95. package/transforms/useClientBundlePlugin.ts +47 -0
  96. package/tsconfig.json +37 -0
  97. package/typeChecker.ts +264 -0
  98. package/types.ts +44 -0
  99. package/ui/MultiScrollList.tsx +242 -0
  100. package/ui/ScrollList.tsx +107 -0
  101. package/ui/index.ts +2 -0
  102. package/{esm/src/uploadRelease.js → uploadRelease.ts} +50 -34
  103. package/{esm/src/useStdoutDimensions.js → useStdoutDimensions.ts} +5 -5
  104. package/cjs/index.js +0 -21
  105. package/cjs/src/aiEditor.js +0 -311
  106. package/cjs/src/auth.js +0 -72
  107. package/cjs/src/builder.js +0 -114
  108. package/cjs/src/capacitorApp.js +0 -313
  109. package/cjs/src/commandDecorators/argMeta.js +0 -88
  110. package/cjs/src/commandDecorators/command.js +0 -324
  111. package/cjs/src/commandDecorators/commandMeta.js +0 -30
  112. package/cjs/src/commandDecorators/helpFormatter.js +0 -211
  113. package/cjs/src/commandDecorators/index.js +0 -31
  114. package/cjs/src/commandDecorators/targetMeta.js +0 -57
  115. package/cjs/src/commandDecorators/types.js +0 -15
  116. package/cjs/src/constants.js +0 -46
  117. package/cjs/src/createTunnel.js +0 -49
  118. package/cjs/src/dependencyScanner.js +0 -220
  119. package/cjs/src/executors.js +0 -964
  120. package/cjs/src/extractDeps.js +0 -103
  121. package/cjs/src/fileEditor.js +0 -120
  122. package/cjs/src/getCredentials.js +0 -44
  123. package/cjs/src/getDirname.js +0 -38
  124. package/cjs/src/getModelFileData.js +0 -66
  125. package/cjs/src/getRelatedCnsts.js +0 -260
  126. package/cjs/src/guideline.js +0 -15
  127. package/cjs/src/index.js +0 -65
  128. package/cjs/src/linter.js +0 -238
  129. package/cjs/src/prompter.js +0 -85
  130. package/cjs/src/scanInfo.js +0 -491
  131. package/cjs/src/selectModel.js +0 -46
  132. package/cjs/src/spinner.js +0 -93
  133. package/cjs/src/streamAi.js +0 -62
  134. package/cjs/src/typeChecker.js +0 -207
  135. package/cjs/src/types.js +0 -15
  136. package/cjs/src/uploadRelease.js +0 -112
  137. package/cjs/src/useStdoutDimensions.js +0 -43
  138. package/esm/index.js +0 -1
  139. package/esm/src/aiEditor.js +0 -282
  140. package/esm/src/auth.js +0 -42
  141. package/esm/src/builder.js +0 -81
  142. package/esm/src/commandDecorators/argMeta.js +0 -54
  143. package/esm/src/commandDecorators/command.js +0 -290
  144. package/esm/src/commandDecorators/commandMeta.js +0 -7
  145. package/esm/src/commandDecorators/targetMeta.js +0 -33
  146. package/esm/src/commandDecorators/types.js +0 -0
  147. package/esm/src/constants.js +0 -17
  148. package/esm/src/createTunnel.js +0 -26
  149. package/esm/src/dependencyScanner.js +0 -187
  150. package/esm/src/executors.js +0 -928
  151. package/esm/src/getCredentials.js +0 -11
  152. package/esm/src/getDirname.js +0 -5
  153. package/esm/src/getModelFileData.js +0 -33
  154. package/esm/src/getRelatedCnsts.js +0 -221
  155. package/esm/src/guideline.js +0 -0
  156. package/esm/src/linter.js +0 -205
  157. package/esm/src/prompter.js +0 -51
  158. package/esm/src/scanInfo.js +0 -455
  159. package/esm/src/selectModel.js +0 -13
  160. package/esm/src/typeChecker.js +0 -174
  161. package/esm/src/types.js +0 -0
  162. package/index.d.ts +0 -1
  163. package/src/aiEditor.d.ts +0 -50
  164. package/src/auth.d.ts +0 -9
  165. package/src/builder.d.ts +0 -18
  166. package/src/capacitorApp.d.ts +0 -39
  167. package/src/commandDecorators/argMeta.d.ts +0 -67
  168. package/src/commandDecorators/command.d.ts +0 -2
  169. package/src/commandDecorators/commandMeta.d.ts +0 -2
  170. package/src/commandDecorators/helpFormatter.d.ts +0 -3
  171. package/src/commandDecorators/index.d.ts +0 -6
  172. package/src/commandDecorators/targetMeta.d.ts +0 -19
  173. package/src/commandDecorators/types.d.ts +0 -1
  174. package/src/constants.d.ts +0 -26
  175. package/src/createTunnel.d.ts +0 -8
  176. package/src/dependencyScanner.d.ts +0 -23
  177. package/src/executors.d.ts +0 -296
  178. package/src/extractDeps.d.ts +0 -7
  179. package/src/fileEditor.d.ts +0 -16
  180. package/src/getCredentials.d.ts +0 -12
  181. package/src/getDirname.d.ts +0 -1
  182. package/src/getModelFileData.d.ts +0 -16
  183. package/src/getRelatedCnsts.d.ts +0 -53
  184. package/src/guideline.d.ts +0 -19
  185. package/src/index.d.ts +0 -23
  186. package/src/linter.d.ts +0 -109
  187. package/src/prompter.d.ts +0 -14
  188. package/src/scanInfo.d.ts +0 -82
  189. package/src/selectModel.d.ts +0 -1
  190. package/src/spinner.d.ts +0 -20
  191. package/src/streamAi.d.ts +0 -6
  192. package/src/typeChecker.d.ts +0 -52
  193. package/src/types.d.ts +0 -31
  194. package/src/uploadRelease.d.ts +0 -10
  195. package/src/useStdoutDimensions.d.ts +0 -1
@@ -1,324 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var command_exports = {};
29
- __export(command_exports, {
30
- runCommands: () => runCommands
31
- });
32
- module.exports = __toCommonJS(command_exports);
33
- var import_common = require("@akanjs/common");
34
- var import_prompts = require("@inquirer/prompts");
35
- var import_chalk = __toESM(require("chalk"));
36
- var import_commander = require("commander");
37
- var import_fs = __toESM(require("fs"));
38
- var import__ = require("..");
39
- var import_executors = require("../executors");
40
- var import_argMeta = require("./argMeta");
41
- var import_helpFormatter = require("./helpFormatter");
42
- var import_targetMeta = require("./targetMeta");
43
- const import_meta = {};
44
- const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
45
- const handleOption = (programCommand, argMeta) => {
46
- const {
47
- type,
48
- flag = argMeta.name.slice(0, 1).toLowerCase(),
49
- desc = argMeta.name,
50
- example,
51
- enum: enumChoices,
52
- ask
53
- } = argMeta.argsOption;
54
- const kebabName = camelToKebabCase(argMeta.name);
55
- const choices = enumChoices?.map(
56
- (choice) => typeof choice === "object" ? { value: choice.value, name: choice.label } : { value: choice, name: choice.toString() }
57
- );
58
- programCommand.option(
59
- `-${flag}, --${kebabName}${type === "boolean" ? " [boolean]" : ` <${kebabName}>`}`,
60
- `${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.map((choice) => choice.name).join(", ")})` : ""}`
61
- );
62
- return programCommand;
63
- };
64
- const handleArgument = (programCommand, argMeta) => {
65
- const kebabName = camelToKebabCase(argMeta.name);
66
- if ((argMeta.argsOption.type ?? "string") !== "string")
67
- throw new Error(`Argument type must be string: ${argMeta.name}`);
68
- programCommand.argument(
69
- `[${kebabName}]`,
70
- `${argMeta.argsOption.desc}${argMeta.argsOption.example ? ` (example: ${argMeta.argsOption.example})` : ""}`
71
- );
72
- return programCommand;
73
- };
74
- const convertOptionValue = (value, type) => {
75
- if (type === "string")
76
- return value;
77
- else if (type === "number")
78
- return Number(value);
79
- else
80
- return value === true || value === "true";
81
- };
82
- const getOptionValue = async (argMeta, opt) => {
83
- const {
84
- name,
85
- argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, example, ask }
86
- } = argMeta;
87
- if (opt[argMeta.name] !== void 0)
88
- return convertOptionValue(opt[argMeta.name], type ?? "string");
89
- else if (defaultValue !== void 0)
90
- return defaultValue;
91
- else if (nullable)
92
- return null;
93
- if (enumChoices) {
94
- const choices = enumChoices.map(
95
- (choice2) => typeof choice2 === "object" ? { value: choice2.value, name: choice2.label } : { value: choice2, name: choice2.toString() }
96
- );
97
- const choice = await (0, import_prompts.select)({ message: ask ?? desc ?? `Select the ${name} value`, choices });
98
- return choice;
99
- } else if (type === "boolean") {
100
- const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
101
- return await (0, import_prompts.confirm)({ message });
102
- } else {
103
- const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
104
- if (argMeta.argsOption.nullable)
105
- return await (0, import_prompts.input)({ message });
106
- else
107
- return convertOptionValue(await (0, import_prompts.input)({ message }), type ?? "string");
108
- }
109
- };
110
- const getArgumentValue = async (argMeta, value) => {
111
- const {
112
- name,
113
- argsOption: { default: defaultValue, type, desc, nullable, example, ask }
114
- } = argMeta;
115
- if (value !== void 0)
116
- return value;
117
- else if (defaultValue !== void 0)
118
- return defaultValue;
119
- else if (nullable)
120
- return null;
121
- const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
122
- return await (0, import_prompts.input)({ message });
123
- };
124
- const getInternalArgumentValue = async (argMeta, value, workspace) => {
125
- if (argMeta.type === "Workspace")
126
- return workspace;
127
- const sysType = argMeta.type.toLowerCase();
128
- const [appNames, libNames, pkgNames] = await workspace.getExecs();
129
- if (sysType === "sys") {
130
- if (value && appNames.includes(value))
131
- return import_executors.AppExecutor.from(workspace, value);
132
- else if (value && libNames.includes(value))
133
- return import_executors.LibExecutor.from(workspace, value);
134
- else {
135
- const sysName = await (0, import_prompts.select)({
136
- message: `Select the App or Lib name`,
137
- choices: [...appNames, ...libNames]
138
- });
139
- if (appNames.includes(sysName))
140
- return import_executors.AppExecutor.from(workspace, sysName);
141
- else if (libNames.includes(sysName))
142
- return import_executors.LibExecutor.from(workspace, sysName);
143
- else
144
- throw new Error(`Invalid system name: ${sysName}`);
145
- }
146
- } else if (sysType === "exec") {
147
- if (value && appNames.includes(value))
148
- return import_executors.AppExecutor.from(workspace, value);
149
- else if (value && libNames.includes(value))
150
- return import_executors.LibExecutor.from(workspace, value);
151
- else if (value && pkgNames.includes(value))
152
- return import_executors.PkgExecutor.from(workspace, value);
153
- else {
154
- const execName = await (0, import_prompts.select)({
155
- message: `Select the App or Lib or Pkg name`,
156
- choices: [...appNames, ...libNames, ...pkgNames]
157
- });
158
- if (appNames.includes(execName))
159
- return import_executors.AppExecutor.from(workspace, execName);
160
- else if (libNames.includes(execName))
161
- return import_executors.LibExecutor.from(workspace, execName);
162
- else if (pkgNames.includes(execName))
163
- return import_executors.PkgExecutor.from(workspace, execName);
164
- else
165
- throw new Error(`Invalid system name: ${execName}`);
166
- }
167
- } else if (sysType === "app") {
168
- if (value && appNames.includes(value))
169
- return import_executors.AppExecutor.from(workspace, value);
170
- const appName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: appNames });
171
- return import_executors.AppExecutor.from(workspace, appName);
172
- } else if (sysType === "lib") {
173
- if (value && libNames.includes(value))
174
- return import_executors.LibExecutor.from(workspace, value);
175
- const libName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: libNames });
176
- return import_executors.LibExecutor.from(workspace, libName);
177
- } else if (sysType === "pkg") {
178
- const pkgs = await workspace.getPkgs();
179
- if (value && pkgs.includes(value))
180
- return import_executors.PkgExecutor.from(workspace, value);
181
- const pkgName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: pkgs });
182
- return import_executors.PkgExecutor.from(workspace, pkgName);
183
- } else if (sysType === "module") {
184
- if (value) {
185
- const [sysName, moduleName2] = value.split(":");
186
- if (appNames.includes(sysName)) {
187
- const app = import_executors.AppExecutor.from(workspace, sysName);
188
- const modules2 = await app.getModules();
189
- if (modules2.includes(moduleName2))
190
- return import_executors.ModuleExecutor.from(app, moduleName2);
191
- else
192
- throw new Error(`Invalid module name: ${moduleName2}`);
193
- } else if (libNames.includes(sysName)) {
194
- const lib = import_executors.LibExecutor.from(workspace, sysName);
195
- const modules2 = await lib.getModules();
196
- if (modules2.includes(moduleName2))
197
- return import_executors.ModuleExecutor.from(lib, moduleName2);
198
- } else
199
- throw new Error(`Invalid system name: ${sysName}`);
200
- }
201
- const { type, name } = await (0, import_prompts.select)({
202
- message: `select the App or Lib name`,
203
- choices: [
204
- ...appNames.map((name2) => ({ name: name2, value: { type: "app", name: name2 } })),
205
- ...libNames.map((name2) => ({ name: name2, value: { type: "lib", name: name2 } }))
206
- ]
207
- });
208
- const executor = type === "app" ? import_executors.AppExecutor.from(workspace, name) : import_executors.LibExecutor.from(workspace, name);
209
- const modules = await executor.getModules();
210
- const moduleName = await (0, import_prompts.select)({
211
- message: `Select the module name`,
212
- choices: modules.map((name2) => ({ name: `${executor.name}:${name2}`, value: name2 }))
213
- });
214
- return import_executors.ModuleExecutor.from(executor, moduleName);
215
- } else
216
- throw new Error(`Invalid system type: ${argMeta.type}`);
217
- };
218
- const runCommands = async (...commands) => {
219
- process.on("unhandledRejection", (error) => {
220
- process.exit(1);
221
- });
222
- const __dirname = (0, import__.getDirname)(import_meta.url);
223
- const hasPackageJson = import_fs.default.existsSync(`${__dirname}/../package.json`);
224
- process.env.AKAN_VERSION = hasPackageJson ? JSON.parse(import_fs.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
225
- const hasHelpFlag = process.argv.includes("--help") || process.argv.includes("-h");
226
- const hasCommand = process.argv.length > 2 && !process.argv[2].startsWith("-");
227
- if (hasHelpFlag || !hasCommand) {
228
- if (process.argv.length === 2 || process.argv.length === 3 && hasHelpFlag) {
229
- import_common.Logger.rawLog((0, import_helpFormatter.formatHelp)(commands, process.env.AKAN_VERSION));
230
- process.exit(0);
231
- }
232
- }
233
- import_commander.program.version(process.env.AKAN_VERSION).description("Akan CLI").configureHelp({
234
- helpWidth: 100
235
- });
236
- const akanBasePackageJson = import_fs.default.existsSync("./node_modules/@akanjs/base/package.json") ? JSON.parse(import_fs.default.readFileSync("./node_modules/@akanjs/base/package.json", "utf8")) : null;
237
- if (akanBasePackageJson && akanBasePackageJson.version !== process.env.AKAN_VERSION) {
238
- import_common.Logger.rawLog(
239
- import_chalk.default.yellow(
240
- `
241
- Akan CLI version is mismatch with installed package. ${process.env.AKAN_VERSION} (global) vs ${akanBasePackageJson.version} (base)
242
- It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`
243
- )
244
- );
245
- }
246
- for (const command of commands) {
247
- const targetMetas = (0, import_targetMeta.getTargetMetas)(command);
248
- for (const targetMeta of targetMetas) {
249
- const kebabKey = camelToKebabCase(targetMeta.key);
250
- const commandNames = targetMeta.targetOption.short === true ? [
251
- kebabKey,
252
- typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
253
- ] : [kebabKey];
254
- for (const commandName of commandNames) {
255
- let programCommand = import_commander.program.command(commandName, {
256
- hidden: targetMeta.targetOption.devOnly
257
- });
258
- const [allArgMetas] = (0, import_argMeta.getArgMetas)(command, targetMeta.key);
259
- for (const argMeta of allArgMetas) {
260
- if (argMeta.type === "Option")
261
- programCommand = handleOption(programCommand, argMeta);
262
- else if (argMeta.type === "Argument")
263
- programCommand = handleArgument(programCommand, argMeta);
264
- else if (argMeta.type === "Workspace")
265
- continue;
266
- else if (argMeta.type === "Module") {
267
- programCommand = programCommand.argument(
268
- `[sys-name:module-name]`,
269
- `${argMeta.type} in this workspace (apps|libs)/<sys-name>/lib/<module-name>`
270
- );
271
- } else {
272
- const sysType = argMeta.type.toLowerCase();
273
- programCommand = programCommand.argument(
274
- `[${sysType}]`,
275
- `${sysType} in this workspace ${sysType}s/<${sysType}Name>`
276
- );
277
- }
278
- }
279
- programCommand = programCommand.option(`-v, --verbose [boolean]`, `verbose output`);
280
- programCommand.helpInformation = () => {
281
- return (0, import_helpFormatter.formatCommandHelp)(command, targetMeta.key);
282
- };
283
- programCommand.action(async (...args) => {
284
- import_common.Logger.rawLog();
285
- const cmdArgs = args.slice(0, args.length - 2);
286
- const opt = args[args.length - 2];
287
- const commandArgs = [];
288
- const workspace = import_executors.WorkspaceExecutor.fromRoot();
289
- for (const argMeta of allArgMetas) {
290
- if (argMeta.type === "Option")
291
- commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
292
- else if (argMeta.type === "Argument")
293
- commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx]);
294
- else
295
- commandArgs[argMeta.idx] = await getInternalArgumentValue(
296
- argMeta,
297
- cmdArgs[argMeta.idx],
298
- workspace
299
- );
300
- if (commandArgs[argMeta.idx] instanceof import_executors.AppExecutor)
301
- process.env.NEXT_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
302
- if (opt.verbose)
303
- import_executors.Executor.setVerbose(true);
304
- }
305
- const cmd = new command();
306
- try {
307
- await cmd[targetMeta.key](...commandArgs);
308
- import_common.Logger.rawLog();
309
- } catch (e) {
310
- const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
311
- import_common.Logger.rawLog(`
312
- ${import_chalk.default.red(errMsg)}`);
313
- throw e;
314
- }
315
- });
316
- }
317
- }
318
- }
319
- await import_commander.program.parseAsync(process.argv);
320
- };
321
- // Annotate the CommonJS export names for ESM import in node:
322
- 0 && (module.exports = {
323
- runCommands
324
- });
@@ -1,30 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var commandMeta_exports = {};
19
- __export(commandMeta_exports, {
20
- Commands: () => Commands
21
- });
22
- module.exports = __toCommonJS(commandMeta_exports);
23
- const Commands = () => {
24
- return function(target) {
25
- };
26
- };
27
- // Annotate the CommonJS export names for ESM import in node:
28
- 0 && (module.exports = {
29
- Commands
30
- });
@@ -1,211 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var helpFormatter_exports = {};
29
- __export(helpFormatter_exports, {
30
- formatCommandHelp: () => formatCommandHelp,
31
- formatHelp: () => formatHelp
32
- });
33
- module.exports = __toCommonJS(helpFormatter_exports);
34
- var import_chalk = __toESM(require("chalk"));
35
- var import_argMeta = require("./argMeta");
36
- var import_targetMeta = require("./targetMeta");
37
- const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
38
- const groupCommands = (commands) => {
39
- const groups = /* @__PURE__ */ new Map();
40
- for (const command of commands) {
41
- const className = command.name.replace("Command", "");
42
- const groupName = className;
43
- if (!groups.has(groupName)) {
44
- groups.set(groupName, { name: groupName, commands: [] });
45
- }
46
- const targetMetas = (0, import_targetMeta.getTargetMetas)(command);
47
- for (const targetMeta of targetMetas) {
48
- if (targetMeta.targetOption.devOnly)
49
- continue;
50
- const [allArgMetas] = (0, import_argMeta.getArgMetas)(command, targetMeta.key);
51
- const args = allArgMetas.filter((arg) => arg.type !== "Option").map((arg) => {
52
- if (arg.type === "Workspace")
53
- return "";
54
- if (arg.type === "Module")
55
- return "[sys:module]";
56
- if (arg.type === "Argument") {
57
- return `[${arg.name}]`;
58
- }
59
- return `[${arg.type.toLowerCase()}]`;
60
- }).filter(Boolean);
61
- const group = groups.get(groupName);
62
- if (group) {
63
- group.commands.push({
64
- key: camelToKebabCase(targetMeta.key),
65
- args,
66
- desc: targetMeta.targetOption.desc
67
- });
68
- }
69
- }
70
- }
71
- return groups;
72
- };
73
- const formatHelp = (commands, version) => {
74
- const groups = groupCommands(commands);
75
- const lines = [];
76
- lines.push("");
77
- lines.push(import_chalk.default.bold.cyan(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
78
- lines.push(
79
- import_chalk.default.bold.cyan(" \u2551") + import_chalk.default.bold.white(" Akan.js Framework CLI ") + import_chalk.default.bold.cyan(" \u2551")
80
- );
81
- lines.push(import_chalk.default.bold.cyan(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"));
82
- lines.push("");
83
- lines.push(import_chalk.default.gray(` Version: ${version}`));
84
- lines.push("");
85
- lines.push(import_chalk.default.bold.yellow(" USAGE"));
86
- lines.push("");
87
- lines.push(import_chalk.default.gray(" $ ") + import_chalk.default.white("akan") + import_chalk.default.gray(" <command> [options]"));
88
- lines.push("");
89
- lines.push(import_chalk.default.bold.yellow(" COMMANDS"));
90
- lines.push("");
91
- for (const [groupName, group] of groups) {
92
- if (group.commands.length === 0)
93
- continue;
94
- lines.push(import_chalk.default.bold.magenta(` ${groupName}`));
95
- lines.push("");
96
- for (const cmd of group.commands) {
97
- const cmdName = import_chalk.default.green(cmd.key);
98
- const cmdArgs = cmd.args.length > 0 ? import_chalk.default.gray(` ${cmd.args.join(" ")}`) : "";
99
- if (cmd.desc) {
100
- const maxLineLength = 70;
101
- const cmdPrefix = ` ${cmdName}${cmdArgs}`;
102
- const indent = " ";
103
- if (cmdPrefix.length + cmd.desc.length + 3 < maxLineLength) {
104
- lines.push(`${cmdPrefix} ${import_chalk.default.gray(cmd.desc)}`);
105
- } else {
106
- lines.push(cmdPrefix);
107
- lines.push(`${indent}${import_chalk.default.gray(cmd.desc)}`);
108
- }
109
- } else {
110
- lines.push(` ${cmdName}${cmdArgs}`);
111
- }
112
- }
113
- lines.push("");
114
- }
115
- lines.push(import_chalk.default.bold.yellow(" OPTIONS"));
116
- lines.push("");
117
- lines.push(` ${import_chalk.default.green("-v, --verbose")} ${import_chalk.default.gray("Enable verbose output")}`);
118
- lines.push(` ${import_chalk.default.green("-h, --help")} ${import_chalk.default.gray("Display this help message")}`);
119
- lines.push(` ${import_chalk.default.green("-V, --version")} ${import_chalk.default.gray("Output version number")}`);
120
- lines.push("");
121
- lines.push(import_chalk.default.bold.yellow(" EXAMPLES"));
122
- lines.push("");
123
- lines.push(import_chalk.default.gray(" # Create a new workspace"));
124
- lines.push(import_chalk.default.white(" $ akan create-workspace myproject"));
125
- lines.push("");
126
- lines.push(import_chalk.default.gray(" # Start development server"));
127
- lines.push(import_chalk.default.white(" $ akan start myapp"));
128
- lines.push("");
129
- lines.push(import_chalk.default.gray(" # Create a new module"));
130
- lines.push(import_chalk.default.white(" $ akan create-module userProfile"));
131
- lines.push("");
132
- lines.push(import_chalk.default.gray(" Documentation: ") + import_chalk.default.cyan("https://akanjs.com/docs"));
133
- lines.push(import_chalk.default.gray(" Report issues: ") + import_chalk.default.cyan("https://github.com/akan-team/akanjs/issues"));
134
- lines.push("");
135
- return lines.join("\n");
136
- };
137
- const formatCommandHelp = (command, key) => {
138
- const [allArgMetas, argMetas] = (0, import_argMeta.getArgMetas)(command, key);
139
- const kebabKey = camelToKebabCase(key);
140
- const lines = [];
141
- const targetMetas = (0, import_targetMeta.getTargetMetas)(command);
142
- const targetMeta = targetMetas.find((t) => t.key === key);
143
- const commandDesc = targetMeta?.targetOption.desc;
144
- lines.push("");
145
- lines.push(import_chalk.default.bold.cyan(` Command: ${kebabKey}`));
146
- if (commandDesc) {
147
- lines.push(import_chalk.default.gray(` ${commandDesc}`));
148
- }
149
- lines.push("");
150
- const args = allArgMetas.filter((arg) => arg.type !== "Option").map((arg) => {
151
- if (arg.type === "Workspace")
152
- return "";
153
- if (arg.type === "Module")
154
- return "[sys:module]";
155
- if (arg.type === "Argument") {
156
- return `[${camelToKebabCase(arg.name)}]`;
157
- }
158
- return `[${arg.type.toLowerCase()}]`;
159
- }).filter(Boolean).join(" ");
160
- lines.push(import_chalk.default.bold.yellow(" USAGE"));
161
- lines.push("");
162
- lines.push(import_chalk.default.gray(" $ ") + import_chalk.default.white(`akan ${kebabKey}`) + (args ? import_chalk.default.gray(` ${args}`) : ""));
163
- lines.push("");
164
- const nonOptionArgs = allArgMetas.filter((arg) => arg.type !== "Option");
165
- if (nonOptionArgs.length > 0) {
166
- lines.push(import_chalk.default.bold.yellow(" ARGUMENTS"));
167
- lines.push("");
168
- for (const arg of nonOptionArgs) {
169
- if (arg.type === "Workspace")
170
- continue;
171
- let argName;
172
- let argDesc;
173
- let example = "";
174
- if (arg.type === "Argument") {
175
- argName = camelToKebabCase(arg.name);
176
- argDesc = arg.argsOption.desc ?? "";
177
- example = arg.argsOption.example ? import_chalk.default.gray(` (e.g., ${String(arg.argsOption.example)})`) : "";
178
- } else if (arg.type === "Module") {
179
- argName = "sys:module";
180
- argDesc = "Module in format: app-name:module-name or lib-name:module-name";
181
- } else {
182
- argName = arg.type.toLowerCase();
183
- argDesc = `${arg.type} name in this workspace`;
184
- }
185
- lines.push(` ${import_chalk.default.green(argName)} ${import_chalk.default.gray(argDesc)}${example}`);
186
- }
187
- lines.push("");
188
- }
189
- const optionArgs = argMetas.filter((a) => a.type === "Option");
190
- if (optionArgs.length > 0) {
191
- lines.push(import_chalk.default.bold.yellow(" OPTIONS"));
192
- lines.push("");
193
- for (const arg of optionArgs) {
194
- const opt = arg.argsOption;
195
- const flag = opt.flag ? `-${opt.flag}, ` : "";
196
- const kebabName = camelToKebabCase(arg.name);
197
- const optName = `${flag}--${kebabName}`;
198
- const optDesc = opt.desc ?? "";
199
- const defaultVal = opt.default !== void 0 ? import_chalk.default.gray(` [default: ${String(opt.default)}]`) : "";
200
- const choices = opt.enum ? import_chalk.default.gray(` (${opt.enum.join(", ")})`) : "";
201
- lines.push(` ${import_chalk.default.green(optName)} ${import_chalk.default.gray(optDesc)}${defaultVal}${choices}`);
202
- }
203
- lines.push("");
204
- }
205
- return lines.join("\n");
206
- };
207
- // Annotate the CommonJS export names for ESM import in node:
208
- 0 && (module.exports = {
209
- formatCommandHelp,
210
- formatHelp
211
- });
@@ -1,31 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var commandDecorators_exports = {};
16
- module.exports = __toCommonJS(commandDecorators_exports);
17
- __reExport(commandDecorators_exports, require("./argMeta"), module.exports);
18
- __reExport(commandDecorators_exports, require("./commandMeta"), module.exports);
19
- __reExport(commandDecorators_exports, require("./targetMeta"), module.exports);
20
- __reExport(commandDecorators_exports, require("./types"), module.exports);
21
- __reExport(commandDecorators_exports, require("./helpFormatter"), module.exports);
22
- __reExport(commandDecorators_exports, require("./command"), module.exports);
23
- // Annotate the CommonJS export names for ESM import in node:
24
- 0 && (module.exports = {
25
- ...require("./argMeta"),
26
- ...require("./commandMeta"),
27
- ...require("./targetMeta"),
28
- ...require("./types"),
29
- ...require("./helpFormatter"),
30
- ...require("./command")
31
- });
@@ -1,57 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var targetMeta_exports = {};
19
- __export(targetMeta_exports, {
20
- Target: () => Target,
21
- getTargetMetas: () => getTargetMetas
22
- });
23
- module.exports = __toCommonJS(targetMeta_exports);
24
- const getTargetMetas = (command) => {
25
- const targetMetaMap = Reflect.getMetadata("target", command.prototype);
26
- if (!targetMetaMap)
27
- throw new Error(`TargetMeta is not defined for ${command.name}`);
28
- return [...targetMetaMap.values()];
29
- };
30
- const getTargetMetaMapOnPrototype = (prototype) => {
31
- const targetMetaMap = Reflect.getMetadata("target", prototype);
32
- return targetMetaMap ?? /* @__PURE__ */ new Map();
33
- };
34
- const setTargetMetaMapOnPrototype = (prototype, targetMetaMap) => {
35
- Reflect.defineMetadata("target", targetMetaMap, prototype);
36
- };
37
- const getTarget = (type) => (targetOption = {}) => {
38
- return (prototype, key, descriptor) => {
39
- const metadataMap = getTargetMetaMapOnPrototype(prototype);
40
- metadataMap.set(key, {
41
- key,
42
- descriptor,
43
- targetOption: { ...targetOption, type }
44
- });
45
- setTargetMetaMapOnPrototype(prototype, metadataMap);
46
- };
47
- };
48
- const Target = {
49
- Public: getTarget("public"),
50
- Cloud: getTarget("cloud"),
51
- Dev: getTarget("dev")
52
- };
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {
55
- Target,
56
- getTargetMetas
57
- });
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var types_exports = {};
15
- module.exports = __toCommonJS(types_exports);