@akanjs/devkit 0.0.89 → 0.0.91

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 (68) hide show
  1. package/index.js +21 -1
  2. package/index.mjs +1 -0
  3. package/package.json +5 -4
  4. package/src/aiEditor.d.ts +14 -0
  5. package/src/aiEditor.js +110 -21
  6. package/src/aiEditor.mjs +124 -0
  7. package/src/auth.js +48 -18
  8. package/src/auth.mjs +42 -0
  9. package/src/capacitorApp.js +42 -9
  10. package/src/{capacitorApp.cjs → capacitorApp.mjs} +9 -42
  11. package/src/commandDecorators/argMeta.js +34 -3
  12. package/src/commandDecorators/{argMeta.cjs → argMeta.mjs} +3 -34
  13. package/src/commandDecorators/command.js +68 -35
  14. package/src/commandDecorators/{command.cjs → command.mjs} +35 -68
  15. package/src/commandDecorators/commandMeta.js +25 -2
  16. package/src/commandDecorators/commandMeta.mjs +7 -0
  17. package/src/commandDecorators/index.js +29 -5
  18. package/src/commandDecorators/index.mjs +5 -0
  19. package/src/commandDecorators/targetMeta.js +26 -2
  20. package/src/commandDecorators/targetMeta.mjs +33 -0
  21. package/src/commandDecorators/types.js +15 -0
  22. package/src/commandDecorators/types.mjs +0 -0
  23. package/src/constants.d.ts +8 -1
  24. package/src/constants.js +34 -5
  25. package/src/constants.mjs +18 -0
  26. package/src/createTunnel.js +27 -4
  27. package/src/createTunnel.mjs +26 -0
  28. package/src/dependencyScanner.js +38 -5
  29. package/src/{dependencyScanner.cjs → dependencyScanner.mjs} +5 -38
  30. package/src/executors.d.ts +21 -1
  31. package/src/executors.js +172 -84
  32. package/src/{executors.cjs → executors.mjs} +138 -118
  33. package/src/extractDeps.js +25 -2
  34. package/src/{extractDeps.cjs → extractDeps.mjs} +2 -25
  35. package/src/getCredentials.js +39 -6
  36. package/src/getCredentials.mjs +11 -0
  37. package/src/getModelFileData.js +39 -6
  38. package/src/getModelFileData.mjs +33 -0
  39. package/src/getRelatedCnsts.d.ts +52 -8
  40. package/src/getRelatedCnsts.js +205 -54
  41. package/src/getRelatedCnsts.mjs +221 -0
  42. package/src/index.js +51 -16
  43. package/src/index.mjs +16 -0
  44. package/src/selectModel.js +39 -6
  45. package/src/selectModel.mjs +13 -0
  46. package/src/streamAi.js +30 -7
  47. package/src/streamAi.mjs +39 -0
  48. package/src/types.js +15 -0
  49. package/src/types.mjs +0 -0
  50. package/src/uploadRelease.js +48 -15
  51. package/src/uploadRelease.mjs +52 -0
  52. package/index.cjs +0 -21
  53. package/src/aiEditor.cjs +0 -92
  54. package/src/auth.cjs +0 -72
  55. package/src/commandDecorators/commandMeta.cjs +0 -30
  56. package/src/commandDecorators/index.cjs +0 -29
  57. package/src/commandDecorators/targetMeta.cjs +0 -57
  58. package/src/commandDecorators/types.cjs +0 -15
  59. package/src/constants.cjs +0 -47
  60. package/src/createTunnel.cjs +0 -49
  61. package/src/getCredentials.cjs +0 -44
  62. package/src/getModelFileData.cjs +0 -66
  63. package/src/getRelatedCnsts.cjs +0 -142
  64. package/src/index.cjs +0 -51
  65. package/src/selectModel.cjs +0 -46
  66. package/src/streamAi.cjs +0 -62
  67. package/src/types.cjs +0 -15
  68. package/src/uploadRelease.cjs +0 -85
