@akanjs/devkit 0.0.146 → 0.0.148

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.
@@ -240,7 +240,7 @@ ${validate.map((v) => `- ${v}`).join("\n")}`;
240
240
  writes.map(async ({ filePath }) => {
241
241
  const typeCheckResult = executor.typeCheck(filePath);
242
242
  const lintResult = await executor.lint(filePath);
243
- const needFix2 = !!typeCheckResult.errors.length || !!lintResult.errors.length;
243
+ const needFix2 = !!typeCheckResult.fileErrors.length || !!lintResult.errors.length;
244
244
  return { filePath, typeCheckResult, lintResult, needFix: needFix2 };
245
245
  })
246
246
  );
@@ -274,7 +274,7 @@ ${fileCheck.lintResult.message}`
274
274
  throw new Error("Failed to create scalar");
275
275
  }
276
276
  #getTypescriptCodes(text) {
277
- const codes = text.match(/```typescript([\s\S]*?)```/g);
277
+ const codes = text.match(/```(typescript|tsx)([\s\S]*?)```/g);
278
278
  if (!codes)
279
279
  return [];
280
280
  const result = codes.map((code) => {
@@ -355,9 +355,9 @@ class Executor {
355
355
  typeCheck(filePath) {
356
356
  const path2 = this.getPath(filePath);
357
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 };
358
+ const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path2);
359
+ const message = typeChecker.formatDiagnostics(fileDiagnostics);
360
+ return { fileDiagnostics, fileErrors, fileWarnings, message };
361
361
  }
362
362
  getLinter() {
363
363
  this.linter ??= new import_linter.Linter(this.cwdPath);
@@ -47,6 +47,9 @@ class Prompter {
47
47
  const content = await import_promises.default.readFile(filePath, "utf-8");
48
48
  return content;
49
49
  }
50
+ static async getUpdateRequest(guideName) {
51
+ return await (0, import_prompts.input)({ message: `What do you want to update in ${guideName}?` });
52
+ }
50
53
  async makeTsFileUpdatePrompt({ context, request }) {
51
54
  return `You are a senior developer writing TypeScript-based programs using Akan.js, an in-house framework. Here's an overview of the Akan.js framework:
52
55
  ${await this.getDocumentation("framework")}
@@ -78,7 +78,10 @@ ${errorMessages}`);
78
78
  ];
79
79
  const errors = diagnostics.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);
80
80
  const warnings = diagnostics.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Warning);
81
- return { diagnostics, errors, warnings };
81
+ const fileDiagnostics = diagnostics.filter((diagnostic) => diagnostic.file?.fileName === filePath);
82
+ const fileErrors = fileDiagnostics.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);
83
+ const fileWarnings = fileDiagnostics.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Warning);
84
+ return { diagnostics, errors, warnings, fileDiagnostics, fileErrors, fileWarnings };
82
85
  }
