@akanjs/devkit 2.3.9-rc.0 → 2.3.9-rc.2
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/aiEditor.test.ts +4 -12
- package/akanContext.ts +225 -12
- package/capacitorApp.test.ts +14 -8
- package/commandDecorators/command.ts +2 -1
- package/commandDecorators/commandDecorators.test.ts +13 -0
- package/executors.test.ts +21 -0
- package/executors.ts +5 -4
- package/index.ts +1 -0
- package/linter.ts +27 -74
- package/package.json +2 -2
- package/typecheck/typecheck.proc.ts +1 -2
- package/workflow/index.ts +1162 -0
package/linter.ts
CHANGED
|
@@ -78,15 +78,12 @@ export class Linter {
|
|
|
78
78
|
|
|
79
79
|
#toBiomePath(filePath: string): string {
|
|
80
80
|
const relativePath = path.relative(this.lintRoot, filePath);
|
|
81
|
-
if (!relativePath.startsWith("..") && !path.isAbsolute(relativePath))
|
|
82
|
-
return relativePath;
|
|
81
|
+
if (!relativePath.startsWith("..") && !path.isAbsolute(relativePath)) return relativePath;
|
|
83
82
|
return filePath;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
#resolveFilePath(filePath: string): string {
|
|
87
|
-
return path.isAbsolute(filePath)
|
|
88
|
-
? filePath
|
|
89
|
-
: path.join(this.lintRoot, filePath);
|
|
86
|
+
return path.isAbsolute(filePath) ? filePath : path.join(this.lintRoot, filePath);
|
|
90
87
|
}
|
|
91
88
|
|
|
92
89
|
async #runBiome(args: string[], input?: string) {
|
|
@@ -125,9 +122,7 @@ export class Linter {
|
|
|
125
122
|
#diagnosticFilePath(diagnostic: BiomeDiagnostic, fallbackFilePath: string) {
|
|
126
123
|
const diagnosticPath = diagnostic.location?.path;
|
|
127
124
|
if (!diagnosticPath) return fallbackFilePath;
|
|
128
|
-
return path.isAbsolute(diagnosticPath)
|
|
129
|
-
? diagnosticPath
|
|
130
|
-
: path.join(this.lintRoot, diagnosticPath);
|
|
125
|
+
return path.isAbsolute(diagnosticPath) ? diagnosticPath : path.join(this.lintRoot, diagnosticPath);
|
|
131
126
|
}
|
|
132
127
|
|
|
133
128
|
#createLintMessage(diagnostic: BiomeDiagnostic): LintMessage {
|
|
@@ -148,8 +143,7 @@ export class Linter {
|
|
|
148
143
|
const resultsByPath = new Map<string, LintResult>();
|
|
149
144
|
|
|
150
145
|
for (const diagnostic of report.diagnostics ?? []) {
|
|
151
|
-
if (diagnostic.severity !== "error" && diagnostic.severity !== "warning")
|
|
152
|
-
continue;
|
|
146
|
+
if (diagnostic.severity !== "error" && diagnostic.severity !== "warning") continue;
|
|
153
147
|
const diagnosticFilePath = this.#diagnosticFilePath(diagnostic, filePath);
|
|
154
148
|
const result =
|
|
155
149
|
resultsByPath.get(diagnosticFilePath) ??
|
|
@@ -178,9 +172,7 @@ export class Linter {
|
|
|
178
172
|
fixableErrorCount: 0,
|
|
179
173
|
fixableWarningCount: 0,
|
|
180
174
|
} satisfies LintResult),
|
|
181
|
-
...[...resultsByPath.entries()]
|
|
182
|
-
.filter(([resultPath]) => resultPath !== filePath)
|
|
183
|
-
.map(([, result]) => result),
|
|
175
|
+
...[...resultsByPath.entries()].filter(([resultPath]) => resultPath !== filePath).map(([, result]) => result),
|
|
184
176
|
];
|
|
185
177
|
}
|
|
186
178
|
|
|
@@ -192,13 +184,8 @@ export class Linter {
|
|
|
192
184
|
};
|
|
193
185
|
}
|
|
194
186
|
|
|
195
|
-
async #checkFile(
|
|
196
|
-
filePath:
|
|
197
|
-
{ write = false }: { write?: boolean } = {},
|
|
198
|
-
): Promise<LintResponse> {
|
|
199
|
-
const originalContent = existsSync(filePath)
|
|
200
|
-
? readFileSync(filePath, "utf8")
|
|
201
|
-
: "";
|
|
187
|
+
async #checkFile(filePath: string, { write = false }: { write?: boolean } = {}): Promise<LintResponse> {
|
|
188
|
+
const originalContent = existsSync(filePath) ? readFileSync(filePath, "utf8") : "";
|
|
202
189
|
const { stdout, stderr } = await this.#runBiome([
|
|
203
190
|
"check",
|
|
204
191
|
...(write ? ["--write"] : []),
|
|
@@ -212,10 +199,7 @@ export class Linter {
|
|
|
212
199
|
const report = this.#parseBiomeReport(stdout || stderr);
|
|
213
200
|
const results = this.#toLintResults(report, filePath);
|
|
214
201
|
const { errors, warnings } = this.#splitMessages(results);
|
|
215
|
-
const output =
|
|
216
|
-
write && existsSync(filePath)
|
|
217
|
-
? readFileSync(filePath, "utf8")
|
|
218
|
-
: undefined;
|
|
202
|
+
const output = write && existsSync(filePath) ? readFileSync(filePath, "utf8") : undefined;
|
|
219
203
|
|
|
220
204
|
return {
|
|
221
205
|
fixed: write && output !== originalContent,
|
|
@@ -226,10 +210,7 @@ export class Linter {
|
|
|
226
210
|
};
|
|
227
211
|
}
|
|
228
212
|
|
|
229
|
-
async lint(
|
|
230
|
-
filePath: string,
|
|
231
|
-
{ fix = false, dryRun = false }: { fix?: boolean; dryRun?: boolean } = {},
|
|
232
|
-
) {
|
|
213
|
+
async lint(filePath: string, { fix = false, dryRun = false }: { fix?: boolean; dryRun?: boolean } = {}) {
|
|
233
214
|
if (fix) return await this.fixFile(filePath, dryRun);
|
|
234
215
|
return await this.lintFile(filePath);
|
|
235
216
|
}
|
|
@@ -241,8 +222,7 @@ export class Linter {
|
|
|
241
222
|
*/
|
|
242
223
|
async lintFile(filePath: string): Promise<LintResponse> {
|
|
243
224
|
const resolvedFilePath = this.#resolveFilePath(filePath);
|
|
244
|
-
if (!existsSync(resolvedFilePath))
|
|
245
|
-
throw new Error(`File not found: ${filePath}`);
|
|
225
|
+
if (!existsSync(resolvedFilePath)) throw new Error(`File not found: ${filePath}`);
|
|
246
226
|
return await this.#checkFile(resolvedFilePath);
|
|
247
227
|
}
|
|
248
228
|
|
|
@@ -279,16 +259,10 @@ export class Linter {
|
|
|
279
259
|
const type = message.severity === 2 ? "error" : "warning";
|
|
280
260
|
const typeColor = message.severity === 2 ? chalk.red : chalk.yellow;
|
|
281
261
|
const icon = message.severity === 2 ? "x" : "!";
|
|
282
|
-
const ruleInfo = message.ruleId
|
|
283
|
-
? chalk.dim(` (${message.ruleId})`)
|
|
284
|
-
: "";
|
|
262
|
+
const ruleInfo = message.ruleId ? chalk.dim(` (${message.ruleId})`) : "";
|
|
285
263
|
|
|
286
|
-
output.push(
|
|
287
|
-
|
|
288
|
-
);
|
|
289
|
-
output.push(
|
|
290
|
-
` ${chalk.gray("at")} ${result.filePath}:${chalk.bold(`${message.line}:${message.column}`)}`,
|
|
291
|
-
);
|
|
264
|
+
output.push(`\n ${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
|
|
265
|
+
output.push(` ${chalk.gray("at")} ${result.filePath}:${chalk.bold(`${message.line}:${message.column}`)}`);
|
|
292
266
|
|
|
293
267
|
// Show source line with underline
|
|
294
268
|
if (sourceLines.length > 0 && message.line <= sourceLines.length) {
|
|
@@ -299,28 +273,19 @@ export class Linter {
|
|
|
299
273
|
|
|
300
274
|
// Create underline
|
|
301
275
|
const underlinePrefix = " ".repeat(message.column - 1);
|
|
302
|
-
const underlineLength = message.endColumn
|
|
303
|
-
? message.endColumn - message.column
|
|
304
|
-
: 1;
|
|
276
|
+
const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
|
|
305
277
|
const underline = "^".repeat(Math.max(1, underlineLength));
|
|
306
278
|
|
|
307
|
-
output.push(
|
|
308
|
-
`${chalk.dim(`${" ".repeat(lineNumber.length)} |`)} ${underlinePrefix}${typeColor(underline)}`,
|
|
309
|
-
);
|
|
279
|
+
output.push(`${chalk.dim(`${" ".repeat(lineNumber.length)} |`)} ${underlinePrefix}${typeColor(underline)}`);
|
|
310
280
|
}
|
|
311
281
|
});
|
|
312
282
|
}
|
|
313
283
|
});
|
|
314
284
|
|
|
315
|
-
if (totalErrors === 0 && totalWarnings === 0)
|
|
316
|
-
return chalk.bold("No Biome errors or warnings found");
|
|
285
|
+
if (totalErrors === 0 && totalWarnings === 0) return chalk.bold("No Biome errors or warnings found");
|
|
317
286
|
|
|
318
|
-
const errorText =
|
|
319
|
-
|
|
320
|
-
const warningText =
|
|
321
|
-
totalWarnings > 0
|
|
322
|
-
? chalk.yellow(`${totalWarnings} warning(s)`)
|
|
323
|
-
: "0 warnings";
|
|
287
|
+
const errorText = totalErrors > 0 ? chalk.red(`${totalErrors} error(s)`) : "0 errors";
|
|
288
|
+
const warningText = totalWarnings > 0 ? chalk.yellow(`${totalWarnings} warning(s)`) : "0 warnings";
|
|
324
289
|
const summary = [`\n${errorText}, ${warningText} found`];
|
|
325
290
|
|
|
326
291
|
return summary.concat(output).join("\n");
|
|
@@ -355,8 +320,7 @@ export class Linter {
|
|
|
355
320
|
column: message.column,
|
|
356
321
|
message: message.message,
|
|
357
322
|
ruleId: message.ruleId,
|
|
358
|
-
severity:
|
|
359
|
-
message.severity === 2 ? ("error" as const) : ("warning" as const),
|
|
323
|
+
severity: message.severity === 2 ? ("error" as const) : ("warning" as const),
|
|
360
324
|
})),
|
|
361
325
|
);
|
|
362
326
|
|
|
@@ -365,8 +329,7 @@ export class Linter {
|
|
|
365
329
|
errorCount: acc.errorCount + result.errorCount,
|
|
366
330
|
warningCount: acc.warningCount + result.warningCount,
|
|
367
331
|
fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
|
|
368
|
-
fixableWarningCount:
|
|
369
|
-
acc.fixableWarningCount + result.fixableWarningCount,
|
|
332
|
+
fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount,
|
|
370
333
|
}),
|
|
371
334
|
{
|
|
372
335
|
errorCount: 0,
|
|
@@ -400,9 +363,7 @@ export class Linter {
|
|
|
400
363
|
*/
|
|
401
364
|
async getErrors(filePath: string): Promise<LintMessage[]> {
|
|
402
365
|
const { results } = await this.lintFile(filePath);
|
|
403
|
-
return results.flatMap((result) =>
|
|
404
|
-
result.messages.filter((message) => message.severity === 2),
|
|
405
|
-
);
|
|
366
|
+
return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
406
367
|
}
|
|
407
368
|
|
|
408
369
|
/**
|
|
@@ -412,9 +373,7 @@ export class Linter {
|
|
|
412
373
|
*/
|
|
413
374
|
async getWarnings(filePath: string): Promise<LintMessage[]> {
|
|
414
375
|
const { results } = await this.lintFile(filePath);
|
|
415
|
-
return results.flatMap((result) =>
|
|
416
|
-
result.messages.filter((message) => message.severity === 1),
|
|
417
|
-
);
|
|
376
|
+
return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
418
377
|
}
|
|
419
378
|
|
|
420
379
|
/**
|
|
@@ -425,11 +384,9 @@ export class Linter {
|
|
|
425
384
|
*/
|
|
426
385
|
async fixFile(filePath: string, dryRun = false): Promise<LintResponse> {
|
|
427
386
|
const resolvedFilePath = this.#resolveFilePath(filePath);
|
|
428
|
-
if (!existsSync(resolvedFilePath))
|
|
429
|
-
throw new Error(`File not found: ${filePath}`);
|
|
387
|
+
if (!existsSync(resolvedFilePath)) throw new Error(`File not found: ${filePath}`);
|
|
430
388
|
|
|
431
|
-
if (!dryRun)
|
|
432
|
-
return await this.#checkFile(resolvedFilePath, { write: true });
|
|
389
|
+
if (!dryRun) return await this.#checkFile(resolvedFilePath, { write: true });
|
|
433
390
|
|
|
434
391
|
const source = readFileSync(resolvedFilePath, "utf8");
|
|
435
392
|
const { stdout } = await this.#runBiome(
|
|
@@ -454,11 +411,8 @@ export class Linter {
|
|
|
454
411
|
*/
|
|
455
412
|
async getConfigForFile(filePath: string): Promise<unknown> {
|
|
456
413
|
const resolvedFilePath = this.#resolveFilePath(filePath);
|
|
457
|
-
if (!existsSync(resolvedFilePath))
|
|
458
|
-
|
|
459
|
-
return JSON.parse(
|
|
460
|
-
readFileSync(path.join(this.lintRoot, "biome.json"), "utf8"),
|
|
461
|
-
) as unknown;
|
|
414
|
+
if (!existsSync(resolvedFilePath)) throw new Error(`File not found: ${filePath}`);
|
|
415
|
+
return JSON.parse(readFileSync(path.join(this.lintRoot, "biome.json"), "utf8")) as unknown;
|
|
462
416
|
}
|
|
463
417
|
|
|
464
418
|
/**
|
|
@@ -472,8 +426,7 @@ export class Linter {
|
|
|
472
426
|
|
|
473
427
|
results.forEach((result) => {
|
|
474
428
|
result.messages.forEach((message) => {
|
|
475
|
-
if (message.ruleId)
|
|
476
|
-
ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
|
|
429
|
+
if (message.ruleId) ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
|
|
477
430
|
});
|
|
478
431
|
});
|
|
479
432
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "2.3.9-rc.
|
|
3
|
+
"version": "2.3.9-rc.2",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@langchain/openai": "^1.4.6",
|
|
33
33
|
"@tailwindcss/node": "^4.3.0",
|
|
34
34
|
"@trapezedev/project": "^7.1.4",
|
|
35
|
-
"akanjs": "2.3.9-rc.
|
|
35
|
+
"akanjs": "2.3.9-rc.2",
|
|
36
36
|
"chalk": "^5.6.2",
|
|
37
37
|
"commander": "^14.0.3",
|
|
38
38
|
"daisyui": "5.5.23",
|
|
@@ -8,8 +8,7 @@ try {
|
|
|
8
8
|
if (!cwdPath) throw new Error("AKAN_TYPECHECK_CWD is required");
|
|
9
9
|
|
|
10
10
|
const typeChecker = new TypeChecker({ cwdPath } as never);
|
|
11
|
-
const { fileDiagnostics, fileErrors, fileWarnings } =
|
|
12
|
-
typeChecker.check(filePath);
|
|
11
|
+
const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(filePath);
|
|
13
12
|
const message = typeChecker.formatDiagnostics(fileDiagnostics);
|
|
14
13
|
Logger.rawLog(
|
|
15
14
|
JSON.stringify({
|