@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.
@@ -1,14 +1,17 @@
1
1
  import { Logger } from "@akanjs/common";
2
2
  import { type AppConfigResult, AppScanResult, type LibConfigResult, LibScanResult, PkgScanResult, WorkspaceScanResult } from "@akanjs/config";
3
3
  import { type ExecOptions, type ForkOptions, type SpawnOptions } from "child_process";
4
+ import { Linter } from "./linter";
4
5
  import { Spinner } from "./spinner";
5
- import type { PackageJson, TsConfigJson } from "./types";
6
+ import { TypeChecker } from "./typeChecker";
7
+ import type { FileContent, PackageJson, TsConfigJson } from "./types";
6
8
  export declare const execEmoji: {
7
9
  workspace: string;
8
10
  app: string;
9
11
  lib: string;
10
12
  pkg: string;
11
13
  dist: string;
14
+ module: string;
12
15
  default: string;
13
16
  };
14
17
  export declare class Executor {
@@ -19,23 +22,24 @@ export declare class Executor {
19
22
  logger: Logger;
20
23
  cwdPath: string;
21
24
  emoji: string;
25
+ typeChecker: TypeChecker | null;
26
+ linter: Linter | null;
22
27
  constructor(name: string, cwdPath: string);
23
28
  exec(command: string, options?: ExecOptions): Promise<unknown>;
24
- spawn(command: string, args?: string[], options?: SpawnOptions): Promise<{
25
- code: number | null;
26
- signal: string | null;
27
- }>;
29
+ spawn(command: string, args?: string[], options?: SpawnOptions): Promise<string>;
28
30
  fork(modulePath: string, args?: string[], options?: ForkOptions): Promise<unknown>;
31
+ getPath(filePath: string): string;
29
32
  mkdir(dirPath: string): this;
33
+ readdir(dirPath: string): Promise<string[]>;
30
34
  exists(filePath: string): boolean;
31
35
  remove(filePath: string): this;
32
36
  removeDir(dirPath: string): this;
33
37
  writeFile(filePath: string, content: string | object, { overwrite }?: {
34
38
  overwrite?: boolean;
35
- }): this;
39
+ }): FileContent;
36
40
  writeJson(filePath: string, content: object): this;
37
- getLocalFile(filePath: string): {
38
- filepath: string;
41
+ getLocalFile(targetPath: string): {
42
+ filePath: string;
39
43
  content: string;
40
44
  };
41
45
  readFile(filePath: string): string;
@@ -49,7 +53,7 @@ export declare class Executor {
49
53
  enableSpin?: boolean | undefined;
50
54
  }): Spinner;
51
55
  getTsConfig(pathname?: string): TsConfigJson;
52
- applyTemplate({ basePath, template, scanResult, dict, overwrite, }: {
56
+ _applyTemplate({ basePath, template, scanResult, dict, overwrite, }: {
53
57
  basePath: string;
54
58
  template: string;
55
59
  scanResult?: AppScanResult | LibScanResult | null;
@@ -57,7 +61,32 @@ export declare class Executor {
57
61
  [key: string]: string;
58
62
  };
59
63
  overwrite?: boolean;
60
- }): Promise<void>;
64
+ }): Promise<FileContent[]>;
65
+ applyTemplate(options: {
66
+ basePath: string;
67
+ template: string;
68
+ dict?: {
69
+ [key: string]: string;
70
+ };
71
+ overwrite?: boolean;
72
+ }): Promise<FileContent[]>;
73
+ getTypeChecker(): TypeChecker;
74
+ typeCheck(filePath: string): {
75
+ diagnostics: import("typescript").Diagnostic[];
76
+ errors: import("typescript").Diagnostic[];
77
+ warnings: import("typescript").Diagnostic[];
78
+ message: string;
79
+ };
80
+ getLinter(): Linter;
81
+ lint(filePath: string, { fix, dryRun }?: {
82
+ fix?: boolean;
83
+ dryRun?: boolean;
84
+ }): Promise<{
85
+ results: import("eslint").ESLint.LintResult[];
86
+ message: string;
87
+ errors: import("eslint").Linter.LintMessage[];
88
+ warnings: import("eslint").Linter.LintMessage[];
89
+ }>;
61
90
  }
