@akanjs/devkit 0.0.125 → 0.0.127

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.
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
18
18
  var argMeta_exports = {};
19
19
  __export(argMeta_exports, {
20
20
  App: () => App,
21
+ Exec: () => Exec,
21
22
  Lib: () => Lib,
22
23
  Option: () => Option,
23
24
  Pkg: () => Pkg,
@@ -30,7 +31,7 @@ __export(argMeta_exports, {
30
31
  module.exports = __toCommonJS(argMeta_exports);
31
32
  var import_reflect_metadata = require("reflect-metadata");
32
33
  const argTypes = ["Option"];
33
- const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg"];
34
+ const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg", "Exec"];
34
35
  const getArgMetas = (command, key) => {
35
36
  const allArgMetas = getArgMetasOnPrototype(command.prototype, key);
36
37
  const argMetas = allArgMetas.filter((argMeta) => argMeta.type === "Option");
@@ -63,11 +64,13 @@ const createArgMetaDecorator = (type) => {
63
64
  const App = createArgMetaDecorator("App");
64
65
  const Lib = createArgMetaDecorator("Lib");
65
66
  const Sys = createArgMetaDecorator("Sys");
67
+ const Exec = createArgMetaDecorator("Exec");
66
68
  const Pkg = createArgMetaDecorator("Pkg");
67
69
  const Workspace = createArgMetaDecorator("Workspace");
68
70
  // Annotate the CommonJS export names for ESM import in node:
69
71
  0 && (module.exports = {
70
72
  App,
73
+ Exec,
71
74
  Lib,
72
75
  Option,
73
76
  Pkg,
@@ -95,7 +95,7 @@ const getArgumentValue = async (argMeta, value, workspace) => {
95
95
  if (argMeta.type === "Workspace")
96
96
  return workspace;
97
97
  const sysType = argMeta.type.toLowerCase();
98
- const [appNames, libNames] = await workspace.getSyss();
98
+ const [appNames, libNames, pkgNames] = await workspace.getExecs();
99
99
  if (sysType === "sys") {
100
100
  if (value && appNames.includes(value))
101
101
  return import_executors.AppExecutor.from(workspace, value);
@@ -113,6 +113,27 @@ const getArgumentValue = async (argMeta, value, workspace) => {
113
113
  else
114
114
  throw new Error(`Invalid system name: ${sysName}`);
115
115
  }
116
+ } else if (sysType === "exec") {
117
+ if (value && appNames.includes(value))
118
+ return import_executors.AppExecutor.from(workspace, value);
119
+ else if (value && libNames.includes(value))
120
+ return import_executors.LibExecutor.from(workspace, value);
121
+ else if (value && pkgNames.includes(value))
122
+ return import_executors.PkgExecutor.from(workspace, value);
123
+ else {
124
+ const execName = await (0, import_prompts.select)({
125
+ message: `Select the App or Lib or Pkg name`,
126
+ choices: [...appNames, ...libNames, ...pkgNames]
127
+ });
128
+ if (appNames.includes(execName))
129
+ return import_executors.AppExecutor.from(workspace, execName);
130
+ else if (libNames.includes(execName))
131
+ return import_executors.LibExecutor.from(workspace, execName);
132
+ else if (pkgNames.includes(execName))
133
+ return import_executors.PkgExecutor.from(workspace, execName);
134
+ else
135
+ throw new Error(`Invalid system name: ${execName}`);
136
+ }
116
137
  } else if (sysType === "app") {
117
138
  if (value && appNames.includes(value))
118
139
  return import_executors.AppExecutor.from(workspace, value);
@@ -326,6 +326,10 @@ class WorkspaceExecutor extends Executor {
326
326
  async getPkgs() {
327
327
  return await this.#getDirHasFile(`${this.workspaceRoot}/pkgs`, "package.json");
328
328
  }
329
+ async getExecs() {
330
+ const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
331
+ return [appNames, libNames, pkgNames];
332
+ }
329
333
  setTsPaths(type, name) {
330
334
  const rootTsConfig = this.readJson("tsconfig.json");
331
335
  if (type === "lib")
@@ -1,6 +1,6 @@
1
1
  import "reflect-metadata";
2
2
  const argTypes = ["Option"];
3
- const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg"];
3
+ const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg", "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");
@@ -33,10 +33,12 @@ const createArgMetaDecorator = (type) => {
33
33
  const App = createArgMetaDecorator("App");
34
34
  const Lib = createArgMetaDecorator("Lib");
35
35
  const Sys = createArgMetaDecorator("Sys");
36
+ const Exec = createArgMetaDecorator("Exec");
36
37
  const Pkg = createArgMetaDecorator("Pkg");
37
38
  const Workspace = createArgMetaDecorator("Workspace");
38
39
  export {
39
40
  App,
41
+ Exec,
40
42
  Lib,
41
43
  Option,
42
44
  Pkg,
@@ -63,7 +63,7 @@ const getArgumentValue = async (argMeta, value, workspace) => {
63
63
  if (argMeta.type === "Workspace")
64
64
  return workspace;
65
65
  const sysType = argMeta.type.toLowerCase();
66
- const [appNames, libNames] = await workspace.getSyss();
66
+ const [appNames, libNames, pkgNames] = await workspace.getExecs();
67
67
  if (sysType === "sys") {
68
68
  if (value && appNames.includes(value))
69
69
  return AppExecutor.from(workspace, value);
@@ -81,6 +81,27 @@ const getArgumentValue = async (argMeta, value, workspace) => {
81
81
  else
82
82
  throw new Error(`Invalid system name: ${sysName}`);
83
83
  }
84
+ } else if (sysType === "exec") {
85
+ if (value && appNames.includes(value))
86
+ return AppExecutor.from(workspace, value);
87
+ else if (value && libNames.includes(value))
88
+ return LibExecutor.from(workspace, value);
89
+ else if (value && pkgNames.includes(value))
90
+ return PkgExecutor.from(workspace, value);
91
+ else {
92
+ const execName = await select({
93
+ message: `Select the App or Lib or Pkg name`,
94
+ choices: [...appNames, ...libNames, ...pkgNames]
95
+ });
96
+ if (appNames.includes(execName))
97
+ return AppExecutor.from(workspace, execName);
98
+ else if (libNames.includes(execName))
99
+ return LibExecutor.from(workspace, execName);
100
+ else if (pkgNames.includes(execName))
101
+ return PkgExecutor.from(workspace, execName);
102
+ else
103
+ throw new Error(`Invalid system name: ${execName}`);
104
+ }
84
105
  } else if (sysType === "app") {
85
106
  if (value && appNames.includes(value))
86
107
  return AppExecutor.from(workspace, value);
@@ -293,6 +293,10 @@ class WorkspaceExecutor extends Executor {
293
293
  async getPkgs() {
294
294
  return await this.#getDirHasFile(`${this.workspaceRoot}/pkgs`, "package.json");
295
295
  }
296
+ async getExecs() {
297
+ const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
298
+ return [appNames, libNames, pkgNames];
299
+ }
296
300
  setTsPaths(type, name) {
297
301
  const rootTsConfig = this.readJson("tsconfig.json");
298
302
  if (type === "lib")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "0.0.125",
3
+ "version": "0.0.127",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,9 +1,9 @@
1
1
  import "reflect-metadata";
2
- import type { AppExecutor, LibExecutor, PkgExecutor, SysExecutor, WorkspaceExecutor } from "../executors";
2
+ import type { AppExecutor, Executor, LibExecutor, PkgExecutor, SysExecutor, WorkspaceExecutor } from "../executors";
3
3
  import type { Type } from "./types";
4
4
  export declare const argTypes: readonly ["Option"];
5
5
  export type ArgType = (typeof argTypes)[number];
6
- export declare const internalArgTypes: readonly ["Workspace", "App", "Lib", "Sys", "Pkg"];
6
+ export declare const internalArgTypes: readonly ["Workspace", "App", "Lib", "Sys", "Pkg", "Exec"];
7
7
  export type InternalArgType = (typeof internalArgTypes)[number];
8
8
  interface ArgsOption {
9
9
  type?: "string" | "number" | "boolean";
@@ -44,6 +44,10 @@ export declare const Sys: (option?: {
44
44
  nullable?: boolean;
45
45
  }) => (prototype: object, key: string, idx: number) => void;
46
46
  export type Sys = SysExecutor;
47
+ export declare const Exec: (option?: {
48
+ nullable?: boolean;
49
+ }) => (prototype: object, key: string, idx: number) => void;
50
+ export type Exec = Executor;
47
51
  export declare const Pkg: (option?: {
48
52
  nullable?: boolean;
49
53
  }) => (prototype: object, key: string, idx: number) => void;
@@ -52,7 +52,7 @@ export declare class WorkspaceExecutor extends Executor {
52
52
  getBaseDevEnv(): {
53
53
  repoName: string;
54
54
  serveDomain: string;
55
- env: "debug" | "testing" | "local" | "develop" | "main";
55
+ env: "testing" | "local" | "debug" | "develop" | "main";
56
56
  name?: string | undefined;
57
57
  };
58
58
  scan(): Promise<WorkspaceScanResult>;
@@ -60,6 +60,7 @@ export declare class WorkspaceExecutor extends Executor {
60
60
  getLibs(): Promise<string[]>;
61
61
  getSyss(): Promise<[string[], string[]]>;
62
62
  getPkgs(): Promise<string[]>;
63
+ getExecs(): Promise<[string[], string[], string[]]>;
63
64
  setTsPaths(type: "app" | "lib", name: string): this;
64
65
  getDirInModule(basePath: string, name: string): Promise<string[]>;
65
66
  commit(message: string, { init, add }?: {