@akanjs/devkit 0.0.97 → 0.0.99

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 (65) hide show
  1. package/index.cjs +21 -0
  2. package/index.js +1 -21
  3. package/package.json +4 -4
  4. package/src/{aiEditor.mjs → aiEditor.cjs} +56 -22
  5. package/src/aiEditor.js +22 -56
  6. package/src/auth.cjs +72 -0
  7. package/src/auth.js +18 -48
  8. package/src/{builder.mjs → builder.cjs} +44 -11
  9. package/src/builder.js +11 -44
  10. package/src/{capacitorApp.mjs → capacitorApp.cjs} +42 -9
  11. package/src/capacitorApp.js +9 -42
  12. package/src/commandDecorators/{argMeta.mjs → argMeta.cjs} +34 -3
  13. package/src/commandDecorators/argMeta.js +3 -34
  14. package/src/commandDecorators/{command.mjs → command.cjs} +70 -37
  15. package/src/commandDecorators/command.js +37 -70
  16. package/src/commandDecorators/commandMeta.cjs +30 -0
  17. package/src/commandDecorators/commandMeta.js +2 -25
  18. package/src/commandDecorators/index.cjs +29 -0
  19. package/src/commandDecorators/index.js +5 -29
  20. package/src/commandDecorators/targetMeta.cjs +57 -0
  21. package/src/commandDecorators/targetMeta.js +2 -26
  22. package/src/commandDecorators/types.cjs +15 -0
  23. package/src/commandDecorators/types.js +0 -15
  24. package/src/constants.cjs +47 -0
  25. package/src/constants.js +4 -33
  26. package/src/createTunnel.cjs +49 -0
  27. package/src/createTunnel.js +4 -27
  28. package/src/{dependencyScanner.mjs → dependencyScanner.cjs} +38 -5
  29. package/src/dependencyScanner.js +5 -38
  30. package/src/{executors.mjs → executors.cjs} +123 -89
  31. package/src/executors.d.ts +1 -1
  32. package/src/executors.js +89 -123
  33. package/src/{extractDeps.mjs → extractDeps.cjs} +25 -2
  34. package/src/extractDeps.js +2 -25
  35. package/src/getCredentials.cjs +44 -0
  36. package/src/getCredentials.js +6 -39
  37. package/src/getModelFileData.cjs +66 -0
  38. package/src/getModelFileData.js +6 -39
  39. package/src/{getRelatedCnsts.mjs → getRelatedCnsts.cjs} +48 -9
  40. package/src/getRelatedCnsts.js +9 -48
  41. package/src/index.cjs +53 -0
  42. package/src/index.js +17 -53
  43. package/src/selectModel.cjs +46 -0
  44. package/src/selectModel.js +6 -39
  45. package/src/streamAi.cjs +62 -0
  46. package/src/streamAi.js +7 -30
  47. package/src/types.cjs +15 -0
  48. package/src/types.js +0 -15
  49. package/src/uploadRelease.cjs +85 -0
  50. package/src/uploadRelease.js +15 -48
  51. package/index.mjs +0 -1
  52. package/src/auth.mjs +0 -42
  53. package/src/commandDecorators/commandMeta.mjs +0 -7
  54. package/src/commandDecorators/index.mjs +0 -5
  55. package/src/commandDecorators/targetMeta.mjs +0 -33
  56. package/src/commandDecorators/types.mjs +0 -0
  57. package/src/constants.mjs +0 -18
  58. package/src/createTunnel.mjs +0 -26
  59. package/src/getCredentials.mjs +0 -11
  60. package/src/getModelFileData.mjs +0 -33
  61. package/src/index.mjs +0 -17
  62. package/src/selectModel.mjs +0 -13
  63. package/src/streamAi.mjs +0 -39
  64. package/src/types.mjs +0 -0
  65. package/src/uploadRelease.mjs +0 -52
package/src/builder.js CHANGED
@@ -1,39 +1,7 @@
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 builder_exports = {};
29
- __export(builder_exports, {
30
- Builder: () => Builder
31
- });
32
- module.exports = __toCommonJS(builder_exports);
33
- var esbuild = __toESM(require("esbuild"));
34
- var import_esbuild_plugin_d = require("esbuild-plugin-d.ts");
35
- var import_fs = __toESM(require("fs"));
36
- var import_extractDeps = require("./extractDeps");
1
+ import * as esbuild from "esbuild";
2
+ import { dtsPlugin } from "esbuild-plugin-d.ts";
3
+ import fs from "fs";
4
+ import { extractDependencies } from "./extractDeps";
37
5
  class Builder {
38
6
  #executor;
39
7
  #distExecutor;
@@ -77,34 +45,33 @@ class Builder {
77
45
  };
78
46
  }