62
91
  interface ExecutorOptions {
63
92
  workspaceRoot: string;
@@ -90,19 +119,19 @@ export declare class WorkspaceExecutor extends Executor {
90
119
  add?: boolean;
91
120
  }): Promise<void>;
92
121
  getScalarConstantFiles(): Promise<{
93
- filepath: string;
122
+ filePath: string;
94
123
  content: string;
95
124
  }[]>;
96
125
  getConstantFiles(): Promise<{
97
- filepath: string;
126
+ filePath: string;
98
127
  content: string;
99
128
  }[]>;
100
129
  getDictionaryFiles(): Promise<{
101
- filepath: string;
130
+ filePath: string;
102
131
  content: string;
103
132
  }[]>;
104
133
  getViewFiles(): Promise<{
105
- filepath: string;
134
+ filePath: string;
106
135
  content: string;
107
136
  }[]>;
108
137
  }
@@ -125,8 +154,8 @@ export declare class SysExecutor extends Executor {
125
154
  }, libScanResults?: {
126
155
  [key: string]: LibScanResult;
127
156
  }): Promise<AppScanResult | LibScanResult>;
128
- getLocalFile(filePath: string): {
129
- filepath: string;
157
+ getLocalFile(targetPath: string): {
158
+ filePath: string;
130
159
  content: string;
131
160
  };
132
161
  getDatabaseModules(): Promise<string[]>;
@@ -136,33 +165,45 @@ export declare class SysExecutor extends Executor {
136
165
  getUnitComponents(): Promise<string[]>;
137
166
  getTemplateComponents(): Promise<string[]>;
138
167
  getViewsSourceCode(): Promise<{
139
- filepath: string;
168
+ filePath: string;
140
169
  content: string;
141
170
  }[]>;
142
171
  getUnitsSourceCode(): Promise<{
143
- filepath: string;
172
+ filePath: string;
144
173
  content: string;
145
174
  }[]>;
146
175
  getTemplatesSourceCode(): Promise<{
147
- filepath: string;
176
+ filePath: string;
148
177
  content: string;
149
178
  }[]>;
150
179
  getScalarConstantFiles(): Promise<{
151
- filepath: string;
180
+ filePath: string;
152
181
  content: string;
153
182
  }[]>;
154
183
  getScalarDictionaryFiles(): Promise<{
155
- filepath: string;
184
+ filePath: string;
156
185
  content: string;
157
186
  }[]>;
158
187
  getConstantFiles(): Promise<{
159
- filepath: string;
188
+ filePath: string;
189
+ content: string;
190
+ }[]>;
191
+ getConstantFilesWithLibs(): Promise<{
192
+ filePath: string;
160
193
  content: string;
161
194
  }[]>;
162
195
  getDictionaryFiles(): Promise<{
163
- filepath: string;
196
+ filePath: string;
164
197
  content: string;
165
198
  }[]>;
199
+ applyTemplate(options: {
200
+ basePath: string;
201
+ template: string;
202
+ dict?: {
203
+ [key: string]: string;
204
+ };
205
+ overwrite?: boolean;
206
+ }): Promise<FileContent[]>;
166
207
  setTsPaths(): this;
167
208
  }
168
209
  interface AppExecutorOptions {
@@ -207,4 +248,14 @@ export declare class PkgExecutor extends Executor {
207
248
  tsconfig?: TsConfigJson;
208
249
  }): Promise<PkgScanResult>;
209
250
  }
251
+ interface ModuleExecutorOptions {
252
+ sys: SysExecutor;
253
+ name: string;
254
+ }
255
+ export declare class ModuleExecutor extends Executor {
256
+ sys: SysExecutor;
257
+ emoji: string;
258
+ constructor({ sys, name }: ModuleExecutorOptions);
259
+ static from(sysExecutor: SysExecutor, name: string): ModuleExecutor;
260
+ }
210
261
  export {};
