@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/src/createTunnel.js
CHANGED
|
@@ -1,30 +1,8 @@
|
|
|
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 createTunnel_exports = {};
|
|
19
|
-
__export(createTunnel_exports, {
|
|
20
|
-
createTunnel: () => createTunnel
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(createTunnel_exports);
|
|
23
|
-
var import_tunnel_ssh = require("tunnel-ssh");
|
|
24
|
-
var import_baseDevEnv = require("./baseDevEnv");
|
|
1
|
+
import { createTunnel as create } from "tunnel-ssh";
|
|
2
|
+
import { getSshTunnelOptions } from "./baseDevEnv";
|
|
25
3
|
const createTunnel = async ({ appName, environment, port = 27017 }) => {
|
|
26
4
|
const tunnelOptions = { autoClose: true, reconnectOnError: true };
|
|
27
|
-
const sshOptions =
|
|
5
|
+
const sshOptions = getSshTunnelOptions(appName, environment);
|
|
28
6
|
const serverOptions = { port };
|
|
29
7
|
const forwardOptions = {
|
|
30
8
|
srcAddr: "0.0.0.0",
|
|
@@ -32,6 +10,9 @@ const createTunnel = async ({ appName, environment, port = 27017 }) => {
|
|
|
32
10
|
dstAddr: `mongo-0.mongo-svc.${appName}-${environment}`,
|
|
33
11
|
dstPort: 27017
|
|
34
12
|
};
|
|
35
|
-
const [server, client] = await (
|
|
13
|
+
const [server, client] = await create(tunnelOptions, serverOptions, sshOptions, forwardOptions);
|
|
36
14
|
return `localhost:${port}`;
|
|
37
15
|
};
|
|
16
|
+
export {
|
|
17
|
+
createTunnel
|
|
18
|
+
};
|
package/src/dependencyScanner.js
CHANGED
|
@@ -1,39 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var dependencyScanner_exports = {};
|
|
30
|
-
__export(dependencyScanner_exports, {
|
|
31
|
-
TypeScriptDependencyScanner: () => TypeScriptDependencyScanner
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(dependencyScanner_exports);
|
|
34
|
-
var fs = __toESM(require("fs"));
|
|
35
|
-
var path = __toESM(require("path"));
|
|
36
|
-
var ts = __toESM(require("typescript"));
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import * as ts from "typescript";
|
|
37
5
|
class TypeScriptDependencyScanner {
|
|
38
6
|
constructor(directory) {
|
|
39
7
|
this.directory = directory;
|
|
@@ -157,3 +125,6 @@ class TypeScriptDependencyScanner {
|
|
|
157
125
|
return graph;
|
|
158
126
|
}
|
|
159
127
|
}
|
|
128
|
+
export {
|
|
129
|
+
TypeScriptDependencyScanner
|
|
130
|
+
};
|
package/src/executors.js
CHANGED
|
@@ -1,67 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 executors_exports = {};
|
|
29
|
-
__export(executors_exports, {
|
|
30
|
-
AppExecutor: () => AppExecutor,
|
|
31
|
-
DistAppExecutor: () => DistAppExecutor,
|
|
32
|
-
DistLibExecutor: () => DistLibExecutor,
|
|
33
|
-
DistPkgExecutor: () => DistPkgExecutor,
|
|
34
|
-
Executor: () => Executor,
|
|
35
|
-
LibExecutor: () => LibExecutor,
|
|
36
|
-
PkgExecutor: () => PkgExecutor,
|
|
37
|
-
SysExecutor: () => SysExecutor,
|
|
38
|
-
WorkspaceExecutor: () => WorkspaceExecutor
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(executors_exports);
|
|
41
|
-
var import_common = require("@akanjs/common");
|
|
42
|
-
var import_config = require("@akanjs/config");
|
|
43
|
-
var import_child_process = require("child_process");
|
|
44
|
-
var import_fs = __toESM(require("fs"));
|
|
45
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
46
|
-
var import_path = __toESM(require("path"));
|
|
47
|
-
var import_baseDevEnv = require("./baseDevEnv");
|
|
48
|
-
var import_dependencyScanner = require("./dependencyScanner");
|
|
1
|
+
import { Logger } from "@akanjs/common";
|
|
2
|
+
import {
|
|
3
|
+
getAppConfig,
|
|
4
|
+
getDefaultFileScan,
|
|
5
|
+
getLibConfig
|
|
6
|
+
} from "@akanjs/config";
|
|
7
|
+
import { exec, fork, spawn } from "child_process";
|
|
8
|
+
import fs from "fs";
|
|
9
|
+
import fsPromise from "fs/promises";
|
|
10
|
+
import path from "path";
|
|
11
|
+
import { getBaseDevEnv } from "./baseDevEnv";
|
|
12
|
+
import { TypeScriptDependencyScanner } from "./dependencyScanner";
|
|
49
13
|
class Executor {
|
|
50
14
|
logger;
|
|
51
15
|
cwdPath;
|
|
52
16
|
constructor(name, cwdPath) {
|
|
53
|
-
this.logger = new
|
|
17
|
+
this.logger = new Logger(name);
|
|
54
18
|
this.cwdPath = cwdPath;
|
|
55
|
-
if (!
|
|
56
|
-
|
|
19
|
+
if (!fs.existsSync(cwdPath))
|
|
20
|
+
fs.mkdirSync(cwdPath, { recursive: true });
|
|
57
21
|
}
|
|
58
22
|
exec(command, options = {}) {
|
|
59
|
-
const proc =
|
|
23
|
+
const proc = exec(command, { cwd: this.cwdPath, ...options });
|
|
60
24
|
proc.stdout?.on("data", (data) => {
|
|
61
|
-
|
|
25
|
+
Logger.raw(data.toString());
|
|
62
26
|
});
|
|
63
27
|
proc.stderr?.on("data", (data) => {
|
|
64
|
-
|
|
28
|
+
Logger.raw(data.toString());
|
|
65
29
|
});
|
|
66
30
|
return new Promise((resolve, reject) => {
|
|
67
31
|
proc.on("exit", (code, signal) => {
|
|
@@ -73,9 +37,9 @@ class Executor {
|
|
|
73
37
|
});
|
|
74
38
|
}
|
|
75
39
|
spawn(command, args = [], options = {}) {
|
|
76
|
-
const proc =
|
|
40
|
+
const proc = spawn(command, args, { cwd: this.cwdPath, stdio: "inherit", ...options });
|
|
77
41
|
proc.stderr?.on("data", (data) => {
|
|
78
|
-
|
|
42
|
+
Logger.raw(data.toString());
|
|
79
43
|
});
|
|
80
44
|
return new Promise((resolve, reject) => {
|
|
81
45
|
proc.on("exit", (code, signal) => {
|
|
@@ -87,16 +51,16 @@ class Executor {
|
|
|
87
51
|
});
|
|
88
52
|
}
|
|
89
53
|
fork(modulePath, args = [], options = {}) {
|
|
90
|
-
const proc =
|
|
54
|
+
const proc = fork(modulePath, args, {
|
|
91
55
|
cwd: this.cwdPath,
|
|
92
56
|
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
93
57
|
...options
|
|
94
58
|
});
|
|
95
59
|
proc.stdout?.on("data", (data) => {
|
|
96
|
-
|
|
60
|
+
Logger.raw(data.toString());
|
|
97
61
|
});
|
|
98
62
|
proc.stderr?.on("data", (data) => {
|
|
99
|
-
|
|
63
|
+
Logger.raw(data.toString());
|
|
100
64
|
});
|
|
101
65
|
return new Promise((resolve, reject) => {
|
|
102
66
|
proc.on("exit", (code, signal) => {
|
|
@@ -108,28 +72,28 @@ class Executor {
|
|
|
108
72
|
});
|
|
109
73
|
}
|
|
110
74
|
mkdir(dirPath) {
|
|
111
|
-
const writePath =
|
|
112
|
-
if (!
|
|
113
|
-
|
|
75
|
+
const writePath = path.isAbsolute(dirPath) ? dirPath : `${this.cwdPath}/${dirPath}`;
|
|
76
|
+
if (!fs.existsSync(writePath))
|
|
77
|
+
fs.mkdirSync(writePath, { recursive: true });
|
|
114
78
|
this.logger.verbose(`Make directory ${writePath}`);
|
|
115
79
|
return this;
|
|
116
80
|
}
|
|
117
81
|
writeFile(filePath, content) {
|
|
118
|
-
const writePath =
|
|
119
|
-
const dir =
|
|
120
|
-
if (!
|
|
121
|
-
|
|
82
|
+
const writePath = path.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
83
|
+
const dir = path.dirname(writePath);
|
|
84
|
+
if (!fs.existsSync(dir))
|
|
85
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
122
86
|
const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
123
|
-
if (
|
|
124
|
-
const currentContent =
|
|
87
|
+
if (fs.existsSync(writePath)) {
|
|
88
|
+
const currentContent = fs.readFileSync(writePath, "utf8");
|
|
125
89
|
if (currentContent === contentStr)
|
|
126
90
|
this.logger.verbose(`File ${writePath} is unchanged`);
|
|
127
91
|
else {
|
|
128
|
-
|
|
92
|
+
fs.writeFileSync(writePath, contentStr, "utf8");
|
|
129
93
|
this.logger.verbose(`File ${writePath} is changed`);
|
|
130
94
|
}
|
|
131
95
|
} else {
|
|
132
|
-
|
|
96
|
+
fs.writeFileSync(writePath, contentStr, "utf8");
|
|
133
97
|
this.logger.verbose(`File ${writePath} is created`);
|
|
134
98
|
}
|
|
135
99
|
return this;
|
|
@@ -139,17 +103,17 @@ class Executor {
|
|
|
139
103
|
return this;
|
|
140
104
|
}
|
|
141
105
|
readFile(filePath) {
|
|
142
|
-
const readPath =
|
|
143
|
-
return
|
|
106
|
+
const readPath = path.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
107
|
+
return fs.readFileSync(readPath, "utf8");
|
|
144
108
|
}
|
|
145
109
|
readJson(filePath) {
|
|
146
|
-
const readPath =
|
|
147
|
-
return JSON.parse(
|
|
110
|
+
const readPath = path.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
111
|
+
return JSON.parse(fs.readFileSync(readPath, "utf8"));
|
|
148
112
|
}
|
|
149
113
|
async cp(srcPath, destPath) {
|
|
150
|
-
const src =
|
|
151
|
-
const dest =
|
|
152
|
-
await
|
|
114
|
+
const src = path.isAbsolute(srcPath) ? srcPath : `${this.cwdPath}/${srcPath}`;
|
|
115
|
+
const dest = path.isAbsolute(destPath) ? destPath : `${this.cwdPath}/${destPath}`;
|
|
116
|
+
await fsPromise.cp(src, dest, { recursive: true });
|
|
153
117
|
}
|
|
154
118
|
log(msg) {
|
|
155
119
|
this.logger.info(msg);
|
|
@@ -188,7 +152,7 @@ class Executor {
|
|
|
188
152
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
189
153
|
this.writeFile(convertedTargetPath, content);
|
|
190
154
|
} else if (targetPath.endsWith(".template")) {
|
|
191
|
-
const content = await
|
|
155
|
+
const content = await fsPromise.readFile(templatePath, "utf8");
|
|
192
156
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
193
157
|
(path2, [key, value]) => path2.replace(new RegExp(`__${key}__`, "g"), value),
|
|
194
158
|
targetPath.slice(0, -9)
|
|
@@ -208,25 +172,25 @@ class Executor {
|
|
|
208
172
|
dict = {}
|
|
209
173
|
}) {
|
|
210
174
|
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
211
|
-
if (
|
|
212
|
-
const filename =
|
|
213
|
-
await this.#applyTemplateFile({ templatePath, targetPath:
|
|
175
|
+
if (fs.statSync(templatePath).isFile()) {
|
|
176
|
+
const filename = path.basename(templatePath);
|
|
177
|
+
await this.#applyTemplateFile({ templatePath, targetPath: path.join(basePath, filename), scanResult }, dict);
|
|
214
178
|
} else {
|
|
215
|
-
if (!
|
|
216
|
-
await
|
|
217
|
-
const subdirs = await
|
|
179
|
+
if (!fs.existsSync(basePath))
|
|
180
|
+
await fsPromise.mkdir(basePath, { recursive: true });
|
|
181
|
+
const subdirs = await fsPromise.readdir(templatePath);
|
|
218
182
|
await Promise.all(
|
|
219
183
|
subdirs.map(async (subdir) => {
|
|
220
|
-
const subpath =
|
|
221
|
-
if (
|
|
184
|
+
const subpath = path.join(templatePath, subdir);
|
|
185
|
+
if (fs.statSync(subpath).isFile())
|
|
222
186
|
await this.#applyTemplateFile(
|
|
223
|
-
{ templatePath: subpath, targetPath:
|
|
187
|
+
{ templatePath: subpath, targetPath: path.join(basePath, subdir), scanResult },
|
|
224
188
|
dict
|
|
225
189
|
);
|
|
226
190
|
else
|
|
227
191
|
await this.applyTemplate({
|
|
228
|
-
basePath:
|
|
229
|
-
template:
|
|
192
|
+
basePath: path.join(basePath, subdir),
|
|
193
|
+
template: path.join(template, subdir),
|
|
230
194
|
scanResult,
|
|
231
195
|
dict
|
|
232
196
|
});
|
|
@@ -244,7 +208,7 @@ class WorkspaceExecutor extends Executor {
|
|
|
244
208
|
this.repoName = repoName;
|
|
245
209
|
}
|
|
246
210
|
static fromRoot() {
|
|
247
|
-
const repoName =
|
|
211
|
+
const repoName = path.basename(process.cwd());
|
|
248
212
|
return new WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
|
|
249
213
|
}
|
|
250
214
|
async scan() {
|
|
@@ -295,14 +259,14 @@ class WorkspaceExecutor extends Executor {
|
|
|
295
259
|
async #getDirHasFile(basePath, targetFilename) {
|
|
296
260
|
const AVOID_DIRS = ["node_modules", "dist", "public", "./next"];
|
|
297
261
|
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
298
|
-
const dirs = await
|
|
262
|
+
const dirs = await fsPromise.readdir(dirname);
|
|
299
263
|
await Promise.all(
|
|
300
264
|
dirs.map(async (dir) => {
|
|
301
265
|
if (AVOID_DIRS.includes(dir))
|
|
302
266
|
return;
|
|
303
|
-
const dirPath =
|
|
304
|
-
if (
|
|
305
|
-
const hasTargetFile =
|
|
267
|
+
const dirPath = path.join(dirname, dir);
|
|
268
|
+
if (fs.lstatSync(dirPath).isDirectory()) {
|
|
269
|
+
const hasTargetFile = fs.existsSync(path.join(dirPath, targetFilename));
|
|
306
270
|
if (hasTargetFile)
|
|
307
271
|
results.push(`${prefix}${dir}`);
|
|
308
272
|
if (maxDepth > 0)
|
|
@@ -326,7 +290,7 @@ class SysExecutor extends Executor {
|
|
|
326
290
|
this.type = type;
|
|
327
291
|
}
|
|
328
292
|
async getConfig(command) {
|
|
329
|
-
return this.type === "app" ? await
|
|
293
|
+
return this.type === "app" ? await getAppConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command }) : await getLibConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
|
|
330
294
|
}
|
|
331
295
|
async scan({
|
|
332
296
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
|
|
@@ -335,7 +299,7 @@ class SysExecutor extends Executor {
|
|
|
335
299
|
if (libScanResults[this.name])
|
|
336
300
|
return libScanResults[this.name];
|
|
337
301
|
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
338
|
-
const scanner = new
|
|
302
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
339
303
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
340
304
|
const pkgPathSet = new Set(
|
|
341
305
|
Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
|
|
@@ -352,17 +316,17 @@ class SysExecutor extends Executor {
|
|
|
352
316
|
const pathSplitLength = path2.split("/").length;
|
|
353
317
|
return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
354
318
|
}).filter((libName) => libName !== this.name);
|
|
355
|
-
if (!
|
|
356
|
-
|
|
357
|
-
const files =
|
|
358
|
-
const dirnames = (await
|
|
359
|
-
(name) =>
|
|
319
|
+
if (!fs.existsSync(`${this.cwdPath}/lib/__scalar`))
|
|
320
|
+
fs.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
|
|
321
|
+
const files = getDefaultFileScan();
|
|
322
|
+
const dirnames = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter(
|
|
323
|
+
(name) => fs.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
|
|
360
324
|
);
|
|
361
325
|
const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
|
|
362
326
|
const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
|
|
363
327
|
await Promise.all(
|
|
364
328
|
databaseDirs.map(async (name) => {
|
|
365
|
-
const filenames = await
|
|
329
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", name));
|
|
366
330
|
filenames.forEach((filename) => {
|
|
367
331
|
if (filename.endsWith(".constant.ts"))
|
|
368
332
|
files.constants.databases.push(name);
|
|
@@ -384,7 +348,7 @@ class SysExecutor extends Executor {
|
|
|
384
348
|
await Promise.all(
|
|
385
349
|
serviceDirs.map(async (dirname) => {
|
|
386
350
|
const name = dirname.slice(1);
|
|
387
|
-
const filenames = await
|
|
351
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", dirname));
|
|
388
352
|
filenames.forEach((filename) => {
|
|
389
353
|
if (filename.endsWith(".dictionary.ts"))
|
|
390
354
|
files.dictionary.services.push(name);
|
|
@@ -399,12 +363,12 @@ class SysExecutor extends Executor {
|
|
|
399
363
|
});
|
|
400
364
|
})
|
|
401
365
|
);
|
|
402
|
-
const scalarDirs = (await
|
|
366
|
+
const scalarDirs = (await fsPromise.readdir(`${this.cwdPath}/lib/__scalar`)).filter(
|
|
403
367
|
(name) => !name.startsWith("_")
|
|
404
368
|
);
|
|
405
369
|
await Promise.all(
|
|
406
370
|
scalarDirs.map(async (name) => {
|
|
407
|
-
const filenames = await
|
|
371
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib/__scalar", name));
|
|
408
372
|
filenames.forEach((filename) => {
|
|
409
373
|
if (filename.endsWith(".constant.ts"))
|
|
410
374
|
files.constants.scalars.push(name);
|
|
@@ -458,15 +422,15 @@ class SysExecutor extends Executor {
|
|
|
458
422
|
return scanResult;
|
|
459
423
|
}
|
|
460
424
|
async getDatabaseModules() {
|
|
461
|
-
const databaseModules = (await
|
|
425
|
+
const databaseModules = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter((name) => !name.startsWith("_")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/${name}/${name}.constant.ts`));
|
|
462
426
|
return databaseModules;
|
|
463
427
|
}
|
|
464
428
|
async getServiceModules() {
|
|
465
|
-
const serviceModules = (await
|
|
429
|
+
const serviceModules = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/${name}/${name}.service.ts`));
|
|
466
430
|
return serviceModules;
|
|
467
431
|
}
|
|
468
432
|
async getScalarModules() {
|
|
469
|
-
const scalarModules = (await
|
|
433
|
+
const scalarModules = (await fsPromise.readdir(`${this.cwdPath}/lib/__scalar`)).filter((name) => !name.startsWith("_")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/__scalar/${name}/${name}.constant.ts`));
|
|
470
434
|
return scalarModules;
|
|
471
435
|
}
|
|
472
436
|
}
|
|
@@ -480,17 +444,17 @@ class AppExecutor extends SysExecutor {
|
|
|
480
444
|
return new AppExecutor({ workspace: executor.workspace, name });
|
|
481
445
|
}
|
|
482
446
|
async getConfig(command) {
|
|
483
|
-
return await
|
|
447
|
+
return await getAppConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
|
|
484
448
|
}
|
|
485
449
|
async syncAssets(libDeps) {
|
|
486
450
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
487
|
-
if (
|
|
488
|
-
await
|
|
489
|
-
const targetDeps = libDeps.filter((dep) =>
|
|
490
|
-
await Promise.all(targetDeps.map((dep) =>
|
|
451
|
+
if (fs.existsSync(projectPublicLibPath))
|
|
452
|
+
await fsPromise.rm(projectPublicLibPath, { recursive: true });
|
|
453
|
+
const targetDeps = libDeps.filter((dep) => fs.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
|
|
454
|
+
await Promise.all(targetDeps.map((dep) => fsPromise.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
|
|
491
455
|
await Promise.all(
|
|
492
456
|
targetDeps.map(
|
|
493
|
-
(dep) =>
|
|
457
|
+
(dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
494
458
|
recursive: true
|
|
495
459
|
})
|
|
496
460
|
)
|
|
@@ -521,7 +485,7 @@ class LibExecutor extends SysExecutor {
|
|
|
521
485
|
return new LibExecutor({ workspace: executor.workspace, name });
|
|
522
486
|
}
|
|
523
487
|
async getConfig(command) {
|
|
524
|
-
return await
|
|
488
|
+
return await getLibConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
|
|
525
489
|
}
|
|
526
490
|
}
|
|
527
491
|
class DistLibExecutor extends Executor {
|
|
@@ -554,7 +518,7 @@ class PkgExecutor extends Executor {
|
|
|
554
518
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`)
|
|
555
519
|
} = {}) {
|
|
556
520
|
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
557
|
-
const scanner = new
|
|
521
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
558
522
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
559
523
|
const pkgPathSet = new Set(
|
|
560
524
|
Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
|
|
@@ -590,3 +554,14 @@ class DistPkgExecutor extends Executor {
|
|
|
590
554
|
});
|
|
591
555
|
}
|
|
592
556
|
}
|
|
557
|
+
export {
|
|
558
|
+
AppExecutor,
|
|
559
|
+
DistAppExecutor,
|
|
560
|
+
DistLibExecutor,
|
|
561
|
+
DistPkgExecutor,
|
|
562
|
+
Executor,
|
|
563
|
+
LibExecutor,
|
|
564
|
+
PkgExecutor,
|
|
565
|
+
SysExecutor,
|
|
566
|
+
WorkspaceExecutor
|
|
567
|
+
};
|
package/src/extractDeps.js
CHANGED
|
@@ -1,25 +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 extractDeps_exports = {};
|
|
19
|
-
__export(extractDeps_exports, {
|
|
20
|
-
extractDependencies: () => extractDependencies
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(extractDeps_exports);
|
|
23
1
|
const NODE_NATIVE_MODULE_SET = /* @__PURE__ */ new Set([
|
|
24
2
|
"assert",
|
|
25
3
|
"async_hooks",
|
|
@@ -97,3 +75,6 @@ const extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =
|
|
|
97
75
|
})
|
|
98
76
|
);
|
|
99
77
|
};
|
|
78
|
+
export {
|
|
79
|
+
extractDependencies
|
|
80
|
+
};
|
package/src/getCredentials.js
CHANGED
|
@@ -1,40 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 getCredentials_exports = {};
|
|
29
|
-
__export(getCredentials_exports, {
|
|
30
|
-
getCredentials: () => getCredentials
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(getCredentials_exports);
|
|
33
|
-
var import_fs = __toESM(require("fs"));
|
|
34
|
-
var import_js_yaml = __toESM(require("js-yaml"));
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import yaml from "js-yaml";
|
|
35
3
|
const getCredentials = (app, environment) => {
|
|
36
|
-
const secret =
|
|
37
|
-
|
|
4
|
+
const secret = yaml.load(
|
|
5
|
+
fs.readFileSync(`${app.workspace.workspaceRoot}/infra/app/values/${app.name}-secret.yaml`, "utf-8")
|
|
38
6
|
);
|
|
39
7
|
return secret[environment];
|
|
40
8
|
};
|
|
9
|
+
export {
|
|
10
|
+
getCredentials
|
|
11
|
+
};
|
package/src/getDependencies.js
CHANGED
|
@@ -1,26 +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 getDependencies_exports = {};
|
|
19
|
-
__export(getDependencies_exports, {
|
|
20
|
-
getDependencies: () => getDependencies
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(getDependencies_exports);
|
|
23
|
-
var import_devkit = require("@nx/devkit");
|
|
1
|
+
import { createProjectGraphAsync } from "@nx/devkit";
|
|
24
2
|
const addLibDepSet = (depName, { libDepSet, npmDepSet, dependencies }) => {
|
|
25
3
|
const deps = dependencies[depName];
|
|
26
4
|
if (!deps)
|
|
@@ -37,7 +15,7 @@ const addLibDepSet = (depName, { libDepSet, npmDepSet, dependencies }) => {
|
|
|
37
15
|
}
|
|
38
16
|
};
|
|
39
17
|
const getDependencies = async (projectName) => {
|
|
40
|
-
const graph = await
|
|
18
|
+
const graph = await createProjectGraphAsync();
|
|
41
19
|
const [libDepSet, npmDepSet] = [/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set()];
|
|
42
20
|
const dependencies = graph.dependencies;
|
|
43
21
|
const projectDeps = dependencies[projectName];
|
|
@@ -49,3 +27,6 @@ const getDependencies = async (projectName) => {
|
|
|
49
27
|
npmDeps: [...npmDepSet.values()].map((depName) => depName.replace("npm:", ""))
|
|
50
28
|
};
|
|
51
29
|
};
|
|
30
|
+
export {
|
|
31
|
+
getDependencies
|
|
32
|
+
};
|