@akanjs/devkit 0.0.89 → 0.0.91
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 +5 -4
- package/src/aiEditor.d.ts +14 -0
- package/src/aiEditor.js +110 -21
- package/src/aiEditor.mjs +124 -0
- package/src/auth.js +48 -18
- package/src/auth.mjs +42 -0
- 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 +68 -35
- package/src/commandDecorators/{command.cjs → command.mjs} +35 -68
- 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.d.ts +8 -1
- package/src/constants.js +34 -5
- 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 +21 -1
- package/src/executors.js +172 -84
- package/src/{executors.cjs → executors.mjs} +138 -118
- 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.d.ts +52 -8
- package/src/getRelatedCnsts.js +205 -54
- package/src/getRelatedCnsts.mjs +221 -0
- package/src/index.js +51 -16
- package/src/index.mjs +16 -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/aiEditor.cjs +0 -92
- 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/getRelatedCnsts.cjs +0 -142
- package/src/index.cjs +0 -51
- 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,64 +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
|
-
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_child_process = require("child_process");
|
|
41
|
-
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
42
|
-
var import_fs = __toESM(require("fs"), 1);
|
|
43
|
-
var import_promises = __toESM(require("fs/promises"), 1);
|
|
44
|
-
var import_path = __toESM(require("path"), 1);
|
|
45
|
-
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 dotenv from "dotenv";
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import fsPromise from "fs/promises";
|
|
11
|
+
import path from "path";
|
|
12
|
+
import { TypeScriptDependencyScanner } from "./dependencyScanner";
|
|
46
13
|
class Executor {
|
|
47
14
|
logger;
|
|
48
15
|
cwdPath;
|
|
49
16
|
constructor(name, cwdPath) {
|
|
50
|
-
this.logger = new
|
|
17
|
+
this.logger = new Logger(name);
|
|
51
18
|
this.cwdPath = cwdPath;
|
|
52
|
-
if (!
|
|
53
|
-
|
|
19
|
+
if (!fs.existsSync(cwdPath))
|
|
20
|
+
fs.mkdirSync(cwdPath, { recursive: true });
|
|
54
21
|
}
|
|
55
22
|
exec(command, options = {}) {
|
|
56
|
-
const proc =
|
|
23
|
+
const proc = exec(command, { cwd: this.cwdPath, ...options });
|
|
57
24
|
proc.stdout?.on("data", (data) => {
|
|
58
|
-
|
|
25
|
+
Logger.raw(data.toString());
|
|
59
26
|
});
|
|
60
27
|
proc.stderr?.on("data", (data) => {
|
|
61
|
-
|
|
28
|
+
Logger.raw(data.toString());
|
|
62
29
|
});
|
|
63
30
|
return new Promise((resolve, reject) => {
|
|
64
31
|
proc.on("exit", (code, signal) => {
|
|
@@ -70,9 +37,9 @@ class Executor {
|
|
|
70
37
|
});
|
|
71
38
|
}
|
|
72
39
|
spawn(command, args = [], options = {}) {
|
|
73
|
-
const proc =
|
|
40
|
+
const proc = spawn(command, args, { cwd: this.cwdPath, stdio: "inherit", ...options });
|
|
74
41
|
proc.stderr?.on("data", (data) => {
|
|
75
|
-
|
|
42
|
+
Logger.raw(data.toString());
|
|
76
43
|
});
|
|
77
44
|
return new Promise((resolve, reject) => {
|
|
78
45
|
proc.on("exit", (code, signal) => {
|
|
@@ -84,16 +51,16 @@ class Executor {
|
|
|
84
51
|
});
|
|
85
52
|
}
|
|
86
53
|
fork(modulePath, args = [], options = {}) {
|
|
87
|
-
const proc =
|
|
54
|
+
const proc = fork(modulePath, args, {
|
|
88
55
|
cwd: this.cwdPath,
|
|
89
56
|
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
90
57
|
...options
|
|
91
58
|
});
|
|
92
59
|
proc.stdout?.on("data", (data) => {
|
|
93
|
-
|
|
60
|
+
Logger.raw(data.toString());
|
|
94
61
|
});
|
|
95
62
|
proc.stderr?.on("data", (data) => {
|
|
96
|
-
|
|
63
|
+
Logger.raw(data.toString());
|
|
97
64
|
});
|
|
98
65
|
return new Promise((resolve, reject) => {
|
|
99
66
|
proc.on("exit", (code, signal) => {
|
|
@@ -105,35 +72,35 @@ class Executor {
|
|
|
105
72
|
});
|
|
106
73
|
}
|
|
107
74
|
#getPath(filePath) {
|
|
108
|
-
return
|
|
75
|
+
return path.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
109
76
|
}
|
|
110
77
|
mkdir(dirPath) {
|
|
111
78
|
const writePath = this.#getPath(dirPath);
|
|
112
|
-
if (!
|
|
113
|
-
|
|
79
|
+
if (!fs.existsSync(writePath))
|
|
80
|
+
fs.mkdirSync(writePath, { recursive: true });
|
|
114
81
|
this.logger.verbose(`Make directory ${writePath}`);
|
|
115
82
|
return this;
|
|
116
83
|
}
|
|
117
84
|
exists(filePath) {
|
|
118
85
|
const readPath = this.#getPath(filePath);
|
|
119
|
-
return
|
|
86
|
+
return fs.existsSync(readPath);
|
|
120
87
|
}
|
|
121
88
|
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
122
89
|
const writePath = this.#getPath(filePath);
|
|
123
|
-
const dir =
|
|
124
|
-
if (!
|
|
125
|
-
|
|
90
|
+
const dir = path.dirname(writePath);
|
|
91
|
+
if (!fs.existsSync(dir))
|
|
92
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
126
93
|
const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
127
|
-
if (
|
|
128
|
-
const currentContent =
|
|
94
|
+
if (fs.existsSync(writePath)) {
|
|
95
|
+
const currentContent = fs.readFileSync(writePath, "utf8");
|
|
129
96
|
if (currentContent === contentStr || !overwrite)
|
|
130
97
|
this.logger.verbose(`File ${writePath} is unchanged`);
|
|
131
98
|
else {
|
|
132
|
-
|
|
99
|
+
fs.writeFileSync(writePath, contentStr, "utf8");
|
|
133
100
|
this.logger.verbose(`File ${writePath} is changed`);
|
|
134
101
|
}
|
|
135
102
|
} else {
|
|
136
|
-
|
|
103
|
+
fs.writeFileSync(writePath, contentStr, "utf8");
|
|
137
104
|
this.logger.verbose(`File ${writePath} is created`);
|
|
138
105
|
}
|
|
139
106
|
return this;
|
|
@@ -143,22 +110,22 @@ class Executor {
|
|
|
143
110
|
return this;
|
|
144
111
|
}
|
|
145
112
|
getLocalFile(filePath) {
|
|
146
|
-
const filepath =
|
|
113
|
+
const filepath = path.isAbsolute(filePath) ? filePath : filePath.replace(this.cwdPath, "");
|
|
147
114
|
const content = this.readFile(filepath);
|
|
148
115
|
return { filepath, content };
|
|
149
116
|
}
|
|
150
117
|
readFile(filePath) {
|
|
151
118
|
const readPath = this.#getPath(filePath);
|
|
152
|
-
return
|
|
119
|
+
return fs.readFileSync(readPath, "utf8");
|
|
153
120
|
}
|
|
154
121
|
readJson(filePath) {
|
|
155
122
|
const readPath = this.#getPath(filePath);
|
|
156
|
-
return JSON.parse(
|
|
123
|
+
return JSON.parse(fs.readFileSync(readPath, "utf8"));
|
|
157
124
|
}
|
|
158
125
|
async cp(srcPath, destPath) {
|
|
159
126
|
const src = this.#getPath(srcPath);
|
|
160
127
|
const dest = this.#getPath(destPath);
|
|
161
|
-
await
|
|
128
|
+
await fsPromise.cp(src, dest, { recursive: true });
|
|
162
129
|
}
|
|
163
130
|
log(msg) {
|
|
164
131
|
this.logger.info(msg);
|
|
@@ -191,9 +158,9 @@ class Executor {
|
|
|
191
158
|
const result = getContent.default(scanResult ?? null, dict);
|
|
192
159
|
if (result === null)
|
|
193
160
|
return;
|
|
194
|
-
const filename = typeof result === "object" ? result.filename :
|
|
161
|
+
const filename = typeof result === "object" ? result.filename : path.basename(targetPath).replace(".js", ".ts");
|
|
195
162
|
const content = typeof result === "object" ? result.content : result;
|
|
196
|
-
const dirname =
|
|
163
|
+
const dirname = path.dirname(targetPath);
|
|
197
164
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
198
165
|
(path2, [key, value]) => path2.replace(new RegExp(`__${key}__`, "g"), value),
|
|
199
166
|
`${dirname}/${filename}`
|
|
@@ -201,7 +168,7 @@ class Executor {
|
|
|
201
168
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
202
169
|
this.writeFile(convertedTargetPath, content);
|
|
203
170
|
} else if (targetPath.endsWith(".template")) {
|
|
204
|
-
const content = await
|
|
171
|
+
const content = await fsPromise.readFile(templatePath, "utf8");
|
|
205
172
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
206
173
|
(path2, [key, value]) => path2.replace(new RegExp(`__${key}__`, "g"), value),
|
|
207
174
|
targetPath.slice(0, -9)
|
|
@@ -222,26 +189,26 @@ class Executor {
|
|
|
222
189
|
overwrite = true
|
|
223
190
|
}) {
|
|
224
191
|
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
225
|
-
if (
|
|
226
|
-
const filename =
|
|
192
|
+
if (fs.statSync(templatePath).isFile()) {
|
|
193
|
+
const filename = path.basename(templatePath);
|
|
227
194
|
await this.#applyTemplateFile(
|
|
228
|
-
{ templatePath, targetPath:
|
|
195
|
+
{ templatePath, targetPath: path.join(basePath, filename), scanResult, overwrite },
|
|
229
196
|
dict
|
|
230
197
|
);
|
|
231
198
|
} else {
|
|
232
|
-
const subdirs = await
|
|
199
|
+
const subdirs = await fsPromise.readdir(templatePath);
|
|
233
200
|
await Promise.all(
|
|
234
201
|
subdirs.map(async (subdir) => {
|
|
235
|
-
const subpath =
|
|
236
|
-
if (
|
|
202
|
+
const subpath = path.join(templatePath, subdir);
|
|
203
|
+
if (fs.statSync(subpath).isFile())
|
|
237
204
|
await this.#applyTemplateFile(
|
|
238
|
-
{ templatePath: subpath, targetPath:
|
|
205
|
+
{ templatePath: subpath, targetPath: path.join(basePath, subdir), scanResult, overwrite },
|
|
239
206
|
dict
|
|
240
207
|
);
|
|
241
208
|
else
|
|
242
209
|
await this.applyTemplate({
|
|
243
|
-
basePath:
|
|
244
|
-
template:
|
|
210
|
+
basePath: path.join(basePath, subdir),
|
|
211
|
+
template: path.join(template, subdir),
|
|
245
212
|
scanResult,
|
|
246
213
|
dict,
|
|
247
214
|
overwrite
|
|
@@ -260,11 +227,11 @@ class WorkspaceExecutor extends Executor {
|
|
|
260
227
|
this.repoName = repoName;
|
|
261
228
|
}
|
|
262
229
|
static fromRoot() {
|
|
263
|
-
const repoName =
|
|
230
|
+
const repoName = path.basename(process.cwd());
|
|
264
231
|
return new WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
|
|
265
232
|
}
|
|
266
233
|
getBaseDevEnv() {
|
|
267
|
-
const envFile =
|
|
234
|
+
const envFile = dotenv.parse(this.readFile(".env"));
|
|
268
235
|
const appName = process.env.NEXT_PUBLIC_APP_NAME ?? envFile.NEXT_PUBLIC_APP_NAME;
|
|
269
236
|
const repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? envFile.NEXT_PUBLIC_REPO_NAME;
|
|
270
237
|
if (!repoName)
|
|
@@ -330,6 +297,26 @@ class WorkspaceExecutor extends Executor {
|
|
|
330
297
|
this.writeJson("tsconfig.json", rootTsConfig);
|
|
331
298
|
return this;
|
|
332
299
|
}
|
|
300
|
+
async getDirInModule(basePath, name) {
|
|
301
|
+
const AVOID_DIRS = ["__lib", "__scalar", `_${name}`];
|
|
302
|
+
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
303
|
+
const dirs = await fsPromise.readdir(dirname);
|
|
304
|
+
await Promise.all(
|
|
305
|
+
dirs.map(async (dir) => {
|
|
306
|
+
if (AVOID_DIRS.includes(dir))
|
|
307
|
+
return;
|
|
308
|
+
const dirPath = path.join(dirname, dir);
|
|
309
|
+
if (fs.lstatSync(dirPath).isDirectory()) {
|
|
310
|
+
results.push(`${name}/${prefix}${dir}`);
|
|
311
|
+
if (maxDepth > 0)
|
|
312
|
+
await getDirs(dirPath, maxDepth - 1, results, `${prefix}${dir}/`);
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
);
|
|
316
|
+
return results;
|
|
317
|
+
};
|
|
318
|
+
return await getDirs(basePath);
|
|
319
|
+
}
|
|
333
320
|
async commit(message, { init = false, add = true } = {}) {
|
|
334
321
|
if (init)
|
|
335
322
|
await this.exec(`git init --quiet`);
|
|
@@ -340,14 +327,14 @@ class WorkspaceExecutor extends Executor {
|
|
|
340
327
|
async #getDirHasFile(basePath, targetFilename) {
|
|
341
328
|
const AVOID_DIRS = ["node_modules", "dist", "public", "./next"];
|
|
342
329
|
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
343
|
-
const dirs = await
|
|
330
|
+
const dirs = await fsPromise.readdir(dirname);
|
|
344
331
|
await Promise.all(
|
|
345
332
|
dirs.map(async (dir) => {
|
|
346
333
|
if (AVOID_DIRS.includes(dir))
|
|
347
334
|
return;
|
|
348
|
-
const dirPath =
|
|
349
|
-
if (
|
|
350
|
-
const hasTargetFile =
|
|
335
|
+
const dirPath = path.join(dirname, dir);
|
|
336
|
+
if (fs.lstatSync(dirPath).isDirectory()) {
|
|
337
|
+
const hasTargetFile = fs.existsSync(path.join(dirPath, targetFilename));
|
|
351
338
|
if (hasTargetFile)
|
|
352
339
|
results.push(`${prefix}${dir}`);
|
|
353
340
|
if (maxDepth > 0)
|
|
@@ -367,6 +354,14 @@ class WorkspaceExecutor extends Executor {
|
|
|
367
354
|
];
|
|
368
355
|
return scalarConstantExampleFiles;
|
|
369
356
|
}
|
|
357
|
+
async getViewFiles() {
|
|
358
|
+
const [appNames, libNames] = await this.getSyss();
|
|
359
|
+
const viewExampleFiles = [
|
|
360
|
+
...(await Promise.all(appNames.map((appName) => AppExecutor.from(this, appName).getViewsSourceCode()))).flat(),
|
|
361
|
+
...(await Promise.all(libNames.map((libName) => LibExecutor.from(this, libName).getViewsSourceCode()))).flat()
|
|
362
|
+
];
|
|
363
|
+
return viewExampleFiles;
|
|
364
|
+
}
|
|
370
365
|
}
|
|
371
366
|
class SysExecutor extends Executor {
|
|
372
367
|
workspace;
|
|
@@ -379,7 +374,11 @@ class SysExecutor extends Executor {
|
|
|
379
374
|
this.type = type;
|
|
380
375
|
}
|
|
381
376
|
async getConfig(command) {
|
|
382
|
-
return this.type === "app" ? await
|
|
377
|
+
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 });
|
|
378
|
+
}
|
|
379
|
+
async getModules() {
|
|
380
|
+
const path2 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
|
|
381
|
+
return await this.workspace.getDirInModule(path2, this.name);
|
|
383
382
|
}
|
|
384
383
|
async scan({
|
|
385
384
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
|
|
@@ -388,7 +387,7 @@ class SysExecutor extends Executor {
|
|
|
388
387
|
if (libScanResults[this.name])
|
|
389
388
|
return libScanResults[this.name];
|
|
390
389
|
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
391
|
-
const scanner = new
|
|
390
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
392
391
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
393
392
|
const pkgPathSet = new Set(
|
|
394
393
|
Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
|
|
@@ -405,17 +404,17 @@ class SysExecutor extends Executor {
|
|
|
405
404
|
const pathSplitLength = path2.split("/").length;
|
|
406
405
|
return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
407
406
|
}).filter((libName) => libName !== this.name);
|
|
408
|
-
if (!
|
|
409
|
-
|
|
410
|
-
const files =
|
|
411
|
-
const dirnames = (await
|
|
412
|
-
(name) =>
|
|
407
|
+
if (!fs.existsSync(`${this.cwdPath}/lib/__scalar`))
|
|
408
|
+
fs.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
|
|
409
|
+
const files = getDefaultFileScan();
|
|
410
|
+
const dirnames = (await fsPromise.readdir(`${this.cwdPath}/lib`)).filter(
|
|
411
|
+
(name) => fs.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
|
|
413
412
|
);
|
|
414
413
|
const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
|
|
415
414
|
const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
|
|
416
415
|
await Promise.all(
|
|
417
416
|
databaseDirs.map(async (name) => {
|
|
418
|
-
const filenames = await
|
|
417
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", name));
|
|
419
418
|
filenames.forEach((filename) => {
|
|
420
419
|
if (filename.endsWith(".constant.ts"))
|
|
421
420
|
files.constants.databases.push(name);
|
|
@@ -437,7 +436,7 @@ class SysExecutor extends Executor {
|
|
|
437
436
|
await Promise.all(
|
|
438
437
|
serviceDirs.map(async (dirname) => {
|
|
439
438
|
const name = dirname.slice(1);
|
|
440
|
-
const filenames = await
|
|
439
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", dirname));
|
|
441
440
|
filenames.forEach((filename) => {
|
|
442
441
|
if (filename.endsWith(".dictionary.ts"))
|
|
443
442
|
files.dictionary.services.push(name);
|
|
@@ -452,12 +451,12 @@ class SysExecutor extends Executor {
|
|
|
452
451
|
});
|
|
453
452
|
})
|
|
454
453
|
);
|
|
455
|
-
const scalarDirs = (await
|
|
454
|
+
const scalarDirs = (await fsPromise.readdir(`${this.cwdPath}/lib/__scalar`)).filter(
|
|
456
455
|
(name) => !name.startsWith("_")
|
|
457
456
|
);
|
|
458
457
|
await Promise.all(
|
|
459
458
|
scalarDirs.map(async (name) => {
|
|
460
|
-
const filenames = await
|
|
459
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib/__scalar", name));
|
|
461
460
|
filenames.forEach((filename) => {
|
|
462
461
|
if (filename.endsWith(".constant.ts"))
|
|
463
462
|
files.constants.scalars.push(name);
|
|
@@ -532,25 +531,47 @@ class SysExecutor extends Executor {
|
|
|
532
531
|
return scanResult;
|
|
533
532
|
}
|
|
534
533
|
getLocalFile(filePath) {
|
|
535
|
-
const filepath =
|
|
534
|
+
const filepath = path.isAbsolute(filePath) ? filePath : `${this.type}s/${this.name}/${filePath}`;
|
|
536
535
|
const content = this.workspace.readFile(filepath);
|
|
537
536
|
return { filepath, content };
|
|
538
537
|
}
|
|
539
538
|
async getDatabaseModules() {
|
|
540
|
-
const databaseModules = (await
|
|
539
|
+
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`));
|
|
541
540
|
return databaseModules;
|
|
542
541
|
}
|
|
543
542
|
async getServiceModules() {
|
|
544
|
-
const serviceModules = (await
|
|
543
|
+
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`));
|
|
545
544
|
return serviceModules;
|
|
546
545
|
}
|
|
547
546
|
async getScalarModules() {
|
|
548
|
-
const scalarModules = (await
|
|
547
|
+
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`));
|
|
549
548
|
return scalarModules;
|
|
550
549
|
}
|
|
551
|
-
async
|
|
552
|
-
const
|
|
553
|
-
return
|
|
550
|
+
async getViewComponents() {
|
|
551
|
+
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`));
|
|
552
|
+
return viewComponents;
|
|
553
|
+
}
|
|
554
|
+
async getUnitComponents() {
|
|
555
|
+
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`));
|
|
556
|
+
return unitComponents;
|
|
557
|
+
}
|
|
558
|
+
async getTemplateComponents() {
|
|
559
|
+
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`));
|
|
560
|
+
return templateComponents;
|
|
561
|
+
}
|
|
562
|
+
async getViewsSourceCode() {
|
|
563
|
+
const viewComponents = await this.getViewComponents();
|
|
564
|
+
return viewComponents.map((viewComponent) => this.getLocalFile(`lib/${viewComponent}/${viewComponent}.View.tsx`));
|
|
565
|
+
}
|
|
566
|
+
async getUnitsSourceCode() {
|
|
567
|
+
const unitComponents = await this.getUnitComponents();
|
|
568
|
+
return unitComponents.map((unitComponent) => this.getLocalFile(`lib/${unitComponent}/${unitComponent}.Unit.tsx`));
|
|
569
|
+
}
|
|
570
|
+
async getTemplatesSourceCode() {
|
|
571
|
+
const templateComponents = await this.getTemplateComponents();
|
|
572
|
+
return templateComponents.map(
|
|
573
|
+
(templateComponent) => this.getLocalFile(`lib/${templateComponent}/${templateComponent}.Template.tsx`)
|
|
574
|
+
);
|
|
554
575
|
}
|
|
555
576
|
async getScalarConstantFiles() {
|
|
556
577
|
const scalarModules = await this.getScalarModules();
|
|
@@ -581,7 +602,7 @@ class AppExecutor extends SysExecutor {
|
|
|
581
602
|
return new AppExecutor({ workspace: executor.workspace, name });
|
|
582
603
|
}
|
|
583
604
|
async getConfig(command) {
|
|
584
|
-
return await
|
|
605
|
+
return await getAppConfig(this.cwdPath, {
|
|
585
606
|
...this.workspace.getBaseDevEnv(),
|
|
586
607
|
type: "app",
|
|
587
608
|
name: this.name,
|
|
@@ -590,13 +611,13 @@ class AppExecutor extends SysExecutor {
|
|
|
590
611
|
}
|
|
591
612
|
async syncAssets(libDeps) {
|
|
592
613
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
593
|
-
if (
|
|
594
|
-
await
|
|
595
|
-
const targetDeps = libDeps.filter((dep) =>
|
|
596
|
-
await Promise.all(targetDeps.map((dep) =>
|
|
614
|
+
if (fs.existsSync(projectPublicLibPath))
|
|
615
|
+
await fsPromise.rm(projectPublicLibPath, { recursive: true });
|
|
616
|
+
const targetDeps = libDeps.filter((dep) => fs.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
|
|
617
|
+
await Promise.all(targetDeps.map((dep) => fsPromise.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
|
|
597
618
|
await Promise.all(
|
|
598
619
|
targetDeps.map(
|
|
599
|
-
(dep) =>
|
|
620
|
+
(dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
600
621
|
recursive: true
|
|
601
622
|
})
|
|
602
623
|
)
|
|
@@ -617,7 +638,7 @@ class LibExecutor extends SysExecutor {
|
|
|
617
638
|
return new LibExecutor({ workspace: executor.workspace, name });
|
|
618
639
|
}
|
|
619
640
|
async getConfig(command) {
|
|
620
|
-
return await
|
|
641
|
+
return await getLibConfig(this.cwdPath, {
|
|
621
642
|
...this.workspace.getBaseDevEnv(),
|
|
622
643
|
type: "lib",
|
|
623
644
|
name: this.name,
|
|
@@ -645,7 +666,7 @@ class PkgExecutor extends Executor {
|
|
|
645
666
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`)
|
|
646
667
|
} = {}) {
|
|
647
668
|
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
648
|
-
const scanner = new
|
|
669
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
649
670
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
650
671
|
const pkgPathSet = new Set(
|
|
651
672
|
Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
|
|
@@ -663,12 +684,11 @@ class PkgExecutor extends Executor {
|
|
|
663
684
|
return pkgScanResult;
|
|
664
685
|
}
|
|
665
686
|
}
|
|
666
|
-
|
|
667
|
-
0 && (module.exports = {
|
|
687
|
+
export {
|
|
668
688
|
AppExecutor,
|
|
669
689
|
Executor,
|
|
670
690
|
LibExecutor,
|
|
671
691
|
PkgExecutor,
|
|
672
692
|
SysExecutor,
|
|
673
693
|
WorkspaceExecutor
|
|
674
|
-
}
|
|
694
|
+
};
|
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
|
+
};
|