@akanjs/devkit 0.0.52 → 0.0.54
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.js +1 -17
- package/package.json +3 -17
- package/src/aiEditor.js +8 -27
- package/src/auth.js +23 -45
- package/src/baseDevEnv.js +4 -23
- package/src/capacitorApp.js +10 -39
- package/src/commandDecorators/argMeta.js +12 -31
- package/src/commandDecorators/command.js +30 -49
- package/src/commandDecorators/commandMeta.js +3 -22
- package/src/commandDecorators/index.js +5 -21
- package/src/commandDecorators/targetMeta.js +4 -23
- package/src/commandDecorators/types.js +0 -15
- package/src/constants.js +11 -30
- package/src/createTunnel.js +7 -26
- package/src/dependencyScanner.js +6 -35
- package/src/executors.js +91 -116
- package/src/extractDeps.js +3 -22
- package/src/getCredentials.js +7 -36
- package/src/getDependencies.js +5 -24
- package/src/getModelFileData.js +7 -36
- package/src/getRelatedCnsts.js +8 -37
- package/src/index.js +18 -34
- package/src/installExternalLib.js +3 -22
- package/src/selectModel.js +7 -36
- package/src/streamAi.js +8 -27
- package/src/types.d.ts +1 -0
- package/src/types.js +0 -15
- package/src/uploadRelease.js +16 -45
package/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
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 devkit_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(devkit_exports);
|
|
17
|
-
__reExport(devkit_exports, require("./src"), module.exports);
|
|
1
|
+
export * from "./src";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "
|
|
3
|
+
"version": "0.0.54",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -14,19 +14,5 @@
|
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@inquirer/prompts": "^7.2.1",
|
|
19
|
-
"@langchain/core": "^0.3.27",
|
|
20
|
-
"@langchain/openai": "^0.3.16",
|
|
21
|
-
"@nx/devkit": "^20.7.2",
|
|
22
|
-
"@trapezedev/project": "^7.1.3",
|
|
23
|
-
"axios": "^1.7.9",
|
|
24
|
-
"commander": "^13.1.0",
|
|
25
|
-
"form-data": "^4.0.1",
|
|
26
|
-
"js-yaml": "^4.1.0",
|
|
27
|
-
"ora": "^3.4.0",
|
|
28
|
-
"reflect-metadata": "^0.2.2",
|
|
29
|
-
"tunnel-ssh": "^5.2.0",
|
|
30
|
-
"typescript": "^5.8.3"
|
|
31
|
-
}
|
|
17
|
+
"dependencies": {}
|
|
32
18
|
}
|
package/src/aiEditor.js
CHANGED
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 aiEditor_exports = {};
|
|
19
|
-
__export(aiEditor_exports, {
|
|
20
|
-
AiEditor: () => AiEditor
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(aiEditor_exports);
|
|
23
|
-
var import_prompts = require("@langchain/core/prompts");
|
|
24
|
-
var import_runnables = require("@langchain/core/runnables");
|
|
25
|
-
var import_openai = require("@langchain/openai");
|
|
1
|
+
import { PromptTemplate } from "@langchain/core/prompts";
|
|
2
|
+
import { RunnableSequence } from "@langchain/core/runnables";
|
|
3
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
26
4
|
class AiEditor {
|
|
27
5
|
chat;
|
|
28
6
|
constructor(apiKey = process.env.DEEPSEEK_API_KEY) {
|
|
29
|
-
this.chat = new
|
|
7
|
+
this.chat = new ChatOpenAI({
|
|
30
8
|
modelName: "deepseek-reasoner",
|
|
31
9
|
temperature: 0.7,
|
|
32
10
|
streaming: true,
|
|
@@ -35,7 +13,7 @@ class AiEditor {
|
|
|
35
13
|
});
|
|
36
14
|
}
|
|
37
15
|
#createProcessingChain() {
|
|
38
|
-
return
|
|
16
|
+
return RunnableSequence.from([PromptTemplate.fromTemplate(`Answer concisely: {question}`), this.chat]);
|
|
39
17
|
}
|
|
40
18
|
async edit(question) {
|
|
41
19
|
const chain = this.#createProcessingChain();
|
|
@@ -44,3 +22,6 @@ class AiEditor {
|
|
|
44
22
|
}
|
|
45
23
|
}
|
|
46
24
|
}
|
|
25
|
+
export {
|
|
26
|
+
AiEditor
|
|
27
|
+
};
|
package/src/auth.js
CHANGED
|
@@ -1,64 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 auth_exports = {};
|
|
29
|
-
__export(auth_exports, {
|
|
30
|
-
getAkanGlobalConfig: () => getAkanGlobalConfig,
|
|
31
|
-
getHostConfig: () => getHostConfig,
|
|
32
|
-
getSelf: () => getSelf,
|
|
33
|
-
setAkanGlobalConfig: () => setAkanGlobalConfig,
|
|
34
|
-
setHostConfig: () => setHostConfig
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(auth_exports);
|
|
37
|
-
var import_fs = __toESM(require("fs"));
|
|
38
|
-
var import_constants = require("./constants");
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import {
|
|
3
|
+
akanCloudBackendUrl,
|
|
4
|
+
akanCloudHost,
|
|
5
|
+
basePath,
|
|
6
|
+
configPath,
|
|
7
|
+
defaultAkanGlobalConfig,
|
|
8
|
+
defaultHostConfig
|
|
9
|
+
} from "./constants";
|
|
39
10
|
const getAkanGlobalConfig = () => {
|
|
40
|
-
const akanConfig =
|
|
11
|
+
const akanConfig = fs.existsSync(configPath) ? JSON.parse(fs.readFileSync(configPath, "utf8")) : defaultAkanGlobalConfig;
|
|
41
12
|
return akanConfig;
|
|
42
13
|
};
|
|
43
14
|
const setAkanGlobalConfig = (akanConfig) => {
|
|
44
|
-
|
|
45
|
-
|
|
15
|
+
fs.mkdirSync(basePath, { recursive: true });
|
|
16
|
+
fs.writeFileSync(configPath, JSON.stringify(akanConfig, null, 2));
|
|
46
17
|
};
|
|
47
|
-
const getHostConfig = (host =
|
|
18
|
+
const getHostConfig = (host = akanCloudHost) => {
|
|
48
19
|
const akanConfig = getAkanGlobalConfig();
|
|
49
|
-
return akanConfig[host] ??
|
|
20
|
+
return akanConfig[host] ?? defaultHostConfig;
|
|
50
21
|
};
|
|
51
|
-
const setHostConfig = (host =
|
|
22
|
+
const setHostConfig = (host = akanCloudHost, config = {}) => {
|
|
52
23
|
const akanConfig = getAkanGlobalConfig();
|
|
53
24
|
akanConfig[host] = config;
|
|
54
25
|
setAkanGlobalConfig(akanConfig);
|
|
55
26
|
};
|
|
56
27
|
const getSelf = async (token) => {
|
|
57
28
|
try {
|
|
58
|
-
const res = await fetch(`${
|
|
29
|
+
const res = await fetch(`${akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
|
|
59
30
|
const user = await res.json();
|
|
60
31
|
return user;
|
|
61
32
|
} catch (e) {
|
|
62
33
|
return null;
|
|
63
34
|
}
|
|
64
35
|
};
|
|
36
|
+
export {
|
|
37
|
+
getAkanGlobalConfig,
|
|
38
|
+
getHostConfig,
|
|
39
|
+
getSelf,
|
|
40
|
+
setAkanGlobalConfig,
|
|
41
|
+
setHostConfig
|
|
42
|
+
};
|
package/src/baseDevEnv.js
CHANGED
|
@@ -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 baseDevEnv_exports = {};
|
|
19
|
-
__export(baseDevEnv_exports, {
|
|
20
|
-
getBaseDevEnv: () => getBaseDevEnv,
|
|
21
|
-
getSshTunnelOptions: () => getSshTunnelOptions
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(baseDevEnv_exports);
|
|
24
1
|
const getBaseDevEnv = () => {
|
|
25
2
|
const appName = process.env.NEXT_PUBLIC_APP_NAME;
|
|
26
3
|
const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
|
|
@@ -43,3 +20,7 @@ const getSshTunnelOptions = (appName, environment) => {
|
|
|
43
20
|
password: process.env.SSU_TUNNEL_PASSWORD ?? repoName
|
|
44
21
|
};
|
|
45
22
|
};
|
|
23
|
+
export {
|
|
24
|
+
getBaseDevEnv,
|
|
25
|
+
getSshTunnelOptions
|
|
26
|
+
};
|
package/src/capacitorApp.js
CHANGED
|
@@ -1,38 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var capacitorApp_exports = {};
|
|
29
|
-
__export(capacitorApp_exports, {
|
|
30
|
-
CapacitorApp: () => CapacitorApp
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(capacitorApp_exports);
|
|
33
|
-
var import_common = require("@akanjs/common");
|
|
34
|
-
var import_project = require("@trapezedev/project");
|
|
35
|
-
var import_fs = __toESM(require("fs"));
|
|
1
|
+
import { capitalize } from "@akanjs/common";
|
|
2
|
+
import { MobileProject } from "@trapezedev/project";
|
|
3
|
+
import fs from "fs";
|
|
36
4
|
class CapacitorApp {
|
|
37
5
|
constructor(app) {
|
|
38
6
|
this.app = app;
|
|
@@ -40,7 +8,7 @@ class CapacitorApp {
|
|
|
40
8
|
project;
|
|
41
9
|
iosTargetName = "App";
|
|
42
10
|
async init() {
|
|
43
|
-
const project = new
|
|
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 =
|
|
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 =
|
|
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${
|
|
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,3 +119,6 @@ class CapacitorApp {
|
|
|
151
119
|
return this.#getPermissionsInAndroid().includes(permission);
|
|
152
120
|
}
|
|
153
121
|
}
|
|
122
|
+
export {
|
|
123
|
+
CapacitorApp
|
|
124
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -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
|
};
|
|
@@ -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
|
+
};
|
|
@@ -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";
|
|
@@ -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
|
+
};
|
|
@@ -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);
|
package/src/constants.js
CHANGED
|
@@ -1,33 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 constants_exports = {};
|
|
19
|
-
__export(constants_exports, {
|
|
20
|
-
akanCloudBackendUrl: () => akanCloudBackendUrl,
|
|
21
|
-
akanCloudClientUrl: () => akanCloudClientUrl,
|
|
22
|
-
akanCloudHost: () => akanCloudHost,
|
|
23
|
-
basePath: () => basePath,
|
|
24
|
-
configPath: () => configPath,
|
|
25
|
-
defaultAkanGlobalConfig: () => defaultAkanGlobalConfig,
|
|
26
|
-
defaultHostConfig: () => defaultHostConfig
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(constants_exports);
|
|
29
|
-
var import_os = require("os");
|
|
30
|
-
const basePath = `${(0, import_os.homedir)()}/.akan`;
|
|
1
|
+
import { homedir } from "os";
|
|
2
|
+
const basePath = `${homedir()}/.akan`;
|
|
31
3
|
const configPath = `${basePath}/config.json`;
|
|
32
4
|
const akanCloudHost = process.env.NEXT_PUBLIC_OPERATION_MODE === "local" ? "http://localhost" : "https://akasys-debug.akamir.com";
|
|
33
5
|
//! Temp
|
|
@@ -35,3 +7,12 @@ const akanCloudBackendUrl = `${akanCloudHost}${process.env.NEXT_PUBLIC_OPERATION
|
|
|
35
7
|
const akanCloudClientUrl = `${akanCloudHost}${process.env.NEXT_PUBLIC_OPERATION_MODE === "local" ? ":4200" : ""}`;
|
|
36
8
|
const defaultHostConfig = {};
|
|
37
9
|
const defaultAkanGlobalConfig = {};
|
|
10
|
+
export {
|
|
11
|
+
akanCloudBackendUrl,
|
|
12
|
+
akanCloudClientUrl,
|
|
13
|
+
akanCloudHost,
|
|
14
|
+
basePath,
|
|
15
|
+
configPath,
|
|
16
|
+
defaultAkanGlobalConfig,
|
|
17
|
+
defaultHostConfig
|
|
18
|
+
};
|