@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.
- package/README.ko.md +65 -0
- package/README.md +62 -6
- package/aiEditor.ts +304 -0
- package/akanApp/akanApp.host.ts +393 -0
- package/akanApp/index.ts +1 -0
- package/akanConfig/akanConfig.test.ts +236 -0
- package/akanConfig/akanConfig.ts +384 -0
- package/akanConfig/index.ts +2 -0
- package/akanConfig/types.ts +23 -0
- package/applicationBuildReporter.ts +69 -0
- package/applicationBuildRunner.ts +302 -0
- package/applicationReleasePackager.ts +206 -0
- package/artifact/implicitRootLayout.ts +155 -0
- package/artifact/index.ts +1 -0
- package/artifact/routeSeedIndex.test.ts +98 -0
- package/artifact/routeSeedIndex.ts +130 -0
- package/auth.ts +41 -0
- package/builder.ts +164 -0
- package/capacitor.base.config.ts +88 -0
- package/capacitorApp.ts +440 -0
- package/commandDecorators/argMeta.ts +102 -0
- package/commandDecorators/command.ts +351 -0
- package/commandDecorators/commandBuilder.ts +224 -0
- package/commandDecorators/commandDecorators.test.ts +212 -0
- package/commandDecorators/commandMeta.ts +7 -0
- package/commandDecorators/dependencyBuilder.ts +100 -0
- package/{esm/src/commandDecorators/helpFormatter.js → commandDecorators/helpFormatter.ts} +100 -47
- package/{esm/src/commandDecorators/index.js → commandDecorators/index.ts} +4 -2
- package/commandDecorators/targetMeta.ts +31 -0
- package/commandDecorators/types.ts +10 -0
- package/constants.ts +25 -0
- package/createTunnel.ts +36 -0
- package/dependencyScanner.ts +357 -0
- package/devkitUtils.test.ts +259 -0
- package/executors.test.ts +315 -0
- package/executors.ts +1390 -0
- package/{esm/src/extractDeps.js → extractDeps.ts} +26 -20
- package/{esm/src/fileEditor.js → fileEditor.ts} +51 -32
- package/fileSys.ts +39 -0
- package/frontendBuild/allRoutesBuilder.ts +103 -0
- package/frontendBuild/buildRouteClient.test.ts +190 -0
- package/frontendBuild/clientBuildTypes.ts +114 -0
- package/frontendBuild/clientEntriesBundler.ts +303 -0
- package/frontendBuild/clientEntryDiscovery.ts +199 -0
- package/frontendBuild/csrArtifactBuilder.ts +237 -0
- package/frontendBuild/cssCompiler.ts +286 -0
- package/frontendBuild/cssImportResolver.ts +116 -0
- package/frontendBuild/fontOptimizer.ts +427 -0
- package/frontendBuild/frontendBuild.test.ts +204 -0
- package/frontendBuild/hmrChangeClassifier.ts +28 -0
- package/frontendBuild/hmrWatcher.ts +102 -0
- package/frontendBuild/index.ts +18 -0
- package/frontendBuild/pagesBundleBuilder.ts +137 -0
- package/frontendBuild/pagesEntrySourceGenerator.ts +37 -0
- package/frontendBuild/precompressArtifacts.ts +59 -0
- package/frontendBuild/routeClientBuilder.ts +290 -0
- package/frontendBuild/routesManifestArtifactSerializer.ts +62 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +139 -0
- package/frontendBuild/vendorSpecifiers.ts +16 -0
- package/frontendBuild/watchRootResolver.ts +28 -0
- package/getCredentials.ts +19 -0
- package/getDirname.ts +3 -0
- package/getModelFileData.ts +59 -0
- package/getRelatedCnsts.ts +313 -0
- package/guideline.ts +19 -0
- package/incrementalBuilder/incrementalBuilder.host.test.ts +51 -0
- package/incrementalBuilder/incrementalBuilder.host.ts +152 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +331 -0
- package/incrementalBuilder/index.ts +1 -0
- package/{esm/src/index.js → index.ts} +28 -15
- package/lint/no-deep-internal-import.grit +25 -0
- package/lint/no-import-client-functions.grit +32 -0
- package/lint/no-import-external-library.grit +21 -0
- package/lint/no-js-private-class-method.grit +42 -0
- package/lint/no-use-client-in-server.grit +7 -0
- package/lint/non-scalar-props-restricted.grit +13 -0
- package/linter.ts +271 -0
- package/mobile/index.ts +1 -0
- package/mobile/mobileTarget.test.ts +53 -0
- package/mobile/mobileTarget.ts +88 -0
- package/package.json +48 -31
- package/prompter.ts +72 -0
- package/scanInfo.ts +606 -0
- package/selectModel.ts +11 -0
- package/{esm/src/spinner.js → spinner.ts} +22 -28
- package/{esm/src/capacitorApp.js → src/capacitorApp.ts} +82 -81
- package/sshTunnel.ts +152 -0
- package/{esm/src/streamAi.js → streamAi.ts} +18 -12
- package/transforms/barrelAnalyzer.ts +278 -0
- package/transforms/barrelImportsPlugin.ts +504 -0
- package/transforms/externalizeFrameworkPlugin.ts +185 -0
- package/transforms/index.ts +5 -0
- package/transforms/rscUseClientTransform.ts +59 -0
- package/transforms/transforms.test.ts +208 -0
- package/transforms/useClientBundlePlugin.ts +47 -0
- package/tsconfig.json +37 -0
- package/typeChecker.ts +264 -0
- package/types.ts +44 -0
- package/ui/MultiScrollList.tsx +242 -0
- package/ui/ScrollList.tsx +107 -0
- package/ui/index.ts +2 -0
- package/{esm/src/uploadRelease.js → uploadRelease.ts} +50 -34
- package/{esm/src/useStdoutDimensions.js → useStdoutDimensions.ts} +5 -5
- package/cjs/index.js +0 -21
- package/cjs/src/aiEditor.js +0 -311
- package/cjs/src/auth.js +0 -72
- package/cjs/src/builder.js +0 -114
- package/cjs/src/capacitorApp.js +0 -313
- package/cjs/src/commandDecorators/argMeta.js +0 -88
- package/cjs/src/commandDecorators/command.js +0 -324
- package/cjs/src/commandDecorators/commandMeta.js +0 -30
- package/cjs/src/commandDecorators/helpFormatter.js +0 -211
- package/cjs/src/commandDecorators/index.js +0 -31
- package/cjs/src/commandDecorators/targetMeta.js +0 -57
- package/cjs/src/commandDecorators/types.js +0 -15
- package/cjs/src/constants.js +0 -46
- package/cjs/src/createTunnel.js +0 -49
- package/cjs/src/dependencyScanner.js +0 -220
- package/cjs/src/executors.js +0 -964
- package/cjs/src/extractDeps.js +0 -103
- package/cjs/src/fileEditor.js +0 -120
- package/cjs/src/getCredentials.js +0 -44
- package/cjs/src/getDirname.js +0 -38
- package/cjs/src/getModelFileData.js +0 -66
- package/cjs/src/getRelatedCnsts.js +0 -260
- package/cjs/src/guideline.js +0 -15
- package/cjs/src/index.js +0 -65
- package/cjs/src/linter.js +0 -238
- package/cjs/src/prompter.js +0 -85
- package/cjs/src/scanInfo.js +0 -491
- package/cjs/src/selectModel.js +0 -46
- package/cjs/src/spinner.js +0 -93
- package/cjs/src/streamAi.js +0 -62
- package/cjs/src/typeChecker.js +0 -207
- package/cjs/src/types.js +0 -15
- package/cjs/src/uploadRelease.js +0 -112
- package/cjs/src/useStdoutDimensions.js +0 -43
- package/esm/index.js +0 -1
- package/esm/src/aiEditor.js +0 -282
- package/esm/src/auth.js +0 -42
- package/esm/src/builder.js +0 -81
- package/esm/src/commandDecorators/argMeta.js +0 -54
- package/esm/src/commandDecorators/command.js +0 -290
- package/esm/src/commandDecorators/commandMeta.js +0 -7
- package/esm/src/commandDecorators/targetMeta.js +0 -33
- package/esm/src/commandDecorators/types.js +0 -0
- package/esm/src/constants.js +0 -17
- package/esm/src/createTunnel.js +0 -26
- package/esm/src/dependencyScanner.js +0 -187
- package/esm/src/executors.js +0 -928
- package/esm/src/getCredentials.js +0 -11
- package/esm/src/getDirname.js +0 -5
- package/esm/src/getModelFileData.js +0 -33
- package/esm/src/getRelatedCnsts.js +0 -221
- package/esm/src/guideline.js +0 -0
- package/esm/src/linter.js +0 -205
- package/esm/src/prompter.js +0 -51
- package/esm/src/scanInfo.js +0 -455
- package/esm/src/selectModel.js +0 -13
- package/esm/src/typeChecker.js +0 -174
- package/esm/src/types.js +0 -0
- package/index.d.ts +0 -1
- package/src/aiEditor.d.ts +0 -50
- package/src/auth.d.ts +0 -9
- package/src/builder.d.ts +0 -18
- package/src/capacitorApp.d.ts +0 -39
- package/src/commandDecorators/argMeta.d.ts +0 -67
- package/src/commandDecorators/command.d.ts +0 -2
- package/src/commandDecorators/commandMeta.d.ts +0 -2
- package/src/commandDecorators/helpFormatter.d.ts +0 -3
- package/src/commandDecorators/index.d.ts +0 -6
- package/src/commandDecorators/targetMeta.d.ts +0 -19
- package/src/commandDecorators/types.d.ts +0 -1
- package/src/constants.d.ts +0 -26
- package/src/createTunnel.d.ts +0 -8
- package/src/dependencyScanner.d.ts +0 -23
- package/src/executors.d.ts +0 -296
- package/src/extractDeps.d.ts +0 -7
- package/src/fileEditor.d.ts +0 -16
- package/src/getCredentials.d.ts +0 -12
- package/src/getDirname.d.ts +0 -1
- package/src/getModelFileData.d.ts +0 -16
- package/src/getRelatedCnsts.d.ts +0 -53
- package/src/guideline.d.ts +0 -19
- package/src/index.d.ts +0 -23
- package/src/linter.d.ts +0 -109
- package/src/prompter.d.ts +0 -14
- package/src/scanInfo.d.ts +0 -82
- package/src/selectModel.d.ts +0 -1
- package/src/spinner.d.ts +0 -20
- package/src/streamAi.d.ts +0 -6
- package/src/typeChecker.d.ts +0 -52
- package/src/types.d.ts +0 -31
- package/src/uploadRelease.d.ts +0 -10
- 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
|
-
});
|
package/cjs/src/prompter.js
DELETED
|
@@ -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
|
-
});
|