@akanjs/cli 3.2.0-rc.31 → 3.2.0-rc.32
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/.build-stamp +2 -2
- package/{CodeAgent-c17abdbf.js → CodeAgent-7m6cmdf8.js} +2 -2
- package/{CodeTui-jed1nj82.js → CodeTui-c6de37ea.js} +1 -1
- package/README.ko.md +7 -0
- package/README.md +7 -0
- package/TunnelShare-9ry4vh0y.js +18 -0
- package/{agent.command-9whnc6vb.js → agent.command-3qstwjef.js} +26 -21
- package/akanCode.js +2 -2
- package/{appExecutor-020cyesq.js → appExecutor-79azsb2w.js} +3 -3
- package/{application.command-4eqvyxkw.js → application.command-8y4kxzvc.js} +36 -24
- package/{applicationBuildRunner-frtcrqfd.js → applicationBuildRunner-trfxv3pd.js} +43 -15
- package/buildBatch.proc.js +10 -10
- package/{cloud.command-hbvmeezn.js → cloud.command-zczv575c.js} +28 -28
- package/cloud.script-t268m15f.js +35 -0
- package/{code.command-0ayrenk4.js → code.command-069wchwn.js} +10 -10
- package/context.command-v3e98f2h.js +64 -0
- package/context.runner-3jr6chgz.js +34 -0
- package/{guideline.command-w1grfwh7.js → guideline.command-zwypaqsh.js} +7 -7
- package/guidelines/errorCodes/errorCodes.instruction.md +1 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +87 -27
- package/guidelines/queryRule/queryRule.instruction.md +3 -1
- package/guidelines/runtimeRule/runtimeRule.instruction.md +7 -3
- package/guidelines/transportRule/transportRule.instruction.md +28 -0
- package/incrementalBuilder.proc.js +12 -9
- package/{index-5d57kx0s.js → index-275a4r3n.js} +3 -3
- package/{index-6zb17wcm.js → index-2jmvfa62.js} +3 -3
- package/{index-9rv2zt48.js → index-2yn3r67f.js} +78 -25
- package/{index-6pxmcaq8.js → index-3txdtztz.js} +1 -1
- package/{index-nm7nt9vm.js → index-4ss4gkv3.js} +2 -2
- package/{index-9wab2ngg.js → index-612fdtbk.js} +1 -1
- package/{index-7bs463x7.js → index-6dzjer7p.js} +6 -6
- package/{index-qssq2d41.js → index-71y6176j.js} +11 -6
- package/{index-4st0hq72.js → index-73x6z7ym.js} +24 -17
- package/{index-vjbne22r.js → index-7wf8snar.js} +1 -1
- package/{index-yvzm8mby.js → index-9wh04mqy.js} +1 -1
- package/{index-yxkjsyx8.js → index-a860mx0m.js} +2 -2
- package/{index-42jhx2ya.js → index-b2sdtgc7.js} +3 -3
- package/{index-1pjwsh2g.js → index-baccvws5.js} +1 -1
- package/{index-99kjwyma.js → index-c669pbyb.js} +4 -3
- package/{index-prgvqqxe.js → index-cd839jw2.js} +126 -113
- package/{index-6469101k.js → index-dadwp2aw.js} +33 -98
- package/{index-7v7tvgt7.js → index-dmcpetwe.js} +123 -43
- package/{index-ba2xd32s.js → index-e9w8wq0a.js} +27 -22
- package/{index-fp5xf6ef.js → index-ebn9kgea.js} +3 -3
- package/{index-s3m89wt2.js → index-exzkev4k.js} +7 -7
- package/{index-m5gg0wzv.js → index-gec8q5z9.js} +57 -30
- package/{index-m3t28rt3.js → index-gt8phqpt.js} +4 -4
- package/{index-g7jgd4xs.js → index-j592zfqc.js} +1 -1
- package/{index-cb91b6d8.js → index-jek2re5k.js} +3 -3
- package/{index-ffa52fwf.js → index-jf4vk1s0.js} +8 -1
- package/{index-v929w7j7.js → index-kykky4re.js} +59 -15
- package/{index-9wjrwjgz.js → index-nk374pqd.js} +8 -8
- package/{index-28nk8w3j.js → index-pk2ja04e.js} +8 -8
- package/{index-jgj31xvw.js → index-qcp6e2ht.js} +22 -5
- package/{index-at6haq2x.js → index-qyhr8wst.js} +61 -18
- package/{index-f16kr6vj.js → index-s885g0jj.js} +2 -2
- package/{index-bj8s07s7.js → index-t2zhw8c7.js} +4 -4
- package/{index-11d7nh8a.js → index-v7ajmsh3.js} +1 -1
- package/{index-dss3ds74.js → index-w1zexzpx.js} +1 -1
- package/{index-g45y5f3e.js → index-wzp3yg01.js} +1 -1
- package/{index-ze48c0vd.js → index-z92zm3wd.js} +2 -2
- package/{index-na8r4a27.js → index-zfnz878d.js} +1 -1
- package/{index-0gaj78wn.js → index-zmd9xxgd.js} +3 -3
- package/{index-p06kfhdf.js → index-zzebpyr0.js} +4 -4
- package/index.js +27 -27
- package/{libExecutor-tq994592.js → libExecutor-jc6f8hm6.js} +2 -2
- package/{library.command-x219mhcx.js → library.command-nxvesvhb.js} +11 -8
- package/{localRegistry.command-zvdcejhn.js → localRegistry.command-4a655xnq.js} +20 -20
- package/{module.command-k6cwcm7g.js → module.command-aaws9byg.js} +9 -9
- package/{package.command-vw7x09f8.js → package.command-j7hv26p0.js} +10 -10
- package/package.json +8 -8
- package/{page.command-gf06paq2.js → page.command-7yffs7n9.js} +7 -7
- package/{pipeline.command-y07dgj9b.js → pipeline.command-7yk0zcng.js} +8 -7
- package/{pkgExecutor-stde3yc3.js → pkgExecutor-arxmvx4t.js} +2 -2
- package/{primitive.command-edydvh07.js → primitive.command-7a1pt715.js} +10 -10
- package/{projectTypecheck-mk8wefvd.js → projectTypecheck-f4qhbecd.js} +1 -1
- package/{quality.command-mdb45vyr.js → quality.command-08bn42t4.js} +13 -10
- package/{repair.command-kvtaeecy.js → repair.command-r59jat74.js} +9 -9
- package/{scalar.command-sjt9p5e1.js → scalar.command-2ex84spb.js} +8 -8
- package/skills/akan-mcp/SKILL.md +6 -2
- package/skills/akan-validate/SKILL.md +3 -3
- package/{subspace.command-mkkqync4.js → subspace.command-2nxakmk3.js} +16 -13
- package/templates/workspaceRoot/.devcontainer/devcontainer.json.template +1 -1
- package/templates/workspaceRoot/README.ts +4 -2
- package/{tunnel.command-tr5b3030.js → tunnel.command-f7ep1qfa.js} +12 -12
- package/{typeChecker-bfrd1n9n.js → typeChecker-7jt6abrs.js} +1 -1
- package/typecheck.proc.js +3 -2
- package/{verify.command-0p9h8tpp.js → verify.command-xbztwp1r.js} +17 -17
- package/{workflow.command-9mfcwqzj.js → workflow.command-pmyx55y4.js} +18 -15
- package/{workspace.command-5hjtmcfs.js → workspace.command-89p90zvb.js} +36 -36
- package/TunnelShare-mbfcaqg0.js +0 -18
- package/cloud.script-9kmbr3d6.js +0 -35
- package/context.command-php852kf.js +0 -61
- package/context.runner-nngmn7c0.js +0 -34
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
camelToKebabCase,
|
|
4
4
|
runner
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-2yn3r67f.js";
|
|
6
6
|
import {
|
|
7
7
|
rootAllowedFiles,
|
|
8
8
|
rootAllowedDirs,
|
|
@@ -16,16 +16,16 @@ import {
|
|
|
16
16
|
renderScopeAgentBlock,
|
|
17
17
|
SysExecutor,
|
|
18
18
|
WorkspaceExecutor
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-71y6176j.js";
|
|
20
20
|
import {
|
|
21
21
|
FileSys2
|
|
22
22
|
} from "./index-by2tvsq6.js";
|
|
23
23
|
import {
|
|
24
24
|
LibExecutor2
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-zfnz878d.js";
|
|
26
26
|
import {
|
|
27
27
|
PkgExecutor2
|
|
28
|
-
} from "./index-
|
|
28
|
+
} from "./index-w1zexzpx.js";
|
|
29
29
|
import {
|
|
30
30
|
collectRecipeSources2,
|
|
31
31
|
scanRecipes2
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
} from "./index-zyb0ebm4.js";
|
|
41
41
|
import {
|
|
42
42
|
MaintainabilityBaseline
|
|
43
|
-
} from "./index-
|
|
43
|
+
} from "./index-baccvws5.js";
|
|
44
44
|
import {
|
|
45
45
|
createFactReader,
|
|
46
46
|
createAst
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
import {
|
|
49
49
|
getNpmRegistryUrl,
|
|
50
50
|
getLatestPackageVersion
|
|
51
|
-
} from "./index-
|
|
51
|
+
} from "./index-jf4vk1s0.js";
|
|
52
52
|
import {
|
|
53
53
|
sysInputs,
|
|
54
54
|
workflowSpecs
|
|
@@ -2162,11 +2162,10 @@ AKAN_PUBLIC_LOG_LEVEL=debug
|
|
|
2162
2162
|
|
|
2163
2163
|
// pkgs/@akanjs/devkit/quality/qualityScanner.ts
|
|
2164
2164
|
import { createHash } from "crypto";
|
|
2165
|
-
import {
|
|
2166
|
-
import
|
|
2165
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
2166
|
+
import path10 from "path";
|
|
2167
2167
|
import { RESERVED_ROUTE_CONFIG_EXPORTS } from "akanjs/common";
|
|
2168
|
-
import
|
|
2169
|
-
import ts21 from "typescript";
|
|
2168
|
+
import ts22 from "typescript";
|
|
2170
2169
|
|
|
2171
2170
|
// pkgs/@akanjs/devkit/quality/commentDensityScanner.ts
|
|
2172
2171
|
import path6 from "path";
|
|
@@ -3228,6 +3227,74 @@ class TestOnlyExportScanner {
|
|
|
3228
3227
|
}
|
|
3229
3228
|
}
|
|
3230
3229
|
|
|
3230
|
+
// pkgs/@akanjs/devkit/quality/workspaceSourceFiles.ts
|
|
3231
|
+
import { readdir as readdir2, readFile as readFile3, stat } from "fs/promises";
|
|
3232
|
+
import path9 from "path";
|
|
3233
|
+
import ignore from "ignore";
|
|
3234
|
+
import ts21 from "typescript";
|
|
3235
|
+
class WorkspaceSourceFiles {
|
|
3236
|
+
#workspaceRoot;
|
|
3237
|
+
constructor(workspaceRoot) {
|
|
3238
|
+
this.#workspaceRoot = workspaceRoot;
|
|
3239
|
+
}
|
|
3240
|
+
async collect(dirs = ["apps", "libs"]) {
|
|
3241
|
+
const ignoreFilter = ignore().add(await this.#readGitIgnore());
|
|
3242
|
+
const files = new Set;
|
|
3243
|
+
for (const dir of dirs) {
|
|
3244
|
+
const absoluteDir = path9.join(this.#workspaceRoot, dir);
|
|
3245
|
+
if (await WorkspaceSourceFiles.#isDirectory(absoluteDir))
|
|
3246
|
+
await this.#walk(absoluteDir, ignoreFilter, files);
|
|
3247
|
+
}
|
|
3248
|
+
return [...files].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
3249
|
+
}
|
|
3250
|
+
async read(file) {
|
|
3251
|
+
const absolutePath = path9.join(this.#workspaceRoot, file);
|
|
3252
|
+
const content = await readFile3(absolutePath, "utf8");
|
|
3253
|
+
const scriptKind = file.endsWith(".tsx") ? ts21.ScriptKind.TSX : ts21.ScriptKind.TS;
|
|
3254
|
+
return {
|
|
3255
|
+
file,
|
|
3256
|
+
absolutePath,
|
|
3257
|
+
content,
|
|
3258
|
+
sourceFile: ts21.createSourceFile(file, content, ts21.ScriptTarget.Latest, true, scriptKind)
|
|
3259
|
+
};
|
|
3260
|
+
}
|
|
3261
|
+
async#readGitIgnore() {
|
|
3262
|
+
const gitIgnorePath = path9.join(this.#workspaceRoot, ".gitignore");
|
|
3263
|
+
if (!await Bun.file(gitIgnorePath).exists())
|
|
3264
|
+
return [];
|
|
3265
|
+
return (await readFile3(gitIgnorePath, "utf8")).split(/\r?\n/);
|
|
3266
|
+
}
|
|
3267
|
+
async#walk(currentPath, ignoreFilter, files) {
|
|
3268
|
+
const entries = await readdir2(currentPath, { withFileTypes: true });
|
|
3269
|
+
for (const entry of entries) {
|
|
3270
|
+
const absolutePath = path9.join(currentPath, entry.name);
|
|
3271
|
+
const relativePath = path9.relative(this.#workspaceRoot, absolutePath).split(path9.sep).join("/");
|
|
3272
|
+
if (WorkspaceSourceFiles.#shouldSkip(relativePath, entry.isDirectory(), ignoreFilter))
|
|
3273
|
+
continue;
|
|
3274
|
+
if (entry.isDirectory()) {
|
|
3275
|
+
await this.#walk(absolutePath, ignoreFilter, files);
|
|
3276
|
+
continue;
|
|
3277
|
+
}
|
|
3278
|
+
if ((relativePath.endsWith(".ts") || relativePath.endsWith(".tsx")) && !relativePath.endsWith(".d.ts")) {
|
|
3279
|
+
files.add(relativePath);
|
|
3280
|
+
} else if (AbstractDoc.isAbstractPath(relativePath)) {
|
|
3281
|
+
files.add(relativePath);
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
static #shouldSkip(relativePath, isDirectory, ignoreFilter) {
|
|
3286
|
+
const ignorePath = isDirectory ? `${relativePath}/` : relativePath;
|
|
3287
|
+
return relativePath === ".git" || relativePath.includes("/.git/") || relativePath.includes("/node_modules/") || ignoreFilter.ignores(relativePath) || ignoreFilter.ignores(ignorePath);
|
|
3288
|
+
}
|
|
3289
|
+
static async#isDirectory(absolutePath) {
|
|
3290
|
+
try {
|
|
3291
|
+
return (await stat(absolutePath)).isDirectory();
|
|
3292
|
+
} catch {
|
|
3293
|
+
return false;
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3231
3298
|
// pkgs/@akanjs/devkit/quality/qualityScanner.ts
|
|
3232
3299
|
var MAX_FILE_LINES = 2000;
|
|
3233
3300
|
var PLACEHOLDER_EXPORT_NAMES = new Set([
|
|
@@ -3302,8 +3369,9 @@ function getRuleFix(rule) {
|
|
|
3302
3369
|
|
|
3303
3370
|
class AkanQualityScanner {
|
|
3304
3371
|
async scan(workspaceRoot) {
|
|
3305
|
-
const
|
|
3306
|
-
const
|
|
3372
|
+
const workspaceFiles = new WorkspaceSourceFiles(workspaceRoot);
|
|
3373
|
+
const targetFiles = await workspaceFiles.collect();
|
|
3374
|
+
const sourceFiles = await Promise.all(targetFiles.filter((file) => !AbstractDoc.isAbstractPath(file)).map((file) => workspaceFiles.read(file)));
|
|
3307
3375
|
const abstractFiles = await Promise.all(targetFiles.filter((file) => AbstractDoc.isAbstractPath(file)).map((file) => this.#readTextFile(workspaceRoot, file)));
|
|
3308
3376
|
const ssr = new SsrScanner().scan(sourceFiles);
|
|
3309
3377
|
const warnings = [
|
|
@@ -3327,53 +3395,15 @@ class AkanQualityScanner {
|
|
|
3327
3395
|
suggestedRules: SUGGESTED_RULES
|
|
3328
3396
|
};
|
|
3329
3397
|
}
|
|
3330
|
-
async
|
|
3331
|
-
const
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
continue;
|
|
3337
|
-
await this.#walkTargetFiles(workspaceRoot, absoluteTargetRoot, ignoreFilter, files);
|
|
3338
|
-
}
|
|
3339
|
-
return files.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
3340
|
-
}
|
|
3341
|
-
async#readGitIgnore(workspaceRoot) {
|
|
3342
|
-
const gitIgnorePath = path9.join(workspaceRoot, ".gitignore");
|
|
3343
|
-
if (!await Bun.file(gitIgnorePath).exists())
|
|
3344
|
-
return [];
|
|
3345
|
-
return (await readFile3(gitIgnorePath, "utf8")).split(/\r?\n/);
|
|
3346
|
-
}
|
|
3347
|
-
async#walkTargetFiles(workspaceRoot, currentPath, ignoreFilter, files) {
|
|
3348
|
-
const entries = await readdir2(currentPath, { withFileTypes: true });
|
|
3349
|
-
for (const entry of entries) {
|
|
3350
|
-
const absolutePath = path9.join(currentPath, entry.name);
|
|
3351
|
-
const relativePath = toPosix(path9.relative(workspaceRoot, absolutePath));
|
|
3352
|
-
if (shouldSkipPath(relativePath, entry.isDirectory(), ignoreFilter))
|
|
3353
|
-
continue;
|
|
3354
|
-
if (entry.isDirectory()) {
|
|
3355
|
-
await this.#walkTargetFiles(workspaceRoot, absolutePath, ignoreFilter, files);
|
|
3356
|
-
continue;
|
|
3357
|
-
}
|
|
3358
|
-
if ((relativePath.endsWith(".ts") || relativePath.endsWith(".tsx")) && !relativePath.endsWith(".d.ts")) {
|
|
3359
|
-
files.push(relativePath);
|
|
3360
|
-
} else if (AbstractDoc.isAbstractPath(relativePath)) {
|
|
3361
|
-
files.push(relativePath);
|
|
3362
|
-
}
|
|
3363
|
-
}
|
|
3364
|
-
}
|
|
3365
|
-
async#readSourceFile(workspaceRoot, file) {
|
|
3366
|
-
const absolutePath = path9.join(workspaceRoot, file);
|
|
3367
|
-
const content = await readFile3(absolutePath, "utf8");
|
|
3368
|
-
return {
|
|
3369
|
-
file,
|
|
3370
|
-
absolutePath,
|
|
3371
|
-
content,
|
|
3372
|
-
sourceFile: ts21.createSourceFile(file, content, ts21.ScriptTarget.Latest, true, getScriptKind(file))
|
|
3373
|
-
};
|
|
3398
|
+
async scanSsr(workspaceRoot, dirs) {
|
|
3399
|
+
const workspaceFiles = new WorkspaceSourceFiles(workspaceRoot);
|
|
3400
|
+
const read = (file) => !AbstractDoc.isAbstractPath(file) && (dirs.some((dir) => file.startsWith(`${dir}/`)) || /^libs\/[^/]+\/lib\/.+\.signal\.ts$/.test(file));
|
|
3401
|
+
const files = (await workspaceFiles.collect([...dirs, "libs"])).filter(read);
|
|
3402
|
+
const { warnings } = new SsrScanner().scan(await Promise.all(files.map((file) => workspaceFiles.read(file))));
|
|
3403
|
+
return warnings.map((warning) => ({ ...warning, fix: warning.fix ?? getRuleFix(warning.rule) })).sort(compareWarnings);
|
|
3374
3404
|
}
|
|
3375
3405
|
async#readTextFile(workspaceRoot, file) {
|
|
3376
|
-
return { file, content: await
|
|
3406
|
+
return { file, content: await readFile4(path10.join(workspaceRoot, file), "utf8") };
|
|
3377
3407
|
}
|
|
3378
3408
|
#scanGlobalQuality(sourceFiles) {
|
|
3379
3409
|
const exportedFunctionLikes = sourceFiles.flatMap((sourceFile) => getExportedFunctionLikes(sourceFile));
|
|
@@ -3466,8 +3496,8 @@ class AkanQualityScanner {
|
|
|
3466
3496
|
const suffix = CONVENTION_SUFFIXES.find((candidate) => sourceFile.file.endsWith(candidate));
|
|
3467
3497
|
if (!suffix)
|
|
3468
3498
|
return [];
|
|
3469
|
-
const modelName = toPascalCase(
|
|
3470
|
-
return getTopLevelDeclarations(sourceFile).filter((declaration) => !isAllowedConventionDeclaration(suffix, modelName, declaration)).map((declaration) => fileWarning(`akan.convention${suffix.replace(".ts", "")}`, "convention", sourceFile.file, `${
|
|
3499
|
+
const modelName = toPascalCase(path10.basename(sourceFile.file, suffix));
|
|
3500
|
+
return getTopLevelDeclarations(sourceFile).filter((declaration) => !isAllowedConventionDeclaration(suffix, modelName, declaration)).map((declaration) => fileWarning(`akan.convention${suffix.replace(".ts", "")}`, "convention", sourceFile.file, `${path10.basename(sourceFile.file)} should not declare top-level ${declaration.kind} "${declaration.name}". Allowed declarations: ${getConventionDescription(suffix, modelName)}.`, declaration.line));
|
|
3471
3501
|
}
|
|
3472
3502
|
#scanAbstractQuality({ file, content }) {
|
|
3473
3503
|
const lineCount = AbstractDoc.lineCountOf(content);
|
|
@@ -3489,7 +3519,7 @@ class AkanQualityScanner {
|
|
|
3489
3519
|
}
|
|
3490
3520
|
const facetShadow = rootEntry?.isDir ? facetIndexShadowOf(sourceFile.file.split("/").slice(2).join("/")) : null;
|
|
3491
3521
|
if (facetShadow)
|
|
3492
|
-
warnings.push(fileWarning("akan.layout.facet-index-shadow", "layout", sourceFile.file, `${
|
|
3522
|
+
warnings.push(fileWarning("akan.layout.facet-index-shadow", "layout", sourceFile.file, `${path10.basename(sourceFile.file)} ${facetShadow}.`));
|
|
3493
3523
|
const libFacetFile = getLibFacetRootFile(sourceFile.file);
|
|
3494
3524
|
if (libFacetFile && !isAllowedLibFacetRootFile(libFacetFile))
|
|
3495
3525
|
warnings.push(fileWarning("akan.layout.lib-facet-file", "layout", sourceFile.file, `Unexpected lib facet root file "${libFacetFile}". ${libFacetRootHintOf(libFacetFile) ?? "Keep direct lib/ root files limited to generated support facets."}`));
|
|
@@ -3568,13 +3598,13 @@ function getExportedFunctionLikes(sourceFile) {
|
|
|
3568
3598
|
duplicateNameExempt: nameExempt || isConventionDuplicateNameExempt(sourceFile.file, isEnumClass)
|
|
3569
3599
|
});
|
|
3570
3600
|
for (const statement of sourceFile.sourceFile.statements) {
|
|
3571
|
-
if (
|
|
3601
|
+
if (ts22.isFunctionDeclaration(statement) && statement.name && isExported(statement))
|
|
3572
3602
|
add(statement.name.text, "function", statement, statement.body);
|
|
3573
|
-
if (
|
|
3603
|
+
if (ts22.isClassDeclaration(statement) && statement.name && isExported(statement))
|
|
3574
3604
|
add(statement.name.text, "class", statement, statement, isEnumClassStatement(sourceFile.sourceFile, statement));
|
|
3575
|
-
if (
|
|
3605
|
+
if (ts22.isVariableStatement(statement) && isExported(statement)) {
|
|
3576
3606
|
for (const declaration of statement.declarationList.declarations) {
|
|
3577
|
-
if (!
|
|
3607
|
+
if (!ts22.isIdentifier(declaration.name) || !isFunctionLikeInitializer(declaration.initializer))
|
|
3578
3608
|
continue;
|
|
3579
3609
|
add(declaration.name.text, "function-variable", declaration, declaration.initializer);
|
|
3580
3610
|
}
|
|
@@ -3602,14 +3632,14 @@ function isConventionDuplicateNameExempt(file, isEnumClass) {
|
|
|
3602
3632
|
return false;
|
|
3603
3633
|
}
|
|
3604
3634
|
function isEnumClassStatement(sourceFile, statement) {
|
|
3605
|
-
if (!
|
|
3635
|
+
if (!ts22.isClassDeclaration(statement))
|
|
3606
3636
|
return false;
|
|
3607
|
-
const heritageClause = statement.heritageClauses?.find((clause) => clause.token ===
|
|
3637
|
+
const heritageClause = statement.heritageClauses?.find((clause) => clause.token === ts22.SyntaxKind.ExtendsKeyword);
|
|
3608
3638
|
const expression = heritageClause?.types[0]?.expression;
|
|
3609
3639
|
return !!expression && expression.getText(sourceFile).startsWith("enumOf(");
|
|
3610
3640
|
}
|
|
3611
3641
|
function getExportedClassNames(sourceFile) {
|
|
3612
|
-
return sourceFile.statements.filter((statement) =>
|
|
3642
|
+
return sourceFile.statements.filter((statement) => ts22.isClassDeclaration(statement)).filter((statement) => isExported(statement)).map((statement) => statement.name?.text).filter((name) => !!name);
|
|
3613
3643
|
}
|
|
3614
3644
|
function isComponentDeclarationFile(file) {
|
|
3615
3645
|
if (!file.endsWith(".tsx"))
|
|
@@ -3625,7 +3655,7 @@ function isComponentDeclarationFile(file) {
|
|
|
3625
3655
|
function getComponentFileDeclarations(sourceFile) {
|
|
3626
3656
|
const reExportedNames = new Set;
|
|
3627
3657
|
for (const statement of sourceFile.statements) {
|
|
3628
|
-
if (
|
|
3658
|
+
if (ts22.isExportDeclaration(statement) && statement.exportClause && ts22.isNamedExports(statement.exportClause)) {
|
|
3629
3659
|
for (const element of statement.exportClause.elements)
|
|
3630
3660
|
reExportedNames.add((element.propertyName ?? element.name).text);
|
|
3631
3661
|
}
|
|
@@ -3635,19 +3665,19 @@ function getComponentFileDeclarations(sourceFile) {
|
|
|
3635
3665
|
const isDefaultExport = isDefaultExportStatement(statement);
|
|
3636
3666
|
const inlineExported = isExported(statement);
|
|
3637
3667
|
const add = (name, kind, line) => declarations.push({ name, kind, line, exported: inlineExported || reExportedNames.has(name), isDefaultExport });
|
|
3638
|
-
if (
|
|
3668
|
+
if (ts22.isInterfaceDeclaration(statement))
|
|
3639
3669
|
add(statement.name.text, "interface", getLine(sourceFile, statement));
|
|
3640
|
-
else if (
|
|
3670
|
+
else if (ts22.isTypeAliasDeclaration(statement))
|
|
3641
3671
|
add(statement.name.text, "type", getLine(sourceFile, statement));
|
|
3642
|
-
else if (
|
|
3672
|
+
else if (ts22.isEnumDeclaration(statement))
|
|
3643
3673
|
add(statement.name.text, "enum", getLine(sourceFile, statement));
|
|
3644
|
-
else if (
|
|
3674
|
+
else if (ts22.isFunctionDeclaration(statement) && statement.name)
|
|
3645
3675
|
add(statement.name.text, "function", getLine(sourceFile, statement));
|
|
3646
|
-
else if (
|
|
3676
|
+
else if (ts22.isClassDeclaration(statement) && statement.name)
|
|
3647
3677
|
add(statement.name.text, "class", getLine(sourceFile, statement));
|
|
3648
|
-
else if (
|
|
3678
|
+
else if (ts22.isVariableStatement(statement)) {
|
|
3649
3679
|
for (const declaration of statement.declarationList.declarations) {
|
|
3650
|
-
if (!
|
|
3680
|
+
if (!ts22.isIdentifier(declaration.name))
|
|
3651
3681
|
continue;
|
|
3652
3682
|
const kind = isFunctionLikeInitializer(declaration.initializer) ? "function" : "variable";
|
|
3653
3683
|
add(declaration.name.text, kind, getLine(sourceFile, declaration));
|
|
@@ -3659,15 +3689,15 @@ function getComponentFileDeclarations(sourceFile) {
|
|
|
3659
3689
|
function getCompoundComponentNames(sourceFile) {
|
|
3660
3690
|
const names = new Set;
|
|
3661
3691
|
for (const statement of sourceFile.statements) {
|
|
3662
|
-
if (!
|
|
3692
|
+
if (!ts22.isExpressionStatement(statement))
|
|
3663
3693
|
continue;
|
|
3664
3694
|
const { expression } = statement;
|
|
3665
|
-
if (!
|
|
3695
|
+
if (!ts22.isBinaryExpression(expression) || expression.operatorToken.kind !== ts22.SyntaxKind.EqualsToken)
|
|
3666
3696
|
continue;
|
|
3667
|
-
if (!
|
|
3697
|
+
if (!ts22.isPropertyAccessExpression(expression.left) || !isPascalCaseName(expression.left.name.text))
|
|
3668
3698
|
continue;
|
|
3669
3699
|
names.add(expression.left.name.text);
|
|
3670
|
-
if (
|
|
3700
|
+
if (ts22.isIdentifier(expression.right) && isPascalCaseName(expression.right.text))
|
|
3671
3701
|
names.add(expression.right.text);
|
|
3672
3702
|
}
|
|
3673
3703
|
return names;
|
|
@@ -3687,11 +3717,11 @@ function isPascalCaseName(name) {
|
|
|
3687
3717
|
return /^[A-Z]/.test(name) && !/^[A-Z0-9_]+$/.test(name);
|
|
3688
3718
|
}
|
|
3689
3719
|
function isDefaultExportStatement(statement) {
|
|
3690
|
-
if (
|
|
3720
|
+
if (ts22.isExportAssignment(statement))
|
|
3691
3721
|
return !statement.isExportEquals;
|
|
3692
|
-
if (!
|
|
3722
|
+
if (!ts22.canHaveModifiers(statement))
|
|
3693
3723
|
return false;
|
|
3694
|
-
return !!
|
|
3724
|
+
return !!ts22.getModifiers(statement)?.some((modifier) => modifier.kind === ts22.SyntaxKind.DefaultKeyword);
|
|
3695
3725
|
}
|
|
3696
3726
|
function getBangCommentWarnings(sourceFile) {
|
|
3697
3727
|
if (!isClientReachableFile(sourceFile.file))
|
|
@@ -3727,11 +3757,11 @@ function getGlobalMutationWarnings(sourceFile) {
|
|
|
3727
3757
|
const warnings = [];
|
|
3728
3758
|
for (const statement of sourceFile.sourceFile.statements) {
|
|
3729
3759
|
const warn = (rule, message) => warnings.push(fileWarning(rule, "file", sourceFile.file, message, getLine(sourceFile.sourceFile, statement)));
|
|
3730
|
-
if (
|
|
3760
|
+
if (ts22.isModuleDeclaration(statement) && statement.name.getText(sourceFile.sourceFile) === "global")
|
|
3731
3761
|
warn("akan.file.global-declaration", "Global declarations require an explicit low-level integration allowlist.");
|
|
3732
|
-
if (
|
|
3762
|
+
if (ts22.isInterfaceDeclaration(statement) && statement.name.text === "Window")
|
|
3733
3763
|
warn("akan.file.window-augmentation", "Window augmentation should be isolated to approved browser integration files.");
|
|
3734
|
-
if (
|
|
3764
|
+
if (ts22.isExpressionStatement(statement) && statement.expression.getText(sourceFile.sourceFile).includes(".prototype."))
|
|
3735
3765
|
warn("akan.file.prototype-mutation", "Prototype mutation should be avoided or isolated to approved low-level integration files.");
|
|
3736
3766
|
}
|
|
3737
3767
|
return warnings;
|
|
@@ -3748,19 +3778,19 @@ function getTopLevelDeclaration(sourceFile, statement) {
|
|
|
3748
3778
|
exported: isExported(statement),
|
|
3749
3779
|
node: statement
|
|
3750
3780
|
});
|
|
3751
|
-
if (
|
|
3781
|
+
if (ts22.isClassDeclaration(statement) && statement.name)
|
|
3752
3782
|
return [declared(statement.name.text, "class")];
|
|
3753
|
-
if (
|
|
3783
|
+
if (ts22.isFunctionDeclaration(statement) && statement.name)
|
|
3754
3784
|
return [declared(statement.name.text, "function")];
|
|
3755
|
-
if (
|
|
3785
|
+
if (ts22.isInterfaceDeclaration(statement))
|
|
3756
3786
|
return [declared(statement.name.text, "interface")];
|
|
3757
|
-
if (
|
|
3787
|
+
if (ts22.isTypeAliasDeclaration(statement))
|
|
3758
3788
|
return [declared(statement.name.text, "type")];
|
|
3759
|
-
if (
|
|
3789
|
+
if (ts22.isEnumDeclaration(statement))
|
|
3760
3790
|
return [declared(statement.name.text, "enum")];
|
|
3761
|
-
if (
|
|
3762
|
-
return statement.declarationList.declarations.filter((declaration) =>
|
|
3763
|
-
if (
|
|
3791
|
+
if (ts22.isVariableStatement(statement))
|
|
3792
|
+
return statement.declarationList.declarations.filter((declaration) => ts22.isIdentifier(declaration.name)).map((declaration) => declared(declaration.name.text, "variable", getLine(sourceFile, declaration)));
|
|
3793
|
+
if (ts22.isExportDeclaration(statement))
|
|
3764
3794
|
return [{ name: "export declaration", kind: "export", line, exported: true, node: statement }];
|
|
3765
3795
|
return [];
|
|
3766
3796
|
}
|
|
@@ -3848,13 +3878,13 @@ function getModuleInfo(file) {
|
|
|
3848
3878
|
return { moduleName, fileName, kind: "database" };
|
|
3849
3879
|
}
|
|
3850
3880
|
function isExportedConst(declaration) {
|
|
3851
|
-
return declaration.exported &&
|
|
3881
|
+
return declaration.exported && ts22.isVariableStatement(declaration.node) && (declaration.node.declarationList.flags & ts22.NodeFlags.Const) !== 0;
|
|
3852
3882
|
}
|
|
3853
3883
|
function isExported(node) {
|
|
3854
|
-
return !!(
|
|
3884
|
+
return !!(ts22.getCombinedModifierFlags(node) & ts22.ModifierFlags.Export);
|
|
3855
3885
|
}
|
|
3856
3886
|
function isFunctionLikeInitializer(node) {
|
|
3857
|
-
return !!node && (
|
|
3887
|
+
return !!node && (ts22.isArrowFunction(node) || ts22.isFunctionExpression(node));
|
|
3858
3888
|
}
|
|
3859
3889
|
function getBodyFingerprint(sourceFile, node) {
|
|
3860
3890
|
if (!node)
|
|
@@ -3864,20 +3894,6 @@ function getBodyFingerprint(sourceFile, node) {
|
|
|
3864
3894
|
return;
|
|
3865
3895
|
return createHash("sha256").update(normalizedBody).digest("hex");
|
|
3866
3896
|
}
|
|
3867
|
-
function shouldSkipPath(relativePath, isDirectory, ignoreFilter) {
|
|
3868
|
-
const ignorePath = isDirectory ? `${relativePath}/` : relativePath;
|
|
3869
|
-
return relativePath === ".git" || relativePath.includes("/.git/") || relativePath.includes("/node_modules/") || ignoreFilter.ignores(relativePath) || ignoreFilter.ignores(ignorePath);
|
|
3870
|
-
}
|
|
3871
|
-
async function isDirectory(absolutePath) {
|
|
3872
|
-
try {
|
|
3873
|
-
return (await stat(absolutePath)).isDirectory();
|
|
3874
|
-
} catch {
|
|
3875
|
-
return false;
|
|
3876
|
-
}
|
|
3877
|
-
}
|
|
3878
|
-
function getScriptKind(file) {
|
|
3879
|
-
return file.endsWith(".tsx") ? ts21.ScriptKind.TSX : ts21.ScriptKind.TS;
|
|
3880
|
-
}
|
|
3881
3897
|
function getLine(sourceFile, node) {
|
|
3882
3898
|
return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;
|
|
3883
3899
|
}
|
|
@@ -3896,9 +3912,6 @@ function findPatternLines(content, pattern) {
|
|
|
3896
3912
|
function toPascalCase(value) {
|
|
3897
3913
|
return value.replace(/(^|[-_./])([a-zA-Z0-9])/g, (_, __, char) => char.toUpperCase()).replace(/[-_./]/g, "");
|
|
3898
3914
|
}
|
|
3899
|
-
function toPosix(value) {
|
|
3900
|
-
return value.split(path9.sep).join("/");
|
|
3901
|
-
}
|
|
3902
3915
|
function groupBy(items, getKey) {
|
|
3903
3916
|
const grouped = new Map;
|
|
3904
3917
|
for (const item of items) {
|