@akanjs/devkit 0.0.142 → 0.0.144
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/cjs/src/aiEditor.js +151 -13
- package/cjs/src/builder.js +1 -2
- package/cjs/src/commandDecorators/argMeta.js +4 -1
- package/cjs/src/commandDecorators/command.js +44 -6
- package/cjs/src/executors.js +165 -60
- package/cjs/src/guideline.js +15 -0
- package/cjs/src/index.js +5 -1
- package/cjs/src/linter.js +238 -0
- package/cjs/src/prompter.js +78 -0
- package/cjs/src/typeChecker.js +203 -0
- package/cjs/src/uploadRelease.js +59 -33
- package/esm/src/aiEditor.js +157 -14
- package/esm/src/builder.js +1 -2
- package/esm/src/commandDecorators/argMeta.js +3 -1
- package/esm/src/commandDecorators/command.js +45 -7
- package/esm/src/executors.js +165 -61
- package/esm/src/guideline.js +0 -0
- package/esm/src/index.js +2 -0
- package/esm/src/linter.js +205 -0
- package/esm/src/prompter.js +45 -0
- package/esm/src/typeChecker.js +170 -0
- package/esm/src/uploadRelease.js +59 -33
- package/package.json +3 -1
- package/src/aiEditor.d.ts +23 -4
- package/src/commandDecorators/argMeta.d.ts +6 -2
- package/src/executors.d.ts +74 -23
- package/src/guideline.d.ts +19 -0
- package/src/index.d.ts +2 -0
- package/src/linter.d.ts +109 -0
- package/src/prompter.d.ts +13 -0
- package/src/typeChecker.d.ts +49 -0
- package/src/types.d.ts +4 -0
- package/src/uploadRelease.d.ts +1 -1
package/cjs/src/executors.js
CHANGED
|
@@ -30,6 +30,7 @@ __export(executors_exports, {
|
|
|
30
30
|
AppExecutor: () => AppExecutor,
|
|
31
31
|
Executor: () => Executor,
|
|
32
32
|
LibExecutor: () => LibExecutor,
|
|
33
|
+
ModuleExecutor: () => ModuleExecutor,
|
|
33
34
|
PkgExecutor: () => PkgExecutor,
|
|
34
35
|
SysExecutor: () => SysExecutor,
|
|
35
36
|
WorkspaceExecutor: () => WorkspaceExecutor,
|
|
@@ -45,13 +46,16 @@ var import_fs = __toESM(require("fs"));
|
|
|
45
46
|
var import_promises = __toESM(require("fs/promises"));
|
|
46
47
|
var import_path = __toESM(require("path"));
|
|
47
48
|
var import_dependencyScanner = require("./dependencyScanner");
|
|
49
|
+
var import_linter = require("./linter");
|
|
48
50
|
var import_spinner = require("./spinner");
|
|
51
|
+
var import_typeChecker = require("./typeChecker");
|
|
49
52
|
const execEmoji = {
|
|
50
53
|
workspace: "\u{1F3E0}",
|
|
51
54
|
app: "\u{1F680}",
|
|
52
55
|
lib: "\u{1F527}",
|
|
53
56
|
pkg: "\u{1F4E6}",
|
|
54
57
|
dist: "\u{1F4BF}",
|
|
58
|
+
module: "\u2699\uFE0F",
|
|
55
59
|
default: "\u2708\uFE0F"
|
|
56
60
|
// for sys executor
|
|
57
61
|
};
|
|
@@ -64,6 +68,8 @@ class Executor {
|
|
|
64
68
|
logger;
|
|
65
69
|
cwdPath;
|
|
66
70
|
emoji = execEmoji.default;
|
|
71
|
+
typeChecker = null;
|
|
72
|
+
linter = null;
|
|
67
73
|
constructor(name, cwdPath) {
|
|
68
74
|
this.name = name;
|
|
69
75
|
this.logger = new import_common.Logger(name);
|
|
@@ -98,28 +104,32 @@ class Executor {
|
|
|
98
104
|
spawn(command, args = [], options = {}) {
|
|
99
105
|
const proc = (0, import_child_process.spawn)(command, args, {
|
|
100
106
|
cwd: this.cwdPath,
|
|
101
|
-
stdio: "inherit",
|
|
107
|
+
// stdio: "inherit",
|
|
102
108
|
...options
|
|
103
109
|
});
|
|
110
|
+
let stdout = "";
|
|
111
|
+
proc.stdout?.on("data", (data) => {
|
|
112
|
+
stdout += data;
|
|
113
|
+
});
|
|
104
114
|
proc.stdout?.on("data", (data) => {
|
|
105
115
|
this.#stdout(data);
|
|
106
116
|
});
|
|
107
117
|
proc.stderr?.on("data", (data) => {
|
|
108
|
-
this.#
|
|
118
|
+
this.#stdout(data);
|
|
109
119
|
});
|
|
110
120
|
return new Promise((resolve, reject) => {
|
|
111
121
|
proc.on("exit", (code, signal) => {
|
|
112
122
|
if (!!code || signal)
|
|
113
|
-
reject({ code, signal });
|
|
123
|
+
reject({ code, signal, stdout });
|
|
114
124
|
else
|
|
115
|
-
resolve(
|
|
125
|
+
resolve(stdout);
|
|
116
126
|
});
|
|
117
127
|
});
|
|
118
128
|
}
|
|
119
129
|
fork(modulePath, args = [], options = {}) {
|
|
120
130
|
const proc = (0, import_child_process.fork)(modulePath, args, {
|
|
121
131
|
cwd: this.cwdPath,
|
|
122
|
-
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
132
|
+
// stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
123
133
|
...options
|
|
124
134
|
});
|
|
125
135
|
proc.stdout?.on("data", (data) => {
|
|
@@ -137,45 +147,70 @@ class Executor {
|
|
|
137
147
|
});
|
|
138
148
|
});
|
|
139
149
|
}
|
|
140
|
-
|
|
141
|
-
|
|
150
|
+
getPath(filePath) {
|
|
151
|
+
if (import_path.default.isAbsolute(filePath))
|
|
152
|
+
return filePath;
|
|
153
|
+
const baseParts = this.cwdPath.split("/").filter(Boolean);
|
|
154
|
+
const targetParts = filePath.split("/").filter(Boolean);
|
|
155
|
+
let overlapLength = 0;
|
|
156
|
+
for (let i = 1; i <= Math.min(baseParts.length, targetParts.length); i++) {
|
|
157
|
+
let isOverlap = true;
|
|
158
|
+
for (let j = 0; j < i; j++)
|
|
159
|
+
if (baseParts[baseParts.length - i + j] !== targetParts[j]) {
|
|
160
|
+
isOverlap = false;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
if (isOverlap)
|
|
164
|
+
overlapLength = i;
|
|
165
|
+
}
|
|
166
|
+
const result = overlapLength > 0 ? `/${[...baseParts, ...targetParts.slice(overlapLength)].join("/")}` : `${this.cwdPath}/${filePath}`;
|
|
167
|
+
return result.replace(/\/+/g, "/");
|
|
142
168
|
}
|
|
143
169
|
mkdir(dirPath) {
|
|
144
|
-
const writePath = this
|
|
170
|
+
const writePath = this.getPath(dirPath);
|
|
145
171
|
if (!import_fs.default.existsSync(writePath))
|
|
146
172
|
import_fs.default.mkdirSync(writePath, { recursive: true });
|
|
147
173
|
this.logger.verbose(`Make directory ${writePath}`);
|
|
148
174
|
return this;
|
|
149
175
|
}
|
|
176
|
+
async readdir(dirPath) {
|
|
177
|
+
const readPath = this.getPath(dirPath);
|
|
178
|
+
try {
|
|
179
|
+
return await import_promises.default.readdir(readPath);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
150
184
|
exists(filePath) {
|
|
151
|
-
const readPath = this
|
|
185
|
+
const readPath = this.getPath(filePath);
|
|
152
186
|
return import_fs.default.existsSync(readPath);
|
|
153
187
|
}
|
|
154
188
|
remove(filePath) {
|
|
155
|
-
const readPath = this
|
|
189
|
+
const readPath = this.getPath(filePath);
|
|
156
190
|
if (import_fs.default.existsSync(readPath))
|
|
157
191
|
import_fs.default.unlinkSync(readPath);
|
|
158
192
|
this.logger.verbose(`Remove file ${readPath}`);
|
|
159
193
|
return this;
|
|
160
194
|
}
|
|
161
195
|
removeDir(dirPath) {
|
|
162
|
-
const readPath = this
|
|
196
|
+
const readPath = this.getPath(dirPath);
|
|
163
197
|
if (import_fs.default.existsSync(readPath))
|
|
164
198
|
import_fs.default.rmSync(readPath, { recursive: true });
|
|
165
199
|
this.logger.verbose(`Remove directory ${readPath}`);
|
|
166
200
|
return this;
|
|
167
201
|
}
|
|
168
202
|
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
169
|
-
const writePath = this
|
|
203
|
+
const writePath = this.getPath(filePath);
|
|
170
204
|
const dir = import_path.default.dirname(writePath);
|
|
171
205
|
if (!import_fs.default.existsSync(dir))
|
|
172
206
|
import_fs.default.mkdirSync(dir, { recursive: true });
|
|
173
|
-
|
|
207
|
+
let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
174
208
|
if (import_fs.default.existsSync(writePath)) {
|
|
175
209
|
const currentContent = import_fs.default.readFileSync(writePath, "utf8");
|
|
176
|
-
if (currentContent === contentStr || !overwrite)
|
|
210
|
+
if (currentContent === contentStr || !overwrite) {
|
|
177
211
|
this.logger.verbose(`File ${writePath} is unchanged`);
|
|
178
|
-
|
|
212
|
+
contentStr = import_fs.default.readFileSync(writePath, "utf-8");
|
|
213
|
+
} else {
|
|
179
214
|
import_fs.default.writeFileSync(writePath, contentStr, "utf8");
|
|
180
215
|
this.logger.verbose(`File ${writePath} is changed`);
|
|
181
216
|
}
|
|
@@ -183,28 +218,28 @@ class Executor {
|
|
|
183
218
|
import_fs.default.writeFileSync(writePath, contentStr, "utf8");
|
|
184
219
|
this.logger.verbose(`File ${writePath} is created`);
|
|
185
220
|
}
|
|
186
|
-
return
|
|
221
|
+
return { filePath: writePath, content: contentStr };
|
|
187
222
|
}
|
|
188
223
|
writeJson(filePath, content) {
|
|
189
224
|
this.writeFile(filePath, JSON.stringify(content, null, 2) + "\n");
|
|
190
225
|
return this;
|
|
191
226
|
}
|
|
192
|
-
getLocalFile(
|
|
193
|
-
const
|
|
194
|
-
const content = this.readFile(
|
|
195
|
-
return {
|
|
227
|
+
getLocalFile(targetPath) {
|
|
228
|
+
const filePath = import_path.default.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
|
|
229
|
+
const content = this.readFile(filePath);
|
|
230
|
+
return { filePath, content };
|
|
196
231
|
}
|
|
197
232
|
readFile(filePath) {
|
|
198
|
-
const readPath = this
|
|
233
|
+
const readPath = this.getPath(filePath);
|
|
199
234
|
return import_fs.default.readFileSync(readPath, "utf8");
|
|
200
235
|
}
|
|
201
236
|
readJson(filePath) {
|
|
202
|
-
const readPath = this
|
|
237
|
+
const readPath = this.getPath(filePath);
|
|
203
238
|
return JSON.parse(import_fs.default.readFileSync(readPath, "utf8"));
|
|
204
239
|
}
|
|
205
240
|
async cp(srcPath, destPath) {
|
|
206
|
-
const src = this
|
|
207
|
-
const dest = this
|
|
241
|
+
const src = this.getPath(srcPath);
|
|
242
|
+
const dest = this.getPath(destPath);
|
|
208
243
|
await import_promises.default.cp(src, dest, { recursive: true });
|
|
209
244
|
}
|
|
210
245
|
log(msg) {
|
|
@@ -240,7 +275,7 @@ class Executor {
|
|
|
240
275
|
const getContent = require(templatePath);
|
|
241
276
|
const result = getContent.default(scanResult ?? null, dict);
|
|
242
277
|
if (result === null)
|
|
243
|
-
return;
|
|
278
|
+
return null;
|
|
244
279
|
const filename = typeof result === "object" ? result.filename : import_path.default.basename(targetPath).replace(".js", ".ts");
|
|
245
280
|
const content = typeof result === "object" ? result.content : result;
|
|
246
281
|
const dirname = import_path.default.dirname(targetPath);
|
|
@@ -249,7 +284,7 @@ class Executor {
|
|
|
249
284
|
`${dirname}/${filename}`
|
|
250
285
|
);
|
|
251
286
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
252
|
-
this.writeFile(convertedTargetPath, content, { overwrite });
|
|
287
|
+
return this.writeFile(convertedTargetPath, content, { overwrite });
|
|
253
288
|
} else if (targetPath.endsWith(".template")) {
|
|
254
289
|
const content = await import_promises.default.readFile(templatePath, "utf8");
|
|
255
290
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
@@ -261,10 +296,11 @@ class Executor {
|
|
|
261
296
|
content
|
|
262
297
|
);
|
|
263
298
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
264
|
-
this.writeFile(convertedTargetPath, convertedContent, { overwrite });
|
|
265
|
-
}
|
|
299
|
+
return this.writeFile(convertedTargetPath, convertedContent, { overwrite });
|
|
300
|
+
} else
|
|
301
|
+
return null;
|
|
266
302
|
}
|
|
267
|
-
async
|
|
303
|
+
async _applyTemplate({
|
|
268
304
|
basePath,
|
|
269
305
|
template,
|
|
270
306
|
scanResult,
|
|
@@ -274,22 +310,24 @@ class Executor {
|
|
|
274
310
|
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
275
311
|
if (import_fs.default.statSync(templatePath).isFile()) {
|
|
276
312
|
const filename = import_path.default.basename(templatePath);
|
|
277
|
-
await this.#applyTemplateFile(
|
|
313
|
+
const fileContent = await this.#applyTemplateFile(
|
|
278
314
|
{ templatePath, targetPath: import_path.default.join(basePath, filename), scanResult, overwrite },
|
|
279
315
|
dict
|
|
280
316
|
);
|
|
317
|
+
return fileContent ? [fileContent] : [];
|
|
281
318
|
} else {
|
|
282
|
-
const subdirs = await
|
|
283
|
-
await Promise.all(
|
|
319
|
+
const subdirs = await this.readdir(templatePath);
|
|
320
|
+
const fileContents = (await Promise.all(
|
|
284
321
|
subdirs.map(async (subdir) => {
|
|
285
322
|
const subpath = import_path.default.join(templatePath, subdir);
|
|
286
|
-
if (import_fs.default.statSync(subpath).isFile())
|
|
287
|
-
await this.#applyTemplateFile(
|
|
323
|
+
if (import_fs.default.statSync(subpath).isFile()) {
|
|
324
|
+
const fileContent = await this.#applyTemplateFile(
|
|
288
325
|
{ templatePath: subpath, targetPath: import_path.default.join(basePath, subdir), scanResult, overwrite },
|
|
289
326
|
dict
|
|
290
327
|
);
|
|
291
|
-
|
|
292
|
-
|
|
328
|
+
return fileContent ? [fileContent] : [];
|
|
329
|
+
} else
|
|
330
|
+
return await this._applyTemplate({
|
|
293
331
|
basePath: import_path.default.join(basePath, subdir),
|
|
294
332
|
template: import_path.default.join(template, subdir),
|
|
295
333
|
scanResult,
|
|
@@ -297,9 +335,41 @@ class Executor {
|
|
|
297
335
|
overwrite
|
|
298
336
|
});
|
|
299
337
|
})
|
|
300
|
-
);
|
|
338
|
+
)).flat();
|
|
339
|
+
return fileContents;
|
|
301
340
|
}
|
|
302
341
|
}
|
|
342
|
+
async applyTemplate(options) {
|
|
343
|
+
const dict = {
|
|
344
|
+
...options.dict ?? {},
|
|
345
|
+
...Object.fromEntries(
|
|
346
|
+
Object.entries(options.dict ?? {}).map(([key, value]) => [(0, import_common.capitalize)(key), (0, import_common.capitalize)(value)])
|
|
347
|
+
)
|
|
348
|
+
};
|
|
349
|
+
return this._applyTemplate({ ...options, dict });
|
|
350
|
+
}
|
|
351
|
+
getTypeChecker() {
|
|
352
|
+
this.typeChecker ??= new import_typeChecker.TypeChecker(this);
|
|
353
|
+
return this.typeChecker;
|
|
354
|
+
}
|
|
355
|
+
typeCheck(filePath) {
|
|
356
|
+
const path2 = this.getPath(filePath);
|
|
357
|
+
const typeChecker = this.getTypeChecker();
|
|
358
|
+
const { diagnostics, errors, warnings } = typeChecker.check(path2);
|
|
359
|
+
const message = typeChecker.formatDiagnostics(diagnostics);
|
|
360
|
+
return { diagnostics, errors, warnings, message };
|
|
361
|
+
}
|
|
362
|
+
getLinter() {
|
|
363
|
+
this.linter ??= new import_linter.Linter(this.cwdPath);
|
|
364
|
+
return this.linter;
|
|
365
|
+
}
|
|
366
|
+
async lint(filePath, { fix = false, dryRun = false } = {}) {
|
|
367
|
+
const path2 = this.getPath(filePath);
|
|
368
|
+
const linter = this.getLinter();
|
|
369
|
+
const { results, errors, warnings } = await linter.lint(path2, { fix, dryRun });
|
|
370
|
+
const message = linter.formatLintResults(results);
|
|
371
|
+
return { results, message, errors, warnings };
|
|
372
|
+
}
|
|
303
373
|
}
|
|
304
374
|
class WorkspaceExecutor extends Executor {
|
|
305
375
|
workspaceRoot;
|
|
@@ -412,7 +482,7 @@ class WorkspaceExecutor extends Executor {
|
|
|
412
482
|
async getDirInModule(basePath, name) {
|
|
413
483
|
const AVOID_DIRS = ["__lib", "__scalar", `_`, `_${name}`];
|
|
414
484
|
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
415
|
-
const dirs = await
|
|
485
|
+
const dirs = await this.readdir(dirname);
|
|
416
486
|
await Promise.all(
|
|
417
487
|
dirs.map(async (dir) => {
|
|
418
488
|
if (dir.includes("_") || AVOID_DIRS.includes(dir))
|
|
@@ -439,7 +509,7 @@ class WorkspaceExecutor extends Executor {
|
|
|
439
509
|
async #getDirHasFile(basePath, targetFilename) {
|
|
440
510
|
const AVOID_DIRS = ["node_modules", "dist", "public", "./next"];
|
|
441
511
|
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
442
|
-
const dirs = await
|
|
512
|
+
const dirs = await this.readdir(dirname);
|
|
443
513
|
await Promise.all(
|
|
444
514
|
dirs.map(async (dir) => {
|
|
445
515
|
if (AVOID_DIRS.includes(dir))
|
|
@@ -537,14 +607,14 @@ class SysExecutor extends Executor {
|
|
|
537
607
|
if (!import_fs.default.existsSync(`${this.cwdPath}/lib/__scalar`))
|
|
538
608
|
import_fs.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
|
|
539
609
|
const files = (0, import_config.getDefaultFileScan)();
|
|
540
|
-
const dirnames = (await
|
|
610
|
+
const dirnames = (await this.readdir("lib")).filter(
|
|
541
611
|
(name) => import_fs.default.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
|
|
542
612
|
);
|
|
543
613
|
const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
|
|
544
614
|
const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
|
|
545
615
|
await Promise.all(
|
|
546
616
|
databaseDirs.map(async (name) => {
|
|
547
|
-
const filenames = await
|
|
617
|
+
const filenames = await this.readdir(import_path.default.join("lib", name));
|
|
548
618
|
filenames.forEach((filename) => {
|
|
549
619
|
if (filename.endsWith(".constant.ts"))
|
|
550
620
|
files.constants.databases.push(name);
|
|
@@ -566,7 +636,7 @@ class SysExecutor extends Executor {
|
|
|
566
636
|
await Promise.all(
|
|
567
637
|
serviceDirs.map(async (dirname) => {
|
|
568
638
|
const name = dirname.slice(1);
|
|
569
|
-
const filenames = await
|
|
639
|
+
const filenames = await this.readdir(import_path.default.join("lib", dirname));
|
|
570
640
|
filenames.forEach((filename) => {
|
|
571
641
|
if (filename.endsWith(".dictionary.ts"))
|
|
572
642
|
files.dictionary.services.push(name);
|
|
@@ -581,12 +651,10 @@ class SysExecutor extends Executor {
|
|
|
581
651
|
});
|
|
582
652
|
})
|
|
583
653
|
);
|
|
584
|
-
const scalarDirs = (await
|
|
585
|
-
(name) => !name.startsWith("_")
|
|
586
|
-
);
|
|
654
|
+
const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
|
|
587
655
|
await Promise.all(
|
|
588
656
|
scalarDirs.map(async (name) => {
|
|
589
|
-
const filenames = await
|
|
657
|
+
const filenames = await this.readdir(import_path.default.join("lib/__scalar", name));
|
|
590
658
|
filenames.forEach((filename) => {
|
|
591
659
|
if (filename.endsWith(".constant.ts"))
|
|
592
660
|
files.constants.scalars.push(name);
|
|
@@ -633,11 +701,11 @@ class SysExecutor extends Executor {
|
|
|
633
701
|
dependencies: [...npmDepSet].filter((dep) => !dep.startsWith("@akanjs")),
|
|
634
702
|
libs: Object.fromEntries(akanConfig.libs.map((libName) => [libName, libScanResults[libName]]))
|
|
635
703
|
};
|
|
636
|
-
await this.
|
|
637
|
-
await this.
|
|
638
|
-
await this.
|
|
704
|
+
await this._applyTemplate({ basePath: "lib", template: "lib", scanResult });
|
|
705
|
+
await this._applyTemplate({ basePath: ".", template: "server.ts", scanResult });
|
|
706
|
+
await this._applyTemplate({ basePath: ".", template: "client.ts", scanResult });
|
|
639
707
|
if (this.type === "lib")
|
|
640
|
-
await this.
|
|
708
|
+
await this._applyTemplate({ basePath: ".", template: "index.ts", scanResult });
|
|
641
709
|
this.writeJson(`akan.${this.type}.json`, scanResult);
|
|
642
710
|
if (this.type === "app")
|
|
643
711
|
return scanResult;
|
|
@@ -660,33 +728,33 @@ class SysExecutor extends Executor {
|
|
|
660
728
|
this.writeJson("package.json", libPkgJsonWithDeps);
|
|
661
729
|
return scanResult;
|
|
662
730
|
}
|
|
663
|
-
getLocalFile(
|
|
664
|
-
const
|
|
665
|
-
const content = this.workspace.readFile(
|
|
666
|
-
return {
|
|
731
|
+
getLocalFile(targetPath) {
|
|
732
|
+
const filePath = import_path.default.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
|
|
733
|
+
const content = this.workspace.readFile(filePath);
|
|
734
|
+
return { filePath, content };
|
|
667
735
|
}
|
|
668
736
|
async getDatabaseModules() {
|
|
669
|
-
const databaseModules = (await
|
|
737
|
+
const databaseModules = (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.constant.ts`));
|
|
670
738
|
return databaseModules;
|
|
671
739
|
}
|
|
672
740
|
async getServiceModules() {
|
|
673
|
-
const serviceModules = (await
|
|
741
|
+
const serviceModules = (await this.readdir("lib")).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.service.ts`));
|
|
674
742
|
return serviceModules;
|
|
675
743
|
}
|
|
676
744
|
async getScalarModules() {
|
|
677
|
-
const scalarModules = (await
|
|
745
|
+
const scalarModules = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/__scalar/${name}/${name}.constant.ts`));
|
|
678
746
|
return scalarModules;
|
|
679
747
|
}
|
|
680
748
|
async getViewComponents() {
|
|
681
|
-
const viewComponents = (await
|
|
749
|
+
const viewComponents = (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.View.tsx`));
|
|
682
750
|
return viewComponents;
|
|
683
751
|
}
|
|
684
752
|
async getUnitComponents() {
|
|
685
|
-
const unitComponents = (await
|
|
753
|
+
const unitComponents = (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.Unit.tsx`));
|
|
686
754
|
return unitComponents;
|
|
687
755
|
}
|
|
688
756
|
async getTemplateComponents() {
|
|
689
|
-
const templateComponents = (await
|
|
757
|
+
const templateComponents = (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => import_fs.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.Template.tsx`));
|
|
690
758
|
return templateComponents;
|
|
691
759
|
}
|
|
692
760
|
async getViewsSourceCode() {
|
|
@@ -717,10 +785,35 @@ class SysExecutor extends Executor {
|
|
|
717
785
|
const modules = await this.getModules();
|
|
718
786
|
return modules.map((module2) => this.getLocalFile(`lib/${module2}/${module2}.constant.ts`));
|
|
719
787
|
}
|
|
788
|
+
async getConstantFilesWithLibs() {
|
|
789
|
+
const config = await this.getConfig();
|
|
790
|
+
const sysContantFiles = await this.getConstantFiles();
|
|
791
|
+
const sysScalarConstantFiles = await this.getScalarConstantFiles();
|
|
792
|
+
const libConstantFiles = await Promise.all(
|
|
793
|
+
config.libs.map(async (lib) => [
|
|
794
|
+
...await LibExecutor.from(this, lib).getConstantFiles(),
|
|
795
|
+
...await LibExecutor.from(this, lib).getScalarConstantFiles()
|
|
796
|
+
])
|
|
797
|
+
);
|
|
798
|
+
return [...sysContantFiles, ...sysScalarConstantFiles, ...libConstantFiles.flat()];
|
|
799
|
+
}
|
|
720
800
|
async getDictionaryFiles() {
|
|
721
801
|
const modules = await this.getModules();
|
|
722
802
|
return modules.map((module2) => this.getLocalFile(`lib/${module2}/${module2}.dictionary.ts`));
|
|
723
803
|
}
|
|
804
|
+
async applyTemplate(options) {
|
|
805
|
+
const dict = {
|
|
806
|
+
...options.dict ?? {},
|
|
807
|
+
...Object.fromEntries(
|
|
808
|
+
Object.entries(options.dict ?? {}).map(([key, value]) => [(0, import_common.capitalize)(key), (0, import_common.capitalize)(value)])
|
|
809
|
+
)
|
|
810
|
+
};
|
|
811
|
+
const akanConfig = await this.getConfig();
|
|
812
|
+
const scanResult = await this.scan({ akanConfig });
|
|
813
|
+
const fileContents = await this._applyTemplate({ ...options, scanResult, dict });
|
|
814
|
+
await this.scan({ akanConfig });
|
|
815
|
+
return fileContents;
|
|
816
|
+
}
|
|
724
817
|
setTsPaths() {
|
|
725
818
|
this.workspace.setTsPaths(this.type, this.name);
|
|
726
819
|
return this;
|
|
@@ -826,11 +919,23 @@ class PkgExecutor extends Executor {
|
|
|
826
919
|
return pkgScanResult;
|
|
827
920
|
}
|
|
828
921
|
}
|
|
922
|
+
class ModuleExecutor extends Executor {
|
|
923
|
+
sys;
|
|
924
|
+
emoji = execEmoji.module;
|
|
925
|
+
constructor({ sys, name }) {
|
|
926
|
+
super(name, `${sys.workspace.workspaceRoot}/${sys.type}s/${sys.name}/lib/${name}`);
|
|
927
|
+
this.sys = sys;
|
|
928
|
+
}
|
|
929
|
+
static from(sysExecutor, name) {
|
|
930
|
+
return new ModuleExecutor({ sys: sysExecutor, name });
|
|
931
|
+
}
|
|
932
|
+
}
|
|
829
933
|
// Annotate the CommonJS export names for ESM import in node:
|
|
830
934
|
0 && (module.exports = {
|
|
831
935
|
AppExecutor,
|
|
832
936
|
Executor,
|
|
833
937
|
LibExecutor,
|
|
938
|
+
ModuleExecutor,
|
|
834
939
|
PkgExecutor,
|
|
835
940
|
SysExecutor,
|
|
836
941
|
WorkspaceExecutor,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var guideline_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(guideline_exports);
|
package/cjs/src/index.js
CHANGED
|
@@ -32,6 +32,8 @@ __reExport(src_exports, require("./commandDecorators"), module.exports);
|
|
|
32
32
|
__reExport(src_exports, require("./aiEditor"), module.exports);
|
|
33
33
|
__reExport(src_exports, require("./builder"), module.exports);
|
|
34
34
|
__reExport(src_exports, require("./spinner"), module.exports);
|
|
35
|
+
__reExport(src_exports, require("./prompter"), module.exports);
|
|
36
|
+
__reExport(src_exports, require("./guideline"), module.exports);
|
|
35
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
38
|
0 && (module.exports = {
|
|
37
39
|
...require("./createTunnel"),
|
|
@@ -51,5 +53,7 @@ __reExport(src_exports, require("./spinner"), module.exports);
|
|
|
51
53
|
...require("./commandDecorators"),
|
|
52
54
|
...require("./aiEditor"),
|
|
53
55
|
...require("./builder"),
|
|
54
|
-
...require("./spinner")
|
|
56
|
+
...require("./spinner"),
|
|
57
|
+
...require("./prompter"),
|
|
58
|
+
...require("./guideline")
|
|
55
59
|
});
|