@akanjs/devkit 0.0.53 → 0.0.55
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.
- package/index.cjs +17 -0
- package/index.js +1 -17
- package/package.json +8 -2
- package/src/aiEditor.cjs +46 -0
- package/src/aiEditor.js +8 -27
- package/src/auth.cjs +64 -0
- package/src/auth.js +23 -45
- package/src/baseDevEnv.cjs +45 -0
- package/src/baseDevEnv.js +4 -23
- package/src/capacitorApp.cjs +153 -0
- package/src/capacitorApp.js +10 -39
- package/src/commandDecorators/argMeta.cjs +67 -0
- package/src/commandDecorators/argMeta.js +12 -31
- package/src/commandDecorators/command.cjs +160 -0
- package/src/commandDecorators/command.js +30 -49
- package/src/commandDecorators/commandMeta.cjs +26 -0
- package/src/commandDecorators/commandMeta.js +3 -22
- package/src/commandDecorators/index.cjs +21 -0
- package/src/commandDecorators/index.js +5 -21
- package/src/commandDecorators/targetMeta.cjs +52 -0
- package/src/commandDecorators/targetMeta.js +4 -23
- package/src/commandDecorators/types.cjs +15 -0
- package/src/commandDecorators/types.js +0 -15
- package/src/constants.cjs +37 -0
- package/src/constants.js +11 -30
- package/src/createTunnel.cjs +37 -0
- package/src/createTunnel.js +7 -26
- package/src/dependencyScanner.cjs +159 -0
- package/src/dependencyScanner.js +6 -35
- package/src/executors.cjs +592 -0
- package/src/executors.js +91 -116
- package/src/extractDeps.cjs +99 -0
- package/src/extractDeps.js +3 -22
- package/src/getCredentials.cjs +40 -0
- package/src/getCredentials.js +7 -36
- package/src/getDependencies.cjs +51 -0
- package/src/getDependencies.js +5 -24
- package/src/getModelFileData.cjs +62 -0
- package/src/getModelFileData.js +7 -36
- package/src/getRelatedCnsts.cjs +138 -0
- package/src/getRelatedCnsts.js +8 -37
- package/src/index.cjs +34 -0
- package/src/index.js +18 -34
- package/src/installExternalLib.cjs +29 -0
- package/src/installExternalLib.js +3 -22
- package/src/selectModel.cjs +42 -0
- package/src/selectModel.js +7 -36
- package/src/streamAi.cjs +56 -0
- package/src/streamAi.js +8 -27
- package/src/types.cjs +15 -0
- package/src/types.d.ts +2 -0
- package/src/types.js +0 -15
- package/src/uploadRelease.cjs +81 -0
- package/src/uploadRelease.js +16 -45
|
@@ -0,0 +1,67 @@
|
|
|
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");
|
|
32
|
+
const argTypes = ["Option"];
|
|
33
|
+
const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg"];
|
|
34
|
+
const getArgMetas = (command, key) => {
|
|
35
|
+
const allArgMetas = getArgMetasOnPrototype(command.prototype, key);
|
|
36
|
+
const argMetas = allArgMetas.filter((argMeta) => argMeta.type === "Option");
|
|
37
|
+
const internalArgMetas = allArgMetas.filter((argMeta) => argMeta.type !== "Option");
|
|
38
|
+
return [allArgMetas, argMetas, internalArgMetas];
|
|
39
|
+
};
|
|
40
|
+
const getArgMetasOnPrototype = (prototype, key) => {
|
|
41
|
+
return Reflect.getMetadata("args", prototype, key) ?? [];
|
|
42
|
+
};
|
|
43
|
+
const setArgMetasOnPrototype = (prototype, key, argMetas) => {
|
|
44
|
+
Reflect.defineMetadata("args", argMetas, prototype, key);
|
|
45
|
+
};
|
|
46
|
+
const getArg = (type) => function(name, argsOption = {}) {
|
|
47
|
+
return function(prototype, key, idx) {
|
|
48
|
+
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
49
|
+
argMetas[idx] = { name, argsOption, key, idx, type };
|
|
50
|
+
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const Option = getArg("Option");
|
|
54
|
+
const createArgMetaDecorator = (type) => {
|
|
55
|
+
return function(option = {}) {
|
|
56
|
+
return function(prototype, key, idx) {
|
|
57
|
+
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
58
|
+
argMetas[idx] = { key, idx, type, option };
|
|
59
|
+
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const App = createArgMetaDecorator("App");
|
|
64
|
+
const Lib = createArgMetaDecorator("Lib");
|
|
65
|
+
const Sys = createArgMetaDecorator("Sys");
|
|
66
|
+
const Pkg = createArgMetaDecorator("Pkg");
|
|
67
|
+
const Workspace = createArgMetaDecorator("Workspace");
|
|
@@ -1,34 +1,4 @@
|
|
|
1
|
-
|
|
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,3 +35,14 @@ const Lib = createArgMetaDecorator("Lib");
|
|
|
65
35
|
const Sys = createArgMetaDecorator("Sys");
|
|
66
36
|
const Pkg = createArgMetaDecorator("Pkg");
|
|
67
37
|
const Workspace = createArgMetaDecorator("Workspace");
|
|
38
|
+
export {
|
|
39
|
+
App,
|
|
40
|
+
Lib,
|
|
41
|
+
Option,
|
|
42
|
+
Pkg,
|
|
43
|
+
Sys,
|
|
44
|
+
Workspace,
|
|
45
|
+
argTypes,
|
|
46
|
+
getArgMetas,
|
|
47
|
+
internalArgTypes
|
|
48
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
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 command_exports = {};
|
|
19
|
+
__export(command_exports, {
|
|
20
|
+
runCommands: () => runCommands
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(command_exports);
|
|
23
|
+
var import_prompts = require("@inquirer/prompts");
|
|
24
|
+
var import_commander = require("commander");
|
|
25
|
+
var import_executors = require("../executors");
|
|
26
|
+
var import_argMeta = require("./argMeta");
|
|
27
|
+
var import_targetMeta = require("./targetMeta");
|
|
28
|
+
const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
29
|
+
const handleOption = (programCommand, argMeta) => {
|
|
30
|
+
const {
|
|
31
|
+
type,
|
|
32
|
+
flag = argMeta.name.slice(0, 1).toLowerCase(),
|
|
33
|
+
desc = argMeta.name,
|
|
34
|
+
example,
|
|
35
|
+
enum: choices,
|
|
36
|
+
ask
|
|
37
|
+
} = argMeta.argsOption;
|
|
38
|
+
const kebabName = camelToKebabCase(argMeta.name);
|
|
39
|
+
programCommand.option(
|
|
40
|
+
`-${flag}, --${kebabName} <${kebabName}>`,
|
|
41
|
+
`${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.join(", ")})` : ""}`
|
|
42
|
+
);
|
|
43
|
+
return programCommand;
|
|
44
|
+
};
|
|
45
|
+
const convertOptionValue = (value, type) => {
|
|
46
|
+
if (type === "string")
|
|
47
|
+
return value;
|
|
48
|
+
else if (type === "number")
|
|
49
|
+
return Number(value);
|
|
50
|
+
else
|
|
51
|
+
return value === "true";
|
|
52
|
+
};
|
|
53
|
+
const getOptionValue = async (argMeta, opt) => {
|
|
54
|
+
const {
|
|
55
|
+
name,
|
|
56
|
+
argsOption: { enum: choices, default: defaultValue, type, desc, nullable, example, ask }
|
|
57
|
+
} = argMeta;
|
|
58
|
+
if (opt[argMeta.name] !== void 0)
|
|
59
|
+
return convertOptionValue(opt[argMeta.name], type ?? "string");
|
|
60
|
+
else if (defaultValue !== void 0)
|
|
61
|
+
return defaultValue;
|
|
62
|
+
else if (nullable)
|
|
63
|
+
return null;
|
|
64
|
+
if (choices) {
|
|
65
|
+
const choice = await (0, import_prompts.select)({
|
|
66
|
+
message: ask ?? `Select the ${name} value`,
|
|
67
|
+
choices: choices.map((choice2) => choice2.toString())
|
|
68
|
+
});
|
|
69
|
+
return choice;
|
|
70
|
+
} else if (type === "boolean") {
|
|
71
|
+
const message = ask ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
|
|
72
|
+
return await (0, import_prompts.confirm)({ message });
|
|
73
|
+
} else {
|
|
74
|
+
const message = ask ?? `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
75
|
+
if (argMeta.argsOption.nullable)
|
|
76
|
+
return await (0, import_prompts.input)({ message });
|
|
77
|
+
else
|
|
78
|
+
return convertOptionValue(await (0, import_prompts.input)({ message }), type ?? "string");
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const getArgumentValue = async (argMeta, value, workspace) => {
|
|
82
|
+
if (argMeta.type === "Workspace")
|
|
83
|
+
return workspace;
|
|
84
|
+
const sysType = argMeta.type.toLowerCase();
|
|
85
|
+
if (sysType === "sys") {
|
|
86
|
+
const [appNames, libNames] = await workspace.getSyss();
|
|
87
|
+
const sysName = await (0, import_prompts.select)({
|
|
88
|
+
message: `Select the App or Lib name`,
|
|
89
|
+
choices: [...appNames, ...libNames]
|
|
90
|
+
});
|
|
91
|
+
if (appNames.includes(sysName))
|
|
92
|
+
return import_executors.AppExecutor.from(workspace, sysName);
|
|
93
|
+
else
|
|
94
|
+
return import_executors.LibExecutor.from(workspace, sysName);
|
|
95
|
+
} else if (sysType === "app") {
|
|
96
|
+
if (value)
|
|
97
|
+
return import_executors.AppExecutor.from(workspace, value);
|
|
98
|
+
const apps = await workspace.getApps();
|
|
99
|
+
const appName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: apps });
|
|
100
|
+
return import_executors.AppExecutor.from(workspace, appName);
|
|
101
|
+
} else if (sysType === "lib") {
|
|
102
|
+
if (value)
|
|
103
|
+
return import_executors.LibExecutor.from(workspace, value);
|
|
104
|
+
const libs = await workspace.getLibs();
|
|
105
|
+
const libName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: libs });
|
|
106
|
+
return import_executors.LibExecutor.from(workspace, libName);
|
|
107
|
+
} else if (sysType === "pkg") {
|
|
108
|
+
if (value)
|
|
109
|
+
return import_executors.PkgExecutor.from(workspace, value);
|
|
110
|
+
const pkgs = await workspace.getPkgs();
|
|
111
|
+
const pkgName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: pkgs });
|
|
112
|
+
return import_executors.PkgExecutor.from(workspace, pkgName);
|
|
113
|
+
} else
|
|
114
|
+
throw new Error(`Invalid system type: ${argMeta.type}`);
|
|
115
|
+
};
|
|
116
|
+
const runCommands = async (...commands) => {
|
|
117
|
+
import_commander.program.version("0.0.1").description("An example CLI for managing a directory");
|
|
118
|
+
for (const command of commands) {
|
|
119
|
+
const targetMetas = (0, import_targetMeta.getTargetMetas)(command);
|
|
120
|
+
for (const targetMeta of targetMetas) {
|
|
121
|
+
const kebabKey = camelToKebabCase(targetMeta.key);
|
|
122
|
+
const commandNames = targetMeta.targetOption.short === true ? [
|
|
123
|
+
kebabKey,
|
|
124
|
+
typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
|
|
125
|
+
] : [kebabKey];
|
|
126
|
+
for (const commandName of commandNames) {
|
|
127
|
+
let programCommand = import_commander.program.command(commandName, {
|
|
128
|
+
hidden: targetMeta.targetOption.devOnly
|
|
129
|
+
});
|
|
130
|
+
const [allArgMetas] = (0, import_argMeta.getArgMetas)(command, targetMeta.key);
|
|
131
|
+
for (const argMeta of allArgMetas) {
|
|
132
|
+
if (argMeta.type === "Option")
|
|
133
|
+
programCommand = handleOption(programCommand, argMeta);
|
|
134
|
+
else if (argMeta.type === "Workspace")
|
|
135
|
+
continue;
|
|
136
|
+
const sysType = argMeta.type.toLowerCase();
|
|
137
|
+
programCommand = programCommand.argument(
|
|
138
|
+
`[${sysType}]`,
|
|
139
|
+
`${sysType} in this workspace ${sysType}s/<${sysType}Name>`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
programCommand.action(async (...args) => {
|
|
143
|
+
const cmdArgs = args.slice(0, args.length - 2);
|
|
144
|
+
const opt = args[args.length - 2];
|
|
145
|
+
const commandArgs = [];
|
|
146
|
+
const workspace = import_executors.WorkspaceExecutor.fromRoot();
|
|
147
|
+
for (const argMeta of allArgMetas) {
|
|
148
|
+
if (argMeta.type === "Option")
|
|
149
|
+
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
150
|
+
else
|
|
151
|
+
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
152
|
+
}
|
|
153
|
+
const cmd = new command();
|
|
154
|
+
await cmd[targetMeta.key](...commandArgs);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
await import_commander.program.parseAsync(process.argv);
|
|
160
|
+
};
|
|
@@ -1,30 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 command_exports = {};
|
|
19
|
-
__export(command_exports, {
|
|
20
|
-
runCommands: () => runCommands
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(command_exports);
|
|
23
|
-
var import_prompts = require("@inquirer/prompts");
|
|
24
|
-
var import_commander = require("commander");
|
|
25
|
-
var import_executors = require("../executors");
|
|
26
|
-
var import_argMeta = require("./argMeta");
|
|
27
|
-
var import_targetMeta = require("./targetMeta");
|
|
1
|
+
import { confirm, input, select } from "@inquirer/prompts";
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { AppExecutor, LibExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
|
|
4
|
+
import { getArgMetas } from "./argMeta";
|
|
5
|
+
import { getTargetMetas } from "./targetMeta";
|
|
28
6
|
const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
29
7
|
const handleOption = (programCommand, argMeta) => {
|
|
30
8
|
const {
|
|
@@ -62,20 +40,20 @@ const getOptionValue = async (argMeta, opt) => {
|
|
|
62
40
|
else if (nullable)
|
|
63
41
|
return null;
|
|
64
42
|
if (choices) {
|
|
65
|
-
const choice = await
|
|
43
|
+
const choice = await select({
|
|
66
44
|
message: ask ?? `Select the ${name} value`,
|
|
67
45
|
choices: choices.map((choice2) => choice2.toString())
|
|
68
46
|
});
|
|
69
47
|
return choice;
|
|
70
48
|
} else if (type === "boolean") {
|
|
71
49
|
const message = ask ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
|
|
72
|
-
return await
|
|
50
|
+
return await confirm({ message });
|
|
73
51
|
} else {
|
|
74
52
|
const message = ask ?? `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
75
53
|
if (argMeta.argsOption.nullable)
|
|
76
|
-
return await
|
|
54
|
+
return await input({ message });
|
|
77
55
|
else
|
|
78
|
-
return convertOptionValue(await
|
|
56
|
+
return convertOptionValue(await input({ message }), type ?? "string");
|
|
79
57
|
}
|
|
80
58
|
};
|
|
81
59
|
const getArgumentValue = async (argMeta, value, workspace) => {
|
|
@@ -84,39 +62,39 @@ const getArgumentValue = async (argMeta, value, workspace) => {
|
|
|
84
62
|
const sysType = argMeta.type.toLowerCase();
|
|
85
63
|
if (sysType === "sys") {
|
|
86
64
|
const [appNames, libNames] = await workspace.getSyss();
|
|
87
|
-
const sysName = await
|
|
65
|
+
const sysName = await select({
|
|
88
66
|
message: `Select the App or Lib name`,
|
|
89
67
|
choices: [...appNames, ...libNames]
|
|
90
68
|
});
|
|
91
69
|
if (appNames.includes(sysName))
|
|
92
|
-
return
|
|
70
|
+
return AppExecutor.from(workspace, sysName);
|
|
93
71
|
else
|
|
94
|
-
return
|
|
72
|
+
return LibExecutor.from(workspace, sysName);
|
|
95
73
|
} else if (sysType === "app") {
|
|
96
74
|
if (value)
|
|
97
|
-
return
|
|
75
|
+
return AppExecutor.from(workspace, value);
|
|
98
76
|
const apps = await workspace.getApps();
|
|
99
|
-
const appName = await
|
|
100
|
-
return
|
|
77
|
+
const appName = await select({ message: `Select the ${sysType} name`, choices: apps });
|
|
78
|
+
return AppExecutor.from(workspace, appName);
|
|
101
79
|
} else if (sysType === "lib") {
|
|
102
80
|
if (value)
|
|
103
|
-
return
|
|
81
|
+
return LibExecutor.from(workspace, value);
|
|
104
82
|
const libs = await workspace.getLibs();
|
|
105
|
-
const libName = await
|
|
106
|
-
return
|
|
83
|
+
const libName = await select({ message: `Select the ${sysType} name`, choices: libs });
|
|
84
|
+
return LibExecutor.from(workspace, libName);
|
|
107
85
|
} else if (sysType === "pkg") {
|
|
108
86
|
if (value)
|
|
109
|
-
return
|
|
87
|
+
return PkgExecutor.from(workspace, value);
|
|
110
88
|
const pkgs = await workspace.getPkgs();
|
|
111
|
-
const pkgName = await
|
|
112
|
-
return
|
|
89
|
+
const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
|
|
90
|
+
return PkgExecutor.from(workspace, pkgName);
|
|
113
91
|
} else
|
|
114
92
|
throw new Error(`Invalid system type: ${argMeta.type}`);
|
|
115
93
|
};
|
|
116
94
|
const runCommands = async (...commands) => {
|
|
117
|
-
|
|
95
|
+
program.version("0.0.1").description("An example CLI for managing a directory");
|
|
118
96
|
for (const command of commands) {
|
|
119
|
-
const targetMetas =
|
|
97
|
+
const targetMetas = getTargetMetas(command);
|
|
120
98
|
for (const targetMeta of targetMetas) {
|
|
121
99
|
const kebabKey = camelToKebabCase(targetMeta.key);
|
|
122
100
|
const commandNames = targetMeta.targetOption.short === true ? [
|
|
@@ -124,10 +102,10 @@ const runCommands = async (...commands) => {
|
|
|
124
102
|
typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
|
|
125
103
|
] : [kebabKey];
|
|
126
104
|
for (const commandName of commandNames) {
|
|
127
|
-
let programCommand =
|
|
105
|
+
let programCommand = program.command(commandName, {
|
|
128
106
|
hidden: targetMeta.targetOption.devOnly
|
|
129
107
|
});
|
|
130
|
-
const [allArgMetas] =
|
|
108
|
+
const [allArgMetas] = getArgMetas(command, targetMeta.key);
|
|
131
109
|
for (const argMeta of allArgMetas) {
|
|
132
110
|
if (argMeta.type === "Option")
|
|
133
111
|
programCommand = handleOption(programCommand, argMeta);
|
|
@@ -143,7 +121,7 @@ const runCommands = async (...commands) => {
|
|
|
143
121
|
const cmdArgs = args.slice(0, args.length - 2);
|
|
144
122
|
const opt = args[args.length - 2];
|
|
145
123
|
const commandArgs = [];
|
|
146
|
-
const workspace =
|
|
124
|
+
const workspace = WorkspaceExecutor.fromRoot();
|
|
147
125
|
for (const argMeta of allArgMetas) {
|
|
148
126
|
if (argMeta.type === "Option")
|
|
149
127
|
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
@@ -156,5 +134,8 @@ const runCommands = async (...commands) => {
|
|
|
156
134
|
}
|
|
157
135
|
}
|
|
158
136
|
}
|
|
159
|
-
await
|
|
137
|
+
await program.parseAsync(process.argv);
|
|
138
|
+
};
|
|
139
|
+
export {
|
|
140
|
+
runCommands
|
|
160
141
|
};
|
|
@@ -0,0 +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 commandMeta_exports = {};
|
|
19
|
+
__export(commandMeta_exports, {
|
|
20
|
+
Commands: () => Commands
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(commandMeta_exports);
|
|
23
|
+
const Commands = () => {
|
|
24
|
+
return function(target) {
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -1,26 +1,7 @@
|
|
|
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);
|
|
23
1
|
const Commands = () => {
|
|
24
2
|
return function(target) {
|
|
25
3
|
};
|
|
26
4
|
};
|
|
5
|
+
export {
|
|
6
|
+
Commands
|
|
7
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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);
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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);
|
|
1
|
+
export * from "./argMeta";
|
|
2
|
+
export * from "./commandMeta";
|
|
3
|
+
export * from "./targetMeta";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./command";
|
|
@@ -0,0 +1,52 @@
|
|
|
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);
|
|
24
|
+
const getTargetMetas = (command) => {
|
|
25
|
+
const targetMetaMap = Reflect.getMetadata("target", command.prototype);
|
|
26
|
+
if (!targetMetaMap)
|
|
27
|
+
throw new Error(`TargetMeta is not defined for ${command.name}`);
|
|
28
|
+
return [...targetMetaMap.values()];
|
|
29
|
+
};
|
|
30
|
+
const getTargetMetaMapOnPrototype = (prototype) => {
|
|
31
|
+
const targetMetaMap = Reflect.getMetadata("target", prototype);
|
|
32
|
+
return targetMetaMap ?? /* @__PURE__ */ new Map();
|
|
33
|
+
};
|
|
34
|
+
const setTargetMetaMapOnPrototype = (prototype, targetMetaMap) => {
|
|
35
|
+
Reflect.defineMetadata("target", targetMetaMap, prototype);
|
|
36
|
+
};
|
|
37
|
+
const getTarget = (type) => (targetOption = {}) => {
|
|
38
|
+
return (prototype, key, descriptor) => {
|
|
39
|
+
const metadataMap = getTargetMetaMapOnPrototype(prototype);
|
|
40
|
+
metadataMap.set(key, {
|
|
41
|
+
key,
|
|
42
|
+
descriptor,
|
|
43
|
+
targetOption: { ...targetOption, type }
|
|
44
|
+
});
|
|
45
|
+
setTargetMetaMapOnPrototype(prototype, metadataMap);
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const Target = {
|
|
49
|
+
Public: getTarget("public"),
|
|
50
|
+
Cloud: getTarget("cloud"),
|
|
51
|
+
Dev: getTarget("dev")
|
|
52
|
+
};
|
|
@@ -1,26 +1,3 @@
|
|
|
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);
|
|
24
1
|
const getTargetMetas = (command) => {
|
|
25
2
|
const targetMetaMap = Reflect.getMetadata("target", command.prototype);
|
|
26
3
|
if (!targetMetaMap)
|
|
@@ -50,3 +27,7 @@ const Target = {
|
|
|
50
27
|
Cloud: getTarget("cloud"),
|
|
51
28
|
Dev: getTarget("dev")
|
|
52
29
|
};
|
|
30
|
+
export {
|
|
31
|
+
Target,
|
|
32
|
+
getTargetMetas
|
|
33
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -1,15 +0,0 @@
|
|
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
-
var types_exports = {};
|
|
15
|
-
module.exports = __toCommonJS(types_exports);
|