83
86
  /**
84
87
  * Format diagnostics for console output
@@ -212,7 +212,7 @@ ${validate.map((v) => `- ${v}`).join("\n")}`;
212
212
  writes.map(async ({ filePath }) => {
213
213
  const typeCheckResult = executor.typeCheck(filePath);
214
214
  const lintResult = await executor.lint(filePath);
215
- const needFix2 = !!typeCheckResult.errors.length || !!lintResult.errors.length;
215
+ const needFix2 = !!typeCheckResult.fileErrors.length || !!lintResult.errors.length;
216
216
  return { filePath, typeCheckResult, lintResult, needFix: needFix2 };
217
217
  })
218
218
  );
@@ -246,7 +246,7 @@ ${fileCheck.lintResult.message}`
246
246
  throw new Error("Failed to create scalar");
247
247
  }
248
248
  #getTypescriptCodes(text) {
249
- const codes = text.match(/```typescript([\s\S]*?)```/g);
249
+ const codes = text.match(/```(typescript|tsx)([\s\S]*?)```/g);
250
250
  if (!codes)
251
251
  return [];
252
252
  const result = codes.map((code) => {
@@ -320,9 +320,9 @@ class Executor {
320
320
  typeCheck(filePath) {
321
321
  const path2 = this.getPath(filePath);
322
322
  const typeChecker = this.getTypeChecker();
323
- const { diagnostics, errors, warnings } = typeChecker.check(path2);
324
- const message = typeChecker.formatDiagnostics(diagnostics);
325
- return { diagnostics, errors, warnings, message };
323
+ const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path2);
324
+ const message = typeChecker.formatDiagnostics(fileDiagnostics);
325
+ return { fileDiagnostics, fileErrors, fileWarnings, message };
326
326
  }
327
327
  getLinter() {
328
328
  this.linter ??= new Linter(this.cwdPath);
@@ -1,4 +1,4 @@
1
- import { select } from "@inquirer/prompts";
1
+ import { input, select } from "@inquirer/prompts";
2
2
  import fsPromise from "fs/promises";
3
3
  class Prompter {
4
4
  static async selectGuideline() {
@@ -15,6 +15,9 @@ class Prompter {
15
15
  const content = await fsPromise.readFile(filePath, "utf-8");
16
16
  return content;
17
17
  }
18
+ static async getUpdateRequest(guideName) {
19
+ return await input({ message: `What do you want to update in ${guideName}?` });
20
+ }
18
21
  async makeTsFileUpdatePrompt({ context, request }) {
19
22
  return `You are a senior developer writing TypeScript-based programs using Akan.js, an in-house framework. Here's an overview of the Akan.js framework:
20
23
  ${await this.getDocumentation("framework")}
@@ -46,7 +46,10 @@ ${errorMessages}`);
46
46
  ];
47
47
  const errors = diagnostics.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);
48
48
  const warnings = diagnostics.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Warning);
49
- return { diagnostics, errors, warnings };
49
+ const fileDiagnostics = diagnostics.filter((diagnostic) => diagnostic.file?.fileName === filePath);
50
+ const fileErrors = fileDiagnostics.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);
51
+ const fileWarnings = fileDiagnostics.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Warning);
52
+ return { diagnostics, errors, warnings, fileDiagnostics, fileErrors, fileWarnings };
50
53
  }
51
54
  /**
52
55
  * Format diagnostics for console output
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "0.0.146",
3
+ "version": "0.0.148",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -72,9 +72,9 @@ export declare class Executor {
72
72
  }): Promise<FileContent[]>;
73
73
  getTypeChecker(): TypeChecker;
74
74
  typeCheck(filePath: string): {
75
- diagnostics: import("typescript").Diagnostic[];
76
- errors: import("typescript").Diagnostic[];
77
- warnings: import("typescript").Diagnostic[];
75
+ fileDiagnostics: import("typescript").Diagnostic[];
76
+ fileErrors: import("typescript").Diagnostic[];
77
+ fileWarnings: import("typescript").Diagnostic[];
78
78
  message: string;
79
79
  };
80
80
  getLinter(): Linter;
@@ -102,7 +102,7 @@ export declare class WorkspaceExecutor extends Executor {
102
102
  getBaseDevEnv(): {
103
103
  repoName: string;
104
104
  serveDomain: string;
105
- env: "debug" | "testing" | "local" | "develop" | "main";
105
+ env: "testing" | "local" | "debug" | "develop" | "main";
106
106
  name?: string | undefined;
107
107
  };
108
108
  scan(): Promise<WorkspaceScanResult>;
@@ -215,7 +215,7 @@ export declare class AppExecutor extends SysExecutor {
215
215
  emoji: string;
216
216
  constructor({ workspace, name }: AppExecutorOptions);
217
217
  static from(executor: SysExecutor | WorkspaceExecutor, name: string): AppExecutor;
218
- getEnv(): "debug" | "testing" | "local" | "develop" | "main";
218
+ getEnv(): "testing" | "local" | "debug" | "develop" | "main";
219
219
  getConfig(command?: string): Promise<AppConfigResult>;
220
220
  syncAssets(libDeps: string[]): Promise<void>;
221
221
  }
package/src/prompter.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare class Prompter {
7
7
  static selectGuideline(): Promise<string>;
8
8
  static getGuideJson(guideName: string): Promise<GuideGenerateJson>;
9
9
  static getInstruction(guideName: string): Promise<string>;
10
+ static getUpdateRequest(guideName: string): Promise<string>;
10
11
  makeTsFileUpdatePrompt({ context, request }: FileUpdateRequestProps): Promise<string>;
11
12
  getDocumentation(guideName: string): Promise<string>;
12
13
  }
@@ -18,6 +18,9 @@ export declare class TypeChecker {
18
18
  diagnostics: ts.Diagnostic[];
19
19
  errors: ts.Diagnostic[];
20
20
  warnings: ts.Diagnostic[];
21
+ fileDiagnostics: ts.Diagnostic[];
22
+ fileErrors: ts.Diagnostic[];
23
+ fileWarnings: ts.Diagnostic[];
21
24
  };
22
25
  /**
23
26
  * Format diagnostics for console output