@akanjs/devkit 1.0.20 → 2.1.0-rc.1

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.
Files changed (195) hide show
  1. package/README.ko.md +65 -0
  2. package/README.md +62 -6
  3. package/aiEditor.ts +304 -0
  4. package/akanApp/akanApp.host.ts +393 -0
  5. package/akanApp/index.ts +1 -0
  6. package/akanConfig/akanConfig.test.ts +236 -0
  7. package/akanConfig/akanConfig.ts +384 -0
  8. package/akanConfig/index.ts +2 -0
  9. package/akanConfig/types.ts +23 -0
  10. package/applicationBuildReporter.ts +69 -0
  11. package/applicationBuildRunner.ts +302 -0
  12. package/applicationReleasePackager.ts +206 -0
  13. package/artifact/implicitRootLayout.ts +155 -0
  14. package/artifact/index.ts +1 -0
  15. package/artifact/routeSeedIndex.test.ts +98 -0
  16. package/artifact/routeSeedIndex.ts +130 -0
  17. package/auth.ts +41 -0
  18. package/builder.ts +164 -0
  19. package/capacitor.base.config.ts +88 -0
  20. package/capacitorApp.ts +440 -0
  21. package/commandDecorators/argMeta.ts +102 -0
  22. package/commandDecorators/command.ts +351 -0
  23. package/commandDecorators/commandBuilder.ts +224 -0
  24. package/commandDecorators/commandDecorators.test.ts +212 -0
  25. package/commandDecorators/commandMeta.ts +7 -0
  26. package/commandDecorators/dependencyBuilder.ts +100 -0
  27. package/{esm/src/commandDecorators/helpFormatter.js → commandDecorators/helpFormatter.ts} +100 -47
  28. package/{esm/src/commandDecorators/index.js → commandDecorators/index.ts} +4 -2
  29. package/commandDecorators/targetMeta.ts +31 -0
  30. package/commandDecorators/types.ts +10 -0
  31. package/constants.ts +25 -0
  32. package/createTunnel.ts +36 -0
  33. package/dependencyScanner.ts +357 -0
  34. package/devkitUtils.test.ts +259 -0
  35. package/executors.test.ts +315 -0
  36. package/executors.ts +1390 -0
  37. package/{esm/src/extractDeps.js → extractDeps.ts} +26 -20
  38. package/{esm/src/fileEditor.js → fileEditor.ts} +51 -32
  39. package/fileSys.ts +39 -0
  40. package/frontendBuild/allRoutesBuilder.ts +103 -0
  41. package/frontendBuild/buildRouteClient.test.ts +190 -0
  42. package/frontendBuild/clientBuildTypes.ts +114 -0
  43. package/frontendBuild/clientEntriesBundler.ts +303 -0
  44. package/frontendBuild/clientEntryDiscovery.ts +199 -0
  45. package/frontendBuild/csrArtifactBuilder.ts +237 -0
  46. package/frontendBuild/cssCompiler.ts +286 -0
  47. package/frontendBuild/cssImportResolver.ts +116 -0
  48. package/frontendBuild/fontOptimizer.ts +427 -0
  49. package/frontendBuild/frontendBuild.test.ts +204 -0
  50. package/frontendBuild/hmrChangeClassifier.ts +28 -0
  51. package/frontendBuild/hmrWatcher.ts +102 -0
  52. package/frontendBuild/index.ts +18 -0
  53. package/frontendBuild/pagesBundleBuilder.ts +137 -0
  54. package/frontendBuild/pagesEntrySourceGenerator.ts +37 -0
  55. package/frontendBuild/precompressArtifacts.ts +59 -0
  56. package/frontendBuild/routeClientBuilder.ts +290 -0
  57. package/frontendBuild/routesManifestArtifactSerializer.ts +62 -0
  58. package/frontendBuild/ssrBaseArtifactBuilder.ts +139 -0
  59. package/frontendBuild/vendorSpecifiers.ts +16 -0
  60. package/frontendBuild/watchRootResolver.ts +28 -0
  61. package/getCredentials.ts +19 -0
  62. package/getDirname.ts +3 -0
  63. package/getModelFileData.ts +59 -0
  64. package/getRelatedCnsts.ts +313 -0
  65. package/guideline.ts +19 -0
  66. package/incrementalBuilder/incrementalBuilder.host.test.ts +51 -0
  67. package/incrementalBuilder/incrementalBuilder.host.ts +152 -0
  68. package/incrementalBuilder/incrementalBuilder.proc.ts +331 -0
  69. package/incrementalBuilder/index.ts +1 -0
  70. package/{esm/src/index.js → index.ts} +28 -15
  71. package/lint/no-deep-internal-import.grit +25 -0
  72. package/lint/no-import-client-functions.grit +32 -0
  73. package/lint/no-import-external-library.grit +21 -0
  74. package/lint/no-js-private-class-method.grit +42 -0
  75. package/lint/no-use-client-in-server.grit +7 -0
  76. package/lint/non-scalar-props-restricted.grit +13 -0
  77. package/linter.ts +271 -0
  78. package/mobile/index.ts +1 -0
  79. package/mobile/mobileTarget.test.ts +53 -0
  80. package/mobile/mobileTarget.ts +88 -0
  81. package/package.json +48 -31
  82. package/prompter.ts +72 -0
  83. package/scanInfo.ts +606 -0
  84. package/selectModel.ts +11 -0
  85. package/{esm/src/spinner.js → spinner.ts} +22 -28
  86. package/{esm/src/capacitorApp.js → src/capacitorApp.ts} +82 -81
  87. package/sshTunnel.ts +152 -0
  88. package/{esm/src/streamAi.js → streamAi.ts} +18 -12
  89. package/transforms/barrelAnalyzer.ts +278 -0
  90. package/transforms/barrelImportsPlugin.ts +504 -0
  91. package/transforms/externalizeFrameworkPlugin.ts +185 -0
  92. package/transforms/index.ts +5 -0
  93. package/transforms/rscUseClientTransform.ts +59 -0
  94. package/transforms/transforms.test.ts +208 -0
  95. package/transforms/useClientBundlePlugin.ts +47 -0
  96. package/tsconfig.json +37 -0
  97. package/typeChecker.ts +264 -0
  98. package/types.ts +44 -0
  99. package/ui/MultiScrollList.tsx +242 -0
  100. package/ui/ScrollList.tsx +107 -0
  101. package/ui/index.ts +2 -0
  102. package/{esm/src/uploadRelease.js → uploadRelease.ts} +50 -34
  103. package/{esm/src/useStdoutDimensions.js → useStdoutDimensions.ts} +5 -5
  104. package/cjs/index.js +0 -21
  105. package/cjs/src/aiEditor.js +0 -311
  106. package/cjs/src/auth.js +0 -72
  107. package/cjs/src/builder.js +0 -114
  108. package/cjs/src/capacitorApp.js +0 -313
  109. package/cjs/src/commandDecorators/argMeta.js +0 -88
  110. package/cjs/src/commandDecorators/command.js +0 -324
  111. package/cjs/src/commandDecorators/commandMeta.js +0 -30
  112. package/cjs/src/commandDecorators/helpFormatter.js +0 -211
  113. package/cjs/src/commandDecorators/index.js +0 -31
  114. package/cjs/src/commandDecorators/targetMeta.js +0 -57
  115. package/cjs/src/commandDecorators/types.js +0 -15
  116. package/cjs/src/constants.js +0 -46
  117. package/cjs/src/createTunnel.js +0 -49
  118. package/cjs/src/dependencyScanner.js +0 -220
  119. package/cjs/src/executors.js +0 -964
  120. package/cjs/src/extractDeps.js +0 -103
  121. package/cjs/src/fileEditor.js +0 -120
  122. package/cjs/src/getCredentials.js +0 -44
  123. package/cjs/src/getDirname.js +0 -38
  124. package/cjs/src/getModelFileData.js +0 -66
  125. package/cjs/src/getRelatedCnsts.js +0 -260
  126. package/cjs/src/guideline.js +0 -15
  127. package/cjs/src/index.js +0 -65
  128. package/cjs/src/linter.js +0 -238
  129. package/cjs/src/prompter.js +0 -85
  130. package/cjs/src/scanInfo.js +0 -491
  131. package/cjs/src/selectModel.js +0 -46
  132. package/cjs/src/spinner.js +0 -93
  133. package/cjs/src/streamAi.js +0 -62
  134. package/cjs/src/typeChecker.js +0 -207
  135. package/cjs/src/types.js +0 -15
  136. package/cjs/src/uploadRelease.js +0 -112
  137. package/cjs/src/useStdoutDimensions.js +0 -43
  138. package/esm/index.js +0 -1
  139. package/esm/src/aiEditor.js +0 -282
  140. package/esm/src/auth.js +0 -42
  141. package/esm/src/builder.js +0 -81
  142. package/esm/src/commandDecorators/argMeta.js +0 -54
  143. package/esm/src/commandDecorators/command.js +0 -290
  144. package/esm/src/commandDecorators/commandMeta.js +0 -7
  145. package/esm/src/commandDecorators/targetMeta.js +0 -33
  146. package/esm/src/commandDecorators/types.js +0 -0
  147. package/esm/src/constants.js +0 -17
  148. package/esm/src/createTunnel.js +0 -26
  149. package/esm/src/dependencyScanner.js +0 -187
  150. package/esm/src/executors.js +0 -928
  151. package/esm/src/getCredentials.js +0 -11
  152. package/esm/src/getDirname.js +0 -5
  153. package/esm/src/getModelFileData.js +0 -33
  154. package/esm/src/getRelatedCnsts.js +0 -221
  155. package/esm/src/guideline.js +0 -0
  156. package/esm/src/linter.js +0 -205
  157. package/esm/src/prompter.js +0 -51
  158. package/esm/src/scanInfo.js +0 -455
  159. package/esm/src/selectModel.js +0 -13
  160. package/esm/src/typeChecker.js +0 -174
  161. package/esm/src/types.js +0 -0
  162. package/index.d.ts +0 -1
  163. package/src/aiEditor.d.ts +0 -50
  164. package/src/auth.d.ts +0 -9
  165. package/src/builder.d.ts +0 -18
  166. package/src/capacitorApp.d.ts +0 -39
  167. package/src/commandDecorators/argMeta.d.ts +0 -67
  168. package/src/commandDecorators/command.d.ts +0 -2
  169. package/src/commandDecorators/commandMeta.d.ts +0 -2
  170. package/src/commandDecorators/helpFormatter.d.ts +0 -3
  171. package/src/commandDecorators/index.d.ts +0 -6
  172. package/src/commandDecorators/targetMeta.d.ts +0 -19
  173. package/src/commandDecorators/types.d.ts +0 -1
  174. package/src/constants.d.ts +0 -26
  175. package/src/createTunnel.d.ts +0 -8
  176. package/src/dependencyScanner.d.ts +0 -23
  177. package/src/executors.d.ts +0 -296
  178. package/src/extractDeps.d.ts +0 -7
  179. package/src/fileEditor.d.ts +0 -16
  180. package/src/getCredentials.d.ts +0 -12
  181. package/src/getDirname.d.ts +0 -1
  182. package/src/getModelFileData.d.ts +0 -16
  183. package/src/getRelatedCnsts.d.ts +0 -53
  184. package/src/guideline.d.ts +0 -19
  185. package/src/index.d.ts +0 -23
  186. package/src/linter.d.ts +0 -109
  187. package/src/prompter.d.ts +0 -14
  188. package/src/scanInfo.d.ts +0 -82
  189. package/src/selectModel.d.ts +0 -1
  190. package/src/spinner.d.ts +0 -20
  191. package/src/streamAi.d.ts +0 -6
  192. package/src/typeChecker.d.ts +0 -52
  193. package/src/types.d.ts +0 -31
  194. package/src/uploadRelease.d.ts +0 -10
  195. package/src/useStdoutDimensions.d.ts +0 -1
