@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
@@ -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);
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,9 +1,41 @@
1
- import { confirm, input, select } from "@inquirer/prompts";
2
- import { program } from "commander";
3
- import fs from "fs";
4
- import { AppExecutor, LibExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
5
- import { getArgMetas } from "./argMeta";
6
- 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_prompts = require("@inquirer/prompts");
34
+ var import_commander = require("commander");
35
+ var import_fs = __toESM(require("fs"));
36
+ var import_executors = require("../executors");
37
+ var import_argMeta = require("./argMeta");
38
+ var import_targetMeta = require("./targetMeta");
7
39
  const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
8
40
  const handleOption = (programCommand, argMeta) => {
9
41
  const {
@@ -41,20 +73,20 @@ const getOptionValue = async (argMeta, opt) => {
41
73
  else if (nullable)
42
74
  return null;
43
75
  if (choices) {
44
- const choice = await select({
76
+ const choice = await (0, import_prompts.select)({
45
77
  message: ask ?? `Select the ${name} value`,
46
78
  choices: choices.map((choice2) => choice2.toString())
47
79
  });
48
80
  return choice;
49
81
  } else if (type === "boolean") {
50
82
  const message = ask ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
51
- return await confirm({ message });
83
+ return await (0, import_prompts.confirm)({ message });
52
84
  } else {
53
- const message = ask ?? `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
85
+ const message = ask ? `${ask}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
54
86
  if (argMeta.argsOption.nullable)
55
- return await input({ message });
87
+ return await (0, import_prompts.input)({ message });
56
88
  else
57
- return convertOptionValue(await input({ message }), type ?? "string");
89
+ return convertOptionValue(await (0, import_prompts.input)({ message }), type ?? "string");
58
90
  }
59
91
  };
60
92
  const getArgumentValue = async (argMeta, value, workspace) => {
@@ -64,46 +96,46 @@ const getArgumentValue = async (argMeta, value, workspace) => {
64
96
  const [appNames, libNames] = await workspace.getSyss();
65
97
  if (sysType === "sys") {
66
98
  if (value && appNames.includes(value))
67
- return AppExecutor.from(workspace, value);
99
+ return import_executors.AppExecutor.from(workspace, value);
68
100
  else if (value && libNames.includes(value))
69
- return LibExecutor.from(workspace, value);
101
+ return import_executors.LibExecutor.from(workspace, value);
70
102
  else {
71
- const sysName = await select({
103
+ const sysName = await (0, import_prompts.select)({
72
104
  message: `Select the App or Lib name`,
73
105
  choices: [...appNames, ...libNames]
74
106
  });
75
107
  if (appNames.includes(sysName))
76
- return AppExecutor.from(workspace, sysName);
108
+ return import_executors.AppExecutor.from(workspace, sysName);
77
109
  else if (libNames.includes(sysName))
78
- return LibExecutor.from(workspace, sysName);
110
+ return import_executors.LibExecutor.from(workspace, sysName);
79
111
  else
80
112
  throw new Error(`Invalid system name: ${sysName}`);
81
113
  }
82
114
  } else if (sysType === "app") {
83
115
  if (value && appNames.includes(value))
84
- return AppExecutor.from(workspace, value);
85
- const appName = await select({ message: `Select the ${sysType} name`, choices: appNames });
86
- return AppExecutor.from(workspace, appName);
116
+ return import_executors.AppExecutor.from(workspace, value);
117
+ const appName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: appNames });
118
+ return import_executors.AppExecutor.from(workspace, appName);
87
119
  } else if (sysType === "lib") {
88
120
  if (value && libNames.includes(value))
89
- return LibExecutor.from(workspace, value);
90
- const libName = await select({ message: `Select the ${sysType} name`, choices: libNames });
91
- return LibExecutor.from(workspace, libName);
121
+ return import_executors.LibExecutor.from(workspace, value);
122
+ const libName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: libNames });
123
+ return import_executors.LibExecutor.from(workspace, libName);
92
124
  } else if (sysType === "pkg") {
93
125
  const pkgs = await workspace.getPkgs();
94
126
  if (value && pkgs.includes(value))
95
- return PkgExecutor.from(workspace, value);
96
- const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
97
- return PkgExecutor.from(workspace, pkgName);
127
+ return import_executors.PkgExecutor.from(workspace, value);
128
+ const pkgName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: pkgs });
129
+ return import_executors.PkgExecutor.from(workspace, pkgName);
98
130
  } else
99
131
  throw new Error(`Invalid system type: ${argMeta.type}`);
100
132
  };
101
133
  const runCommands = async (...commands) => {
102
- const hasPackageJson = fs.existsSync(`${__dirname}/package.json`);
103
- const version = hasPackageJson ? JSON.parse(fs.readFileSync(`${__dirname}/package.json`, "utf8")).version : "0.0.1";
104
- program.version(version).description("Akan CLI");
134
+ const hasPackageJson = import_fs.default.existsSync(`${__dirname}/package.json`);
135
+ const version = hasPackageJson ? JSON.parse(import_fs.default.readFileSync(`${__dirname}/package.json`, "utf8")).version : "0.0.1";
136
+ import_commander.program.version(version).description("Akan CLI");
105
137
  for (const command of commands) {
106
- const targetMetas = getTargetMetas(command);
138
+ const targetMetas = (0, import_targetMeta.getTargetMetas)(command);
107
139
  for (const targetMeta of targetMetas) {
108
140
  const kebabKey = camelToKebabCase(targetMeta.key);
109
141
  const commandNames = targetMeta.targetOption.short === true ? [
@@ -111,10 +143,10 @@ const runCommands = async (...commands) => {
111
143
  typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
112
144
  ] : [kebabKey];
113
145
  for (const commandName of commandNames) {
114
- let programCommand = program.command(commandName, {
146
+ let programCommand = import_commander.program.command(commandName, {
115
147
  hidden: targetMeta.targetOption.devOnly
116
148
  });
117
- const [allArgMetas] = getArgMetas(command, targetMeta.key);
149
+ const [allArgMetas] = (0, import_argMeta.getArgMetas)(command, targetMeta.key);
118
150
  for (const argMeta of allArgMetas) {
119
151
  if (argMeta.type === "Option")
120
152
  programCommand = handleOption(programCommand, argMeta);
@@ -130,7 +162,7 @@ const runCommands = async (...commands) => {
130
162
  const cmdArgs = args.slice(0, args.length - 2);
131
163
  const opt = args[args.length - 2];
132
164
  const commandArgs = [];
133
- const workspace = WorkspaceExecutor.fromRoot();
165
+ const workspace = import_executors.WorkspaceExecutor.fromRoot();
134
166
  for (const argMeta of allArgMetas) {
135
167
  if (argMeta.type === "Option")
136
168
  commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
@@ -143,8 +175,9 @@ const runCommands = async (...commands) => {
143
175
  }
144
176
  }
145
177
  }
146
- await program.parseAsync(process.argv);
178
+ await import_commander.program.parseAsync(process.argv);
147
179
  };
148
- export {
180
+ // Annotate the CommonJS export names for ESM import in node:
181
+ 0 && (module.exports = {
149
182
  runCommands
150
- };
183
+ });
@@ -1,41 +1,9 @@
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_prompts = require("@inquirer/prompts");
34
- var import_commander = require("commander");
35
- var import_fs = __toESM(require("fs"), 1);
36
- var import_executors = require("../executors");
37
- var import_argMeta = require("./argMeta");
38
- var import_targetMeta = require("./targetMeta");
1
+ import { confirm, input, select } from "@inquirer/prompts";
2
+ import { program } from "commander";
3
+ import fs from "fs";
4
+ import { AppExecutor, LibExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
5
+ import { getArgMetas } from "./argMeta";
6
+ import { getTargetMetas } from "./targetMeta";
39
7
  const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
40
8
  const handleOption = (programCommand, argMeta) => {
41
9
  const {
@@ -73,20 +41,20 @@ const getOptionValue = async (argMeta, opt) => {
73
41
  else if (nullable)
74
42
  return null;
75
43
  if (choices) {
76
- const choice = await (0, import_prompts.select)({
44
+ const choice = await select({
77
45
  message: ask ?? `Select the ${name} value`,
78
46
  choices: choices.map((choice2) => choice2.toString())
79
47
  });
80
48
  return choice;
81
49
  } else if (type === "boolean") {
82
50
  const message = ask ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
83
- return await (0, import_prompts.confirm)({ message });
51
+ return await confirm({ message });
84
52
  } else {
85
- const message = ask ?? `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
53
+ const message = ask ? `${ask}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
86
54
  if (argMeta.argsOption.nullable)
87
- return await (0, import_prompts.input)({ message });
55
+ return await input({ message });
88
56
  else
89
- return convertOptionValue(await (0, import_prompts.input)({ message }), type ?? "string");
57
+ return convertOptionValue(await input({ message }), type ?? "string");
90
58
  }
91
59
  };
92
60
  const getArgumentValue = async (argMeta, value, workspace) => {
@@ -96,46 +64,46 @@ const getArgumentValue = async (argMeta, value, workspace) => {
96
64
  const [appNames, libNames] = await workspace.getSyss();
97
65
  if (sysType === "sys") {
98
66
  if (value && appNames.includes(value))
99
- return import_executors.AppExecutor.from(workspace, value);
67
+ return AppExecutor.from(workspace, value);
100
68
  else if (value && libNames.includes(value))
101
- return import_executors.LibExecutor.from(workspace, value);
69
+ return LibExecutor.from(workspace, value);
102
70
  else {
103
- const sysName = await (0, import_prompts.select)({
71
+ const sysName = await select({
104
72
  message: `Select the App or Lib name`,
105
73
  choices: [...appNames, ...libNames]
106
74
  });
107
75
  if (appNames.includes(sysName))
108
- return import_executors.AppExecutor.from(workspace, sysName);
76
+ return AppExecutor.from(workspace, sysName);
109
77
  else if (libNames.includes(sysName))
110
- return import_executors.LibExecutor.from(workspace, sysName);
78
+ return LibExecutor.from(workspace, sysName);
111
79
  else
112
80
  throw new Error(`Invalid system name: ${sysName}`);
113
81
  }
114
82
  } else if (sysType === "app") {
115
83
  if (value && appNames.includes(value))
116
- return import_executors.AppExecutor.from(workspace, value);
117
- const appName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: appNames });
118
- return import_executors.AppExecutor.from(workspace, appName);
84
+ return AppExecutor.from(workspace, value);
85
+ const appName = await select({ message: `Select the ${sysType} name`, choices: appNames });
86
+ return AppExecutor.from(workspace, appName);
119
87
  } else if (sysType === "lib") {
120
88
  if (value && libNames.includes(value))
121
- return import_executors.LibExecutor.from(workspace, value);
122
- const libName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: libNames });
123
- return import_executors.LibExecutor.from(workspace, libName);
89
+ return LibExecutor.from(workspace, value);
90
+ const libName = await select({ message: `Select the ${sysType} name`, choices: libNames });
91
+ return LibExecutor.from(workspace, libName);
124
92
  } else if (sysType === "pkg") {
125
93
  const pkgs = await workspace.getPkgs();
126
94
  if (value && pkgs.includes(value))
127
- return import_executors.PkgExecutor.from(workspace, value);
128
- const pkgName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: pkgs });
129
- return import_executors.PkgExecutor.from(workspace, pkgName);
95
+ return PkgExecutor.from(workspace, value);
96
+ const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
97
+ return PkgExecutor.from(workspace, pkgName);
130
98
  } else
131
99
  throw new Error(`Invalid system type: ${argMeta.type}`);
132
100
  };
133
101
  const runCommands = async (...commands) => {
134
- const hasPackageJson = import_fs.default.existsSync(`${__dirname}/package.json`);
135
- const version = hasPackageJson ? JSON.parse(import_fs.default.readFileSync(`${__dirname}/package.json`, "utf8")).version : "0.0.1";
136
- import_commander.program.version(version).description("Akan CLI");
102
+ const hasPackageJson = fs.existsSync(`${__dirname}/package.json`);
103
+ const version = hasPackageJson ? JSON.parse(fs.readFileSync(`${__dirname}/package.json`, "utf8")).version : "0.0.1";
104
+ program.version(version).description("Akan CLI");
137
105
  for (const command of commands) {
138
- const targetMetas = (0, import_targetMeta.getTargetMetas)(command);
106
+ const targetMetas = getTargetMetas(command);
139
107
  for (const targetMeta of targetMetas) {
140
108
  const kebabKey = camelToKebabCase(targetMeta.key);
141
109
  const commandNames = targetMeta.targetOption.short === true ? [
@@ -143,10 +111,10 @@ const runCommands = async (...commands) => {
143
111
  typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
144
112
  ] : [kebabKey];
145
113
  for (const commandName of commandNames) {
146
- let programCommand = import_commander.program.command(commandName, {
114
+ let programCommand = program.command(commandName, {
147
115
  hidden: targetMeta.targetOption.devOnly
148
116
  });
149
- const [allArgMetas] = (0, import_argMeta.getArgMetas)(command, targetMeta.key);
117
+ const [allArgMetas] = getArgMetas(command, targetMeta.key);
150
118
  for (const argMeta of allArgMetas) {
151
119
  if (argMeta.type === "Option")
152
120
  programCommand = handleOption(programCommand, argMeta);
@@ -162,7 +130,7 @@ const runCommands = async (...commands) => {
162
130
  const cmdArgs = args.slice(0, args.length - 2);
163
131
  const opt = args[args.length - 2];
164
132
  const commandArgs = [];
165
- const workspace = import_executors.WorkspaceExecutor.fromRoot();
133
+ const workspace = WorkspaceExecutor.fromRoot();
166
134
  for (const argMeta of allArgMetas) {
167
135
  if (argMeta.type === "Option")
168
136
  commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
@@ -175,9 +143,8 @@ const runCommands = async (...commands) => {
175
143
  }
176
144
  }
177
145
  }
178
- await import_commander.program.parseAsync(process.argv);
146
+ await program.parseAsync(process.argv);
179
147
  };
180
- // Annotate the CommonJS export names for ESM import in node:
181
- 0 && (module.exports = {
148
+ export {
182
149
  runCommands
183
- });
150
+ };
@@ -1,7 +1,30 @@
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);
1
23
  const Commands = () => {
2
24
  return function(target) {
3
25
  };
4
26
  };
5
- export {
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
6
29
  Commands
7
- };
30
+ });
@@ -0,0 +1,7 @@
1
+ const Commands = () => {
2
+ return function(target) {
3
+ };
4
+ };
5
+ export {
6
+ Commands
7
+ };
@@ -1,5 +1,29 @@
1
- export * from "./argMeta";
2
- export * from "./commandMeta";
3
- export * from "./targetMeta";
4
- export * from "./types";
5
- export * from "./command";
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("./command"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./argMeta"),
25
+ ...require("./commandMeta"),
26
+ ...require("./targetMeta"),
27
+ ...require("./types"),
28
+ ...require("./command")
29
+ });
@@ -0,0 +1,5 @@
1
+ export * from "./argMeta";
2
+ export * from "./commandMeta";
3
+ export * from "./targetMeta";
4
+ export * from "./types";
5
+ export * from "./command";
@@ -1,3 +1,26 @@
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);
1
24
  const getTargetMetas = (command) => {
2
25
  const targetMetaMap = Reflect.getMetadata("target", command.prototype);
3
26
  if (!targetMetaMap)
@@ -27,7 +50,8 @@ const Target = {
27
50
  Cloud: getTarget("cloud"),
28
51
  Dev: getTarget("dev")
29
52
  };
30
- export {
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
31
55
  Target,
32
56
  getTargetMetas
33
- };
57
+ });