@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
|
@@ -1,65 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
Executor: () => Executor,
|
|
32
|
-
LibExecutor: () => LibExecutor,
|
|
33
|
-
PkgExecutor: () => PkgExecutor,
|
|
34
|
-
SysExecutor: () => SysExecutor,
|
|
35
|
-
WorkspaceExecutor: () => WorkspaceExecutor
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(executors_exports);
|
|
38
|
-
var import_common = require("@akanjs/common");
|
|
39
|
-
var import_config = require("@akanjs/config");
|
|
40
|
-
var import_chalk = __toESM(require("chalk"), 1);
|
|
41
|
-
var import_child_process = require("child_process");
|
|
42
|
-
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
43
|
-
var import_fs = __toESM(require("fs"), 1);
|
|
44
|
-
var import_promises = __toESM(require("fs/promises"), 1);
|
|
45
|
-
var import_path = __toESM(require("path"), 1);
|
|
46
|
-
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 chalk from "chalk";
|
|
8
|
+
import { exec, fork, spawn } from "child_process";
|
|
9
|
+
import dotenv from "dotenv";
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
import fsPromise from "fs/promises";
|
|
12
|
+
import path from "path";
|
|
13
|
+
import { TypeScriptDependencyScanner } from "./dependencyScanner";
|
|
47
14
|
class Executor {
|
|
48
15
|
logger;
|
|
49
16
|
cwdPath;
|
|
50
17
|
constructor(name, cwdPath) {
|
|
51
|
-
this.logger = new
|
|
18
|
+
this.logger = new Logger(name);
|
|
52
19
|
this.cwdPath = cwdPath;
|
|
53
|
-
if (!
|
|
54
|
-
|
|
20
|
+
if (!fs.existsSync(cwdPath))
|
|
21
|
+
fs.mkdirSync(cwdPath, { recursive: true });
|
|
55
22
|
}
|
|
56
23
|
exec(command, options = {}) {
|
|
57
|
-
const proc =
|
|
24
|
+
const proc = exec(command, { cwd: this.cwdPath, ...options });
|
|
58
25
|
proc.stdout?.on("data", (data) => {
|
|
59
|
-
|
|
26
|
+
Logger.raw(data.toString());
|
|
60
27
|
});
|
|
61
28
|
proc.stderr?.on("data", (data) => {
|
|
62
|
-
|
|
29
|
+
Logger.raw(chalk.red(data.toString()));
|
|
63
30
|
});
|
|
64
31
|
return new Promise((resolve, reject) => {
|
|
65
32
|
proc.on("exit", (code, signal) => {
|
|
@@ -71,12 +38,12 @@ class Executor {
|
|
|
71
38
|
});
|
|
72
39
|
}
|
|
73
40
|
spawn(command, args = [], options = {}) {
|
|
74
|
-
const proc =
|
|
41
|
+
const proc = spawn(command, args, { cwd: this.cwdPath, stdio: "inherit", ...options });
|
|
75
42
|
proc.stdout?.on("data", (data) => {
|
|
76
|
-
|
|
43
|
+
Logger.raw(chalk.dim(data.toString()));
|
|
77
44
|
});
|
|
78
45
|
proc.stderr?.on("data", (data) => {
|
|
79
|
-
|
|
46
|
+
Logger.raw(chalk.dim(data.toString()));
|
|
80
47
|
});
|
|
81
48
|
return new Promise((resolve, reject) => {
|
|
82
49
|
proc.on("exit", (code, signal) => {
|
|
@@ -88,16 +55,16 @@ class Executor {
|
|
|
88
55
|
});
|
|
89
56
|
}
|
|
90
57
|
fork(modulePath, args = [], options = {}) {
|
|
91
|
-
const proc =
|
|
58
|
+
const proc = fork(modulePath, args, {
|
|
92
59
|
cwd: this.cwdPath,
|
|
93
60
|
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
94
61
|
...options
|
|
95
62
|
});
|
|
96
63
|
proc.stdout?.on("data", (data) => {
|
|
97
|
-
|
|
64
|
+
Logger.raw(data.toString());
|
|
98
65
|
});
|
|
99
66
|
proc.stderr?.on("data", (data) => {
|
|
100
|
-
|
|
67
|
+
Logger.raw(data.toString());
|
|
101
68
|
});
|
|
102
69
|
return new Promise((resolve, reject) => {
|
|
103
70
|
proc.on("exit", (code, signal) => {
|
|
@@ -109,35 +76,35 @@ class Executor {
|
|
|
109
76
|
});
|
|
110
77
|
}
|
|
111
78
|
#getPath(filePath) {
|
|
112
|
-
return
|
|
79
|
+
return path.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
113
80
|
}
|
|
114
81
|
mkdir(dirPath) {
|
|
115
82
|
const writePath = this.#getPath(dirPath);
|
|
116
|
-
if (!
|
|
117
|
-
|
|
83
|
+
if (!fs.existsSync(writePath))
|
|
84
|
+
fs.mkdirSync(writePath, { recursive: true });
|
|
118
85
|
this.logger.verbose(`Make directory ${writePath}`);
|
|
119
86
|
return this;
|
|
120
87
|
}
|
|
121
88
|
exists(filePath) {
|
|
122
89
|
const readPath = this.#getPath(filePath);
|
|
123
|
-
return
|
|
90
|
+
return fs.existsSync(readPath);
|
|
124
91
|
}
|
|
125
92
|
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
126
93
|
const writePath = this.#getPath(filePath);
|
|
127
|
-
const dir =
|
|
128
|
-
if (!
|
|
129
|
-
|
|
94
|
+
const dir = path.dirname(writePath);
|
|
95
|
+
if (!fs.existsSync(dir))
|
|
96
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
130
97
|
const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
131
|
-
if (
|
|
132
|
-
const currentContent =
|
|
98
|
+
if (fs.existsSync(writePath)) {
|
|
99
|
+
const currentContent = fs.readFileSync(writePath, "utf8");
|
|
133
100
|
if (currentContent === contentStr || !overwrite)
|
|
134
101
|
this.logger.verbose(`File ${writePath} is unchanged`);
|
|
135
102
|
else {
|
|
136
|
-
|
|
103
|
+
fs.writeFileSync(writePath, contentStr, "utf8");
|
|
137
104
|
this.logger.verbose(`File ${writePath} is changed`);
|
|
138
105
|
}
|
|
139
106
|
} else {
|
|
140
|
-
|
|
107
|
+
fs.writeFileSync(writePath, contentStr, "utf8");
|
|
141
108
|
this.logger.verbose(`File ${writePath} is created`);
|
|
142
109
|
}
|
|
143
110
|
return this;
|
|
@@ -147,22 +114,22 @@ class Executor {
|
|
|
147
114
|
return this;
|
|
148
115
|
}
|
|
149
116
|
getLocalFile(filePath) {
|
|
150
|
-
const filepath =
|
|
117
|
+
const filepath = path.isAbsolute(filePath) ? filePath : filePath.replace(this.cwdPath, "");
|
|
151
118
|
const content = this.readFile(filepath);
|
|
152
119
|
return { filepath, content };
|
|
153
120
|
}
|
|
154
121
|
readFile(filePath) {
|
|
155
122
|
const readPath = this.#getPath(filePath);
|
|
156
|
-
return
|
|
123
|
+
return fs.readFileSync(readPath, "utf8");
|
|
157
124
|
}
|
|
158
125
|
readJson(filePath) {
|
|
159
126
|
const readPath = this.#getPath(filePath);
|
|
160
|
-
return JSON.parse(
|
|
127
|
+
return JSON.parse(fs.readFileSync(readPath, "utf8"));
|
|
161
128
|
}
|
|
162
129
|
async cp(srcPath, destPath) {
|
|
163
130
|
const src = this.#getPath(srcPath);
|
|
164
131
|
const dest = this.#getPath(destPath);
|
|
165
|
-
await
|
|
132
|
+
await fsPromise.cp(src, dest, { recursive: true });
|
|
166
133
|
}
|
|
167
134
|
log(msg) {
|
|
168
135
|
this.logger.info(msg);
|
|
@@ -195,9 +162,9 @@ class Executor {
|
|
|
195
162
|
const result = getContent.default(scanResult ?? null, dict);
|
|
196
163
|
if (result === null)
|
|
197
164
|
return;
|
|
198
|
-
const filename = typeof result === "object" ? result.filename :
|
|
165
|
+
const filename = typeof result === "object" ? result.filename : path.basename(targetPath).replace(".js", ".ts");
|
|
199
166
|
const content = typeof result === "object" ? result.content : result;
|
|
200
|
-
const dirname =
|
|
167
|
+
const dirname = path.dirname(targetPath);
|
|
201
168
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
202
169
|
(path2, [key, value]) => path2.replace(new RegExp(`__${key}__`, "g"), value),
|
|
203
170
|
`${dirname}/${filename}`
|
|
@@ -205,7 +172,7 @@ class Executor {
|
|
|
205
172
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
206
173
|
this.writeFile(convertedTargetPath, content);
|
|
207
174
|
} else if (targetPath.endsWith(".template")) {
|
|
208
|
-
const content = await
|
|
175
|
+
const content = await fsPromise.readFile(templatePath, "utf8");
|
|
209
176
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
210
177
|
(path2, [key, value]) => path2.replace(new RegExp(`__${key}__`, "g"), value),
|
|
211
178
|
targetPath.slice(0, -9)
|
|
@@ -226,26 +193,26 @@ class Executor {
|
|
|
226
193
|
overwrite = true
|
|
227
194
|
}) {
|
|
228
195
|
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
229
|
-
if (
|
|
230
|
-
const filename =
|
|
196
|
+
if (fs.statSync(templatePath).isFile()) {
|
|
197
|
+
const filename = path.basename(templatePath);
|
|
231
198
|
await this.#applyTemplateFile(
|
|
232
|
-
{ templatePath, targetPath:
|
|
199
|
+
{ templatePath, targetPath: path.join(basePath, filename), scanResult, overwrite },
|
|
233
200
|
dict
|
|
234
201
|
);
|
|
235
202
|
} else {
|
|
236
|
-
const subdirs = await
|
|
203
|
+
const subdirs = await fsPromise.readdir(templatePath);
|
|
237
204
|
await Promise.all(
|
|
238
205
|
subdirs.map(async (subdir) => {
|
|
239
|
-
const subpath =
|
|
240
|
-
if (
|
|
206
|
+
const subpath = path.join(templatePath, subdir);
|
|
207
|
+
if (fs.statSync(subpath).isFile())
|
|
241
208
|
await this.#applyTemplateFile(
|
|
242
|
-
{ templatePath: subpath, targetPath:
|
|
209
|
+
{ templatePath: subpath, targetPath: path.join(basePath, subdir), scanResult, overwrite },
|
|
243
210
|
dict
|
|
244
211
|
);
|
|
245
212
|
else
|
|
246
213
|
await this.applyTemplate({
|
|
247
|
-
basePath:
|
|
248
|
-
template:
|
|
214
|
+
basePath: path.join(basePath, subdir),
|
|
215
|
+
template: path.join(template, subdir),
|
|
249
216
|
scanResult,
|
|
250
217
|
dict,
|
|
251
218
|
overwrite
|
|
@@ -264,11 +231,11 @@ class WorkspaceExecutor extends Executor {
|
|
|
264
231
|
this.repoName = repoName;
|
|
265
232
|
}
|
|
266
233
|
static fromRoot() {
|
|
267
|
-
const repoName =
|
|
234
|
+
const repoName = path.basename(process.cwd());
|
|
268
235
|
return new WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
|
|
269
236
|
}
|
|
270
237
|
getBaseDevEnv() {
|
|
271
|
-
const envFile =
|
|
238
|
+
const envFile = dotenv.parse(this.readFile(".env"));
|
|
272
239
|
const appName = process.env.NEXT_PUBLIC_APP_NAME ?? envFile.NEXT_PUBLIC_APP_NAME;
|
|
273
240
|
const repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? envFile.NEXT_PUBLIC_REPO_NAME;
|
|
274
241
|
if (!repoName)
|
|
@@ -337,13 +304,13 @@ class WorkspaceExecutor extends Executor {
|
|
|
337
304
|
async getDirInModule(basePath, name) {
|
|
338
305
|
const AVOID_DIRS = ["__lib", "__scalar", `_${name}`];
|
|
339
306
|
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
340
|
-
const dirs = await
|
|
307
|
+
const dirs = await fsPromise.readdir(dirname);
|
|
341
308
|
await Promise.all(
|
|
342
309
|
dirs.map(async (dir) => {
|
|
343
310
|
if (AVOID_DIRS.includes(dir))
|
|
344
311
|
return;
|
|
345
|
-
const dirPath =
|
|
346
|
-
if (
|
|
312
|
+
const dirPath = path.join(dirname, dir);
|
|
313
|
+
if (fs.lstatSync(dirPath).isDirectory()) {
|
|
347
314
|
results.push(`${name}/${prefix}${dir}`);
|
|
348
315
|
if (maxDepth > 0)
|
|
349
316
|
await getDirs(dirPath, maxDepth - 1, results, `${prefix}${dir}/`);
|
|
@@ -364,14 +331,14 @@ class WorkspaceExecutor extends Executor {
|
|
|
364
331
|
async #getDirHasFile(basePath, targetFilename) {
|
|
365
332
|
const AVOID_DIRS = ["node_modules", "dist", "public", "./next"];
|
|
366
333
|
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
367
|
-
const dirs = await
|
|
334
|
+
const dirs = await fsPromise.readdir(dirname);
|
|
368
335
|
await Promise.all(
|
|
369
336
|
dirs.map(async (dir) => {
|
|
370
337
|
if (AVOID_DIRS.includes(dir))
|
|
371
338
|
return;
|
|
372
|
-
const dirPath =
|
|
373
|
-
if (
|
|
374
|
-
const hasTargetFile =
|
|
339
|
+
const dirPath = path.join(dirname, dir);
|
|
340
|
+
if (fs.lstatSync(dirPath).isDirectory()) {
|
|
341
|
+
const hasTargetFile = fs.existsSync(path.join(dirPath, targetFilename));
|
|
375
342
|
if (hasTargetFile)
|
|
376
343
|
results.push(`${prefix}${dir}`);
|
|
377
344
|
if (maxDepth > 0)
|
|
@@ -411,7 +378,7 @@ class SysExecutor extends Executor {
|
|
|
411
378
|
this.type = type;
|
|
412
379
|
}
|
|
413
380
|
async getConfig(command) {
|
|
414
|
-
return this.type === "app" ? await
|
|
381
|
+
return this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name, command }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name, command });
|
|
415
382
|
}
|
|
416
383
|
async getModules() {
|
|
417
384
|
const path2 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
|
|
@@ -424,7 +391,7 @@ class SysExecutor extends Executor {
|
|
|
424
391
|
if (libScanResults[this.name])
|
|
425
392
|
return libScanResults[this.name];
|
|
426
393
|
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
427
|
-
const scanner = new
|
|
394
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
428
395
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
429
396
|
const pkgPathSet = new Set(
|
|
430
397
|
Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
|
|
@@ -441,17 +408,17 @@ class SysExecutor extends Executor {
|
|
|
441
408
|
const pathSplitLength = path2.split("/").length;
|
|
442
409
|
return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
443
410
|
}).filter((libName) => libName !== this.name);
|
|
444
|
-
if (!
|
|
445
|
-
|
|
446
|
-
const files =
|
|
447
|
-
const dirnames = (await
|
|
448
|
-
(name) =>
|
|
411
|
+
if (!fs.existsSync(`${this.cwdPath}/lib/__scalar`))
|
|
412
|
+
fs.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
|
|
413
|
+
const files = getDefaultFileScan();
|
|
414
|
+
const dirnames = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter(
|
|
415
|
+
(name) => fs.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
|
|
449
416
|
);
|
|
450
417
|
const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
|
|
451
418
|
const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
|
|
452
419
|
await Promise.all(
|
|
453
420
|
databaseDirs.map(async (name) => {
|
|
454
|
-
const filenames = await
|
|
421
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", name));
|
|
455
422
|
filenames.forEach((filename) => {
|
|
456
423
|
if (filename.endsWith(".constant.ts"))
|
|
457
424
|
files.constants.databases.push(name);
|
|
@@ -473,7 +440,7 @@ class SysExecutor extends Executor {
|
|
|
473
440
|
await Promise.all(
|
|
474
441
|
serviceDirs.map(async (dirname) => {
|
|
475
442
|
const name = dirname.slice(1);
|
|
476
|
-
const filenames = await
|
|
443
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", dirname));
|
|
477
444
|
filenames.forEach((filename) => {
|
|
478
445
|
if (filename.endsWith(".dictionary.ts"))
|
|
479
446
|
files.dictionary.services.push(name);
|
|
@@ -488,12 +455,12 @@ class SysExecutor extends Executor {
|
|
|
488
455
|
});
|
|
489
456
|
})
|
|
490
457
|
);
|
|
491
|
-
const scalarDirs = (await
|
|
458
|
+
const scalarDirs = (await fsPromise.readdir(`${this.cwdPath}/lib/__scalar`)).filter(
|
|
492
459
|
(name) => !name.startsWith("_")
|
|
493
460
|
);
|
|
494
461
|
await Promise.all(
|
|
495
462
|
scalarDirs.map(async (name) => {
|
|
496
|
-
const filenames = await
|
|
463
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib/__scalar", name));
|
|
497
464
|
filenames.forEach((filename) => {
|
|
498
465
|
if (filename.endsWith(".constant.ts"))
|
|
499
466
|
files.constants.scalars.push(name);
|
|
@@ -568,32 +535,32 @@ class SysExecutor extends Executor {
|
|
|
568
535
|
return scanResult;
|
|
569
536
|
}
|
|
570
537
|
getLocalFile(filePath) {
|
|
571
|
-
const filepath =
|
|
538
|
+
const filepath = path.isAbsolute(filePath) ? filePath : `${this.type}s/${this.name}/${filePath}`;
|
|
572
539
|
const content = this.workspace.readFile(filepath);
|
|
573
540
|
return { filepath, content };
|
|
574
541
|
}
|
|
575
542
|
async getDatabaseModules() {
|
|
576
|
-
const databaseModules = (await
|
|
543
|
+
const databaseModules = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/${name}/${name}.constant.ts`));
|
|
577
544
|
return databaseModules;
|
|
578
545
|
}
|
|
579
546
|
async getServiceModules() {
|
|
580
|
-
const serviceModules = (await
|
|
547
|
+
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`));
|
|
581
548
|
return serviceModules;
|
|
582
549
|
}
|
|
583
550
|
async getScalarModules() {
|
|
584
|
-
const scalarModules = (await
|
|
551
|
+
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`));
|
|
585
552
|
return scalarModules;
|
|
586
553
|
}
|
|
587
554
|
async getViewComponents() {
|
|
588
|
-
const viewComponents = (await
|
|
555
|
+
const viewComponents = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/${name}/${name}.View.tsx`));
|
|
589
556
|
return viewComponents;
|
|
590
557
|
}
|
|
591
558
|
async getUnitComponents() {
|
|
592
|
-
const unitComponents = (await
|
|
559
|
+
const unitComponents = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/${name}/${name}.Unit.tsx`));
|
|
593
560
|
return unitComponents;
|
|
594
561
|
}
|
|
595
562
|
async getTemplateComponents() {
|
|
596
|
-
const templateComponents = (await
|
|
563
|
+
const templateComponents = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => fs.existsSync(`${this.cwdPath}/lib/${name}/${name}.Template.tsx`));
|
|
597
564
|
return templateComponents;
|
|
598
565
|
}
|
|
599
566
|
async getViewsSourceCode() {
|
|
@@ -639,7 +606,7 @@ class AppExecutor extends SysExecutor {
|
|
|
639
606
|
return new AppExecutor({ workspace: executor.workspace, name });
|
|
640
607
|
}
|
|
641
608
|
async getConfig(command) {
|
|
642
|
-
return await
|
|
609
|
+
return await getAppConfig(this.cwdPath, {
|
|
643
610
|
...this.workspace.getBaseDevEnv(),
|
|
644
611
|
type: "app",
|
|
645
612
|
name: this.name,
|
|
@@ -648,13 +615,13 @@ class AppExecutor extends SysExecutor {
|
|
|
648
615
|
}
|
|
649
616
|
async syncAssets(libDeps) {
|
|
650
617
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
651
|
-
if (
|
|
652
|
-
await
|
|
653
|
-
const targetDeps = libDeps.filter((dep) =>
|
|
654
|
-
await Promise.all(targetDeps.map((dep) =>
|
|
618
|
+
if (fs.existsSync(projectPublicLibPath))
|
|
619
|
+
await fsPromise.rm(projectPublicLibPath, { recursive: true });
|
|
620
|
+
const targetDeps = libDeps.filter((dep) => fs.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
|
|
621
|
+
await Promise.all(targetDeps.map((dep) => fsPromise.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
|
|
655
622
|
await Promise.all(
|
|
656
623
|
targetDeps.map(
|
|
657
|
-
(dep) =>
|
|
624
|
+
(dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
658
625
|
recursive: true
|
|
659
626
|
})
|
|
660
627
|
)
|
|
@@ -675,7 +642,7 @@ class LibExecutor extends SysExecutor {
|
|
|
675
642
|
return new LibExecutor({ workspace: executor.workspace, name });
|
|
676
643
|
}
|
|
677
644
|
async getConfig(command) {
|
|
678
|
-
return await
|
|
645
|
+
return await getLibConfig(this.cwdPath, {
|
|
679
646
|
...this.workspace.getBaseDevEnv(),
|
|
680
647
|
type: "lib",
|
|
681
648
|
name: this.name,
|
|
@@ -703,7 +670,7 @@ class PkgExecutor extends Executor {
|
|
|
703
670
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`)
|
|
704
671
|
} = {}) {
|
|
705
672
|
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
706
|
-
const scanner = new
|
|
673
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
707
674
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
708
675
|
const pkgPathSet = new Set(
|
|
709
676
|
Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
|
|
@@ -721,12 +688,11 @@ class PkgExecutor extends Executor {
|
|
|
721
688
|
return pkgScanResult;
|
|
722
689
|
}
|
|
723
690
|
}
|
|
724
|
-
|
|
725
|
-
0 && (module.exports = {
|
|
691
|
+
export {
|
|
726
692
|
AppExecutor,
|
|
727
693
|
Executor,
|
|
728
694
|
LibExecutor,
|
|
729
695
|
PkgExecutor,
|
|
730
696
|
SysExecutor,
|
|
731
697
|
WorkspaceExecutor
|
|
732
|
-
}
|
|
698
|
+
};
|
package/src/extractDeps.js
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
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);
|
|
1
23
|
const NODE_NATIVE_MODULE_SET = /* @__PURE__ */ new Set([
|
|
2
24
|
"assert",
|
|
3
25
|
"async_hooks",
|
|
@@ -75,6 +97,7 @@ const extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =
|
|
|
75
97
|
})
|
|
76
98
|
);
|
|
77
99
|
};
|
|
78
|
-
export
|
|
100
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
+
0 && (module.exports = {
|
|
79
102
|
extractDependencies
|
|
80
|
-
};
|
|
103
|
+
});
|
|
@@ -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,7 +75,6 @@ const extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =
|
|
|
97
75
|
})
|
|
98
76
|
);
|
|
99
77
|
};
|
|
100
|
-
|
|
101
|
-
0 && (module.exports = {
|
|
78
|
+
export {
|
|
102
79
|
extractDependencies
|
|
103
|
-
}
|
|
80
|
+
};
|
package/src/getCredentials.js
CHANGED
|
@@ -1,11 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 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"));
|
|
3
35
|
const getCredentials = (app, environment) => {
|
|
4
|
-
const secret =
|
|
5
|
-
|
|
36
|
+
const secret = import_js_yaml.default.load(
|
|
37
|
+
import_fs.default.readFileSync(`${app.workspace.workspaceRoot}/infra/app/values/${app.name}-secret.yaml`, "utf-8")
|
|
6
38
|
);
|
|
7
39
|
return secret[environment];
|
|
8
40
|
};
|
|
9
|
-
export
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
10
43
|
getCredentials
|
|
11
|
-
};
|
|
44
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import yaml from "js-yaml";
|
|
3
|
+
const getCredentials = (app, environment) => {
|
|
4
|
+
const secret = yaml.load(
|
|
5
|
+
fs.readFileSync(`${app.workspace.workspaceRoot}/infra/app/values/${app.name}-secret.yaml`, "utf-8")
|
|
6
|
+
);
|
|
7
|
+
return secret[environment];
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
getCredentials
|
|
11
|
+
};
|