package/cjs/src/index.js DELETED
@@ -1,65 +0,0 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var src_exports = {};
16
- module.exports = __toCommonJS(src_exports);
17
- __reExport(src_exports, require("./createTunnel"), module.exports);
18
- __reExport(src_exports, require("./getCredentials"), module.exports);
19
- __reExport(src_exports, require("./uploadRelease"), module.exports);
20
- __reExport(src_exports, require("./getModelFileData"), module.exports);
21
- __reExport(src_exports, require("./getRelatedCnsts"), module.exports);
22
- __reExport(src_exports, require("./selectModel"), module.exports);
23
- __reExport(src_exports, require("./streamAi"), module.exports);
24
- __reExport(src_exports, require("./executors"), module.exports);
25
- __reExport(src_exports, require("./dependencyScanner"), module.exports);
26
- __reExport(src_exports, require("./constants"), module.exports);
27
- __reExport(src_exports, require("./auth"), module.exports);
28
- __reExport(src_exports, require("./types"), module.exports);
29
- __reExport(src_exports, require("./capacitorApp"), module.exports);
30
- __reExport(src_exports, require("./extractDeps"), module.exports);
31
- __reExport(src_exports, require("./commandDecorators"), module.exports);
32
- __reExport(src_exports, require("./aiEditor"), module.exports);
33
- __reExport(src_exports, require("./builder"), module.exports);
34
- __reExport(src_exports, require("./spinner"), module.exports);
35
- __reExport(src_exports, require("./prompter"), module.exports);
36
- __reExport(src_exports, require("./guideline"), module.exports);
37
- __reExport(src_exports, require("./getDirname"), module.exports);
38
- __reExport(src_exports, require("./useStdoutDimensions"), module.exports);
39
- __reExport(src_exports, require("./scanInfo"), module.exports);
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- ...require("./createTunnel"),
43
- ...require("./getCredentials"),
44
- ...require("./uploadRelease"),
45
- ...require("./getModelFileData"),
46
- ...require("./getRelatedCnsts"),
47
- ...require("./selectModel"),
48
- ...require("./streamAi"),
49
- ...require("./executors"),
50
- ...require("./dependencyScanner"),
51
- ...require("./constants"),
52
- ...require("./auth"),
53
- ...require("./types"),
54
- ...require("./capacitorApp"),
55
- ...require("./extractDeps"),
56
- ...require("./commandDecorators"),
57
- ...require("./aiEditor"),
58
- ...require("./builder"),
59
- ...require("./spinner"),
60
- ...require("./prompter"),
61
- ...require("./guideline"),
62
- ...require("./getDirname"),
63
- ...require("./useStdoutDimensions"),
64
- ...require("./scanInfo")
65
- });
package/cjs/src/linter.js DELETED
@@ -1,238 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var linter_exports = {};
29
- __export(linter_exports, {
30
- Linter: () => Linter
31
- });
32
- module.exports = __toCommonJS(linter_exports);
33
- var import_common = require("@akanjs/common");
34
- var import_chalk = __toESM(require("chalk"));
35
- var import_eslint = require("eslint");
36
- var fs = __toESM(require("fs"));
37
- var path = __toESM(require("path"));
38
- class Linter {
39
- #logger = new import_common.Logger("Linter");
40
- #eslint;
41
- lintRoot;
42
- constructor(cwdPath) {
43
- this.lintRoot = this.#findEslintRootPath(cwdPath);
44
- this.#eslint = new import_eslint.ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
45
- }
46
- #findEslintRootPath(dir) {
47
- const configPath = path.join(dir, "eslint.config.ts");
48
- if (fs.existsSync(configPath))
49
- return dir;
50
- const parentDir = path.dirname(dir);
51
- return this.#findEslintRootPath(parentDir);
52
- }
53
- async lint(filePath, { fix = false, dryRun = false } = {}) {
54
- if (fix)
55
- return await this.fixFile(filePath, dryRun);
56
- return await this.lintFile(filePath);
57
- }
58
- /**
59
- * Lint a single file using ESLint
60
- * @param filePath - Path to the file to lint
61
- * @returns Array of ESLint results
62
- */
63
- async lintFile(filePath) {
64
- if (!fs.existsSync(filePath))
65
- throw new Error(`File not found: ${filePath}`);
66
- const isIgnored = await this.#eslint.isPathIgnored(filePath);
67
- if (isIgnored) {
68
- this.#logger.warn(`File ${filePath} is ignored by ESLint configuration`);
69
- return { fixed: false, results: [], errors: [], warnings: [] };
70
- }
71
- const results = await this.#eslint.lintFiles([filePath]);
72
- const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
73
- const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
74
- return { fixed: false, results, errors, warnings };
75
- }
76
- /**
77
- * Format lint results for console output
78
- * @param results - Array of ESLint results
79
- * @returns Formatted string
80
- */
81
- formatLintResults(results) {
82
- if (results.length === 0)
83
- return "No files to lint";
84
- const output = [];
85
- let totalErrors = 0;
86
- let totalWarnings = 0;
87
- results.forEach((result) => {
88
- totalErrors += result.errorCount;
89
- totalWarnings += result.warningCount;
90
- if (result.messages.length > 0) {
91
- output.push(`
92
- ${import_chalk.default.cyan(result.filePath)}`);
93
- let sourceLines = [];
94
- if (fs.existsSync(result.filePath)) {
95
- try {
96
- const sourceContent = fs.readFileSync(result.filePath, "utf8");
97
- sourceLines = sourceContent.split("\n");
98
- } catch (error) {
99
- }
100
- }
101
- result.messages.forEach((message) => {
102
- const type = message.severity === 2 ? "error" : "warning";
103
- const typeColor = message.severity === 2 ? import_chalk.default.red : import_chalk.default.yellow;
104
- const icon = message.severity === 2 ? "\u274C" : "\u26A0\uFE0F";
105
- const ruleInfo = message.ruleId ? import_chalk.default.dim(` (${message.ruleId})`) : "";
106
- output.push(`
107
- ${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
108
- output.push(` ${import_chalk.default.gray("at")} ${result.filePath}:${import_chalk.default.bold(`${message.line}:${message.column}`)}`);
109
- if (sourceLines.length > 0 && message.line <= sourceLines.length) {
110
- const sourceLine = sourceLines[message.line - 1];
111
- const lineNumber = message.line.toString().padStart(5, " ");
112
- output.push(`
113
- ${import_chalk.default.dim(lineNumber + " |")} ${sourceLine}`);
114
- const underlinePrefix = " ".repeat(message.column - 1);
115
- const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
116
- const underline = "^".repeat(Math.max(1, underlineLength));
117
- output.push(`${import_chalk.default.dim(" ".repeat(lineNumber.length) + " |")} ${underlinePrefix}${typeColor(underline)}`);
118
- }
119
- });
120
- }
121
- });
122
- if (totalErrors === 0 && totalWarnings === 0)
123
- return import_chalk.default.bold("\u2705 No ESLint errors or warnings found");
124
- const errorText = totalErrors > 0 ? import_chalk.default.red(`${totalErrors} error(s)`) : "0 errors";
125
- const warningText = totalWarnings > 0 ? import_chalk.default.yellow(`${totalWarnings} warning(s)`) : "0 warnings";
126
- const summary = [`
127
- ${errorText}, ${warningText} found`];
128
- return summary.concat(output).join("\n");
129
- }
130
- /**
131
- * Get detailed lint information
132
- * @param filePath - Path to the file to lint
133
- * @returns Object containing detailed lint information
134
- */
135
- async getDetailedLintInfo(filePath) {
136
- const { results } = await this.lintFile(filePath);
137
- const details = results.flatMap(
138
- (result) => result.messages.map((message) => ({
139
- line: message.line,
140
- column: message.column,
141
- message: message.message,
142
- ruleId: message.ruleId,
143
- severity: message.severity === 2 ? "error" : "warning",
144
- fix: message.fix,
145
- suggestions: message.suggestions
146
- }))
147
- );
148
- const stats = results.reduce(
149
- (acc, result) => ({
150
- errorCount: acc.errorCount + result.errorCount,
151
- warningCount: acc.warningCount + result.warningCount,
152
- fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
153
- fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
154
- }),
155
- { errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 }
156
- );
157
- return { results, details, stats };
158
- }
159
- /**
160
- * Check if a file has lint errors
161
- * @param filePath - Path to the file to check
162
- * @returns true if there are no errors, false otherwise
163
- */
164
- async hasNoLintErrors(filePath) {
165
- try {
166
- const { results } = await this.lintFile(filePath);
167
- return results.every((result) => result.errorCount === 0);
168
- } catch (error) {
169
- return false;
170
- }
171
- }
172
- /**
173
- * Get only error messages (excluding warnings)
174
- * @param filePath - Path to the file to lint
175
- * @returns Array of error messages
176
- */
177
- async getErrors(filePath) {
178
- const { results } = await this.lintFile(filePath);
179
- return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
180
- }
181
- /**
182
- * Get only warning messages
183
- * @param filePath - Path to the file to lint
184
- * @returns Array of warning messages
185
- */
186
- async getWarnings(filePath) {
187
- const { results } = await this.lintFile(filePath);
188
- return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
189
- }
190
- /**
191
- * Fix lint errors automatically
192
- * @param filePath - Path to the file to fix
193
- * @param dryRun - If true, returns the fixed content without writing to file
194
- * @returns Fixed content and remaining issues
195
- */
196
- async fixFile(filePath, dryRun = false) {
197
- if (!fs.existsSync(filePath))
198
- throw new Error(`File not found: ${filePath}`);
199
- const eslint = new import_eslint.ESLint({ cwd: this.lintRoot, fix: true });
200
- const results = await eslint.lintFiles([filePath]);
201
- const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
202
- const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
203
- if (!dryRun)
204
- await import_eslint.ESLint.outputFixes(results);
205
- const fixedResult = results[0];
206
- return { fixed: fixedResult.output !== void 0, output: fixedResult.output, results, errors, warnings };
207
- }
208
- /**
209
- * Get ESLint configuration for a file
210
- * @param filePath - Path to the file
211
- * @returns ESLint configuration object
212
- */
213
- async getConfigForFile(filePath) {
214
- const eslint = new import_eslint.ESLint();
215
- const config = await eslint.calculateConfigForFile(filePath);
216
- return config;
217
- }
218
- /**
219
- * Get rules that are causing errors in a file
220
- * @param filePath - Path to the file to check
221
- * @returns Object mapping rule IDs to their error counts
222
- */
223
- async getProblematicRules(filePath) {
224
- const { results } = await this.lintFile(filePath);
225
- const ruleCounts = {};
226
- results.forEach((result) => {
227
- result.messages.forEach((message) => {
228
- if (message.ruleId)
229
- ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
230
- });
231
- });
232
- return ruleCounts;
233
- }
234
- }
235
- // Annotate the CommonJS export names for ESM import in node:
236
- 0 && (module.exports = {
237
- Linter
238
- });
@@ -1,85 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var prompter_exports = {};
29
- __export(prompter_exports, {
30
- Prompter: () => Prompter
31
- });
32
- module.exports = __toCommonJS(prompter_exports);
33
- var import_prompts = require("@inquirer/prompts");
34
- var import_promises = __toESM(require("fs/promises"));
35
- var import_getDirname = require("./getDirname");
36
- const import_meta = {};
37
- class Prompter {
38
- static async selectGuideline() {
39
- const guideNames = (await import_promises.default.readdir(`${(0, import_getDirname.getDirname)(import_meta.url)}/src/guidelines`)).filter(
40
- (name) => !name.startsWith("_")
41
- );
42
- return await (0, import_prompts.select)({ message: "Select a guideline", choices: guideNames.map((name) => ({ name, value: name })) });
43
- }
44
- static async getGuideJson(guideName) {
45
- const filePath = `${(0, import_getDirname.getDirname)(import_meta.url)}/src/guidelines/${guideName}/${guideName}.generate.json`;
46
- const guideJson = await import_promises.default.readFile(filePath, "utf-8");
47
- return JSON.parse(guideJson);
48
- }
49
- static async getInstruction(guideName) {
50
- const filePath = `${(0, import_getDirname.getDirname)(import_meta.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
51
- const content = await import_promises.default.readFile(filePath, "utf-8");
52
- return content;
53
- }
54
- static async getUpdateRequest(guideName) {
55
- return await (0, import_prompts.input)({ message: `What do you want to update in ${guideName}?` });
56
- }
57
- async makeTsFileUpdatePrompt({ context, request }) {
58
- 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:
59
- ${await this.getDocumentation("framework")}
60
- Please understand the following background information, write code that meets the requirements, verify that it satisfies the validation conditions, and return the result.
61
-
62
- # Background Information
63
- \`\`\`markdown
64
- ${context}
65
- \`\`\`
66
-
67
- # Requirements
68
- \`\`\`markdown
69
- ${request}
70
- \`\`\`
71
- `;
72
- }
73
- async getDocumentation(guideName) {
74
- const filePath = `${(0, import_getDirname.getDirname)(import_meta.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
75
- const document = await import_promises.default.readFile(filePath, "utf-8");
76
- return `\`\`\`markdown
77
- ${document}
78
- \`\`\`
79
- `;
80
- }
81
- }
82
- // Annotate the CommonJS export names for ESM import in node:
83
- 0 && (module.exports = {
84
- Prompter
85
- });