@ultrst-armada/krnl 1.0.18 → 1.0.19
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/package.json +1 -1
- package/packages/cli/dist/bin/krnl.cjs +145 -143
- package/packages/cli/dist/bin/krnl.js +1 -1
- package/packages/cli/dist/{chunk-OOVZPIMX.js → chunk-FKQ5QRQF.js} +140 -138
- package/packages/cli/dist/index.cjs +140 -138
- package/packages/cli/dist/index.js +1 -1
- package/packages/core/dist/index.cjs +94 -79
- package/packages/core/dist/index.d.cts +7 -15
- package/packages/core/dist/index.d.ts +7 -15
- package/packages/core/dist/index.js +94 -79
- package/packages/validate/dist/index.cjs +51 -41
- package/packages/validate/dist/index.js +48 -38
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/KrnlValidatorEngine.ts
|
|
2
2
|
import * as fs2 from "fs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as path4 from "path";
|
|
4
4
|
import { Project } from "ts-morph";
|
|
5
5
|
|
|
6
6
|
// src/rules/fileLimits.ts
|
|
@@ -276,6 +276,9 @@ function checkOrchestrationRules(sf) {
|
|
|
276
276
|
|
|
277
277
|
// src/rules/workspaceRules.ts
|
|
278
278
|
import * as fs from "fs";
|
|
279
|
+
import * as path3 from "path";
|
|
280
|
+
|
|
281
|
+
// src/rules/topLevelPurityRules.ts
|
|
279
282
|
import * as path2 from "path";
|
|
280
283
|
import { SyntaxKind as SyntaxKind3 } from "ts-morph";
|
|
281
284
|
function checkTopLevelPurity(sf) {
|
|
@@ -341,25 +344,27 @@ function checkTopLevelPurity(sf) {
|
|
|
341
344
|
}
|
|
342
345
|
return { errors, warnings };
|
|
343
346
|
}
|
|
347
|
+
|
|
348
|
+
// src/rules/workspaceRules.ts
|
|
344
349
|
function checkWorkspaceLayout(projectRoot, errors) {
|
|
345
|
-
const krnlDir =
|
|
346
|
-
const srcDir =
|
|
350
|
+
const krnlDir = path3.join(projectRoot, "krnl");
|
|
351
|
+
const srcDir = path3.join(projectRoot, "src");
|
|
347
352
|
const targetDir = fs.existsSync(krnlDir) ? krnlDir : fs.existsSync(srcDir) ? srcDir : null;
|
|
348
353
|
if (!targetDir) return;
|
|
349
|
-
const backendDir =
|
|
350
|
-
const frontendDir =
|
|
354
|
+
const backendDir = path3.join(targetDir, "backend");
|
|
355
|
+
const frontendDir = path3.join(targetDir, "frontend");
|
|
351
356
|
if (fs.existsSync(backendDir)) {
|
|
352
|
-
const bServices =
|
|
357
|
+
const bServices = path3.join(backendDir, "services");
|
|
353
358
|
if (fs.existsSync(bServices)) {
|
|
354
359
|
for (const sEntry of fs.readdirSync(bServices, { withFileTypes: true })) {
|
|
355
360
|
if (!sEntry.isDirectory()) continue;
|
|
356
|
-
const sDir =
|
|
357
|
-
const sLibs =
|
|
361
|
+
const sDir = path3.join(bServices, sEntry.name);
|
|
362
|
+
const sLibs = path3.join(sDir, "libraries");
|
|
358
363
|
if (fs.existsSync(sLibs)) {
|
|
359
364
|
for (const entry of fs.readdirSync(sLibs, { withFileTypes: true })) {
|
|
360
365
|
if (!entry.isDirectory()) continue;
|
|
361
|
-
const libPath =
|
|
362
|
-
if (!fs.existsSync(
|
|
366
|
+
const libPath = path3.join(sLibs, entry.name);
|
|
367
|
+
if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
|
|
363
368
|
errors.push({
|
|
364
369
|
ruleId: "krnl/concept-manifest-required",
|
|
365
370
|
filePath: libPath,
|
|
@@ -369,12 +374,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
369
374
|
}
|
|
370
375
|
}
|
|
371
376
|
}
|
|
372
|
-
const sFuncs =
|
|
377
|
+
const sFuncs = path3.join(sDir, "functionalities");
|
|
373
378
|
if (fs.existsSync(sFuncs)) {
|
|
374
379
|
for (const entry of fs.readdirSync(sFuncs, { withFileTypes: true })) {
|
|
375
380
|
if (!entry.isDirectory()) continue;
|
|
376
|
-
const funcPath =
|
|
377
|
-
if (!fs.existsSync(
|
|
381
|
+
const funcPath = path3.join(sFuncs, entry.name);
|
|
382
|
+
if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
|
|
378
383
|
errors.push({
|
|
379
384
|
ruleId: "krnl/functionality-manifest-required",
|
|
380
385
|
filePath: funcPath,
|
|
@@ -386,12 +391,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
386
391
|
}
|
|
387
392
|
}
|
|
388
393
|
}
|
|
389
|
-
const bLibs =
|
|
394
|
+
const bLibs = path3.join(backendDir, "libraries");
|
|
390
395
|
if (fs.existsSync(bLibs)) {
|
|
391
396
|
for (const entry of fs.readdirSync(bLibs, { withFileTypes: true })) {
|
|
392
397
|
if (!entry.isDirectory()) continue;
|
|
393
|
-
const libPath =
|
|
394
|
-
if (!fs.existsSync(
|
|
398
|
+
const libPath = path3.join(bLibs, entry.name);
|
|
399
|
+
if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
|
|
395
400
|
errors.push({
|
|
396
401
|
ruleId: "krnl/concept-manifest-required",
|
|
397
402
|
filePath: libPath,
|
|
@@ -401,12 +406,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
401
406
|
}
|
|
402
407
|
}
|
|
403
408
|
}
|
|
404
|
-
const bFuncs =
|
|
409
|
+
const bFuncs = path3.join(backendDir, "functionalities");
|
|
405
410
|
if (fs.existsSync(bFuncs)) {
|
|
406
411
|
for (const entry of fs.readdirSync(bFuncs, { withFileTypes: true })) {
|
|
407
412
|
if (!entry.isDirectory()) continue;
|
|
408
|
-
const funcPath =
|
|
409
|
-
if (!fs.existsSync(
|
|
413
|
+
const funcPath = path3.join(bFuncs, entry.name);
|
|
414
|
+
if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
|
|
410
415
|
errors.push({
|
|
411
416
|
ruleId: "krnl/functionality-manifest-required",
|
|
412
417
|
filePath: funcPath,
|
|
@@ -418,12 +423,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
418
423
|
}
|
|
419
424
|
}
|
|
420
425
|
if (fs.existsSync(frontendDir)) {
|
|
421
|
-
const fLibs =
|
|
426
|
+
const fLibs = path3.join(frontendDir, "libraries");
|
|
422
427
|
if (fs.existsSync(fLibs)) {
|
|
423
428
|
for (const entry of fs.readdirSync(fLibs, { withFileTypes: true })) {
|
|
424
429
|
if (!entry.isDirectory()) continue;
|
|
425
|
-
const libPath =
|
|
426
|
-
if (!fs.existsSync(
|
|
430
|
+
const libPath = path3.join(fLibs, entry.name);
|
|
431
|
+
if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
|
|
427
432
|
errors.push({
|
|
428
433
|
ruleId: "krnl/frontend-concept-manifest-required",
|
|
429
434
|
filePath: libPath,
|
|
@@ -433,12 +438,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
433
438
|
}
|
|
434
439
|
}
|
|
435
440
|
}
|
|
436
|
-
const fFuncs =
|
|
441
|
+
const fFuncs = path3.join(frontendDir, "functionalities");
|
|
437
442
|
if (fs.existsSync(fFuncs)) {
|
|
438
443
|
for (const entry of fs.readdirSync(fFuncs, { withFileTypes: true })) {
|
|
439
444
|
if (!entry.isDirectory()) continue;
|
|
440
|
-
const funcPath =
|
|
441
|
-
if (!fs.existsSync(
|
|
445
|
+
const funcPath = path3.join(fFuncs, entry.name);
|
|
446
|
+
if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
|
|
442
447
|
errors.push({
|
|
443
448
|
ruleId: "krnl/frontend-functionality-manifest-required",
|
|
444
449
|
filePath: funcPath,
|
|
@@ -482,6 +487,9 @@ function checkServiceBoundaries(sf) {
|
|
|
482
487
|
}
|
|
483
488
|
|
|
484
489
|
// src/rules/scopedLibraryRules.ts
|
|
490
|
+
import { SyntaxKind as SyntaxKind5 } from "ts-morph";
|
|
491
|
+
|
|
492
|
+
// src/rules/scopedLibraryTypeHelpers.ts
|
|
485
493
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
486
494
|
var PRIMITIVE_AND_BUILTIN_TYPES = /* @__PURE__ */ new Set([
|
|
487
495
|
"string",
|
|
@@ -534,14 +542,6 @@ var PRIMITIVE_AND_BUILTIN_TYPES = /* @__PURE__ */ new Set([
|
|
|
534
542
|
"ReturnType",
|
|
535
543
|
"InstanceType"
|
|
536
544
|
]);
|
|
537
|
-
function detectServiceContext(filePath) {
|
|
538
|
-
const normalized = filePath.replace(/\\/g, "/");
|
|
539
|
-
const match = normalized.match(/(?:^|\/)services\/([^/]+)\/libraries\/([^/]+)/);
|
|
540
|
-
if (match) {
|
|
541
|
-
return { serviceName: match[1], libraryName: match[2] };
|
|
542
|
-
}
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
545
|
function containsIdentifier(name, target) {
|
|
546
546
|
return name.toLowerCase().includes(target.toLowerCase());
|
|
547
547
|
}
|
|
@@ -562,6 +562,16 @@ function hasContextualTypeReference(node, serviceName, localTypes) {
|
|
|
562
562
|
}
|
|
563
563
|
return false;
|
|
564
564
|
}
|
|
565
|
+
|
|
566
|
+
// src/rules/scopedLibraryRules.ts
|
|
567
|
+
function detectServiceContext(filePath) {
|
|
568
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
569
|
+
const match = normalized.match(/(?:^|\/)services\/([^/]+)\/libraries\/([^/]+)/);
|
|
570
|
+
if (match) {
|
|
571
|
+
return { serviceName: match[1], libraryName: match[2] };
|
|
572
|
+
}
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
565
575
|
function checkScopedLibraryRules(sf) {
|
|
566
576
|
const errors = [];
|
|
567
577
|
const warnings = [];
|
|
@@ -611,7 +621,7 @@ function checkScopedLibraryRules(sf) {
|
|
|
611
621
|
for (const decl of stmt.getDeclarations()) {
|
|
612
622
|
const varName = decl.getName();
|
|
613
623
|
const init = decl.getInitializer();
|
|
614
|
-
const isFunction = init && (init.getKind() ===
|
|
624
|
+
const isFunction = init && (init.getKind() === SyntaxKind5.ArrowFunction || init.getKind() === SyntaxKind5.FunctionExpression);
|
|
615
625
|
if (isFunction) {
|
|
616
626
|
const isContextual = hasContextualTypeReference(decl, serviceName, localTypes);
|
|
617
627
|
const hasServiceName = containsIdentifier(varName, serviceName);
|
|
@@ -702,13 +712,13 @@ var KrnlValidatorEngine = class {
|
|
|
702
712
|
limitOptions;
|
|
703
713
|
constructor(optionsOrRoot) {
|
|
704
714
|
const options = typeof optionsOrRoot === "string" ? { projectRoot: optionsOrRoot } : optionsOrRoot;
|
|
705
|
-
this.projectRoot =
|
|
715
|
+
this.projectRoot = path4.resolve(options.projectRoot || process.cwd());
|
|
706
716
|
this.limitOptions = {
|
|
707
717
|
maxFileLineLimit: options.maxFileLineLimit ?? 200,
|
|
708
718
|
maxMainLogicLimit: options.maxMainLogicLimit ?? 20,
|
|
709
719
|
maxHelperLineLimit: options.maxHelperLineLimit ?? 30
|
|
710
720
|
};
|
|
711
|
-
const tsConfigPath =
|
|
721
|
+
const tsConfigPath = path4.join(this.projectRoot, "tsconfig.json");
|
|
712
722
|
if (fs2.existsSync(tsConfigPath)) {
|
|
713
723
|
this.project = new Project({ tsConfigFilePath: tsConfigPath, skipAddingFilesFromTsConfig: true });
|
|
714
724
|
} else {
|
|
@@ -743,7 +753,7 @@ var KrnlValidatorEngine = class {
|
|
|
743
753
|
}
|
|
744
754
|
validateSourceFile(sf) {
|
|
745
755
|
const filePath = sf.getFilePath();
|
|
746
|
-
const baseName =
|
|
756
|
+
const baseName = path4.basename(filePath);
|
|
747
757
|
if (baseName.includes("_pb.") || baseName.endsWith(".d.ts")) {
|
|
748
758
|
return { errors: [], warnings: [], promotableAssets: [] };
|
|
749
759
|
}
|
|
@@ -778,7 +788,7 @@ var KrnlValidatorEngine = class {
|
|
|
778
788
|
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
779
789
|
for (const entry of entries) {
|
|
780
790
|
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
|
|
781
|
-
const full =
|
|
791
|
+
const full = path4.join(dir, entry.name);
|
|
782
792
|
if (entry.isDirectory()) {
|
|
783
793
|
this.collectSourceFiles(full, collected);
|
|
784
794
|
} else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".js") || entry.name.endsWith(".tsx") || entry.name.endsWith(".jsx"))) {
|