@@ -0,0 +1,19 @@
1
+ export interface GuideScan {
2
+ type: "example" | "source" | "usage" | (string & {});
3
+ description: string;
4
+ path: string;
5
+ filterText?: string;
6
+ sample?: number;
7
+ }
8
+ export interface GuideUpdate {
9
+ filePath: string;
10
+ contents: string[];
11
+ rules: string[];
12
+ }
13
+ export interface GuideGenerateJson {
14
+ title: string;
15
+ description: string;
16
+ scans: GuideScan[];
17
+ update: GuideUpdate;
18
+ page: string;
19
+ }
package/src/index.d.ts CHANGED
@@ -16,3 +16,5 @@ export * from "./commandDecorators";
16
16
  export * from "./aiEditor";
17
17
  export * from "./builder";
18
18
  export * from "./spinner";
19
+ export * from "./prompter";
20
+ export * from "./guideline";
@@ -0,0 +1,109 @@
1
+ import { ESLint, type Linter as ESLintLinter } from "eslint";
2
+ export declare class Linter {
3
+ #private;
4
+ lintRoot: string;
5
+ constructor(cwdPath: string);
6
+ lint(filePath: string, { fix, dryRun }?: {
7
+ fix?: boolean;
8
+ dryRun?: boolean;
9
+ }): Promise<{
10
+ fixed: boolean;
11
+ output?: string;
12
+ results: ESLint.LintResult[];
13
+ errors: ESLintLinter.LintMessage[];
14
+ warnings: ESLintLinter.LintMessage[];
15
+ }>;
16
+ /**
17
+ * Lint a single file using ESLint
18
+ * @param filePath - Path to the file to lint
19
+ * @returns Array of ESLint results
20
+ */
21
+ lintFile(filePath: string): Promise<{
22
+ fixed: boolean;
23
+ output?: string;
24
+ results: ESLint.LintResult[];
25
+ errors: ESLintLinter.LintMessage[];
26
+ warnings: ESLintLinter.LintMessage[];
27
+ }>;
28
+ /**
29
+ * Format lint results for console output
30
+ * @param results - Array of ESLint results
31
+ * @returns Formatted string
32
+ */
33
+ formatLintResults(results: ESLint.LintResult[]): string;
34
+ /**
35
+ * Get detailed lint information
36
+ * @param filePath - Path to the file to lint
37
+ * @returns Object containing detailed lint information
38
+ */
39
+ getDetailedLintInfo(filePath: string): Promise<{
40
+ results: ESLint.LintResult[];
41
+ details: {
42
+ line: number;
43
+ column: number;
44
+ message: string;
45
+ ruleId: string | null;
46
+ severity: "error" | "warning";
47
+ fix?: {
48
+ range: [number, number];
49
+ text: string;
50
+ };
51
+ suggestions?: {
52
+ desc: string;
53
+ fix: {
54
+ range: [number, number];
55
+ text: string;
56
+ };
57
+ }[];
58
+ }[];
59
+ stats: {
60
+ errorCount: number;
61
+ warningCount: number;
62
+ fixableErrorCount: number;
63
+ fixableWarningCount: number;
64
+ };
65
+ }>;
66
+ /**
67
+ * Check if a file has lint errors
68
+ * @param filePath - Path to the file to check
69
+ * @returns true if there are no errors, false otherwise
70
+ */
71
+ hasNoLintErrors(filePath: string): Promise<boolean>;
72
+ /**
73
+ * Get only error messages (excluding warnings)
74
+ * @param filePath - Path to the file to lint
75
+ * @returns Array of error messages
76
+ */
77
+ getErrors(filePath: string): Promise<ESLintLinter.LintMessage[]>;
78
+ /**
79
+ * Get only warning messages
80
+ * @param filePath - Path to the file to lint
81
+ * @returns Array of warning messages
82
+ */
83
+ getWarnings(filePath: string): Promise<ESLintLinter.LintMessage[]>;
84
+ /**
85
+ * Fix lint errors automatically
86
+ * @param filePath - Path to the file to fix
87
+ * @param dryRun - If true, returns the fixed content without writing to file
88
+ * @returns Fixed content and remaining issues
89
+ */
90
+ fixFile(filePath: string, dryRun?: boolean): Promise<{
91
+ fixed: boolean;
92
+ output?: string;
93
+ results: ESLint.LintResult[];
94
+ errors: ESLintLinter.LintMessage[];
95
+ warnings: ESLintLinter.LintMessage[];
96
+ }>;
97
+ /**
98
+ * Get ESLint configuration for a file
99
+ * @param filePath - Path to the file
100
+ * @returns ESLint configuration object
101
+ */
102
+ getConfigForFile(filePath: string): Promise<unknown>;
103
+ /**
104
+ * Get rules that are causing errors in a file
105
+ * @param filePath - Path to the file to check
106
+ * @returns Object mapping rule IDs to their error counts
107
+ */
108
+ getProblematicRules(filePath: string): Promise<Record<string, number>>;
109
+ }
@@ -0,0 +1,13 @@
1
+ import type { GuideGenerateJson } from "./guideline";
2
+ interface FileUpdateRequestProps {
3
+ context: string;
4
+ request: string;
5
+ }
6
+ export declare class Prompter {
7
+ static selectGuideline(): Promise<string>;
8
+ static getGuideJson(guideName: string): Promise<GuideGenerateJson>;
9
+ static getInstruction(guideName: string): Promise<string>;
10
+ makeTsFileUpdatePrompt({ context, request }: FileUpdateRequestProps): Promise<string>;
11
+ getDocumentation(guideName: string): Promise<string>;
12
+ }
13
+ export {};
@@ -0,0 +1,49 @@
1
+ import * as ts from "typescript";
2
+ import type { Executor } from "./executors";
3
+ export declare class TypeChecker {
4
+ #private;
5
+ readonly configPath: string;
6
+ readonly configFile: {
7
+ config?: any;
8
+ error?: ts.Diagnostic;
9
+ };
10
+ readonly config: ts.ParsedCommandLine;
11
+ constructor(executor: Executor);
12
+ /**
13
+ * Type-check a single TypeScript file
14
+ * @param filePath - Path to the TypeScript file to check
15
+ * @returns Array of diagnostic messages
16
+ */
17
+ check(filePath: string): {
18
+ diagnostics: ts.Diagnostic[];
19
+ errors: ts.Diagnostic[];
20
+ warnings: ts.Diagnostic[];
21
+ };
22
+ /**
23
+ * Format diagnostics for console output
24
+ * @param diagnostics - Array of TypeScript diagnostics
25
+ * @returns Formatted string
26
+ */
27
+ formatDiagnostics(diagnostics: ts.Diagnostic[]): string;
28
+ /**
29
+ * Get detailed diagnostic information with code snippet
30
+ * @param filePath - Path to the TypeScript file to check
31
+ * @returns Object containing diagnostics and detailed information
32
+ */
33
+ getDetailedDiagnostics(filePath: string): {
34
+ diagnostics: ts.Diagnostic[];
35
+ details: {
36
+ line: number;
37
+ column: number;
38
+ message: string;
39
+ code: number;
40
+ codeSnippet?: string;
41
+ }[];
42
+ };
43
+ /**
44
+ * Check if a file has type errors
45
+ * @param filePath - Path to the TypeScript file to check
46
+ * @returns true if there are no type errors, false otherwise
47
+ */
48
+ hasNoTypeErrors(filePath: string): boolean;
49
+ }
package/src/types.d.ts CHANGED
@@ -24,3 +24,7 @@ export interface TsConfigJson {
24
24
  path: string;
25
25
  }[];
26
26
  }
27
+ export interface FileContent {
28
+ filePath: string;
29
+ content: string;
30
+ }
@@ -1,4 +1,4 @@
1
- export declare const uploadRelease: (projectName: string, { workspaceRoot, environment, buildNum, platformVersion, local, }: {
1
+ export declare const uploadRelease: (appName: string, { workspaceRoot, environment, buildNum, platformVersion, local, }: {
2
2
  workspaceRoot: string;
3
3
  environment: string;
4
4
  buildNum: number;