@akanjs/devkit 0.0.102 → 0.0.104
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 +21 -1
- package/index.mjs +1 -0
- package/package.json +4 -4
- package/src/aiEditor.js +56 -22
- package/src/{aiEditor.cjs → aiEditor.mjs} +22 -56
- package/src/auth.js +48 -18
- package/src/auth.mjs +42 -0
- package/src/builder.js +42 -9
- package/src/{builder.cjs → builder.mjs} +9 -42
- package/src/capacitorApp.js +42 -9
- package/src/{capacitorApp.cjs → capacitorApp.mjs} +9 -42
- package/src/commandDecorators/argMeta.js +34 -3
- package/src/commandDecorators/{argMeta.cjs → argMeta.mjs} +3 -34
- package/src/commandDecorators/command.js +70 -37
- package/src/commandDecorators/{command.cjs → command.mjs} +37 -70
- package/src/commandDecorators/commandMeta.js +25 -2
- package/src/commandDecorators/commandMeta.mjs +7 -0
- package/src/commandDecorators/index.js +29 -5
- package/src/commandDecorators/index.mjs +5 -0
- package/src/commandDecorators/targetMeta.js +26 -2
- package/src/commandDecorators/targetMeta.mjs +33 -0
- package/src/commandDecorators/types.js +15 -0
- package/src/commandDecorators/types.mjs +0 -0
- package/src/constants.js +33 -4
- package/src/constants.mjs +18 -0
- package/src/createTunnel.js +27 -4
- package/src/createTunnel.mjs +26 -0
- package/src/dependencyScanner.js +38 -5
- package/src/{dependencyScanner.cjs → dependencyScanner.mjs} +5 -38
- package/src/executors.d.ts +1 -1
- package/src/executors.js +123 -89
- package/src/{executors.cjs → executors.mjs} +89 -123
- package/src/extractDeps.js +25 -2
- package/src/{extractDeps.cjs → extractDeps.mjs} +2 -25
- package/src/getCredentials.js +39 -6
- package/src/getCredentials.mjs +11 -0
- package/src/getModelFileData.js +39 -6
- package/src/getModelFileData.mjs +33 -0
- package/src/getRelatedCnsts.js +48 -9
- package/src/{getRelatedCnsts.cjs → getRelatedCnsts.mjs} +9 -48
- package/src/index.js +53 -17
- package/src/index.mjs +17 -0
- package/src/selectModel.js +39 -6
- package/src/selectModel.mjs +13 -0
- package/src/streamAi.js +30 -7
- package/src/streamAi.mjs +39 -0
- package/src/types.js +15 -0
- package/src/types.mjs +0 -0
- package/src/uploadRelease.js +48 -15
- package/src/uploadRelease.mjs +52 -0
- package/index.cjs +0 -21
- package/src/auth.cjs +0 -72
- package/src/commandDecorators/commandMeta.cjs +0 -30
- package/src/commandDecorators/index.cjs +0 -29
- package/src/commandDecorators/targetMeta.cjs +0 -57
- package/src/commandDecorators/types.cjs +0 -15
- package/src/constants.cjs +0 -47
- package/src/createTunnel.cjs +0 -49
- package/src/getCredentials.cjs +0 -44
- package/src/getModelFileData.cjs +0 -66
- package/src/index.cjs +0 -53
- package/src/selectModel.cjs +0 -46
- package/src/streamAi.cjs +0 -62
- package/src/types.cjs +0 -15
- package/src/uploadRelease.cjs +0 -85
package/src/capacitorApp.js
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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"));
|
|
4
36
|
class CapacitorApp {
|
|
5
37
|
constructor(app) {
|
|
6
38
|
this.app = app;
|
|
@@ -8,7 +40,7 @@ class CapacitorApp {
|
|
|
8
40
|
project;
|
|
9
41
|
iosTargetName = "App";
|
|
10
42
|
async init() {
|
|
11
|
-
const project = new MobileProject(this.app.cwdPath, {
|
|
43
|
+
const project = new import_project.MobileProject(this.app.cwdPath, {
|
|
12
44
|
android: { path: "android" },
|
|
13
45
|
ios: { path: "ios/App" }
|
|
14
46
|
});
|
|
@@ -26,7 +58,7 @@ class CapacitorApp {
|
|
|
26
58
|
await this.project.commit();
|
|
27
59
|
}
|
|
28
60
|
async releaseIos() {
|
|
29
|
-
const isAdded =
|
|
61
|
+
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
30
62
|
if (!isAdded) {
|
|
31
63
|
await this.app.spawn("npx cap add ios");
|
|
32
64
|
await this.app.spawn("npx @capacitor/assets generate");
|
|
@@ -35,7 +67,7 @@ class CapacitorApp {
|
|
|
35
67
|
await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "ios"]);
|
|
36
68
|
}
|
|
37
69
|
async releaseAndroid() {
|
|
38
|
-
const isAdded =
|
|
70
|
+
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
39
71
|
if (!isAdded) {
|
|
40
72
|
await this.app.spawn("npx cap add android");
|
|
41
73
|
await this.app.spawn("npx @capacitor/assets generate");
|
|
@@ -67,7 +99,7 @@ class CapacitorApp {
|
|
|
67
99
|
}
|
|
68
100
|
async #setPermissionInIos(permissions) {
|
|
69
101
|
const updateNs = Object.fromEntries(
|
|
70
|
-
Object.entries(permissions).map(([key, value]) => [`NS${capitalize(key)}`, value])
|
|
102
|
+
Object.entries(permissions).map(([key, value]) => [`NS${(0, import_common.capitalize)(key)}`, value])
|
|
71
103
|
);
|
|
72
104
|
await Promise.all([
|
|
73
105
|
this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", updateNs),
|
|
@@ -119,6 +151,7 @@ class CapacitorApp {
|
|
|
119
151
|
return this.#getPermissionsInAndroid().includes(permission);
|
|
120
152
|
}
|
|
121
153
|
}
|
|
122
|
-
export
|
|
154
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
155
|
+
0 && (module.exports = {
|
|
123
156
|
CapacitorApp
|
|
124
|
-
};
|
|
157
|
+
});
|
|
@@ -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);
|
|
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,7 +119,6 @@ class CapacitorApp {
|
|
|
151
119
|
return this.#getPermissionsInAndroid().includes(permission);
|
|
152
120
|
}
|
|
153
121
|
}
|
|
154
|
-
|
|
155
|
-
0 && (module.exports = {
|
|
122
|
+
export {
|
|
156
123
|
CapacitorApp
|
|
157
|
-
}
|
|
124
|
+
};
|
|
@@ -1,4 +1,34 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,11 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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_common = require("@akanjs/common");
|
|
34
|
+
var import_prompts = require("@inquirer/prompts");
|
|
35
|
+
var import_chalk = __toESM(require("chalk"));
|
|
36
|
+
var import_commander = require("commander");
|
|
37
|
+
var import_fs = __toESM(require("fs"));
|
|
38
|
+
var import_executors = require("../executors");
|
|
39
|
+
var import_argMeta = require("./argMeta");
|
|
40
|
+
var import_targetMeta = require("./targetMeta");
|
|
9
41
|
const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
10
42
|
const handleOption = (programCommand, argMeta) => {
|
|
11
43
|
const {
|
|
@@ -43,20 +75,20 @@ const getOptionValue = async (argMeta, opt) => {
|
|
|
43
75
|
else if (nullable)
|
|
44
76
|
return null;
|
|
45
77
|
if (choices) {
|
|
46
|
-
const choice = await select({
|
|
78
|
+
const choice = await (0, import_prompts.select)({
|
|
47
79
|
message: ask ?? desc ?? `Select the ${name} value`,
|
|
48
80
|
choices: choices.map((choice2) => choice2.toString())
|
|
49
81
|
});
|
|
50
82
|
return choice;
|
|
51
83
|
} else if (type === "boolean") {
|
|
52
84
|
const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
|
|
53
|
-
return await confirm({ message });
|
|
85
|
+
return await (0, import_prompts.confirm)({ message });
|
|
54
86
|
} else {
|
|
55
87
|
const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
56
88
|
if (argMeta.argsOption.nullable)
|
|
57
|
-
return await input({ message });
|
|
89
|
+
return await (0, import_prompts.input)({ message });
|
|
58
90
|
else
|
|
59
|
-
return convertOptionValue(await input({ message }), type ?? "string");
|
|
91
|
+
return convertOptionValue(await (0, import_prompts.input)({ message }), type ?? "string");
|
|
60
92
|
}
|
|
61
93
|
};
|
|
62
94
|
const getArgumentValue = async (argMeta, value, workspace) => {
|
|
@@ -66,46 +98,46 @@ const getArgumentValue = async (argMeta, value, workspace) => {
|
|
|
66
98
|
const [appNames, libNames] = await workspace.getSyss();
|
|
67
99
|
if (sysType === "sys") {
|
|
68
100
|
if (value && appNames.includes(value))
|
|
69
|
-
return AppExecutor.from(workspace, value);
|
|
101
|
+
return import_executors.AppExecutor.from(workspace, value);
|
|
70
102
|
else if (value && libNames.includes(value))
|
|
71
|
-
return LibExecutor.from(workspace, value);
|
|
103
|
+
return import_executors.LibExecutor.from(workspace, value);
|
|
72
104
|
else {
|
|
73
|
-
const sysName = await select({
|
|
105
|
+
const sysName = await (0, import_prompts.select)({
|
|
74
106
|
message: `Select the App or Lib name`,
|
|
75
107
|
choices: [...appNames, ...libNames]
|
|
76
108
|
});
|
|
77
109
|
if (appNames.includes(sysName))
|
|
78
|
-
return AppExecutor.from(workspace, sysName);
|
|
110
|
+
return import_executors.AppExecutor.from(workspace, sysName);
|
|
79
111
|
else if (libNames.includes(sysName))
|
|
80
|
-
return LibExecutor.from(workspace, sysName);
|
|
112
|
+
return import_executors.LibExecutor.from(workspace, sysName);
|
|
81
113
|
else
|
|
82
114
|
throw new Error(`Invalid system name: ${sysName}`);
|
|
83
115
|
}
|
|
84
116
|
} else if (sysType === "app") {
|
|
85
117
|
if (value && appNames.includes(value))
|
|
86
|
-
return AppExecutor.from(workspace, value);
|
|
87
|
-
const appName = await select({ message: `Select the ${sysType} name`, choices: appNames });
|
|
88
|
-
return AppExecutor.from(workspace, appName);
|
|
118
|
+
return import_executors.AppExecutor.from(workspace, value);
|
|
119
|
+
const appName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: appNames });
|
|
120
|
+
return import_executors.AppExecutor.from(workspace, appName);
|
|
89
121
|
} else if (sysType === "lib") {
|
|
90
122
|
if (value && libNames.includes(value))
|
|
91
|
-
return LibExecutor.from(workspace, value);
|
|
92
|
-
const libName = await select({ message: `Select the ${sysType} name`, choices: libNames });
|
|
93
|
-
return LibExecutor.from(workspace, libName);
|
|
123
|
+
return import_executors.LibExecutor.from(workspace, value);
|
|
124
|
+
const libName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: libNames });
|
|
125
|
+
return import_executors.LibExecutor.from(workspace, libName);
|
|
94
126
|
} else if (sysType === "pkg") {
|
|
95
127
|
const pkgs = await workspace.getPkgs();
|
|
96
128
|
if (value && pkgs.includes(value))
|
|
97
|
-
return PkgExecutor.from(workspace, value);
|
|
98
|
-
const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
|
|
99
|
-
return PkgExecutor.from(workspace, pkgName);
|
|
129
|
+
return import_executors.PkgExecutor.from(workspace, value);
|
|
130
|
+
const pkgName = await (0, import_prompts.select)({ message: `Select the ${sysType} name`, choices: pkgs });
|
|
131
|
+
return import_executors.PkgExecutor.from(workspace, pkgName);
|
|
100
132
|
} else
|
|
101
133
|
throw new Error(`Invalid system type: ${argMeta.type}`);
|
|
102
134
|
};
|
|
103
135
|
const runCommands = async (...commands) => {
|
|
104
|
-
const hasPackageJson =
|
|
105
|
-
const version = hasPackageJson ? JSON.parse(
|
|
106
|
-
program.version(version).description("Akan CLI");
|
|
136
|
+
const hasPackageJson = import_fs.default.existsSync(`${__dirname}/package.json`);
|
|
137
|
+
const version = hasPackageJson ? JSON.parse(import_fs.default.readFileSync(`${__dirname}/package.json`, "utf8")).version : "0.0.1";
|
|
138
|
+
import_commander.program.version(version).description("Akan CLI");
|
|
107
139
|
for (const command of commands) {
|
|
108
|
-
const targetMetas = getTargetMetas(command);
|
|
140
|
+
const targetMetas = (0, import_targetMeta.getTargetMetas)(command);
|
|
109
141
|
for (const targetMeta of targetMetas) {
|
|
110
142
|
const kebabKey = camelToKebabCase(targetMeta.key);
|
|
111
143
|
const commandNames = targetMeta.targetOption.short === true ? [
|
|
@@ -113,10 +145,10 @@ const runCommands = async (...commands) => {
|
|
|
113
145
|
typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
|
|
114
146
|
] : [kebabKey];
|
|
115
147
|
for (const commandName of commandNames) {
|
|
116
|
-
let programCommand = program.command(commandName, {
|
|
148
|
+
let programCommand = import_commander.program.command(commandName, {
|
|
117
149
|
hidden: targetMeta.targetOption.devOnly
|
|
118
150
|
});
|
|
119
|
-
const [allArgMetas] = getArgMetas(command, targetMeta.key);
|
|
151
|
+
const [allArgMetas] = (0, import_argMeta.getArgMetas)(command, targetMeta.key);
|
|
120
152
|
for (const argMeta of allArgMetas) {
|
|
121
153
|
if (argMeta.type === "Option")
|
|
122
154
|
programCommand = handleOption(programCommand, argMeta);
|
|
@@ -132,7 +164,7 @@ const runCommands = async (...commands) => {
|
|
|
132
164
|
const cmdArgs = args.slice(0, args.length - 2);
|
|
133
165
|
const opt = args[args.length - 2];
|
|
134
166
|
const commandArgs = [];
|
|
135
|
-
const workspace = WorkspaceExecutor.fromRoot();
|
|
167
|
+
const workspace = import_executors.WorkspaceExecutor.fromRoot();
|
|
136
168
|
for (const argMeta of allArgMetas) {
|
|
137
169
|
if (argMeta.type === "Option")
|
|
138
170
|
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
@@ -144,14 +176,15 @@ const runCommands = async (...commands) => {
|
|
|
144
176
|
await cmd[targetMeta.key](...commandArgs);
|
|
145
177
|
} catch (e) {
|
|
146
178
|
const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
|
|
147
|
-
Logger.error(`Command Error: ${
|
|
179
|
+
import_common.Logger.error(`Command Error: ${import_chalk.default.red(errMsg)}`);
|
|
148
180
|
}
|
|
149
181
|
});
|
|
150
182
|
}
|
|
151
183
|
}
|
|
152
184
|
}
|
|
153
|
-
await program.parseAsync(process.argv);
|
|
185
|
+
await import_commander.program.parseAsync(process.argv);
|
|
154
186
|
};
|
|
155
|
-
export
|
|
187
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
188
|
+
0 && (module.exports = {
|
|
156
189
|
runCommands
|
|
157
|
-
};
|
|
190
|
+
});
|
|
@@ -1,43 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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_common = require("@akanjs/common");
|
|
34
|
-
var import_prompts = require("@inquirer/prompts");
|
|
35
|
-
var import_chalk = __toESM(require("chalk"), 1);
|
|
36
|
-
var import_commander = require("commander");
|
|
37
|
-
var import_fs = __toESM(require("fs"), 1);
|
|
38
|
-
var import_executors = require("../executors");
|
|
39
|
-
var import_argMeta = require("./argMeta");
|
|
40
|
-
var import_targetMeta = require("./targetMeta");
|
|
1
|
+
import { Logger } from "@akanjs/common";
|
|
2
|
+
import { confirm, input, select } from "@inquirer/prompts";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import { AppExecutor, LibExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
|
|
7
|
+
import { getArgMetas } from "./argMeta";
|
|
8
|
+
import { getTargetMetas } from "./targetMeta";
|
|
41
9
|
const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
42
10
|
const handleOption = (programCommand, argMeta) => {
|
|
43
11
|
const {
|
|
@@ -75,20 +43,20 @@ const getOptionValue = async (argMeta, opt) => {
|
|
|
75
43
|
else if (nullable)
|
|
76
44
|
return null;
|
|
77
45
|
if (choices) {
|
|
78
|
-
const choice = await
|
|
46
|
+
const choice = await select({
|
|
79
47
|
message: ask ?? desc ?? `Select the ${name} value`,
|
|
80
48
|
choices: choices.map((choice2) => choice2.toString())
|
|
81
49
|
});
|
|
82
50
|
return choice;
|
|
83
51
|
} else if (type === "boolean") {
|
|
84
52
|
const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
|
|
85
|
-
return await
|
|
53
|
+
return await confirm({ message });
|
|
86
54
|
} else {
|
|
87
55
|
const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
88
56
|
if (argMeta.argsOption.nullable)
|
|
89
|
-
return await
|
|
57
|
+
return await input({ message });
|
|
90
58
|
else
|
|
91
|
-
return convertOptionValue(await
|
|
59
|
+
return convertOptionValue(await input({ message }), type ?? "string");
|
|
92
60
|
}
|
|
93
61
|
};
|
|
94
62
|
const getArgumentValue = async (argMeta, value, workspace) => {
|
|
@@ -98,46 +66,46 @@ const getArgumentValue = async (argMeta, value, workspace) => {
|
|
|
98
66
|
const [appNames, libNames] = await workspace.getSyss();
|
|
99
67
|
if (sysType === "sys") {
|
|
100
68
|
if (value && appNames.includes(value))
|
|
101
|
-
return
|
|
69
|
+
return AppExecutor.from(workspace, value);
|
|
102
70
|
else if (value && libNames.includes(value))
|
|
103
|
-
return
|
|
71
|
+
return LibExecutor.from(workspace, value);
|
|
104
72
|
else {
|
|
105
|
-
const sysName = await
|
|
73
|
+
const sysName = await select({
|
|
106
74
|
message: `Select the App or Lib name`,
|
|
107
75
|
choices: [...appNames, ...libNames]
|
|
108
76
|
});
|
|
109
77
|
if (appNames.includes(sysName))
|
|
110
|
-
return
|
|
78
|
+
return AppExecutor.from(workspace, sysName);
|
|
111
79
|
else if (libNames.includes(sysName))
|
|
112
|
-
return
|
|
80
|
+
return LibExecutor.from(workspace, sysName);
|
|
113
81
|
else
|
|
114
82
|
throw new Error(`Invalid system name: ${sysName}`);
|
|
115
83
|
}
|
|
116
84
|
} else if (sysType === "app") {
|
|
117
85
|
if (value && appNames.includes(value))
|
|
118
|
-
return
|
|
119
|
-
const appName = await
|
|
120
|
-
return
|
|
86
|
+
return AppExecutor.from(workspace, value);
|
|
87
|
+
const appName = await select({ message: `Select the ${sysType} name`, choices: appNames });
|
|
88
|
+
return AppExecutor.from(workspace, appName);
|
|
121
89
|
} else if (sysType === "lib") {
|
|
122
90
|
if (value && libNames.includes(value))
|
|
123
|
-
return
|
|
124
|
-
const libName = await
|
|
125
|
-
return
|
|
91
|
+
return LibExecutor.from(workspace, value);
|
|
92
|
+
const libName = await select({ message: `Select the ${sysType} name`, choices: libNames });
|
|
93
|
+
return LibExecutor.from(workspace, libName);
|
|
126
94
|
} else if (sysType === "pkg") {
|
|
127
95
|
const pkgs = await workspace.getPkgs();
|
|
128
96
|
if (value && pkgs.includes(value))
|
|
129
|
-
return
|
|
130
|
-
const pkgName = await
|
|
131
|
-
return
|
|
97
|
+
return PkgExecutor.from(workspace, value);
|
|
98
|
+
const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
|
|
99
|
+
return PkgExecutor.from(workspace, pkgName);
|
|
132
100
|
} else
|
|
133
101
|
throw new Error(`Invalid system type: ${argMeta.type}`);
|
|
134
102
|
};
|
|
135
103
|
const runCommands = async (...commands) => {
|
|
136
|
-
const hasPackageJson =
|
|
137
|
-
const version = hasPackageJson ? JSON.parse(
|
|
138
|
-
|
|
104
|
+
const hasPackageJson = fs.existsSync(`${__dirname}/package.json`);
|
|
105
|
+
const version = hasPackageJson ? JSON.parse(fs.readFileSync(`${__dirname}/package.json`, "utf8")).version : "0.0.1";
|
|
106
|
+
program.version(version).description("Akan CLI");
|
|
139
107
|
for (const command of commands) {
|
|
140
|
-
const targetMetas =
|
|
108
|
+
const targetMetas = getTargetMetas(command);
|
|
141
109
|
for (const targetMeta of targetMetas) {
|
|
142
110
|
const kebabKey = camelToKebabCase(targetMeta.key);
|
|
143
111
|
const commandNames = targetMeta.targetOption.short === true ? [
|
|
@@ -145,10 +113,10 @@ const runCommands = async (...commands) => {
|
|
|
145
113
|
typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
|
|
146
114
|
] : [kebabKey];
|
|
147
115
|
for (const commandName of commandNames) {
|
|
148
|
-
let programCommand =
|
|
116
|
+
let programCommand = program.command(commandName, {
|
|
149
117
|
hidden: targetMeta.targetOption.devOnly
|
|
150
118
|
});
|
|
151
|
-
const [allArgMetas] =
|
|
119
|
+
const [allArgMetas] = getArgMetas(command, targetMeta.key);
|
|
152
120
|
for (const argMeta of allArgMetas) {
|
|
153
121
|
if (argMeta.type === "Option")
|
|
154
122
|
programCommand = handleOption(programCommand, argMeta);
|
|
@@ -164,7 +132,7 @@ const runCommands = async (...commands) => {
|
|
|
164
132
|
const cmdArgs = args.slice(0, args.length - 2);
|
|
165
133
|
const opt = args[args.length - 2];
|
|
166
134
|
const commandArgs = [];
|
|
167
|
-
const workspace =
|
|
135
|
+
const workspace = WorkspaceExecutor.fromRoot();
|
|
168
136
|
for (const argMeta of allArgMetas) {
|
|
169
137
|
if (argMeta.type === "Option")
|
|
170
138
|
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
@@ -176,15 +144,14 @@ const runCommands = async (...commands) => {
|
|
|
176
144
|
await cmd[targetMeta.key](...commandArgs);
|
|
177
145
|
} catch (e) {
|
|
178
146
|
const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
|
|
179
|
-
|
|
147
|
+
Logger.error(`Command Error: ${chalk.red(errMsg)}`);
|
|
180
148
|
}
|
|
181
149
|
});
|
|
182
150
|
}
|
|
183
151
|
}
|
|
184
152
|
}
|
|
185
|
-
await
|
|
153
|
+
await program.parseAsync(process.argv);
|
|
186
154
|
};
|
|
187
|
-
|
|
188
|
-
0 && (module.exports = {
|
|
155
|
+
export {
|
|
189
156
|
runCommands
|
|
190
|
-
}
|
|
157
|
+
};
|