@akanjs/devkit 0.0.142 → 0.0.143

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.
@@ -109,8 +109,10 @@ class AiSession {
109
109
  import_common.Logger.raw(chunk);
110
110
  }
111
111
  } = {}) {
112
- if (!AiSession.#chat)
112
+ if (!AiSession.#chat) {
113
+ import_common.Logger.rawLog(import_chalk.default.yellow("\u{1F916}akan-editor is not initialized. LLM configuration should be set first."));
113
114
  await AiSession.init();
115
+ }
114
116
  if (!AiSession.#chat)
115
117
  throw new Error("Failed to initialize the AI session");
116
118
  const loader = new import_spinner.Spinner(`${AiSession.#chat.model} is thinking...`, {
@@ -21,6 +21,7 @@ __export(argMeta_exports, {
21
21
  Argument: () => Argument,
22
22
  Exec: () => Exec,
23
23
  Lib: () => Lib,
24
+ Module: () => Module,
24
25
  Option: () => Option,
25
26
  Pkg: () => Pkg,
26
27
  Sys: () => Sys,
@@ -32,7 +33,7 @@ __export(argMeta_exports, {
32
33
  module.exports = __toCommonJS(argMeta_exports);
33
34
  var import_reflect_metadata = require("reflect-metadata");
34
35
  const argTypes = ["Argument", "Option"];
35
- const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg", "Exec"];
36
+ const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg", "Module", "Exec"];
36
37
  const getArgMetas = (command, key) => {
37
38
  const allArgMetas = getArgMetasOnPrototype(command.prototype, key);
38
39
  const argMetas = allArgMetas.filter((argMeta) => argMeta.type === "Option");
@@ -68,6 +69,7 @@ const Lib = createArgMetaDecorator("Lib");
68
69
  const Sys = createArgMetaDecorator("Sys");
69
70
  const Exec = createArgMetaDecorator("Exec");
70
71
  const Pkg = createArgMetaDecorator("Pkg");
72
+ const Module = createArgMetaDecorator("Module");
71
73
  const Workspace = createArgMetaDecorator("Workspace");
72
74
  // Annotate the CommonJS export names for ESM import in node:
73
75
  0 && (module.exports = {
@@ -75,6 +77,7 @@ const Workspace = createArgMetaDecorator("Workspace");
75
77
  Argument,
76
78
  Exec,
77
79
  Lib,
80
+ Module,
78
81
  Option,
79
82
  Pkg,
80
83
  Sys,
@@ -174,6 +174,38 @@ const getInternalArgumentValue = async (argMeta, value, workspace) => {
174
174
  return import_executors.PkgExecutor.from(workspace, value);
175
175
  const pkgName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: pkgs });
176
176
  return import_executors.PkgExecutor.from(workspace, pkgName);
177
+ } else if (sysType === "module") {
178
+ if (value) {
179
+ const [sysName, moduleName2] = value.split(":");
180
+ if (appNames.includes(sysName)) {
181
+ const app = import_executors.AppExecutor.from(workspace, sysName);
182
+ const modules2 = await app.getModules();
183
+ if (modules2.includes(moduleName2))
184
+ return import_executors.ModuleExecutor.from(app, moduleName2);
185
+ else
186
+ throw new Error(`Invalid module name: ${moduleName2}`);
187
+ } else if (libNames.includes(sysName)) {
188
+ const lib = import_executors.LibExecutor.from(workspace, sysName);
189
+ const modules2 = await lib.getModules();
190
+ if (modules2.includes(moduleName2))
191
+ return import_executors.ModuleExecutor.from(lib, moduleName2);
192
+ } else
193
+ throw new Error(`Invalid system name: ${sysName}`);
194
+ }
195
+ const { type, name } = await (0, import_prompts.select)({
196
+ message: `select the App or Lib name`,
197
+ choices: [
198
+ ...appNames.map((name2) => ({ name: name2, value: { type: "app", name: name2 } })),
199
+ ...libNames.map((name2) => ({ name: name2, value: { type: "lib", name: name2 } }))
200
+ ]
201
+ });
202
+ const executor = type === "app" ? import_executors.AppExecutor.from(workspace, name) : import_executors.LibExecutor.from(workspace, name);
203
+ const modules = await executor.getModules();
204
+ const moduleName = await (0, import_prompts.select)({
205
+ message: `Select the module name`,
206
+ choices: modules.map((name2) => ({ name: `${executor.name}:${name2}`, value: name2 }))
207
+ });
208
+ return import_executors.ModuleExecutor.from(executor, moduleName);
177
209
  } else
178
210
  throw new Error(`Invalid system type: ${argMeta.type}`);
179
211
  };
@@ -205,11 +237,18 @@ const runCommands = async (...commands) => {
205
237
  programCommand = handleArgument(programCommand, argMeta);
206
238
  else if (argMeta.type === "Workspace")
207
239
  continue;
208
- const sysType = argMeta.type.toLowerCase();
209
- programCommand = programCommand.argument(
210
- `[${sysType}]`,
211
- `${sysType} in this workspace ${sysType}s/<${sysType}Name>`
212
- );
240
+ else if (argMeta.type === "Module") {
241
+ programCommand = programCommand.argument(
242
+ `[sys-name:module-name]`,
243
+ `${argMeta.type} in this workspace (apps|libs)/<sys-name>/lib/<module-name>`
244
+ );
245
+ } else {
246
+ const sysType = argMeta.type.toLowerCase();
247
+ programCommand = programCommand.argument(
248
+ `[${sysType}]`,
249
+ `${sysType} in this workspace ${sysType}s/<${sysType}Name>`
250
+ );
251
+ }
213
252
  }
214
253
  programCommand = programCommand.option(`-v, --verbose [boolean]`, `verbose output`);
215
254
  programCommand.action(async (...args) => {
@@ -30,6 +30,7 @@ __export(executors_exports, {
30
30
  AppExecutor: () => AppExecutor,
31
31
  Executor: () => Executor,
32
32
  LibExecutor: () => LibExecutor,
33
+ ModuleExecutor: () => ModuleExecutor,
33
34
  PkgExecutor: () => PkgExecutor,
34
35
  SysExecutor: () => SysExecutor,
35
36
  WorkspaceExecutor: () => WorkspaceExecutor,
@@ -52,6 +53,7 @@ const execEmoji = {
52
53
  lib: "\u{1F527}",
53
54
  pkg: "\u{1F4E6}",
54
55
  dist: "\u{1F4BF}",
56
+ module: "\u2699\uFE0F",
55
57
  default: "\u2708\uFE0F"
56
58
  // for sys executor
57
59
  };
@@ -826,11 +828,23 @@ class PkgExecutor extends Executor {
826
828
  return pkgScanResult;
827
829
  }
828
830
  }
831
+ class ModuleExecutor extends Executor {
832
+ sys;
833
+ emoji = execEmoji.module;
834
+ constructor({ sys, name }) {
835
+ super(name, `${sys.workspace.workspaceRoot}/${sys.type}s/${sys.name}/lib/${name}`);
836
+ this.sys = sys;
837
+ }
838
+ static from(sysExecutor, name) {
839
+ return new ModuleExecutor({ sys: sysExecutor, name });
840
+ }
841
+ }
829
842
  // Annotate the CommonJS export names for ESM import in node:
830
843
  0 && (module.exports = {
831
844
  AppExecutor,
832
845
  Executor,
833
846
  LibExecutor,
847
+ ModuleExecutor,
834
848
  PkgExecutor,
835
849
  SysExecutor,
836
850
  WorkspaceExecutor,
@@ -76,8 +76,10 @@ class AiSession {
76
76
  Logger.raw(chunk);
77
77
  }
78
78
  } = {}) {
79
- if (!AiSession.#chat)
79
+ if (!AiSession.#chat) {
80
+ Logger.rawLog(chalk.yellow("\u{1F916}akan-editor is not initialized. LLM configuration should be set first."));
80
81
  await AiSession.init();
82
+ }
81
83
  if (!AiSession.#chat)
82
84
  throw new Error("Failed to initialize the AI session");
83
85
  const loader = new Spinner(`${AiSession.#chat.model} is thinking...`, {
@@ -1,6 +1,6 @@
1
1
  import "reflect-metadata";
2
2
  const argTypes = ["Argument", "Option"];
3
- const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg", "Exec"];
3
+ const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg", "Module", "Exec"];
4
4
  const getArgMetas = (command, key) => {
5
5
  const allArgMetas = getArgMetasOnPrototype(command.prototype, key);
6
6
  const argMetas = allArgMetas.filter((argMeta) => argMeta.type === "Option");
@@ -36,12 +36,14 @@ const Lib = createArgMetaDecorator("Lib");
36
36
  const Sys = createArgMetaDecorator("Sys");
37
37
  const Exec = createArgMetaDecorator("Exec");
38
38
  const Pkg = createArgMetaDecorator("Pkg");
39
+ const Module = createArgMetaDecorator("Module");
39
40
  const Workspace = createArgMetaDecorator("Workspace");
40
41
  export {
41
42
  App,
42
43
  Argument,
43
44
  Exec,
44
45
  Lib,
46
+ Module,
45
47
  Option,
46
48
  Pkg,
47
49
  Sys,
@@ -3,7 +3,7 @@ import { confirm, input, select } from "@inquirer/prompts";
3
3
  import chalk from "chalk";
4
4
  import { program } from "commander";
5
5
  import fs from "fs";
6
- import { AppExecutor, Executor, LibExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
6
+ import { AppExecutor, Executor, LibExecutor, ModuleExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
7
7
  import { getArgMetas } from "./argMeta";
8
8
  import { getTargetMetas } from "./targetMeta";
9
9
  const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -142,6 +142,38 @@ const getInternalArgumentValue = async (argMeta, value, workspace) => {
142
142
  return PkgExecutor.from(workspace, value);
143
143
  const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
144
144
  return PkgExecutor.from(workspace, pkgName);
145
+ } else if (sysType === "module") {
146
+ if (value) {
147
+ const [sysName, moduleName2] = value.split(":");
148
+ if (appNames.includes(sysName)) {
149
+ const app = AppExecutor.from(workspace, sysName);
150
+ const modules2 = await app.getModules();
151
+ if (modules2.includes(moduleName2))
152
+ return ModuleExecutor.from(app, moduleName2);
153
+ else
154
+ throw new Error(`Invalid module name: ${moduleName2}`);
155
+ } else if (libNames.includes(sysName)) {
156
+ const lib = LibExecutor.from(workspace, sysName);
157
+ const modules2 = await lib.getModules();
158
+ if (modules2.includes(moduleName2))
159
+ return ModuleExecutor.from(lib, moduleName2);
160
+ } else
161
+ throw new Error(`Invalid system name: ${sysName}`);
162
+ }
163
+ const { type, name } = await select({
164
+ message: `select the App or Lib name`,
165
+ choices: [
166
+ ...appNames.map((name2) => ({ name: name2, value: { type: "app", name: name2 } })),
167
+ ...libNames.map((name2) => ({ name: name2, value: { type: "lib", name: name2 } }))
168
+ ]
169
+ });
170
+ const executor = type === "app" ? AppExecutor.from(workspace, name) : LibExecutor.from(workspace, name);
171
+ const modules = await executor.getModules();
172
+ const moduleName = await select({
173
+ message: `Select the module name`,
174
+ choices: modules.map((name2) => ({ name: `${executor.name}:${name2}`, value: name2 }))
175
+ });
176
+ return ModuleExecutor.from(executor, moduleName);
145
177
  } else
146
178
  throw new Error(`Invalid system type: ${argMeta.type}`);
147
179
  };
@@ -173,11 +205,18 @@ const runCommands = async (...commands) => {
173
205
  programCommand = handleArgument(programCommand, argMeta);
174
206
  else if (argMeta.type === "Workspace")
175
207
  continue;
176
- const sysType = argMeta.type.toLowerCase();
177
- programCommand = programCommand.argument(
178
- `[${sysType}]`,
179
- `${sysType} in this workspace ${sysType}s/<${sysType}Name>`
180
- );
208
+ else if (argMeta.type === "Module") {
209
+ programCommand = programCommand.argument(
210
+ `[sys-name:module-name]`,
211
+ `${argMeta.type} in this workspace (apps|libs)/<sys-name>/lib/<module-name>`
212
+ );
213
+ } else {
214
+ const sysType = argMeta.type.toLowerCase();
215
+ programCommand = programCommand.argument(
216
+ `[${sysType}]`,
217
+ `${sysType} in this workspace ${sysType}s/<${sysType}Name>`
218
+ );
219
+ }
181
220
  }
182
221
  programCommand = programCommand.option(`-v, --verbose [boolean]`, `verbose output`);
183
222
  programCommand.action(async (...args) => {
@@ -18,6 +18,7 @@ const execEmoji = {
18
18
  lib: "\u{1F527}",
19
19
  pkg: "\u{1F4E6}",
20
20
  dist: "\u{1F4BF}",
21
+ module: "\u2699\uFE0F",
21
22
  default: "\u2708\uFE0F"
22
23
  // for sys executor
23
24
  };
@@ -792,10 +793,22 @@ class PkgExecutor extends Executor {
792
793
  return pkgScanResult;
793
794
  }
794
795
  }
796
+ class ModuleExecutor extends Executor {
797
+ sys;
798
+ emoji = execEmoji.module;
799
+ constructor({ sys, name }) {
800
+ super(name, `${sys.workspace.workspaceRoot}/${sys.type}s/${sys.name}/lib/${name}`);
801
+ this.sys = sys;
802
+ }
803
+ static from(sysExecutor, name) {
804
+ return new ModuleExecutor({ sys: sysExecutor, name });
805
+ }
806
+ }
795
807
  export {
796
808
  AppExecutor,
797
809
  Executor,
798
810
  LibExecutor,
811
+ ModuleExecutor,
799
812
  PkgExecutor,
800
813
  SysExecutor,
801
814
  WorkspaceExecutor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "0.0.142",
3
+ "version": "0.0.143",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,9 +1,9 @@
1
1
  import "reflect-metadata";
2
- import type { AppExecutor, Executor, LibExecutor, PkgExecutor, SysExecutor, WorkspaceExecutor } from "../executors";
2
+ import type { AppExecutor, Executor, LibExecutor, ModuleExecutor, PkgExecutor, SysExecutor, WorkspaceExecutor } from "../executors";
3
3
  import type { Type } from "./types";
4
4
  export declare const argTypes: readonly ["Argument", "Option"];
5
5
  export type ArgType = (typeof argTypes)[number];
6
- export declare const internalArgTypes: readonly ["Workspace", "App", "Lib", "Sys", "Pkg", "Exec"];
6
+ export declare const internalArgTypes: readonly ["Workspace", "App", "Lib", "Sys", "Pkg", "Module", "Exec"];
7
7
  export type InternalArgType = (typeof internalArgTypes)[number];
8
8
  interface ArgsOption {
9
9
  type?: "string" | "number" | "boolean";
@@ -53,6 +53,10 @@ export declare const Pkg: (option?: {
53
53
  nullable?: boolean;
54
54
  }) => (prototype: object, key: string, idx: number) => void;
55
55
  export type Pkg = PkgExecutor;
56
+ export declare const Module: (option?: {
57
+ nullable?: boolean;
58
+ }) => (prototype: object, key: string, idx: number) => void;
59
+ export type Module = ModuleExecutor;
56
60
  export declare const Workspace: (option?: {
57
61
  nullable?: boolean;
58
62
  }) => (prototype: object, key: string, idx: number) => void;
@@ -9,6 +9,7 @@ export declare const execEmoji: {
9
9
  lib: string;
10
10
  pkg: string;
11
11
  dist: string;
12
+ module: string;
12
13
  default: string;
13
14
  };
14
15
  export declare class Executor {
@@ -73,7 +74,7 @@ export declare class WorkspaceExecutor extends Executor {
73
74
  getBaseDevEnv(): {
74
75
  repoName: string;
75
76
  serveDomain: string;
76
- env: "debug" | "testing" | "local" | "develop" | "main";
77
+ env: "testing" | "local" | "debug" | "develop" | "main";
77
78
  name?: string | undefined;
78
79
  };
79
80
  scan(): Promise<WorkspaceScanResult>;
@@ -174,7 +175,7 @@ export declare class AppExecutor extends SysExecutor {
174
175
  emoji: string;
175
176
  constructor({ workspace, name }: AppExecutorOptions);
176
177
  static from(executor: SysExecutor | WorkspaceExecutor, name: string): AppExecutor;
177
- getEnv(): "debug" | "testing" | "local" | "develop" | "main";
178
+ getEnv(): "testing" | "local" | "debug" | "develop" | "main";
178
179
  getConfig(command?: string): Promise<AppConfigResult>;
179
180
  syncAssets(libDeps: string[]): Promise<void>;
180
181
  }
@@ -207,4 +208,14 @@ export declare class PkgExecutor extends Executor {
207
208
  tsconfig?: TsConfigJson;
208
209
  }): Promise<PkgScanResult>;
209
210
  }
211
+ interface ModuleExecutorOptions {
212
+ sys: SysExecutor;
213
+ name: string;
214
+ }
215
+ export declare class ModuleExecutor extends Executor {
216
+ sys: SysExecutor;
217
+ emoji: string;
218
+ constructor({ sys, name }: ModuleExecutorOptions);
219
+ static from(sysExecutor: SysExecutor, name: string): ModuleExecutor;
220
+ }
210
221
  export {};