package/src/executors.js CHANGED
@@ -1,31 +1,64 @@
1
- import { Logger } from "@akanjs/common";
2
- import {
3
- getAppConfig,
4
- getDefaultFileScan,
5
- getLibConfig
6
- } from "@akanjs/config";
7
- import { exec, fork, spawn } from "child_process";
8
- import dotenv from "dotenv";
9
- import fs from "fs";
10
- import fsPromise from "fs/promises";
11
- import path from "path";
12
- import { TypeScriptDependencyScanner } from "./dependencyScanner";
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 executors_exports = {};
29
+ __export(executors_exports, {
30
+ AppExecutor: () => AppExecutor,
31
+ Executor: () => Executor,
32
+ LibExecutor: () => LibExecutor,
33
+ PkgExecutor: () => PkgExecutor,
34
+ SysExecutor: () => SysExecutor,
35
+ WorkspaceExecutor: () => WorkspaceExecutor
36
+ });
37
+ module.exports = __toCommonJS(executors_exports);
38
+ var import_common = require("@akanjs/common");
39
+ var import_config = require("@akanjs/config");
40
+ var import_child_process = require("child_process");
41
+ var import_dotenv = __toESM(require("dotenv"));
42
+ var import_fs = __toESM(require("fs"));
43
+ var import_promises = __toESM(require("fs/promises"));
44
+ var import_path = __toESM(require("path"));
45
+ var import_dependencyScanner = require("./dependencyScanner");
13
46
  class Executor {
14
47
  logger;
15
48
  cwdPath;
16
49
  constructor(name, cwdPath) {
17
- this.logger = new Logger(name);
50
+ this.logger = new import_common.Logger(name);
18
51
  this.cwdPath = cwdPath;
19
- if (!fs.existsSync(cwdPath))
20
- fs.mkdirSync(cwdPath, { recursive: true });
52
+ if (!import_fs.default.existsSync(cwdPath))
53
+ import_fs.default.mkdirSync(cwdPath, { recursive: true });
21
54
  }
22
55
  exec(command, options = {}) {
23
- const proc = exec(command, { cwd: this.cwdPath, ...options });
56
+ const proc = (0, import_child_process.exec)(command, { cwd: this.cwdPath, ...options });
24
57
  proc.stdout?.on("data", (data) => {
25
- Logger.raw(data.toString());
58
+ import_common.Logger.raw(data.toString());
26
59
  });
27
60
  proc.stderr?.on("data", (data) => {
28
- Logger.raw(data.toString());
61
+ import_common.Logger.raw(data.toString());
29
62
  });
30
63
  return new Promise((resolve, reject) => {
31
64
  proc.on("exit", (code, signal) => {
@@ -37,9 +70,9 @@ class Executor {
37
70
  });
38
71
  }
39
72
  spawn(command, args = [], options = {}) {
40
- const proc = spawn(command, args, { cwd: this.cwdPath, stdio: "inherit", ...options });
73
+ const proc = (0, import_child_process.spawn)(command, args, { cwd: this.cwdPath, stdio: "inherit", ...options });
41
74
  proc.stderr?.on("data", (data) => {
42
- Logger.raw(data.toString());
75
+ import_common.Logger.raw(data.toString());
43
76
  });
44
77
  return new Promise((resolve, reject) => {
45
78
  proc.on("exit", (code, signal) => {
@@ -51,16 +84,16 @@ class Executor {
51
84
  });
52
85
  }
53
86
  fork(modulePath, args = [], options = {}) {
54
- const proc = fork(modulePath, args, {
87
+ const proc = (0, import_child_process.fork)(modulePath, args, {
55
88
  cwd: this.cwdPath,
56
89
  stdio: ["ignore", "inherit", "inherit", "ipc"],
57
90
  ...options
58
91
  });
59
92
  proc.stdout?.on("data", (data) => {
60
- Logger.raw(data.toString());
93
+ import_common.Logger.raw(data.toString());
61
94
  });
62
95
  proc.stderr?.on("data", (data) => {
63
- Logger.raw(data.toString());
96
+ import_common.Logger.raw(data.toString());
64
97
  });
65
98
  return new Promise((resolve, reject) => {
66
99
  proc.on("exit", (code, signal) => {
@@ -72,35 +105,35 @@ class Executor {
72
105
  });
73
106
  }
74
107
  #getPath(filePath) {
75
- return path.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
108
+ return import_path.default.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
76
109
  }
77
110
  mkdir(dirPath) {
78
111
  const writePath = this.#getPath(dirPath);
79
- if (!fs.existsSync(writePath))
80
- fs.mkdirSync(writePath, { recursive: true });
112
+ if (!import_fs.default.existsSync(writePath))
113
+ import_fs.default.mkdirSync(writePath, { recursive: true });
81
114
  this.logger.verbose(`Make directory ${writePath}`);
82
115
  return this;
83
116
  }
84
117
  exists(filePath) {
85
118
  const readPath = this.#getPath(filePath);
86
- return fs.existsSync(readPath);
119
+ return import_fs.default.existsSync(readPath);
87
120
  }
88
121
  writeFile(filePath, content, { overwrite = true } = {}) {
89
122
  const writePath = this.#getPath(filePath);
90
- const dir = path.dirname(writePath);
91
- if (!fs.existsSync(dir))
92
- fs.mkdirSync(dir, { recursive: true });
123
+ const dir = import_path.default.dirname(writePath);
124
+ if (!import_fs.default.existsSync(dir))
125
+ import_fs.default.mkdirSync(dir, { recursive: true });
93
126
  const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
94
- if (fs.existsSync(writePath)) {
95
- const currentContent = fs.readFileSync(writePath, "utf8");
127
+ if (import_fs.default.existsSync(writePath)) {
128
+ const currentContent = import_fs.default.readFileSync(writePath, "utf8");
96
129
  if (currentContent === contentStr || !overwrite)
97
130
  this.logger.verbose(`File ${writePath} is unchanged`);
98
131
  else {
99
- fs.writeFileSync(writePath, contentStr, "utf8");
132
+ import_fs.default.writeFileSync(writePath, contentStr, "utf8");
100
133
  this.logger.verbose(`File ${writePath} is changed`);
101
134
  }
102
135
  } else {
103
- fs.writeFileSync(writePath, contentStr, "utf8");
136
+ import_fs.default.writeFileSync(writePath, contentStr, "utf8");
104
137
  this.logger.verbose(`File ${writePath} is created`);
105
138
  }
106
139
  return this;
@@ -110,22 +143,22 @@ class Executor {
110
143
  return this;
111
144
  }
112
145
  getLocalFile(filePath) {
113
- const filepath = path.isAbsolute(filePath) ? filePath : filePath.replace(this.cwdPath, "");
146
+ const filepath = import_path.default.isAbsolute(filePath) ? filePath : filePath.replace(this.cwdPath, "");
114
147
  const content = this.readFile(filepath);
115
148
  return { filepath, content };
116
149
  }
117
150
  readFile(filePath) {
118
151
  const readPath = this.#getPath(filePath);
119
- return fs.readFileSync(readPath, "utf8");
152
+ return import_fs.default.readFileSync(readPath, "utf8");
120
153
  }
121
154
  readJson(filePath) {
122
155
  const readPath = this.#getPath(filePath);
123
- return JSON.parse(fs.readFileSync(readPath, "utf8"));
156
+ return JSON.parse(import_fs.default.readFileSync(readPath, "utf8"));
124
157
  }
125
158
  async cp(srcPath, destPath) {
126
159
  const src = this.#getPath(srcPath);
127
160
  const dest = this.#getPath(destPath);
128
- await fsPromise.cp(src, dest, { recursive: true });
161
+ await import_promises.default.cp(src, dest, { recursive: true });
129
162
  }
130
163
  log(msg) {
131
164
  this.logger.info(msg);
@@ -158,9 +191,9 @@ class Executor {
158
191
  const result = getContent.default(scanResult ?? null, dict);
159
192
  if (result === null)
160
193
  return;
161
- const filename = typeof result === "object" ? result.filename : path.basename(targetPath).replace(".js", ".ts");
194
+ const filename = typeof result === "object" ? result.filename : import_path.default.basename(targetPath).replace(".js", ".ts");
162
195
  const content = typeof result === "object" ? result.content : result;
163
- const dirname = path.dirname(targetPath);
196
+ const dirname = import_path.default.dirname(targetPath);
164
197
  const convertedTargetPath = Object.entries(dict).reduce(
165
198
  (path2, [key, value]) => path2.replace(new RegExp(`__${key}__`, "g"), value),
166
199
  `${dirname}/${filename}`
@@ -168,7 +201,7 @@ class Executor {
168
201
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
169
202
  this.writeFile(convertedTargetPath, content);
170
203
  } else if (targetPath.endsWith(".template")) {
171
- const content = await fsPromise.readFile(templatePath, "utf8");
204
+ const content = await import_promises.default.readFile(templatePath, "utf8");
172
205
  const convertedTargetPath = Object.entries(dict).reduce(
173
206
  (path2, [key, value]) => path2.replace(new RegExp(`__${key}__`, "g"), value),
174
207
  targetPath.slice(0, -9)
@@ -189,26 +222,26 @@ class Executor {
189
222
  overwrite = true
190
223
  }) {
191
224
  const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
192
- if (fs.statSync(templatePath).isFile()) {
193
- const filename = path.basename(templatePath);
225
+ if (import_fs.default.statSync(templatePath).isFile()) {
226
+ const filename = import_path.default.basename(templatePath);
194
227
  await this.#applyTemplateFile(
195
- { templatePath, targetPath: path.join(basePath, filename), scanResult, overwrite },
228
+ { templatePath, targetPath: import_path.default.join(basePath, filename), scanResult, overwrite },
196
229
  dict
197
230
  );
198
231
  } else {
199
- const subdirs = await fsPromise.readdir(templatePath);
232
+ const subdirs = await import_promises.default.readdir(templatePath);
200
233
  await Promise.all(
201
234
  subdirs.map(async (subdir) => {
202
- const subpath = path.join(templatePath, subdir);
203
- if (fs.statSync(subpath).isFile())
235
+ const subpath = import_path.default.join(templatePath, subdir);
236
+ if (import_fs.default.statSync(subpath).isFile())
204
237
  await this.#applyTemplateFile(
205
- { templatePath: subpath, targetPath: path.join(basePath, subdir), scanResult, overwrite },
238
+ { templatePath: subpath, targetPath: import_path.default.join(basePath, subdir), scanResult, overwrite },
206
239
  dict
207
240
  );
208
241
  else
209
242
  await this.applyTemplate({
210
- basePath: path.join(basePath, subdir),
211
- template: path.join(template, subdir),
243
+ basePath: import_path.default.join(basePath, subdir),
244
+ template: import_path.default.join(template, subdir),
212
245
  scanResult,
213
246
  dict,
214
247
  overwrite
@@ -227,11 +260,11 @@ class WorkspaceExecutor extends Executor {
227
260
  this.repoName = repoName;
228
261
  }
229
262
  static fromRoot() {
230
- const repoName = path.basename(process.cwd());
263
+ const repoName = import_path.default.basename(process.cwd());
231
264
  return new WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
232
265
  }
233
266
  getBaseDevEnv() {
234
- const envFile = dotenv.parse(this.readFile(".env"));
267
+ const envFile = import_dotenv.default.parse(this.readFile(".env"));
235
268
  const appName = process.env.NEXT_PUBLIC_APP_NAME ?? envFile.NEXT_PUBLIC_APP_NAME;
236
269
  const repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? envFile.NEXT_PUBLIC_REPO_NAME;
237
270
  if (!repoName)
@@ -297,6 +330,26 @@ class WorkspaceExecutor extends Executor {
297
330
  this.writeJson("tsconfig.json", rootTsConfig);
298
331
  return this;
299
332
  }
333
+ async getDirInModule(basePath, name) {
334
+ const AVOID_DIRS = ["__lib", "__scalar", `_${name}`];
335
+ const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
336
+ const dirs = await import_promises.default.readdir(dirname);
337
+ await Promise.all(
338
+ dirs.map(async (dir) => {
339
+ if (AVOID_DIRS.includes(dir))
340
+ return;
341
+ const dirPath = import_path.default.join(dirname, dir);
342
+ if (import_fs.default.lstatSync(dirPath).isDirectory()) {
343
+ results.push(`${name}/${prefix}${dir}`);
344
+ if (maxDepth > 0)
345
+ await getDirs(dirPath, maxDepth - 1, results, `${prefix}${dir}/`);
346
+ }
347
+ })
348
+ );
349
+ return results;
350
+ };
351
+ return await getDirs(basePath);
352
+ }
300
353
  async commit(message, { init = false, add = true } = {}) {
301
354
  if (init)
302
355
  await this.exec(`git init --quiet`);
@@ -307,14 +360,14 @@ class WorkspaceExecutor extends Executor {
307
360
  async #getDirHasFile(basePath, targetFilename) {
308
361
  const AVOID_DIRS = ["node_modules", "dist", "public", "./next"];
309
362
  const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
310
- const dirs = await fsPromise.readdir(dirname);
363
+ const dirs = await import_promises.default.readdir(dirname);
311
364
  await Promise.all(
312
365
  dirs.map(async (dir) => {
313
366
  if (AVOID_DIRS.includes(dir))
314
367
  return;
315
- const dirPath = path.join(dirname, dir);
316
- if (fs.lstatSync(dirPath).isDirectory()) {
317
- const hasTargetFile = fs.existsSync(path.join(dirPath, targetFilename));
368
+ const dirPath = import_path.default.join(dirname, dir);
369
+ if (import_fs.default.lstatSync(dirPath).isDirectory()) {
370
+ const hasTargetFile = import_fs.default.existsSync(import_path.default.join(dirPath, targetFilename));
318
371
  if (hasTargetFile)
319
372
  results.push(`${prefix}${dir}`);
320
373
  if (maxDepth > 0)
@@ -334,6 +387,14 @@ class WorkspaceExecutor extends Executor {
334
387
  ];
335
388
  return scalarConstantExampleFiles;
336
389
  }
390
+ async getViewFiles() {
391
+ const [appNames, libNames] = await this.getSyss();
392
+ const viewExampleFiles = [
393
+ ...(await Promise.all(appNames.map((appName) => AppExecutor.from(this, appName).getViewsSourceCode()))).flat(),
394
+ ...(await Promise.all(libNames.map((libName) => LibExecutor.from(this, libName).getViewsSourceCode()))).flat()
395
+ ];
396
+ return viewExampleFiles;
397
+ }
337
398
  }
338
399
  class SysExecutor extends Executor {
339
400
  workspace;
@@ -346,7 +407,11 @@ class SysExecutor extends Executor {
346
407
  this.type = type;
347
408
  }
348
409
  async getConfig(command) {
349
- return this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name, command }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name, command });
410
+ return this.type === "app" ? await (0, import_config.getAppConfig)(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name, command }) : await (0, import_config.getLibConfig)(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name, command });
411
+ }
412
+ async getModules() {
413
+ const path2 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
414
+ return await this.workspace.getDirInModule(path2, this.name);
350
415
  }
351
416
  async scan({
352
417
  tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
@@ -355,7 +420,7 @@ class SysExecutor extends Executor {
355
420
  if (libScanResults[this.name])
356
421
  return libScanResults[this.name];
357
422
  const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
358
- const scanner = new TypeScriptDependencyScanner(this.cwdPath);
423
+ const scanner = new import_dependencyScanner.TypeScriptDependencyScanner(this.cwdPath);
359
424
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
360
425
  const pkgPathSet = new Set(
361
426
  Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
@@ -372,17 +437,17 @@ class SysExecutor extends Executor {
372
437
  const pathSplitLength = path2.split("/").length;
373
438
  return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
374
439
  }).filter((libName) => libName !== this.name);
375
- if (!fs.existsSync(`${this.cwdPath}/lib/__scalar`))
376
- fs.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
377
- const files = getDefaultFileScan();
378
- const dirnames = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter(
379
- (name) => fs.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
440
+ if (!import_fs.default.existsSync(`${this.cwdPath}/lib/__scalar`))
441
+ import_fs.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
442
+ const files = (0, import_config.getDefaultFileScan)();
443
+ const dirnames = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter(
444
+ (name) => import_fs.default.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
380
445
  );
381
446
  const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
382
447
  const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
383
448
  await Promise.all(
384
449
  databaseDirs.map(async (name) => {
385
- const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", name));
450
+ const filenames = await import_promises.default.readdir(import_path.default.join(this.cwdPath, "lib", name));
386
451
  filenames.forEach((filename) => {
387
452
  if (filename.endsWith(".constant.ts"))
388
453
  files.constants.databases.push(name);
@@ -404,7 +469,7 @@ class SysExecutor extends Executor {
404
469
  await Promise.all(
405
470
  serviceDirs.map(async (dirname) => {
406
471
  const name = dirname.slice(1);
407
- const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", dirname));
472
+ const filenames = await import_promises.default.readdir(import_path.default.join(this.cwdPath, "lib", dirname));
408
473
  filenames.forEach((filename) => {
409
474
  if (filename.endsWith(".dictionary.ts"))
410
475
  files.dictionary.services.push(name);
@@ -419,12 +484,12 @@ class SysExecutor extends Executor {
419
484
  });
420
485
  })
421
486
  );
422
- const scalarDirs = (await fsPromise.readdir(`${this.cwdPath}/lib/__scalar`)).filter(
487
+ const scalarDirs = (await import_promises.default.readdir(`${this.cwdPath}/lib/__scalar`)).filter(
423
488
  (name) => !name.startsWith("_")
424
489
  );
425
490
  await Promise.all(
426
491
  scalarDirs.map(async (name) => {
427
- const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib/__scalar", name));
492
+ const filenames = await import_promises.default.readdir(import_path.default.join(this.cwdPath, "lib/__scalar", name));
428
493
  filenames.forEach((filename) => {
429
494
  if (filename.endsWith(".constant.ts"))
430
495
  files.constants.scalars.push(name);
@@ -499,25 +564,47 @@ class SysExecutor extends Executor {
499
564
  return scanResult;
500
565
  }
501
566
  getLocalFile(filePath) {
502
- const filepath = path.isAbsolute(filePath) ? filePath : `${this.type}s/${this.name}/${filePath}`;
567
+ const filepath = import_path.default.isAbsolute(filePath) ? filePath : `${this.type}s/${this.name}/${filePath}`;
503
568
  const content = this.workspace.readFile(filepath);
504
569
  return { filepath, content };
505
570
  }
506
571
  async getDatabaseModules() {
507
- const databaseModules = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/${name}/${name}.constant.ts`));
572
+ const databaseModules = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.constant.ts`));
508
573
  return databaseModules;
509
574
  }
510
575
  async getServiceModules() {
511
- const serviceModules = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/${name}/${name}.service.ts`));
576
+ const serviceModules = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.service.ts`));
512
577
  return serviceModules;
513
578
  }
514
579
  async getScalarModules() {
515
- const scalarModules = (await fsPromise.readdir(`${this.cwdPath}/lib/__scalar`)).filter((name) => !name.startsWith("_")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/__scalar/${name}/${name}.constant.ts`));
580
+ const scalarModules = (await import_promises.default.readdir(`${this.cwdPath}/lib/__scalar`)).filter((name) => !name.startsWith("_")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/__scalar/${name}/${name}.constant.ts`));
516
581
  return scalarModules;
517
582
  }
518
- async getViewModules() {
519
- const viewModules = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/${name}/${name}.View.tsx`));
520
- return viewModules;
583
+ async getViewComponents() {
584
+ const viewComponents = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.View.tsx`));
585
+ return viewComponents;
586
+ }
587
+ async getUnitComponents() {
588
+ const unitComponents = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.Unit.tsx`));
589
+ return unitComponents;
590
+ }
591
+ async getTemplateComponents() {
592
+ const templateComponents = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.Template.tsx`));
593
+ return templateComponents;
594
+ }
595
+ async getViewsSourceCode() {
596
+ const viewComponents = await this.getViewComponents();
597
+ return viewComponents.map((viewComponent) => this.getLocalFile(`lib/${viewComponent}/${viewComponent}.View.tsx`));
598
+ }
599
+ async getUnitsSourceCode() {
600
+ const unitComponents = await this.getUnitComponents();
601
+ return unitComponents.map((unitComponent) => this.getLocalFile(`lib/${unitComponent}/${unitComponent}.Unit.tsx`));
602
+ }
603
+ async getTemplatesSourceCode() {
604
+ const templateComponents = await this.getTemplateComponents();
605
+ return templateComponents.map(
606
+ (templateComponent) => this.getLocalFile(`lib/${templateComponent}/${templateComponent}.Template.tsx`)
607
+ );
521
608
  }
522
609
  async getScalarConstantFiles() {
523
610
  const scalarModules = await this.getScalarModules();
@@ -548,7 +635,7 @@ class AppExecutor extends SysExecutor {
548
635
  return new AppExecutor({ workspace: executor.workspace, name });
549
636
  }
550
637
  async getConfig(command) {
551
- return await getAppConfig(this.cwdPath, {
638
+ return await (0, import_config.getAppConfig)(this.cwdPath, {
552
639
  ...this.workspace.getBaseDevEnv(),
553
640
  type: "app",
554
641
  name: this.name,
@@ -557,13 +644,13 @@ class AppExecutor extends SysExecutor {
557
644
  }
558
645
  async syncAssets(libDeps) {
559
646
  const projectPublicLibPath = `${this.cwdPath}/public/libs`;
560
- if (fs.existsSync(projectPublicLibPath))
561
- await fsPromise.rm(projectPublicLibPath, { recursive: true });
562
- const targetDeps = libDeps.filter((dep) => fs.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
563
- await Promise.all(targetDeps.map((dep) => fsPromise.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
647
+ if (import_fs.default.existsSync(projectPublicLibPath))
648
+ await import_promises.default.rm(projectPublicLibPath, { recursive: true });
649
+ const targetDeps = libDeps.filter((dep) => import_fs.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
650
+ await Promise.all(targetDeps.map((dep) => import_promises.default.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
564
651
  await Promise.all(
565
652
  targetDeps.map(
566
- (dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
653
+ (dep) => import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
567
654
  recursive: true
568
655
  })
569
656
  )
@@ -584,7 +671,7 @@ class LibExecutor extends SysExecutor {
584
671
  return new LibExecutor({ workspace: executor.workspace, name });
585
672
  }
586
673
  async getConfig(command) {
587
- return await getLibConfig(this.cwdPath, {
674
+ return await (0, import_config.getLibConfig)(this.cwdPath, {
588
675
  ...this.workspace.getBaseDevEnv(),
589
676
  type: "lib",
590
677
  name: this.name,
@@ -612,7 +699,7 @@ class PkgExecutor extends Executor {
612
699
  tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`)
613
700
  } = {}) {
614
701
  const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
615
- const scanner = new TypeScriptDependencyScanner(this.cwdPath);
702
+ const scanner = new import_dependencyScanner.TypeScriptDependencyScanner(this.cwdPath);
616
703
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
617
704
  const pkgPathSet = new Set(
618
705
  Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
@@ -630,11 +717,12 @@ class PkgExecutor extends Executor {
630
717
  return pkgScanResult;
631
718
  }
632
719
  }
633
- export {
720
+ // Annotate the CommonJS export names for ESM import in node:
721
+ 0 && (module.exports = {
634
722
  AppExecutor,
635
723
  Executor,
636
724
  LibExecutor,
637
725
  PkgExecutor,
638
726
  SysExecutor,
639
727
  WorkspaceExecutor
640
- };
728
+ });