@akanjs/devkit 0.0.88 → 0.0.90
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 +24 -31
- package/src/executors.js +180 -131
- package/src/{executors.cjs → executors.mjs} +146 -168
- 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.d.ts +0 -1
- package/src/index.js +51 -17
- 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 -53
- package/src/installExternalLib.cjs +0 -33
- package/src/installExternalLib.d.ts +0 -2
- package/src/installExternalLib.js +0 -10
- 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,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"), 1);
|
|
45
|
-
var import_promises = __toESM(require("fs/promises"), 1);
|
|
46
|
-
var import_path = __toESM(require("path"), 1);
|
|
47
|
-
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
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 dotenv from "dotenv";
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import fsPromise from "fs/promises";
|
|
11
|
+
import path from "path";
|
|
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,35 +72,35 @@ class Executor {
|
|
|
108
72
|
});
|
|
109
73
|
}
|
|
110
74
|
#getPath(filePath) {
|
|
111
|
-
return
|
|
75
|
+
return path.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
112
76
|
}
|
|
113
77
|
mkdir(dirPath) {
|
|
114
78
|
const writePath = this.#getPath(dirPath);
|
|
115
|
-
if (!
|
|
116
|
-
|
|
79
|
+
if (!fs.existsSync(writePath))
|
|
80
|
+
fs.mkdirSync(writePath, { recursive: true });
|
|
117
81
|
this.logger.verbose(`Make directory ${writePath}`);
|
|
118
82
|
return this;
|
|
119
83
|
}
|
|
120
84
|
exists(filePath) {
|
|
121
85
|
const readPath = this.#getPath(filePath);
|
|
122
|
-
return
|
|
86
|
+
return fs.existsSync(readPath);
|
|
123
87
|
}
|
|
124
88
|
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
125
89
|
const writePath = this.#getPath(filePath);
|
|
126
|
-
const dir =
|
|
127
|
-
if (!
|
|
128
|
-
|
|
90
|
+
const dir = path.dirname(writePath);
|
|
91
|
+
if (!fs.existsSync(dir))
|
|
92
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
129
93
|
const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
130
|
-
if (
|
|
131
|
-
const currentContent =
|
|
94
|
+
if (fs.existsSync(writePath)) {
|
|
95
|
+
const currentContent = fs.readFileSync(writePath, "utf8");
|
|
132
96
|
if (currentContent === contentStr || !overwrite)
|
|
133
97
|
this.logger.verbose(`File ${writePath} is unchanged`);
|
|
134
98
|
else {
|
|
135
|
-
|
|
99
|
+
fs.writeFileSync(writePath, contentStr, "utf8");
|
|
136
100
|
this.logger.verbose(`File ${writePath} is changed`);
|
|
137
101
|
}
|
|
138
102
|
} else {
|
|
139
|
-
|
|
103
|
+
fs.writeFileSync(writePath, contentStr, "utf8");
|
|
140
104
|
this.logger.verbose(`File ${writePath} is created`);
|
|
141
105
|
}
|
|
142
106
|
return this;
|
|
@@ -146,22 +110,22 @@ class Executor {
|
|
|
146
110
|
return this;
|
|
147
111
|
}
|
|
148
112
|
getLocalFile(filePath) {
|
|
149
|
-
const filepath =
|
|
113
|
+
const filepath = path.isAbsolute(filePath) ? filePath : filePath.replace(this.cwdPath, "");
|
|
150
114
|
const content = this.readFile(filepath);
|
|
151
115
|
return { filepath, content };
|
|
152
116
|
}
|
|
153
117
|
readFile(filePath) {
|
|
154
118
|
const readPath = this.#getPath(filePath);
|
|
155
|
-
return
|
|
119
|
+
return fs.readFileSync(readPath, "utf8");
|
|
156
120
|
}
|
|
157
121
|
readJson(filePath) {
|
|
158
122
|
const readPath = this.#getPath(filePath);
|
|
159
|
-
return JSON.parse(
|
|
123
|
+
return JSON.parse(fs.readFileSync(readPath, "utf8"));
|
|
160
124
|
}
|
|
161
125
|
async cp(srcPath, destPath) {
|
|
162
126
|
const src = this.#getPath(srcPath);
|
|
163
127
|
const dest = this.#getPath(destPath);
|
|
164
|
-
await
|
|
128
|
+
await fsPromise.cp(src, dest, { recursive: true });
|
|
165
129
|
}
|
|
166
130
|
log(msg) {
|
|
167
131
|
this.logger.info(msg);
|
|
@@ -194,9 +158,9 @@ class Executor {
|
|
|
194
158
|
const result = getContent.default(scanResult ?? null, dict);
|
|
195
159
|
if (result === null)
|
|
196
160
|
return;
|
|
197
|
-
const filename = typeof result === "object" ? result.filename :
|
|
161
|
+
const filename = typeof result === "object" ? result.filename : path.basename(targetPath).replace(".js", ".ts");
|
|
198
162
|
const content = typeof result === "object" ? result.content : result;
|
|
199
|
-
const dirname =
|
|
163
|
+
const dirname = path.dirname(targetPath);
|
|
200
164
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
201
165
|
(path2, [key, value]) => path2.replace(new RegExp(`__${key}__`, "g"), value),
|
|
202
166
|
`${dirname}/${filename}`
|
|
@@ -204,7 +168,7 @@ class Executor {
|
|
|
204
168
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
205
169
|
this.writeFile(convertedTargetPath, content);
|
|
206
170
|
} else if (targetPath.endsWith(".template")) {
|
|
207
|
-
const content = await
|
|
171
|
+
const content = await fsPromise.readFile(templatePath, "utf8");
|
|
208
172
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
209
173
|
(path2, [key, value]) => path2.replace(new RegExp(`__${key}__`, "g"), value),
|
|
210
174
|
targetPath.slice(0, -9)
|
|
@@ -225,26 +189,26 @@ class Executor {
|
|
|
225
189
|
overwrite = true
|
|
226
190
|
}) {
|
|
227
191
|
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
228
|
-
if (
|
|
229
|
-
const filename =
|
|
192
|
+
if (fs.statSync(templatePath).isFile()) {
|
|
193
|
+
const filename = path.basename(templatePath);
|
|
230
194
|
await this.#applyTemplateFile(
|
|
231
|
-
{ templatePath, targetPath:
|
|
195
|
+
{ templatePath, targetPath: path.join(basePath, filename), scanResult, overwrite },
|
|
232
196
|
dict
|
|
233
197
|
);
|
|
234
198
|
} else {
|
|
235
|
-
const subdirs = await
|
|
199
|
+
const subdirs = await fsPromise.readdir(templatePath);
|
|
236
200
|
await Promise.all(
|
|
237
201
|
subdirs.map(async (subdir) => {
|
|
238
|
-
const subpath =
|
|
239
|
-
if (
|
|
202
|
+
const subpath = path.join(templatePath, subdir);
|
|
203
|
+
if (fs.statSync(subpath).isFile())
|
|
240
204
|
await this.#applyTemplateFile(
|
|
241
|
-
{ templatePath: subpath, targetPath:
|
|
205
|
+
{ templatePath: subpath, targetPath: path.join(basePath, subdir), scanResult, overwrite },
|
|
242
206
|
dict
|
|
243
207
|
);
|
|
244
208
|
else
|
|
245
209
|
await this.applyTemplate({
|
|
246
|
-
basePath:
|
|
247
|
-
template:
|
|
210
|
+
basePath: path.join(basePath, subdir),
|
|
211
|
+
template: path.join(template, subdir),
|
|
248
212
|
scanResult,
|
|
249
213
|
dict,
|
|
250
214
|
overwrite
|
|
@@ -263,11 +227,11 @@ class WorkspaceExecutor extends Executor {
|
|
|
263
227
|
this.repoName = repoName;
|
|
264
228
|
}
|
|
265
229
|
static fromRoot() {
|
|
266
|
-
const repoName =
|
|
230
|
+
const repoName = path.basename(process.cwd());
|
|
267
231
|
return new WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
|
|
268
232
|
}
|
|
269
233
|
getBaseDevEnv() {
|
|
270
|
-
const envFile =
|
|
234
|
+
const envFile = dotenv.parse(this.readFile(".env"));
|
|
271
235
|
const appName = process.env.NEXT_PUBLIC_APP_NAME ?? envFile.NEXT_PUBLIC_APP_NAME;
|
|
272
236
|
const repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? envFile.NEXT_PUBLIC_REPO_NAME;
|
|
273
237
|
if (!repoName)
|
|
@@ -333,24 +297,44 @@ class WorkspaceExecutor extends Executor {
|
|
|
333
297
|
this.writeJson("tsconfig.json", rootTsConfig);
|
|
334
298
|
return this;
|
|
335
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
|
+
}
|
|
336
320
|
async commit(message, { init = false, add = true } = {}) {
|
|
337
321
|
if (init)
|
|
338
|
-
await this.exec(`git init`);
|
|
322
|
+
await this.exec(`git init --quiet`);
|
|
339
323
|
if (add)
|
|
340
324
|
await this.exec(`git add .`);
|
|
341
|
-
await this.exec(`git commit -m "${message}"`);
|
|
325
|
+
await this.exec(`git commit --quiet -m "${message}"`);
|
|
342
326
|
}
|
|
343
327
|
async #getDirHasFile(basePath, targetFilename) {
|
|
344
328
|
const AVOID_DIRS = ["node_modules", "dist", "public", "./next"];
|
|
345
329
|
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
346
|
-
const dirs = await
|
|
330
|
+
const dirs = await fsPromise.readdir(dirname);
|
|
347
331
|
await Promise.all(
|
|
348
332
|
dirs.map(async (dir) => {
|
|
349
333
|
if (AVOID_DIRS.includes(dir))
|
|
350
334
|
return;
|
|
351
|
-
const dirPath =
|
|
352
|
-
if (
|
|
353
|
-
const hasTargetFile =
|
|
335
|
+
const dirPath = path.join(dirname, dir);
|
|
336
|
+
if (fs.lstatSync(dirPath).isDirectory()) {
|
|
337
|
+
const hasTargetFile = fs.existsSync(path.join(dirPath, targetFilename));
|
|
354
338
|
if (hasTargetFile)
|
|
355
339
|
results.push(`${prefix}${dir}`);
|
|
356
340
|
if (maxDepth > 0)
|
|
@@ -370,6 +354,14 @@ class WorkspaceExecutor extends Executor {
|
|
|
370
354
|
];
|
|
371
355
|
return scalarConstantExampleFiles;
|
|
372
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
|
+
}
|
|
373
365
|
}
|
|
374
366
|
class SysExecutor extends Executor {
|
|
375
367
|
workspace;
|
|
@@ -382,7 +374,11 @@ class SysExecutor extends Executor {
|
|
|
382
374
|
this.type = type;
|
|
383
375
|
}
|
|
384
376
|
async getConfig(command) {
|
|
385
|
-
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);
|
|
386
382
|
}
|
|
387
383
|
async scan({
|
|
388
384
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
|
|
@@ -391,7 +387,7 @@ class SysExecutor extends Executor {
|
|
|
391
387
|
if (libScanResults[this.name])
|
|
392
388
|
return libScanResults[this.name];
|
|
393
389
|
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
394
|
-
const scanner = new
|
|
390
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
395
391
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
396
392
|
const pkgPathSet = new Set(
|
|
397
393
|
Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
|
|
@@ -408,17 +404,17 @@ class SysExecutor extends Executor {
|
|
|
408
404
|
const pathSplitLength = path2.split("/").length;
|
|
409
405
|
return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
410
406
|
}).filter((libName) => libName !== this.name);
|
|
411
|
-
if (!
|
|
412
|
-
|
|
413
|
-
const files =
|
|
414
|
-
const dirnames = (await
|
|
415
|
-
(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()
|
|
416
412
|
);
|
|
417
413
|
const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
|
|
418
414
|
const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
|
|
419
415
|
await Promise.all(
|
|
420
416
|
databaseDirs.map(async (name) => {
|
|
421
|
-
const filenames = await
|
|
417
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", name));
|
|
422
418
|
filenames.forEach((filename) => {
|
|
423
419
|
if (filename.endsWith(".constant.ts"))
|
|
424
420
|
files.constants.databases.push(name);
|
|
@@ -440,7 +436,7 @@ class SysExecutor extends Executor {
|
|
|
440
436
|
await Promise.all(
|
|
441
437
|
serviceDirs.map(async (dirname) => {
|
|
442
438
|
const name = dirname.slice(1);
|
|
443
|
-
const filenames = await
|
|
439
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib", dirname));
|
|
444
440
|
filenames.forEach((filename) => {
|
|
445
441
|
if (filename.endsWith(".dictionary.ts"))
|
|
446
442
|
files.dictionary.services.push(name);
|
|
@@ -455,12 +451,12 @@ class SysExecutor extends Executor {
|
|
|
455
451
|
});
|
|
456
452
|
})
|
|
457
453
|
);
|
|
458
|
-
const scalarDirs = (await
|
|
454
|
+
const scalarDirs = (await fsPromise.readdir(`${this.cwdPath}/lib/__scalar`)).filter(
|
|
459
455
|
(name) => !name.startsWith("_")
|
|
460
456
|
);
|
|
461
457
|
await Promise.all(
|
|
462
458
|
scalarDirs.map(async (name) => {
|
|
463
|
-
const filenames = await
|
|
459
|
+
const filenames = await fsPromise.readdir(path.join(this.cwdPath, "lib/__scalar", name));
|
|
464
460
|
filenames.forEach((filename) => {
|
|
465
461
|
if (filename.endsWith(".constant.ts"))
|
|
466
462
|
files.constants.scalars.push(name);
|
|
@@ -535,25 +531,47 @@ class SysExecutor extends Executor {
|
|
|
535
531
|
return scanResult;
|
|
536
532
|
}
|
|
537
533
|
getLocalFile(filePath) {
|
|
538
|
-
const filepath =
|
|
534
|
+
const filepath = path.isAbsolute(filePath) ? filePath : `${this.type}s/${this.name}/${filePath}`;
|
|
539
535
|
const content = this.workspace.readFile(filepath);
|
|
540
536
|
return { filepath, content };
|
|
541
537
|
}
|
|
542
538
|
async getDatabaseModules() {
|
|
543
|
-
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`));
|
|
544
540
|
return databaseModules;
|
|
545
541
|
}
|
|
546
542
|
async getServiceModules() {
|
|
547
|
-
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`));
|
|
548
544
|
return serviceModules;
|
|
549
545
|
}
|
|
550
546
|
async getScalarModules() {
|
|
551
|
-
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`));
|
|
552
548
|
return scalarModules;
|
|
553
549
|
}
|
|
554
|
-
async
|
|
555
|
-
const
|
|
556
|
-
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
|
+
);
|
|
557
575
|
}
|
|
558
576
|
async getScalarConstantFiles() {
|
|
559
577
|
const scalarModules = await this.getScalarModules();
|
|
@@ -573,8 +591,10 @@ class SysExecutor extends Executor {
|
|
|
573
591
|
}
|
|
574
592
|
}
|
|
575
593
|
class AppExecutor extends SysExecutor {
|
|
594
|
+
dist;
|
|
576
595
|
constructor({ workspace, name }) {
|
|
577
596
|
super({ workspace, name, type: "app" });
|
|
597
|
+
this.dist = new Executor(`${name} Dist App Executor`, `${this.workspace.workspaceRoot}/dist/apps/${name}`);
|
|
578
598
|
}
|
|
579
599
|
static from(executor, name) {
|
|
580
600
|
if (executor instanceof WorkspaceExecutor)
|
|
@@ -582,7 +602,7 @@ class AppExecutor extends SysExecutor {
|
|
|
582
602
|
return new AppExecutor({ workspace: executor.workspace, name });
|
|
583
603
|
}
|
|
584
604
|
async getConfig(command) {
|
|
585
|
-
return await
|
|
605
|
+
return await getAppConfig(this.cwdPath, {
|
|
586
606
|
...this.workspace.getBaseDevEnv(),
|
|
587
607
|
type: "app",
|
|
588
608
|
name: this.name,
|
|
@@ -591,36 +611,26 @@ class AppExecutor extends SysExecutor {
|
|
|
591
611
|
}
|
|
592
612
|
async syncAssets(libDeps) {
|
|
593
613
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
594
|
-
if (
|
|
595
|
-
await
|
|
596
|
-
const targetDeps = libDeps.filter((dep) =>
|
|
597
|
-
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 })));
|
|
598
618
|
await Promise.all(
|
|
599
619
|
targetDeps.map(
|
|
600
|
-
(dep) =>
|
|
620
|
+
(dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
601
621
|
recursive: true
|
|
602
622
|
})
|
|
603
623
|
)
|
|
604
624
|
);
|
|
605
625
|
}
|
|
606
626
|
}
|
|
607
|
-
class DistAppExecutor extends Executor {
|
|
608
|
-
name;
|
|
609
|
-
constructor({ workspace, name }) {
|
|
610
|
-
super(`${name} Dist App Executor`, `${workspace.workspaceRoot}/dist/apps/${name}`);
|
|
611
|
-
this.name = name;
|
|
612
|
-
}
|
|
613
|
-
static from(executor, name) {
|
|
614
|
-
if (executor instanceof WorkspaceExecutor)
|
|
615
|
-
return new DistAppExecutor({ workspace: executor, name });
|
|
616
|
-
return new DistAppExecutor({ workspace: executor.workspace, name });
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
627
|
class LibExecutor extends SysExecutor {
|
|
620
628
|
workspaceRoot;
|
|
621
629
|
repoName;
|
|
630
|
+
dist;
|
|
622
631
|
constructor({ workspace, name }) {
|
|
623
632
|
super({ workspace, name, type: "lib" });
|
|
633
|
+
this.dist = new Executor(`${name} Dist Lib Executor`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
|
|
624
634
|
}
|
|
625
635
|
static from(executor, name) {
|
|
626
636
|
if (executor instanceof WorkspaceExecutor)
|
|
@@ -628,7 +638,7 @@ class LibExecutor extends SysExecutor {
|
|
|
628
638
|
return new LibExecutor({ workspace: executor.workspace, name });
|
|
629
639
|
}
|
|
630
640
|
async getConfig(command) {
|
|
631
|
-
return await
|
|
641
|
+
return await getLibConfig(this.cwdPath, {
|
|
632
642
|
...this.workspace.getBaseDevEnv(),
|
|
633
643
|
type: "lib",
|
|
634
644
|
name: this.name,
|
|
@@ -636,25 +646,15 @@ class LibExecutor extends SysExecutor {
|
|
|
636
646
|
});
|
|
637
647
|
}
|
|
638
648
|
}
|
|
639
|
-
class DistLibExecutor extends Executor {
|
|
640
|
-
name;
|
|
641
|
-
constructor({ workspace, name }) {
|
|
642
|
-
super(`${name} Dist Lib Executor`, `${workspace.workspaceRoot}/dist/libs/${name}`);
|
|
643
|
-
this.name = name;
|
|
644
|
-
}
|
|
645
|
-
static from(executor, name) {
|
|
646
|
-
if (executor instanceof WorkspaceExecutor)
|
|
647
|
-
return new DistAppExecutor({ workspace: executor, name });
|
|
648
|
-
return new DistLibExecutor({ workspace: executor.workspace, name });
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
649
|
class PkgExecutor extends Executor {
|
|
652
650
|
workspace;
|
|
653
651
|
name;
|
|
652
|
+
dist;
|
|
654
653
|
constructor({ workspace = WorkspaceExecutor.fromRoot(), name }) {
|
|
655
654
|
super(`${name} Pkg Executor`, `${workspace.workspaceRoot}/pkgs/${name}`);
|
|
656
655
|
this.workspace = workspace;
|
|
657
656
|
this.name = name;
|
|
657
|
+
this.dist = new Executor(`${name} Dist Pkg Executor`, `${this.workspace.workspaceRoot}/dist/pkgs/${name}`);
|
|
658
658
|
}
|
|
659
659
|
static from(executor, name) {
|
|
660
660
|
if (executor instanceof WorkspaceExecutor)
|
|
@@ -666,7 +666,7 @@ class PkgExecutor extends Executor {
|
|
|
666
666
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`)
|
|
667
667
|
} = {}) {
|
|
668
668
|
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
669
|
-
const scanner = new
|
|
669
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
670
670
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
671
671
|
const pkgPathSet = new Set(
|
|
672
672
|
Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
|
|
@@ -684,33 +684,11 @@ class PkgExecutor extends Executor {
|
|
|
684
684
|
return pkgScanResult;
|
|
685
685
|
}
|
|
686
686
|
}
|
|
687
|
-
|
|
688
|
-
workspaceRoot;
|
|
689
|
-
repoName;
|
|
690
|
-
name;
|
|
691
|
-
constructor({ workspaceRoot, repoName, name }) {
|
|
692
|
-
super(`${name} Dist Pkg Executor`, `${workspaceRoot}/dist/pkgs/${name}`);
|
|
693
|
-
this.workspaceRoot = workspaceRoot;
|
|
694
|
-
this.repoName = repoName;
|
|
695
|
-
this.name = name;
|
|
696
|
-
}
|
|
697
|
-
static from(workspaceExecutor, name) {
|
|
698
|
-
return new DistPkgExecutor({
|
|
699
|
-
workspaceRoot: workspaceExecutor.workspaceRoot,
|
|
700
|
-
repoName: workspaceExecutor.repoName,
|
|
701
|
-
name
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
706
|
-
0 && (module.exports = {
|
|
687
|
+
export {
|
|
707
688
|
AppExecutor,
|
|
708
|
-
DistAppExecutor,
|
|
709
|
-
DistLibExecutor,
|
|
710
|
-
DistPkgExecutor,
|
|
711
689
|
Executor,
|
|
712
690
|
LibExecutor,
|
|
713
691
|
PkgExecutor,
|
|
714
692
|
SysExecutor,
|
|
715
693
|
WorkspaceExecutor
|
|
716
|
-
}
|
|
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
|
+
};
|