@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
package/index.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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 devkit_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(devkit_exports);
|
|
17
|
+
__reExport(devkit_exports, require("./src"), module.exports);
|
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.55",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -28,5 +28,11 @@
|
|
|
28
28
|
"reflect-metadata": "^0.2.2",
|
|
29
29
|
"tunnel-ssh": "^5.2.0",
|
|
30
30
|
"typescript": "^5.8.3"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"require": "./index.cjs",
|
|
35
|
+
"import": "./index.js"
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
}
|
package/src/aiEditor.cjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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 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");
|
|
26
|
+
class AiEditor {
|
|
27
|
+
chat;
|
|
28
|
+
constructor(apiKey = process.env.DEEPSEEK_API_KEY) {
|
|
29
|
+
this.chat = new import_openai.ChatOpenAI({
|
|
30
|
+
modelName: "deepseek-reasoner",
|
|
31
|
+
temperature: 0.7,
|
|
32
|
+
streaming: true,
|
|
33
|
+
// Enable streaming
|
|
34
|
+
configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
#createProcessingChain() {
|
|
38
|
+
return import_runnables.RunnableSequence.from([import_prompts.PromptTemplate.fromTemplate(`Answer concisely: {question}`), this.chat]);
|
|
39
|
+
}
|
|
40
|
+
async edit(question) {
|
|
41
|
+
const chain = this.#createProcessingChain();
|
|
42
|
+
const stream = await chain.stream({ question });
|
|
43
|
+
for await (const chunk of stream) {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
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.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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 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"), 1);
|
|
38
|
+
var import_constants = require("./constants");
|
|
39
|
+
const getAkanGlobalConfig = () => {
|
|
40
|
+
const akanConfig = import_fs.default.existsSync(import_constants.configPath) ? JSON.parse(import_fs.default.readFileSync(import_constants.configPath, "utf8")) : import_constants.defaultAkanGlobalConfig;
|
|
41
|
+
return akanConfig;
|
|
42
|
+
};
|
|
43
|
+
const setAkanGlobalConfig = (akanConfig) => {
|
|
44
|
+
import_fs.default.mkdirSync(import_constants.basePath, { recursive: true });
|
|
45
|
+
import_fs.default.writeFileSync(import_constants.configPath, JSON.stringify(akanConfig, null, 2));
|
|
46
|
+
};
|
|
47
|
+
const getHostConfig = (host = import_constants.akanCloudHost) => {
|
|
48
|
+
const akanConfig = getAkanGlobalConfig();
|
|
49
|
+
return akanConfig[host] ?? import_constants.defaultHostConfig;
|
|
50
|
+
};
|
|
51
|
+
const setHostConfig = (host = import_constants.akanCloudHost, config = {}) => {
|
|
52
|
+
const akanConfig = getAkanGlobalConfig();
|
|
53
|
+
akanConfig[host] = config;
|
|
54
|
+
setAkanGlobalConfig(akanConfig);
|
|
55
|
+
};
|
|
56
|
+
const getSelf = async (token) => {
|
|
57
|
+
try {
|
|
58
|
+
const res = await fetch(`${import_constants.akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
|
|
59
|
+
const user = await res.json();
|
|
60
|
+
return user;
|
|
61
|
+
} catch (e) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
};
|
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
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
const getBaseDevEnv = () => {
|
|
25
|
+
const appName = process.env.NEXT_PUBLIC_APP_NAME;
|
|
26
|
+
const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
|
|
27
|
+
if (!repoName)
|
|
28
|
+
throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
|
|
29
|
+
const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
|
|
30
|
+
if (!serveDomain)
|
|
31
|
+
throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
|
|
32
|
+
const env = process.env.NEXT_PUBLIC_ENV ?? "debug";
|
|
33
|
+
if (!env)
|
|
34
|
+
throw new Error("NEXT_PUBLIC_ENV is not set");
|
|
35
|
+
return { ...appName ? { appName } : {}, repoName, serveDomain, env };
|
|
36
|
+
};
|
|
37
|
+
const getSshTunnelOptions = (appName, environment) => {
|
|
38
|
+
const { serveDomain, repoName } = getBaseDevEnv();
|
|
39
|
+
return {
|
|
40
|
+
host: `${appName}-${environment}.${serveDomain}`,
|
|
41
|
+
port: process.env.SSU_TUNNEL_PORT ? parseInt(process.env.SSU_TUNNEL_PORT) : 32767,
|
|
42
|
+
username: process.env.SSU_TUNNEL_USERNAME ?? "root",
|
|
43
|
+
password: process.env.SSU_TUNNEL_PASSWORD ?? repoName
|
|
44
|
+
};
|
|
45
|
+
};
|
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
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
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"), 1);
|
|
36
|
+
class CapacitorApp {
|
|
37
|
+
constructor(app) {
|
|
38
|
+
this.app = app;
|
|
39
|
+
}
|
|
40
|
+
project;
|
|
41
|
+
iosTargetName = "App";
|
|
42
|
+
async init() {
|
|
43
|
+
const project = new import_project.MobileProject(this.app.cwdPath, {
|
|
44
|
+
android: { path: "android" },
|
|
45
|
+
ios: { path: "ios/App" }
|
|
46
|
+
});
|
|
47
|
+
await project.load();
|
|
48
|
+
if (!project.android)
|
|
49
|
+
throw new Error(`Android is not added, Please add platform first
|
|
50
|
+
akan serve-android ${this.app.name}`);
|
|
51
|
+
if (!project.ios)
|
|
52
|
+
throw new Error(`iOS is not added, Please add platform first
|
|
53
|
+
akan serve-ios ${this.app.name}`);
|
|
54
|
+
this.project = project;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
async save() {
|
|
58
|
+
await this.project.commit();
|
|
59
|
+
}
|
|
60
|
+
async releaseIos() {
|
|
61
|
+
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
62
|
+
if (!isAdded) {
|
|
63
|
+
await this.app.spawn("npx cap add ios");
|
|
64
|
+
await this.app.spawn("npx @capacitor/assets generate");
|
|
65
|
+
} else
|
|
66
|
+
this.app.log(`iOS already added, skip adding process`);
|
|
67
|
+
await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "ios"]);
|
|
68
|
+
}
|
|
69
|
+
async releaseAndroid() {
|
|
70
|
+
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
71
|
+
if (!isAdded) {
|
|
72
|
+
await this.app.spawn("npx cap add android");
|
|
73
|
+
await this.app.spawn("npx @capacitor/assets generate");
|
|
74
|
+
} else
|
|
75
|
+
this.app.log(`android already added, skip adding process`);
|
|
76
|
+
await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "android"]);
|
|
77
|
+
}
|
|
78
|
+
async addCamera() {
|
|
79
|
+
await this.#setPermissionInIos({
|
|
80
|
+
cameraUsageDescription: "$(PRODUCT_NAME) requires access to the camera to take photos.",
|
|
81
|
+
photoAddUsageDescription: "$(PRODUCT_NAME) requires access to the photo library to take photos.",
|
|
82
|
+
photoUsageDescription: "$(PRODUCT_NAME) requires access to the photo library to take photos."
|
|
83
|
+
});
|
|
84
|
+
this.#setPermissionsInAndroid(["READ_MEDIA_IMAGES", "READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"]);
|
|
85
|
+
}
|
|
86
|
+
async addContact() {
|
|
87
|
+
await this.#setPermissionInIos({
|
|
88
|
+
contactsUsageDescription: "$(PRODUCT_NAME) requires access to the contacts to add new contacts."
|
|
89
|
+
});
|
|
90
|
+
this.#setPermissionsInAndroid(["READ_CONTACTS", "WRITE_CONTACTS"]);
|
|
91
|
+
}
|
|
92
|
+
async addLocation() {
|
|
93
|
+
await this.#setPermissionInIos({
|
|
94
|
+
locationAlwaysUsageDescription: "$(PRODUCT_NAME) requires access to the location to get the user's location.",
|
|
95
|
+
locationWhenInUseUsageDescription: "$(PRODUCT_NAME) requires access to the location to get the user's location."
|
|
96
|
+
});
|
|
97
|
+
this.#setPermissionsInAndroid(["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION"]);
|
|
98
|
+
this.#setFeaturesInAndroid(["android.hardware.location.gps"]);
|
|
99
|
+
}
|
|
100
|
+
async #setPermissionInIos(permissions) {
|
|
101
|
+
const updateNs = Object.fromEntries(
|
|
102
|
+
Object.entries(permissions).map(([key, value]) => [`NS${(0, import_common.capitalize)(key)}`, value])
|
|
103
|
+
);
|
|
104
|
+
await Promise.all([
|
|
105
|
+
this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", updateNs),
|
|
106
|
+
this.project.ios.updateInfoPlist(this.iosTargetName, "Release", updateNs)
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
#setFeaturesInAndroid(features) {
|
|
110
|
+
for (const feature of features) {
|
|
111
|
+
if (this.#hasFeatureInAndroid(feature)) {
|
|
112
|
+
this.app.logger.info(`${feature} already exists in android`);
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
this.app.logger.info(`Adding ${feature} to android`);
|
|
116
|
+
this.project.android.getAndroidManifest().injectFragment("manifest", `<uses-feature android:name="${feature}" />`);
|
|
117
|
+
}
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
#getFeaturesInAndroid() {
|
|
121
|
+
const androidManifest = this.project.android.getAndroidManifest();
|
|
122
|
+
const element = androidManifest.getDocumentElement();
|
|
123
|
+
if (!element)
|
|
124
|
+
throw new Error("manifest not found");
|
|
125
|
+
const usesFeature = element.getElementsByTagName("uses-feature");
|
|
126
|
+
return Array.from(usesFeature).map((feature) => feature.getAttribute("android:name"));
|
|
127
|
+
}
|
|
128
|
+
#hasFeatureInAndroid(feature) {
|
|
129
|
+
return this.#getFeaturesInAndroid().includes(feature);
|
|
130
|
+
}
|
|
131
|
+
#setPermissionsInAndroid(permissions) {
|
|
132
|
+
for (const permission of permissions) {
|
|
133
|
+
if (this.#hasPermissionInAndroid(permission)) {
|
|
134
|
+
this.app.logger.info(`${permission} already exists in android`);
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
this.app.logger.info(`Adding ${permission} to android`);
|
|
138
|
+
this.project.android.getAndroidManifest().injectFragment("manifest", `<uses-permission android:name="android.permission.${permission}" />`);
|
|
139
|
+
}
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
#getPermissionsInAndroid() {
|
|
143
|
+
const androidManifest = this.project.android.getAndroidManifest();
|
|
144
|
+
const element = androidManifest.getDocumentElement();
|
|
145
|
+
if (!element)
|
|
146
|
+
throw new Error("manifest not found");
|
|
147
|
+
const usesPermission = element.getElementsByTagName("uses-permission");
|
|
148
|
+
return Array.from(usesPermission).map((permission) => permission.getAttribute("android:name"));
|
|
149
|
+
}
|
|
150
|
+
#hasPermissionInAndroid(permission) {
|
|
151
|
+
return this.#getPermissionsInAndroid().includes(permission);
|
|
152
|
+
}
|
|
153
|
+
}
|
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
|
+
};
|