79
47
  async build(options = {}) {
80
- if (import_fs.default.existsSync(this.#distExecutor.cwdPath))
48
+ if (fs.existsSync(this.#distExecutor.cwdPath))
81
49
  await this.#distExecutor.exec(`rm -rf ${this.#distExecutor.cwdPath}`);
82
- const plugins = [(0, import_esbuild_plugin_d.dtsPlugin)({ tsconfig: `${this.#executor.cwdPath}/tsconfig.json` })];
50
+ const plugins = [dtsPlugin({ tsconfig: `${this.#executor.cwdPath}/tsconfig.json` })];
83
51
  const [buildResult] = await Promise.all([
84
52
  esbuild.build({ ...this.#getBuildOptions("cjs", options), write: false, plugins }),
85
53
  esbuild.build({ write: true, ...this.#getBuildOptions("esm", options) }),
86
54
  esbuild.build({ ...this.#getAssetBuildOptions() })
87
55
  ]);
88
56
  const existingDeps = Object.keys(this.#pkgJson.dependencies ?? {});
89
- const dependencies = (0, import_extractDeps.extractDependencies)(buildResult.outputFiles, this.#rootPackageJson, existingDeps);
57
+ const dependencies = extractDependencies(buildResult.outputFiles, this.#rootPackageJson, existingDeps);
90
58
  const pkgPackageJson = {
91
59
  ...this.#pkgJson,
92
60
  main: "./index.js",
93
61
  engines: { node: ">=22" },
94
62
  dependencies,
95
63
  exports: {
64
+ ...this.#pkgJson.exports ?? {},
96
65
  ".": {
97
66
  require: this.#pkgJson.type === "module" ? "./index.cjs" : "./index.js",
98
67
  import: this.#pkgJson.type === "module" ? "./index.js" : "./index.mjs"
99
- },
100
- ...this.#pkgJson.exports ?? {}
68
+ }
101
69
  }
102
70
  };
103
71
  buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
104
72
  this.#distExecutor.writeJson("package.json", pkgPackageJson);
105
73
  }
106
74
  }
107
- // Annotate the CommonJS export names for ESM import in node:
108
- 0 && (module.exports = {
75
+ export {
109
76
  Builder
110
- });
77
+ };
@@ -1,6 +1,38 @@
1
- import { capitalize } from "@akanjs/common";
2
- import { MobileProject } from "@trapezedev/project";
3
- import fs from "fs";
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 capacitorApp_exports = {};
29
+ __export(capacitorApp_exports, {
30
+ CapacitorApp: () => CapacitorApp
31
+ });
32
+ module.exports = __toCommonJS(capacitorApp_exports);
33
+ var import_common = require("@akanjs/common");
34
+ var import_project = require("@trapezedev/project");
35
+ var import_fs = __toESM(require("fs"), 1);
4
36
  class CapacitorApp {
5
37
  constructor(app) {
6
38
  this.app = app;
@@ -8,7 +40,7 @@ class CapacitorApp {
8
40
  project;
9
41
  iosTargetName = "App";
10
42
  async init() {
11
- const project = new MobileProject(this.app.cwdPath, {
43
+ const project = new import_project.MobileProject(this.app.cwdPath, {
12
44
  android: { path: "android" },
13
45
  ios: { path: "ios/App" }
14
46
  });
@@ -26,7 +58,7 @@ class CapacitorApp {
26
58
  await this.project.commit();
27
59
  }
28
60
  async releaseIos() {
29
- const isAdded = fs.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
61
+ const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
30
62
  if (!isAdded) {
31
63
  await this.app.spawn("npx cap add ios");
32
64
  await this.app.spawn("npx @capacitor/assets generate");
@@ -35,7 +67,7 @@ class CapacitorApp {
35
67
  await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "ios"]);
36
68
  }
37
69
  async releaseAndroid() {
38
- const isAdded = fs.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
70
+ const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
39
71
  if (!isAdded) {
40
72
  await this.app.spawn("npx cap add android");
41
73
  await this.app.spawn("npx @capacitor/assets generate");
@@ -67,7 +99,7 @@ class CapacitorApp {
67
99
  }
68
100
  async #setPermissionInIos(permissions) {
69
101
  const updateNs = Object.fromEntries(
70
- Object.entries(permissions).map(([key, value]) => [`NS${capitalize(key)}`, value])
102
+ Object.entries(permissions).map(([key, value]) => [`NS${(0, import_common.capitalize)(key)}`, value])
71
103
  );
72
104
  await Promise.all([
73
105
  this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", updateNs),
@@ -119,6 +151,7 @@ class CapacitorApp {
119
151
  return this.#getPermissionsInAndroid().includes(permission);
120
152
  }
121
153
  }
122
- export {
154
+ // Annotate the CommonJS export names for ESM import in node:
155
+ 0 && (module.exports = {
123
156
  CapacitorApp
124
- };
157
+ });
@@ -1,38 +1,6 @@
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 capacitorApp_exports = {};
29
- __export(capacitorApp_exports, {
30
- CapacitorApp: () => CapacitorApp
31
- });
32
- module.exports = __toCommonJS(capacitorApp_exports);
33
- var import_common = require("@akanjs/common");
34
- var import_project = require("@trapezedev/project");
35
- var import_fs = __toESM(require("fs"));
1
+ import { capitalize } from "@akanjs/common";
2
+ import { MobileProject } from "@trapezedev/project";
3
+ import fs from "fs";
36
4
  class CapacitorApp {
37
5
  constructor(app) {
38
6
  this.app = app;
@@ -40,7 +8,7 @@ class CapacitorApp {
40
8
  project;
41
9
  iosTargetName = "App";
42
10
  async init() {
43
- const project = new import_project.MobileProject(this.app.cwdPath, {
11
+ const project = new MobileProject(this.app.cwdPath, {
44
12
  android: { path: "android" },
45
13
  ios: { path: "ios/App" }
46
14
  });
@@ -58,7 +26,7 @@ class CapacitorApp {
58
26
  await this.project.commit();
59
27
  }
60
28
  async releaseIos() {
61
- const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
29
+ const isAdded = fs.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
62
30
  if (!isAdded) {
63
31
  await this.app.spawn("npx cap add ios");
64
32
  await this.app.spawn("npx @capacitor/assets generate");
@@ -67,7 +35,7 @@ class CapacitorApp {
67
35
  await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "ios"]);
68
36
  }
69
37
  async releaseAndroid() {
70
- const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
38
+ const isAdded = fs.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
71
39
  if (!isAdded) {
72
40
  await this.app.spawn("npx cap add android");
73
41
  await this.app.spawn("npx @capacitor/assets generate");
@@ -99,7 +67,7 @@ class CapacitorApp {
99
67
  }
100
68
  async #setPermissionInIos(permissions) {
101
69
  const updateNs = Object.fromEntries(
102
- Object.entries(permissions).map(([key, value]) => [`NS${(0, import_common.capitalize)(key)}`, value])
70
+ Object.entries(permissions).map(([key, value]) => [`NS${capitalize(key)}`, value])
103
71
  );
104
72
  await Promise.all([
105
73
  this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", updateNs),
@@ -151,7 +119,6 @@ class CapacitorApp {
151
119
  return this.#getPermissionsInAndroid().includes(permission);
152
120
  }
153
121
  }
154
- // Annotate the CommonJS export names for ESM import in node:
155
- 0 && (module.exports = {
122
+ export {
156
123
  CapacitorApp
157
- });
124
+ };
@@ -1,4 +1,34 @@
1
- import "reflect-metadata";
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 argMeta_exports = {};
19
+ __export(argMeta_exports, {
20
+ App: () => App,
21
+ Lib: () => Lib,
22
+ Option: () => Option,
23
+ Pkg: () => Pkg,
24
+ Sys: () => Sys,
25
+ Workspace: () => Workspace,
26
+ argTypes: () => argTypes,
27
+ getArgMetas: () => getArgMetas,
28
+ internalArgTypes: () => internalArgTypes
29
+ });
30
+ module.exports = __toCommonJS(argMeta_exports);
31
+ var import_reflect_metadata = require("reflect-metadata");
2
32
  const argTypes = ["Option"];
3
33
  const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg"];
4
34
  const getArgMetas = (command, key) => {
@@ -35,7 +65,8 @@ const Lib = createArgMetaDecorator("Lib");
35
65
  const Sys = createArgMetaDecorator("Sys");
36
66
  const Pkg = createArgMetaDecorator("Pkg");
37
67
  const Workspace = createArgMetaDecorator("Workspace");
38
- export {
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
39
70
  App,
40
71
  Lib,
41
72
  Option,
@@ -45,4 +76,4 @@ export {
45
76
  argTypes,
46
77
  getArgMetas,
47
78
  internalArgTypes
48
- };
79
+ });
@@ -1,34 +1,4 @@
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 argMeta_exports = {};
19
- __export(argMeta_exports, {
20
- App: () => App,
21
- Lib: () => Lib,
22
- Option: () => Option,
23
- Pkg: () => Pkg,
24
- Sys: () => Sys,
25
- Workspace: () => Workspace,
26
- argTypes: () => argTypes,
27
- getArgMetas: () => getArgMetas,
28
- internalArgTypes: () => internalArgTypes
29
- });
30
- module.exports = __toCommonJS(argMeta_exports);
31
- var import_reflect_metadata = require("reflect-metadata");
1
+ import "reflect-metadata";
32
2
  const argTypes = ["Option"];
33
3
  const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg"];
34
4
  const getArgMetas = (command, key) => {
@@ -65,8 +35,7 @@ const Lib = createArgMetaDecorator("Lib");
65
35
  const Sys = createArgMetaDecorator("Sys");
66
36
  const Pkg = createArgMetaDecorator("Pkg");
67
37
  const Workspace = createArgMetaDecorator("Workspace");
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
38
+ export {
70
39
  App,
71
40
  Lib,
72
41
  Option,
@@ -76,4 +45,4 @@ const Workspace = createArgMetaDecorator("Workspace");
76
45
  argTypes,
77
46
  getArgMetas,
78
47
  internalArgTypes
79
- });
48
+ };
@@ -1,11 +1,43 @@
1
- import { Logger } from "@akanjs/common";
2
- import { confirm, input, select } from "@inquirer/prompts";
3
- import chalk from "chalk";
4
- import { program } from "commander";
5
- import fs from "fs";
6
- import { AppExecutor, LibExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
7
- import { getArgMetas } from "./argMeta";
8
- import { getTargetMetas } from "./targetMeta";
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"), 1);
36
+ var import_commander = require("commander");
37
+ var import_fs = __toESM(require("fs"), 1);
38
+ var import_executors = require("../executors");
39
+ var import_argMeta = require("./argMeta");
40
+ var import_targetMeta = require("./targetMeta");
9
41
  const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
10
42
  const handleOption = (programCommand, argMeta) => {
11
43
  const {
@@ -43,20 +75,20 @@ const getOptionValue = async (argMeta, opt) => {
43
75
  else if (nullable)
44
76
  return null;
45
77
  if (choices) {
46
- const choice = await select({
78
+ const choice = await (0, import_prompts.select)({
47
79
  message: ask ?? desc ?? `Select the ${name} value`,
48
80
  choices: choices.map((choice2) => choice2.toString())
49
81
  });
50
82
  return choice;
51
83
  } else if (type === "boolean") {
52
84
  const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
53
- return await confirm({ message });
85
+ return await (0, import_prompts.confirm)({ message });
54
86
  } else {
55
87
  const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
56
88
  if (argMeta.argsOption.nullable)
57
- return await input({ message });
89
+ return await (0, import_prompts.input)({ message });
58
90
  else
59
- return convertOptionValue(await input({ message }), type ?? "string");
91
+ return convertOptionValue(await (0, import_prompts.input)({ message }), type ?? "string");
60
92
  }
61
93
  };
62
94
  const getArgumentValue = async (argMeta, value, workspace) => {
@@ -66,46 +98,46 @@ const getArgumentValue = async (argMeta, value, workspace) => {
66
98
  const [appNames, libNames] = await workspace.getSyss();
67
99
  if (sysType === "sys") {
68
100
  if (value && appNames.includes(value))
69
- return AppExecutor.from(workspace, value);
101
+ return import_executors.AppExecutor.from(workspace, value);
70
102
  else if (value && libNames.includes(value))
71
- return LibExecutor.from(workspace, value);
103
+ return import_executors.LibExecutor.from(workspace, value);
72
104
  else {
73
- const sysName = await select({
105
+ const sysName = await (0, import_prompts.select)({
74
106
  message: `Select the App or Lib name`,
75
107
  choices: [...appNames, ...libNames]
76
108
  });
77
109
  if (appNames.includes(sysName))
78
- return AppExecutor.from(workspace, sysName);
110
+ return import_executors.AppExecutor.from(workspace, sysName);
79
111
  else if (libNames.includes(sysName))
80
- return LibExecutor.from(workspace, sysName);
112
+ return import_executors.LibExecutor.from(workspace, sysName);
81
113
  else
82
114
  throw new Error(`Invalid system name: ${sysName}`);
83
115
  }
84
116
  } else if (sysType === "app") {
85
117
  if (value && appNames.includes(value))
86
- return AppExecutor.from(workspace, value);
87
- const appName = await select({ message: `Select the ${sysType} name`, choices: appNames });
88
- return AppExecutor.from(workspace, appName);
118
+ return import_executors.AppExecutor.from(workspace, value);
119
+ const appName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: appNames });
120
+ return import_executors.AppExecutor.from(workspace, appName);
89
121
  } else if (sysType === "lib") {
90
122
  if (value && libNames.includes(value))
91
- return LibExecutor.from(workspace, value);
92
- const libName = await select({ message: `Select the ${sysType} name`, choices: libNames });
93
- return LibExecutor.from(workspace, libName);
123
+ return import_executors.LibExecutor.from(workspace, value);
124
+ const libName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: libNames });
125
+ return import_executors.LibExecutor.from(workspace, libName);
94
126
  } else if (sysType === "pkg") {
95
127
  const pkgs = await workspace.getPkgs();
96
128
  if (value && pkgs.includes(value))
97
- return PkgExecutor.from(workspace, value);
98
- const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
99
- return PkgExecutor.from(workspace, pkgName);
129
+ return import_executors.PkgExecutor.from(workspace, value);
130
+ const pkgName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: pkgs });
131
+ return import_executors.PkgExecutor.from(workspace, pkgName);
100
132
  } else
101
133
  throw new Error(`Invalid system type: ${argMeta.type}`);
102
134
  };
103
135
  const runCommands = async (...commands) => {
104
- const hasPackageJson = fs.existsSync(`${__dirname}/package.json`);
105
- const version = hasPackageJson ? JSON.parse(fs.readFileSync(`${__dirname}/package.json`, "utf8")).version : "0.0.1";
106
- program.version(version).description("Akan CLI");
136
+ const hasPackageJson = import_fs.default.existsSync(`${__dirname}/package.json`);
137
+ const version = hasPackageJson ? JSON.parse(import_fs.default.readFileSync(`${__dirname}/package.json`, "utf8")).version : "0.0.1";
138
+ import_commander.program.version(version).description("Akan CLI");
107
139
  for (const command of commands) {
108
- const targetMetas = getTargetMetas(command);
140
+ const targetMetas = (0, import_targetMeta.getTargetMetas)(command);
109
141
  for (const targetMeta of targetMetas) {
110
142
  const kebabKey = camelToKebabCase(targetMeta.key);
111
143
  const commandNames = targetMeta.targetOption.short === true ? [
@@ -113,10 +145,10 @@ const runCommands = async (...commands) => {
113
145
  typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
114
146
  ] : [kebabKey];
115
147
  for (const commandName of commandNames) {
116
- let programCommand = program.command(commandName, {
148
+ let programCommand = import_commander.program.command(commandName, {
117
149
  hidden: targetMeta.targetOption.devOnly
118
150
  });
119
- const [allArgMetas] = getArgMetas(command, targetMeta.key);
151
+ const [allArgMetas] = (0, import_argMeta.getArgMetas)(command, targetMeta.key);
120
152
  for (const argMeta of allArgMetas) {
121
153
  if (argMeta.type === "Option")
122
154
  programCommand = handleOption(programCommand, argMeta);
@@ -132,7 +164,7 @@ const runCommands = async (...commands) => {
132
164
  const cmdArgs = args.slice(0, args.length - 2);
133
165
  const opt = args[args.length - 2];
134
166
  const commandArgs = [];
135
- const workspace = WorkspaceExecutor.fromRoot();
167
+ const workspace = import_executors.WorkspaceExecutor.fromRoot();
136
168
  for (const argMeta of allArgMetas) {
137
169
  if (argMeta.type === "Option")
138
170
  commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
@@ -144,14 +176,15 @@ const runCommands = async (...commands) => {
144
176
  await cmd[targetMeta.key](...commandArgs);
145
177
  } catch (e) {
146
178
  const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
147
- Logger.error(`Command Error: ${chalk.red(errMsg)}`);
179
+ import_common.Logger.error(`Command Error: ${import_chalk.default.red(errMsg)}`);
148
180
  }
149
181
  });
150
182
  }
151
183
  }
152
184
  }
153
- await program.parseAsync(process.argv);
185
+ await import_commander.program.parseAsync(process.argv);
154
186
  };
155
- export {
187
+ // Annotate the CommonJS export names for ESM import in node:
188
+ 0 && (module.exports = {
156
189
  runCommands
157
- };
190
+ });