@akanjs/devkit 0.0.143 → 0.0.145
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 +152 -16
- package/cjs/src/builder.js +1 -2
- package/cjs/src/commandDecorators/command.js +0 -1
- package/cjs/src/executors.js +151 -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 +158 -17
- package/esm/src/builder.js +1 -2
- package/esm/src/commandDecorators/command.js +0 -1
- package/esm/src/executors.js +152 -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/executors.d.ts +63 -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
|
@@ -46,7 +46,9 @@ var import_fs = __toESM(require("fs"));
|
|
|
46
46
|
var import_promises = __toESM(require("fs/promises"));
|
|
47
47
|
var import_path = __toESM(require("path"));
|
|
48
48
|
var import_dependencyScanner = require("./dependencyScanner");
|
|
49
|
+
var import_linter = require("./linter");
|
|
49
50
|
var import_spinner = require("./spinner");
|
|
51
|
+
var import_typeChecker = require("./typeChecker");
|
|
50
52
|
const execEmoji = {
|
|
51
53
|
workspace: "\u{1F3E0}",
|
|
52
54
|
app: "\u{1F680}",
|
|
@@ -66,6 +68,8 @@ class Executor {
|
|
|
66
68
|
logger;
|
|
67
69
|
cwdPath;
|
|
68
70
|
emoji = execEmoji.default;
|
|
71
|
+
typeChecker = null;
|
|
72
|
+
linter = null;
|
|
69
73
|
constructor(name, cwdPath) {
|
|
70
74
|
this.name = name;
|
|
71
75
|
this.logger = new import_common.Logger(name);
|
|
@@ -100,28 +104,32 @@ class Executor {
|
|
|
100
104
|
spawn(command, args = [], options = {}) {
|
|
101
105
|
const proc = (0, import_child_process.spawn)(command, args, {
|
|
102
106
|
cwd: this.cwdPath,
|
|
103
|
-
stdio: "inherit",
|
|
107
|
+
// stdio: "inherit",
|
|
104
108
|
...options
|
|
105
109
|
});
|
|
110
|
+
let stdout = "";
|
|
111
|
+
proc.stdout?.on("data", (data) => {
|
|
112
|
+
stdout += data;
|
|
113
|
+
});
|
|
106
114
|
proc.stdout?.on("data", (data) => {
|
|
107
115
|
this.#stdout(data);
|
|
108
116
|
});
|
|
109
117
|
proc.stderr?.on("data", (data) => {
|
|
110
|
-
this.#
|
|
118
|
+
this.#stdout(data);
|
|
111
119
|
});
|
|
112
120
|
return new Promise((resolve, reject) => {
|
|
113
121
|
proc.on("exit", (code, signal) => {
|
|
114
122
|
if (!!code || signal)
|
|
115
|
-
reject({ code, signal });
|
|
123
|
+
reject({ code, signal, stdout });
|
|
116
124
|
else
|
|
117
|
-
resolve(
|
|
125
|
+
resolve(stdout);
|
|
118
126
|
});
|
|
119
127
|
});
|
|
120
128
|
}
|
|
121
129
|
fork(modulePath, args = [], options = {}) {
|
|
122
130
|
const proc = (0, import_child_process.fork)(modulePath, args, {
|
|
123
131
|
cwd: this.cwdPath,
|
|
124
|
-
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
132
|
+
// stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
125
133
|
...options
|
|
126
134
|
});
|
|
127
135
|
proc.stdout?.on("data", (data) => {
|
|
@@ -139,45 +147,70 @@ class Executor {
|
|
|
139
147
|
});
|
|
140
148
|
});
|
|
141
149
|
}
|
|
142
|
-
|
|
143
|
-
|
|
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, "/");
|
|
144
168
|
}
|
|
145
169
|
mkdir(dirPath) {
|
|
146
|
-
const writePath = this
|
|
170
|
+
const writePath = this.getPath(dirPath);
|
|
147
171
|
if (!import_fs.default.existsSync(writePath))
|
|
148
172
|
import_fs.default.mkdirSync(writePath, { recursive: true });
|
|
149
173
|
this.logger.verbose(`Make directory ${writePath}`);
|
|
150
174
|
return this;
|
|
151
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
|
+
}
|
|
152
184
|
exists(filePath) {
|
|
153
|
-
const readPath = this
|
|
185
|
+
const readPath = this.getPath(filePath);
|
|
154
186
|
return import_fs.default.existsSync(readPath);
|
|
155
187
|
}
|
|
156
188
|
remove(filePath) {
|
|
157
|
-
const readPath = this
|
|
189
|
+
const readPath = this.getPath(filePath);
|
|
158
190
|
if (import_fs.default.existsSync(readPath))
|
|
159
191
|
import_fs.default.unlinkSync(readPath);
|
|
160
192
|
this.logger.verbose(`Remove file ${readPath}`);
|
|
161
193
|
return this;
|
|
162
194
|
}
|
|
163
195
|
removeDir(dirPath) {
|
|
164
|
-
const readPath = this
|
|
196
|
+
const readPath = this.getPath(dirPath);
|
|
165
197
|
if (import_fs.default.existsSync(readPath))
|
|
166
198
|
import_fs.default.rmSync(readPath, { recursive: true });
|
|
167
199
|
this.logger.verbose(`Remove directory ${readPath}`);
|
|
168
200
|
return this;
|
|
169
201
|
}
|
|
170
202
|
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
171
|
-
const writePath = this
|
|
203
|
+
const writePath = this.getPath(filePath);
|
|
172
204
|
const dir = import_path.default.dirname(writePath);
|
|
173
205
|
if (!import_fs.default.existsSync(dir))
|
|
174
206
|
import_fs.default.mkdirSync(dir, { recursive: true });
|
|
175
|
-
|
|
207
|
+
let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
176
208
|
if (import_fs.default.existsSync(writePath)) {
|
|
177
209
|
const currentContent = import_fs.default.readFileSync(writePath, "utf8");
|
|
178
|
-
if (currentContent === contentStr || !overwrite)
|
|
210
|
+
if (currentContent === contentStr || !overwrite) {
|
|
179
211
|
this.logger.verbose(`File ${writePath} is unchanged`);
|
|
180
|
-
|
|
212
|
+
contentStr = import_fs.default.readFileSync(writePath, "utf-8");
|
|
213
|
+
} else {
|
|
181
214
|
import_fs.default.writeFileSync(writePath, contentStr, "utf8");
|
|
182
215
|
this.logger.verbose(`File ${writePath} is changed`);
|
|
183
216
|
}
|
|
@@ -185,28 +218,28 @@ class Executor {
|
|
|
185
218
|
import_fs.default.writeFileSync(writePath, contentStr, "utf8");
|
|
186
219
|
this.logger.verbose(`File ${writePath} is created`);
|
|
187
220
|
}
|
|
188
|
-
return
|
|
221
|
+
return { filePath: writePath, content: contentStr };
|
|
189
222
|
}
|
|
190
223
|
writeJson(filePath, content) {
|
|
191
224
|
this.writeFile(filePath, JSON.stringify(content, null, 2) + "\n");
|
|
192
225
|
return this;
|
|
193
226
|
}
|
|
194
|
-
getLocalFile(
|
|
195
|
-
const
|
|
196
|
-
const content = this.readFile(
|
|
197
|
-
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 };
|
|
198
231
|
}
|
|
199
232
|
readFile(filePath) {
|
|
200
|
-
const readPath = this
|
|
233
|
+
const readPath = this.getPath(filePath);
|
|
201
234
|
return import_fs.default.readFileSync(readPath, "utf8");
|
|
202
235
|
}
|
|
203
236
|
readJson(filePath) {
|
|
204
|
-
const readPath = this
|
|
237
|
+
const readPath = this.getPath(filePath);
|
|
205
238
|
return JSON.parse(import_fs.default.readFileSync(readPath, "utf8"));
|
|
206
239
|
}
|
|
207
240
|
async cp(srcPath, destPath) {
|
|
208
|
-
const src = this
|
|
209
|
-
const dest = this
|
|
241
|
+
const src = this.getPath(srcPath);
|
|
242
|
+
const dest = this.getPath(destPath);
|
|
210
243
|
await import_promises.default.cp(src, dest, { recursive: true });
|
|
211
244
|
}
|
|
212
245
|
log(msg) {
|
|
@@ -242,7 +275,7 @@ class Executor {
|
|
|
242
275
|
const getContent = require(templatePath);
|
|
243
276
|
const result = getContent.default(scanResult ?? null, dict);
|
|
244
277
|
if (result === null)
|
|
245
|
-
return;
|
|
278
|
+
return null;
|
|
246
279
|
const filename = typeof result === "object" ? result.filename : import_path.default.basename(targetPath).replace(".js", ".ts");
|
|
247
280
|
const content = typeof result === "object" ? result.content : result;
|
|
248
281
|
const dirname = import_path.default.dirname(targetPath);
|
|
@@ -251,7 +284,7 @@ class Executor {
|
|
|
251
284
|
`${dirname}/${filename}`
|
|
252
285
|
);
|
|
253
286
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
254
|
-
this.writeFile(convertedTargetPath, content, { overwrite });
|
|
287
|
+
return this.writeFile(convertedTargetPath, content, { overwrite });
|
|
255
288
|
} else if (targetPath.endsWith(".template")) {
|
|
256
289
|
const content = await import_promises.default.readFile(templatePath, "utf8");
|
|
257
290
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
@@ -263,10 +296,11 @@ class Executor {
|
|
|
263
296
|
content
|
|
264
297
|
);
|
|
265
298
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
266
|
-
this.writeFile(convertedTargetPath, convertedContent, { overwrite });
|
|
267
|
-
}
|
|
299
|
+
return this.writeFile(convertedTargetPath, convertedContent, { overwrite });
|
|
300
|
+
} else
|
|
301
|
+
return null;
|
|
268
302
|
}
|
|
269
|
-
async
|
|
303
|
+
async _applyTemplate({
|
|
270
304
|
basePath,
|
|
271
305
|
template,
|
|
272
306
|
scanResult,
|
|
@@ -276,22 +310,24 @@ class Executor {
|
|
|
276
310
|
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
277
311
|
if (import_fs.default.statSync(templatePath).isFile()) {
|
|
278
312
|
const filename = import_path.default.basename(templatePath);
|
|
279
|
-
await this.#applyTemplateFile(
|
|
313
|
+
const fileContent = await this.#applyTemplateFile(
|
|
280
314
|
{ templatePath, targetPath: import_path.default.join(basePath, filename), scanResult, overwrite },
|
|
281
315
|
dict
|
|
282
316
|
);
|
|
317
|
+
return fileContent ? [fileContent] : [];
|
|
283
318
|
} else {
|
|
284
|
-
const subdirs = await
|
|
285
|
-
await Promise.all(
|
|
319
|
+
const subdirs = await this.readdir(templatePath);
|
|
320
|
+
const fileContents = (await Promise.all(
|
|
286
321
|
subdirs.map(async (subdir) => {
|
|
287
322
|
const subpath = import_path.default.join(templatePath, subdir);
|
|
288
|
-
if (import_fs.default.statSync(subpath).isFile())
|
|
289
|
-
await this.#applyTemplateFile(
|
|
323
|
+
if (import_fs.default.statSync(subpath).isFile()) {
|
|
324
|
+
const fileContent = await this.#applyTemplateFile(
|
|
290
325
|
{ templatePath: subpath, targetPath: import_path.default.join(basePath, subdir), scanResult, overwrite },
|
|
291
326
|
dict
|
|
292
327
|
);
|
|
293
|
-
|
|
294
|
-
|
|
328
|
+
return fileContent ? [fileContent] : [];
|
|
329
|
+
} else
|
|
330
|
+
return await this._applyTemplate({
|
|
295
331
|
basePath: import_path.default.join(basePath, subdir),
|
|
296
332
|
template: import_path.default.join(template, subdir),
|
|
297
333
|
scanResult,
|
|
@@ -299,9 +335,41 @@ class Executor {
|
|
|
299
335
|
overwrite
|
|
300
336
|
});
|
|
301
337
|
})
|
|
302
|
-
);
|
|
338
|
+
)).flat();
|
|
339
|
+
return fileContents;
|
|
303
340
|
}
|
|
304
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
|
+
}
|
|
305
373
|
}
|
|
306
374
|
class WorkspaceExecutor extends Executor {
|
|
307
375
|
workspaceRoot;
|
|
@@ -414,7 +482,7 @@ class WorkspaceExecutor extends Executor {
|
|
|
414
482
|
async getDirInModule(basePath, name) {
|
|
415
483
|
const AVOID_DIRS = ["__lib", "__scalar", `_`, `_${name}`];
|
|
416
484
|
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
417
|
-
const dirs = await
|
|
485
|
+
const dirs = await this.readdir(dirname);
|
|
418
486
|
await Promise.all(
|
|
419
487
|
dirs.map(async (dir) => {
|
|
420
488
|
if (dir.includes("_") || AVOID_DIRS.includes(dir))
|
|
@@ -441,7 +509,7 @@ class WorkspaceExecutor extends Executor {
|
|
|
441
509
|
async #getDirHasFile(basePath, targetFilename) {
|
|
442
510
|
const AVOID_DIRS = ["node_modules", "dist", "public", "./next"];
|
|
443
511
|
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
444
|
-
const dirs = await
|
|
512
|
+
const dirs = await this.readdir(dirname);
|
|
445
513
|
await Promise.all(
|
|
446
514
|
dirs.map(async (dir) => {
|
|
447
515
|
if (AVOID_DIRS.includes(dir))
|
|
@@ -539,14 +607,14 @@ class SysExecutor extends Executor {
|
|
|
539
607
|
if (!import_fs.default.existsSync(`${this.cwdPath}/lib/__scalar`))
|
|
540
608
|
import_fs.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
|
|
541
609
|
const files = (0, import_config.getDefaultFileScan)();
|
|
542
|
-
const dirnames = (await
|
|
610
|
+
const dirnames = (await this.readdir("lib")).filter(
|
|
543
611
|
(name) => import_fs.default.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
|
|
544
612
|
);
|
|
545
613
|
const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
|
|
546
614
|
const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
|
|
547
615
|
await Promise.all(
|
|
548
616
|
databaseDirs.map(async (name) => {
|
|
549
|
-
const filenames = await
|
|
617
|
+
const filenames = await this.readdir(import_path.default.join("lib", name));
|
|
550
618
|
filenames.forEach((filename) => {
|
|
551
619
|
if (filename.endsWith(".constant.ts"))
|
|
552
620
|
files.constants.databases.push(name);
|
|
@@ -568,7 +636,7 @@ class SysExecutor extends Executor {
|
|
|
568
636
|
await Promise.all(
|
|
569
637
|
serviceDirs.map(async (dirname) => {
|
|
570
638
|
const name = dirname.slice(1);
|
|
571
|
-
const filenames = await
|
|
639
|
+
const filenames = await this.readdir(import_path.default.join("lib", dirname));
|
|
572
640
|
filenames.forEach((filename) => {
|
|
573
641
|
if (filename.endsWith(".dictionary.ts"))
|
|
574
642
|
files.dictionary.services.push(name);
|
|
@@ -583,12 +651,10 @@ class SysExecutor extends Executor {
|
|
|
583
651
|
});
|
|
584
652
|
})
|
|
585
653
|
);
|
|
586
|
-
const scalarDirs = (await
|
|
587
|
-
(name) => !name.startsWith("_")
|
|
588
|
-
);
|
|
654
|
+
const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
|
|
589
655
|
await Promise.all(
|
|
590
656
|
scalarDirs.map(async (name) => {
|
|
591
|
-
const filenames = await
|
|
657
|
+
const filenames = await this.readdir(import_path.default.join("lib/__scalar", name));
|
|
592
658
|
filenames.forEach((filename) => {
|
|
593
659
|
if (filename.endsWith(".constant.ts"))
|
|
594
660
|
files.constants.scalars.push(name);
|
|
@@ -635,11 +701,11 @@ class SysExecutor extends Executor {
|
|
|
635
701
|
dependencies: [...npmDepSet].filter((dep) => !dep.startsWith("@akanjs")),
|
|
636
702
|
libs: Object.fromEntries(akanConfig.libs.map((libName) => [libName, libScanResults[libName]]))
|
|
637
703
|
};
|
|
638
|
-
await this.
|
|
639
|
-
await this.
|
|
640
|
-
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 });
|
|
641
707
|
if (this.type === "lib")
|
|
642
|
-
await this.
|
|
708
|
+
await this._applyTemplate({ basePath: ".", template: "index.ts", scanResult });
|
|
643
709
|
this.writeJson(`akan.${this.type}.json`, scanResult);
|
|
644
710
|
if (this.type === "app")
|
|
645
711
|
return scanResult;
|
|
@@ -662,33 +728,33 @@ class SysExecutor extends Executor {
|
|
|
662
728
|
this.writeJson("package.json", libPkgJsonWithDeps);
|
|
663
729
|
return scanResult;
|
|
664
730
|
}
|
|
665
|
-
getLocalFile(
|
|
666
|
-
const
|
|
667
|
-
const content = this.workspace.readFile(
|
|
668
|
-
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 };
|
|
669
735
|
}
|
|
670
736
|
async getDatabaseModules() {
|
|
671
|
-
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`));
|
|
672
738
|
return databaseModules;
|
|
673
739
|
}
|
|
674
740
|
async getServiceModules() {
|
|
675
|
-
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`));
|
|
676
742
|
return serviceModules;
|
|
677
743
|
}
|
|
678
744
|
async getScalarModules() {
|
|
679
|
-
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`));
|
|
680
746
|
return scalarModules;
|
|
681
747
|
}
|
|
682
748
|
async getViewComponents() {
|
|
683
|
-
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`));
|
|
684
750
|
return viewComponents;
|
|
685
751
|
}
|
|
686
752
|
async getUnitComponents() {
|
|
687
|
-
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`));
|
|
688
754
|
return unitComponents;
|
|
689
755
|
}
|
|
690
756
|
async getTemplateComponents() {
|
|
691
|
-
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`));
|
|
692
758
|
return templateComponents;
|
|
693
759
|
}
|
|
694
760
|
async getViewsSourceCode() {
|
|
@@ -719,10 +785,35 @@ class SysExecutor extends Executor {
|
|
|
719
785
|
const modules = await this.getModules();
|
|
720
786
|
return modules.map((module2) => this.getLocalFile(`lib/${module2}/${module2}.constant.ts`));
|
|
721
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
|
+
}
|
|
722
800
|
async getDictionaryFiles() {
|
|
723
801
|
const modules = await this.getModules();
|
|
724
802
|
return modules.map((module2) => this.getLocalFile(`lib/${module2}/${module2}.dictionary.ts`));
|
|
725
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
|
+
}
|
|
726
817
|
setTsPaths() {
|
|
727
818
|
this.workspace.setTsPaths(this.type, this.name);
|
|
728
819
|
return this;
|
|
@@ -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
|
});
|