@ultrst-armada/krnl 1.0.17 → 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
|
@@ -24,20 +24,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/bin/krnl.ts
|
|
27
|
-
var
|
|
27
|
+
var path14 = __toESM(require("path"), 1);
|
|
28
28
|
var fs12 = __toESM(require("fs"), 1);
|
|
29
29
|
|
|
30
30
|
// ../validate/dist/index.js
|
|
31
31
|
var fs2 = __toESM(require("fs"), 1);
|
|
32
|
-
var
|
|
32
|
+
var path4 = __toESM(require("path"), 1);
|
|
33
33
|
var import_ts_morph = require("ts-morph");
|
|
34
34
|
var path = __toESM(require("path"), 1);
|
|
35
35
|
var import_ts_morph2 = require("ts-morph");
|
|
36
36
|
var import_ts_morph3 = require("ts-morph");
|
|
37
37
|
var fs = __toESM(require("fs"), 1);
|
|
38
|
+
var path3 = __toESM(require("path"), 1);
|
|
38
39
|
var path2 = __toESM(require("path"), 1);
|
|
39
40
|
var import_ts_morph4 = require("ts-morph");
|
|
40
41
|
var import_ts_morph5 = require("ts-morph");
|
|
42
|
+
var import_ts_morph6 = require("ts-morph");
|
|
41
43
|
function checkFileLimits(sf, options) {
|
|
42
44
|
const errors = [];
|
|
43
45
|
const warnings = [];
|
|
@@ -364,24 +366,24 @@ function checkTopLevelPurity(sf) {
|
|
|
364
366
|
return { errors, warnings };
|
|
365
367
|
}
|
|
366
368
|
function checkWorkspaceLayout(projectRoot, errors) {
|
|
367
|
-
const krnlDir =
|
|
368
|
-
const srcDir =
|
|
369
|
+
const krnlDir = path3.join(projectRoot, "krnl");
|
|
370
|
+
const srcDir = path3.join(projectRoot, "src");
|
|
369
371
|
const targetDir = fs.existsSync(krnlDir) ? krnlDir : fs.existsSync(srcDir) ? srcDir : null;
|
|
370
372
|
if (!targetDir) return;
|
|
371
|
-
const backendDir =
|
|
372
|
-
const frontendDir =
|
|
373
|
+
const backendDir = path3.join(targetDir, "backend");
|
|
374
|
+
const frontendDir = path3.join(targetDir, "frontend");
|
|
373
375
|
if (fs.existsSync(backendDir)) {
|
|
374
|
-
const bServices =
|
|
376
|
+
const bServices = path3.join(backendDir, "services");
|
|
375
377
|
if (fs.existsSync(bServices)) {
|
|
376
378
|
for (const sEntry of fs.readdirSync(bServices, { withFileTypes: true })) {
|
|
377
379
|
if (!sEntry.isDirectory()) continue;
|
|
378
|
-
const sDir =
|
|
379
|
-
const sLibs =
|
|
380
|
+
const sDir = path3.join(bServices, sEntry.name);
|
|
381
|
+
const sLibs = path3.join(sDir, "libraries");
|
|
380
382
|
if (fs.existsSync(sLibs)) {
|
|
381
383
|
for (const entry of fs.readdirSync(sLibs, { withFileTypes: true })) {
|
|
382
384
|
if (!entry.isDirectory()) continue;
|
|
383
|
-
const libPath =
|
|
384
|
-
if (!fs.existsSync(
|
|
385
|
+
const libPath = path3.join(sLibs, entry.name);
|
|
386
|
+
if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
|
|
385
387
|
errors.push({
|
|
386
388
|
ruleId: "krnl/concept-manifest-required",
|
|
387
389
|
filePath: libPath,
|
|
@@ -391,12 +393,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
391
393
|
}
|
|
392
394
|
}
|
|
393
395
|
}
|
|
394
|
-
const sFuncs =
|
|
396
|
+
const sFuncs = path3.join(sDir, "functionalities");
|
|
395
397
|
if (fs.existsSync(sFuncs)) {
|
|
396
398
|
for (const entry of fs.readdirSync(sFuncs, { withFileTypes: true })) {
|
|
397
399
|
if (!entry.isDirectory()) continue;
|
|
398
|
-
const funcPath =
|
|
399
|
-
if (!fs.existsSync(
|
|
400
|
+
const funcPath = path3.join(sFuncs, entry.name);
|
|
401
|
+
if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
|
|
400
402
|
errors.push({
|
|
401
403
|
ruleId: "krnl/functionality-manifest-required",
|
|
402
404
|
filePath: funcPath,
|
|
@@ -408,12 +410,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
408
410
|
}
|
|
409
411
|
}
|
|
410
412
|
}
|
|
411
|
-
const bLibs =
|
|
413
|
+
const bLibs = path3.join(backendDir, "libraries");
|
|
412
414
|
if (fs.existsSync(bLibs)) {
|
|
413
415
|
for (const entry of fs.readdirSync(bLibs, { withFileTypes: true })) {
|
|
414
416
|
if (!entry.isDirectory()) continue;
|
|
415
|
-
const libPath =
|
|
416
|
-
if (!fs.existsSync(
|
|
417
|
+
const libPath = path3.join(bLibs, entry.name);
|
|
418
|
+
if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
|
|
417
419
|
errors.push({
|
|
418
420
|
ruleId: "krnl/concept-manifest-required",
|
|
419
421
|
filePath: libPath,
|
|
@@ -423,12 +425,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
|
-
const bFuncs =
|
|
428
|
+
const bFuncs = path3.join(backendDir, "functionalities");
|
|
427
429
|
if (fs.existsSync(bFuncs)) {
|
|
428
430
|
for (const entry of fs.readdirSync(bFuncs, { withFileTypes: true })) {
|
|
429
431
|
if (!entry.isDirectory()) continue;
|
|
430
|
-
const funcPath =
|
|
431
|
-
if (!fs.existsSync(
|
|
432
|
+
const funcPath = path3.join(bFuncs, entry.name);
|
|
433
|
+
if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
|
|
432
434
|
errors.push({
|
|
433
435
|
ruleId: "krnl/functionality-manifest-required",
|
|
434
436
|
filePath: funcPath,
|
|
@@ -440,12 +442,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
440
442
|
}
|
|
441
443
|
}
|
|
442
444
|
if (fs.existsSync(frontendDir)) {
|
|
443
|
-
const fLibs =
|
|
445
|
+
const fLibs = path3.join(frontendDir, "libraries");
|
|
444
446
|
if (fs.existsSync(fLibs)) {
|
|
445
447
|
for (const entry of fs.readdirSync(fLibs, { withFileTypes: true })) {
|
|
446
448
|
if (!entry.isDirectory()) continue;
|
|
447
|
-
const libPath =
|
|
448
|
-
if (!fs.existsSync(
|
|
449
|
+
const libPath = path3.join(fLibs, entry.name);
|
|
450
|
+
if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
|
|
449
451
|
errors.push({
|
|
450
452
|
ruleId: "krnl/frontend-concept-manifest-required",
|
|
451
453
|
filePath: libPath,
|
|
@@ -455,12 +457,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
|
|
|
455
457
|
}
|
|
456
458
|
}
|
|
457
459
|
}
|
|
458
|
-
const fFuncs =
|
|
460
|
+
const fFuncs = path3.join(frontendDir, "functionalities");
|
|
459
461
|
if (fs.existsSync(fFuncs)) {
|
|
460
462
|
for (const entry of fs.readdirSync(fFuncs, { withFileTypes: true })) {
|
|
461
463
|
if (!entry.isDirectory()) continue;
|
|
462
|
-
const funcPath =
|
|
463
|
-
if (!fs.existsSync(
|
|
464
|
+
const funcPath = path3.join(fFuncs, entry.name);
|
|
465
|
+
if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
|
|
464
466
|
errors.push({
|
|
465
467
|
ruleId: "krnl/frontend-functionality-manifest-required",
|
|
466
468
|
filePath: funcPath,
|
|
@@ -551,14 +553,6 @@ var PRIMITIVE_AND_BUILTIN_TYPES = /* @__PURE__ */ new Set([
|
|
|
551
553
|
"ReturnType",
|
|
552
554
|
"InstanceType"
|
|
553
555
|
]);
|
|
554
|
-
function detectServiceContext(filePath) {
|
|
555
|
-
const normalized = filePath.replace(/\\/g, "/");
|
|
556
|
-
const match = normalized.match(/(?:^|\/)services\/([^/]+)\/libraries\/([^/]+)/);
|
|
557
|
-
if (match) {
|
|
558
|
-
return { serviceName: match[1], libraryName: match[2] };
|
|
559
|
-
}
|
|
560
|
-
return null;
|
|
561
|
-
}
|
|
562
556
|
function containsIdentifier(name, target) {
|
|
563
557
|
return name.toLowerCase().includes(target.toLowerCase());
|
|
564
558
|
}
|
|
@@ -570,7 +564,7 @@ function isCustomContextualType(typeName, serviceName, localTypes) {
|
|
|
570
564
|
return false;
|
|
571
565
|
}
|
|
572
566
|
function hasContextualTypeReference(node, serviceName, localTypes) {
|
|
573
|
-
const typeRefs = node.getDescendantsOfKind(
|
|
567
|
+
const typeRefs = node.getDescendantsOfKind(import_ts_morph6.SyntaxKind.TypeReference);
|
|
574
568
|
for (const ref of typeRefs) {
|
|
575
569
|
const text = ref.getTypeName().getText().trim();
|
|
576
570
|
if (isCustomContextualType(text, serviceName, localTypes)) {
|
|
@@ -579,6 +573,14 @@ function hasContextualTypeReference(node, serviceName, localTypes) {
|
|
|
579
573
|
}
|
|
580
574
|
return false;
|
|
581
575
|
}
|
|
576
|
+
function detectServiceContext(filePath) {
|
|
577
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
578
|
+
const match = normalized.match(/(?:^|\/)services\/([^/]+)\/libraries\/([^/]+)/);
|
|
579
|
+
if (match) {
|
|
580
|
+
return { serviceName: match[1], libraryName: match[2] };
|
|
581
|
+
}
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
582
584
|
function checkScopedLibraryRules(sf) {
|
|
583
585
|
const errors = [];
|
|
584
586
|
const warnings = [];
|
|
@@ -717,13 +719,13 @@ var KrnlValidatorEngine = class {
|
|
|
717
719
|
limitOptions;
|
|
718
720
|
constructor(optionsOrRoot) {
|
|
719
721
|
const options = typeof optionsOrRoot === "string" ? { projectRoot: optionsOrRoot } : optionsOrRoot;
|
|
720
|
-
this.projectRoot =
|
|
722
|
+
this.projectRoot = path4.resolve(options.projectRoot || process.cwd());
|
|
721
723
|
this.limitOptions = {
|
|
722
724
|
maxFileLineLimit: options.maxFileLineLimit ?? 200,
|
|
723
725
|
maxMainLogicLimit: options.maxMainLogicLimit ?? 20,
|
|
724
726
|
maxHelperLineLimit: options.maxHelperLineLimit ?? 30
|
|
725
727
|
};
|
|
726
|
-
const tsConfigPath =
|
|
728
|
+
const tsConfigPath = path4.join(this.projectRoot, "tsconfig.json");
|
|
727
729
|
if (fs2.existsSync(tsConfigPath)) {
|
|
728
730
|
this.project = new import_ts_morph.Project({ tsConfigFilePath: tsConfigPath, skipAddingFilesFromTsConfig: true });
|
|
729
731
|
} else {
|
|
@@ -758,7 +760,7 @@ var KrnlValidatorEngine = class {
|
|
|
758
760
|
}
|
|
759
761
|
validateSourceFile(sf) {
|
|
760
762
|
const filePath = sf.getFilePath();
|
|
761
|
-
const baseName =
|
|
763
|
+
const baseName = path4.basename(filePath);
|
|
762
764
|
if (baseName.includes("_pb.") || baseName.endsWith(".d.ts")) {
|
|
763
765
|
return { errors: [], warnings: [], promotableAssets: [] };
|
|
764
766
|
}
|
|
@@ -793,7 +795,7 @@ var KrnlValidatorEngine = class {
|
|
|
793
795
|
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
794
796
|
for (const entry of entries) {
|
|
795
797
|
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
|
|
796
|
-
const full =
|
|
798
|
+
const full = path4.join(dir, entry.name);
|
|
797
799
|
if (entry.isDirectory()) {
|
|
798
800
|
this.collectSourceFiles(full, collected);
|
|
799
801
|
} else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".js") || entry.name.endsWith(".tsx") || entry.name.endsWith(".jsx"))) {
|
|
@@ -841,24 +843,24 @@ async function runValidate(projectRoot = process.cwd()) {
|
|
|
841
843
|
}
|
|
842
844
|
|
|
843
845
|
// src/commands/generators/functionalityOrchestrationGenerator.ts
|
|
844
|
-
var
|
|
846
|
+
var path6 = __toESM(require("path"), 1);
|
|
845
847
|
var fs4 = __toESM(require("fs"), 1);
|
|
846
848
|
|
|
847
849
|
// src/commands/generators/common.ts
|
|
848
850
|
var fs3 = __toESM(require("fs"), 1);
|
|
849
|
-
var
|
|
851
|
+
var path5 = __toESM(require("path"), 1);
|
|
850
852
|
function getPlaneRoots(projectRoot) {
|
|
851
|
-
const krnlRoot =
|
|
853
|
+
const krnlRoot = path5.join(projectRoot, "krnl");
|
|
852
854
|
if (fs3.existsSync(krnlRoot)) {
|
|
853
855
|
return {
|
|
854
|
-
backend:
|
|
855
|
-
frontend:
|
|
856
|
+
backend: path5.join(krnlRoot, "backend"),
|
|
857
|
+
frontend: path5.join(krnlRoot, "frontend"),
|
|
856
858
|
isKrnlDir: true
|
|
857
859
|
};
|
|
858
860
|
}
|
|
859
861
|
return {
|
|
860
|
-
backend:
|
|
861
|
-
frontend:
|
|
862
|
+
backend: path5.join(projectRoot, "src"),
|
|
863
|
+
frontend: path5.join(projectRoot, "src"),
|
|
862
864
|
isKrnlDir: false
|
|
863
865
|
};
|
|
864
866
|
}
|
|
@@ -866,10 +868,10 @@ function getPlaneRoots(projectRoot) {
|
|
|
866
868
|
// src/commands/generators/functionalityOrchestrationGenerator.ts
|
|
867
869
|
function generateFunctionalityOrchestration(name, projectRoot) {
|
|
868
870
|
const { backend } = getPlaneRoots(projectRoot);
|
|
869
|
-
const orchDir =
|
|
870
|
-
fs4.mkdirSync(
|
|
871
|
+
const orchDir = path6.join(backend, "orchestrations", name);
|
|
872
|
+
fs4.mkdirSync(path6.join(orchDir, "tests"), { recursive: true });
|
|
871
873
|
fs4.writeFileSync(
|
|
872
|
-
|
|
874
|
+
path6.join(orchDir, `${name}FunctionalityOrchestration.ts`),
|
|
873
875
|
`import { FunctionalityOrchestration } from '@ultrst-armada/krnl-core';
|
|
874
876
|
|
|
875
877
|
/**
|
|
@@ -895,7 +897,7 @@ export default ${name}FunctionalityOrchestration;
|
|
|
895
897
|
`
|
|
896
898
|
);
|
|
897
899
|
fs4.writeFileSync(
|
|
898
|
-
|
|
900
|
+
path6.join(orchDir, "tests", `${name}FunctionalityOrchestration.test.ts`),
|
|
899
901
|
`import { describe, it, expect } from 'vitest';
|
|
900
902
|
import { ${name}FunctionalityOrchestration } from '../${name}FunctionalityOrchestration.js';
|
|
901
903
|
|
|
@@ -914,11 +916,11 @@ describe('${name}FunctionalityOrchestration', () => {
|
|
|
914
916
|
|
|
915
917
|
// src/commands/generators/functionalityGenerator.ts
|
|
916
918
|
var fs6 = __toESM(require("fs"), 1);
|
|
917
|
-
var
|
|
919
|
+
var path8 = __toESM(require("path"), 1);
|
|
918
920
|
|
|
919
921
|
// ../core/dist/index.js
|
|
920
922
|
var fs5 = __toESM(require("fs"), 1);
|
|
921
|
-
var
|
|
923
|
+
var path7 = __toESM(require("path"), 1);
|
|
922
924
|
var import_gutts = require("@dinilmusick/gutts");
|
|
923
925
|
var gutts = __toESM(require("@dinilmusick/gutts"), 1);
|
|
924
926
|
var runtimeProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
|
|
@@ -971,7 +973,7 @@ var KrnlPackageReconciler = class {
|
|
|
971
973
|
}
|
|
972
974
|
resolvedDevDeps[pkg] = versions[versions.length - 1];
|
|
973
975
|
}
|
|
974
|
-
const pkgJsonPath =
|
|
976
|
+
const pkgJsonPath = path7.join(projectRoot, "package.json");
|
|
975
977
|
let updated = false;
|
|
976
978
|
if (fs5.existsSync(pkgJsonPath)) {
|
|
977
979
|
const pkgContent = JSON.parse(fs5.readFileSync(pkgJsonPath, "utf8"));
|
|
@@ -1009,15 +1011,15 @@ var KrnlPackageReconciler = class {
|
|
|
1009
1011
|
*/
|
|
1010
1012
|
static findManifests(projectRoot) {
|
|
1011
1013
|
const searchDirs = [
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1014
|
+
path7.join(projectRoot, "krnl", "backend", "services"),
|
|
1015
|
+
path7.join(projectRoot, "krnl", "backend", "libraries"),
|
|
1016
|
+
path7.join(projectRoot, "krnl", "backend", "functionalities"),
|
|
1017
|
+
path7.join(projectRoot, "krnl", "frontend", "libraries"),
|
|
1018
|
+
path7.join(projectRoot, "krnl", "frontend", "functionalities"),
|
|
1019
|
+
path7.join(projectRoot, "src", "backend", "services"),
|
|
1020
|
+
path7.join(projectRoot, "src", "services"),
|
|
1021
|
+
path7.join(projectRoot, "src", "functionalities"),
|
|
1022
|
+
path7.join(projectRoot, "src", "libraries")
|
|
1021
1023
|
];
|
|
1022
1024
|
const found = [];
|
|
1023
1025
|
for (const dir of searchDirs) {
|
|
@@ -1032,7 +1034,7 @@ var KrnlPackageReconciler = class {
|
|
|
1032
1034
|
const entries = fs5.readdirSync(dir, { withFileTypes: true });
|
|
1033
1035
|
for (const entry of entries) {
|
|
1034
1036
|
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
|
|
1035
|
-
const full =
|
|
1037
|
+
const full = path7.join(dir, entry.name);
|
|
1036
1038
|
if (entry.isDirectory()) {
|
|
1037
1039
|
this.scanRecursive(full, found);
|
|
1038
1040
|
} else if (entry.isFile() && entry.name === "manifest.json") {
|
|
@@ -1050,7 +1052,7 @@ function generateFunctionality(name, projectRoot, parentServiceOrOptions) {
|
|
|
1050
1052
|
const options = typeof parentServiceOrOptions === "string" ? { parentService: parentServiceOrOptions } : parentServiceOrOptions || {};
|
|
1051
1053
|
let targetService = options.parentService;
|
|
1052
1054
|
if (!targetService) {
|
|
1053
|
-
const servicesDir =
|
|
1055
|
+
const servicesDir = path8.join(backend, "services");
|
|
1054
1056
|
if (fs6.existsSync(servicesDir)) {
|
|
1055
1057
|
const existing = fs6.readdirSync(servicesDir, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
1056
1058
|
if (existing.length === 1) {
|
|
@@ -1058,15 +1060,15 @@ function generateFunctionality(name, projectRoot, parentServiceOrOptions) {
|
|
|
1058
1060
|
}
|
|
1059
1061
|
}
|
|
1060
1062
|
}
|
|
1061
|
-
const bFuncDir = targetService ?
|
|
1062
|
-
fs6.mkdirSync(
|
|
1063
|
-
fs6.mkdirSync(
|
|
1064
|
-
fs6.mkdirSync(
|
|
1065
|
-
fs6.mkdirSync(
|
|
1063
|
+
const bFuncDir = targetService ? path8.join(backend, "services", targetService, "functionalities", name) : path8.join(backend, "functionalities", name);
|
|
1064
|
+
fs6.mkdirSync(path8.join(bFuncDir, "main_function"), { recursive: true });
|
|
1065
|
+
fs6.mkdirSync(path8.join(bFuncDir, "helper_functions"), { recursive: true });
|
|
1066
|
+
fs6.mkdirSync(path8.join(bFuncDir, "events"), { recursive: true });
|
|
1067
|
+
fs6.mkdirSync(path8.join(bFuncDir, "tests"), { recursive: true });
|
|
1066
1068
|
if (options.withState) {
|
|
1067
|
-
fs6.mkdirSync(
|
|
1069
|
+
fs6.mkdirSync(path8.join(bFuncDir, "state_data"), { recursive: true });
|
|
1068
1070
|
fs6.writeFileSync(
|
|
1069
|
-
|
|
1071
|
+
path8.join(bFuncDir, "state_data", "state.ts"),
|
|
1070
1072
|
`export interface ${name}State {
|
|
1071
1073
|
executionCount: number;
|
|
1072
1074
|
}
|
|
@@ -1078,7 +1080,7 @@ export const initialState: ${name}State = {
|
|
|
1078
1080
|
);
|
|
1079
1081
|
}
|
|
1080
1082
|
fs6.writeFileSync(
|
|
1081
|
-
|
|
1083
|
+
path8.join(bFuncDir, `${name}Atom.ts`),
|
|
1082
1084
|
`export interface ${name}Input {
|
|
1083
1085
|
payload?: string;
|
|
1084
1086
|
}
|
|
@@ -1090,7 +1092,7 @@ export interface ${name}Output {
|
|
|
1090
1092
|
`
|
|
1091
1093
|
);
|
|
1092
1094
|
fs6.writeFileSync(
|
|
1093
|
-
|
|
1095
|
+
path8.join(bFuncDir, "manifest.json"),
|
|
1094
1096
|
JSON.stringify(
|
|
1095
1097
|
{
|
|
1096
1098
|
name,
|
|
@@ -1103,7 +1105,7 @@ export interface ${name}Output {
|
|
|
1103
1105
|
)
|
|
1104
1106
|
);
|
|
1105
1107
|
fs6.writeFileSync(
|
|
1106
|
-
|
|
1108
|
+
path8.join(bFuncDir, "main_function", "logic.ts"),
|
|
1107
1109
|
`import type { ${name}Input, ${name}Output } from "../${name}Atom.js";
|
|
1108
1110
|
|
|
1109
1111
|
export const main = async (input: ${name}Input, context: any): Promise<${name}Output> => {
|
|
@@ -1115,13 +1117,13 @@ export const main = async (input: ${name}Input, context: any): Promise<${name}Ou
|
|
|
1115
1117
|
`
|
|
1116
1118
|
);
|
|
1117
1119
|
fs6.writeFileSync(
|
|
1118
|
-
|
|
1120
|
+
path8.join(bFuncDir, "main_function", "lifecycle.ts"),
|
|
1119
1121
|
`export async function onMount() {}
|
|
1120
1122
|
export async function onTeardown() {}
|
|
1121
1123
|
`
|
|
1122
1124
|
);
|
|
1123
1125
|
fs6.writeFileSync(
|
|
1124
|
-
|
|
1126
|
+
path8.join(bFuncDir, "helper_functions", "helper.ts"),
|
|
1125
1127
|
`/**
|
|
1126
1128
|
* @role component
|
|
1127
1129
|
*/
|
|
@@ -1131,7 +1133,7 @@ export function exampleHelper(): boolean {
|
|
|
1131
1133
|
`
|
|
1132
1134
|
);
|
|
1133
1135
|
fs6.writeFileSync(
|
|
1134
|
-
|
|
1136
|
+
path8.join(bFuncDir, "events", "events.ts"),
|
|
1135
1137
|
`/**
|
|
1136
1138
|
* @role component
|
|
1137
1139
|
*/
|
|
@@ -1141,7 +1143,7 @@ export interface ${name}CompletedEvent {
|
|
|
1141
1143
|
`
|
|
1142
1144
|
);
|
|
1143
1145
|
fs6.writeFileSync(
|
|
1144
|
-
|
|
1146
|
+
path8.join(bFuncDir, "tests", `${name}.test.ts`),
|
|
1145
1147
|
`import { describe, it, expect } from "vitest";
|
|
1146
1148
|
|
|
1147
1149
|
describe("${name} functionality", () => {
|
|
@@ -1151,10 +1153,10 @@ describe("${name} functionality", () => {
|
|
|
1151
1153
|
});
|
|
1152
1154
|
`
|
|
1153
1155
|
);
|
|
1154
|
-
const fFuncDir =
|
|
1155
|
-
fs6.mkdirSync(
|
|
1156
|
+
const fFuncDir = path8.join(frontend, "functionalities", name);
|
|
1157
|
+
fs6.mkdirSync(path8.join(fFuncDir, "tests"), { recursive: true });
|
|
1156
1158
|
fs6.writeFileSync(
|
|
1157
|
-
|
|
1159
|
+
path8.join(fFuncDir, `${name}0.tsx`),
|
|
1158
1160
|
`import React from "react";
|
|
1159
1161
|
|
|
1160
1162
|
export const ${name}0: React.FC = () => {
|
|
@@ -1169,11 +1171,11 @@ export default ${name}0;
|
|
|
1169
1171
|
`
|
|
1170
1172
|
);
|
|
1171
1173
|
fs6.writeFileSync(
|
|
1172
|
-
|
|
1174
|
+
path8.join(fFuncDir, "manifest.json"),
|
|
1173
1175
|
JSON.stringify({ name: `${name}UI`, dependencies: {} }, null, 2)
|
|
1174
1176
|
);
|
|
1175
1177
|
fs6.writeFileSync(
|
|
1176
|
-
|
|
1178
|
+
path8.join(fFuncDir, "tests", `${name}0.test.tsx`),
|
|
1177
1179
|
`import { describe, it, expect } from "vitest";
|
|
1178
1180
|
|
|
1179
1181
|
describe("${name}0 Component", () => {
|
|
@@ -1184,19 +1186,19 @@ describe("${name}0 Component", () => {
|
|
|
1184
1186
|
`
|
|
1185
1187
|
);
|
|
1186
1188
|
KrnlPackageReconciler.reconcile(projectRoot, true);
|
|
1187
|
-
console.log(`\u2705 Created Backend Functionality: ${
|
|
1188
|
-
console.log(`\u2705 Created Frontend Functionality: ${
|
|
1189
|
+
console.log(`\u2705 Created Backend Functionality: ${path8.relative(projectRoot, bFuncDir)}/`);
|
|
1190
|
+
console.log(`\u2705 Created Frontend Functionality: ${path8.relative(projectRoot, fFuncDir)}/`);
|
|
1189
1191
|
}
|
|
1190
1192
|
|
|
1191
1193
|
// src/commands/generators/libraryGenerator.ts
|
|
1192
1194
|
var fs7 = __toESM(require("fs"), 1);
|
|
1193
|
-
var
|
|
1195
|
+
var path9 = __toESM(require("path"), 1);
|
|
1194
1196
|
function generateLibrary(name, projectRoot, parentService) {
|
|
1195
1197
|
const { backend, frontend } = getPlaneRoots(projectRoot);
|
|
1196
1198
|
const conceptName = name.endsWith("Concepts") ? name : `${name}Concepts`;
|
|
1197
1199
|
let targetService = parentService;
|
|
1198
1200
|
if (!targetService) {
|
|
1199
|
-
const servicesDir =
|
|
1201
|
+
const servicesDir = path9.join(backend, "services");
|
|
1200
1202
|
if (fs7.existsSync(servicesDir)) {
|
|
1201
1203
|
const existing = fs7.readdirSync(servicesDir, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
1202
1204
|
if (existing.length === 1) {
|
|
@@ -1207,10 +1209,10 @@ function generateLibrary(name, projectRoot, parentService) {
|
|
|
1207
1209
|
if (!targetService) {
|
|
1208
1210
|
targetService = "App";
|
|
1209
1211
|
}
|
|
1210
|
-
const bLibDir =
|
|
1211
|
-
fs7.mkdirSync(
|
|
1212
|
+
const bLibDir = path9.join(backend, "services", targetService, "libraries", conceptName);
|
|
1213
|
+
fs7.mkdirSync(path9.join(bLibDir, "tests"), { recursive: true });
|
|
1212
1214
|
fs7.writeFileSync(
|
|
1213
|
-
|
|
1215
|
+
path9.join(bLibDir, "definitions.ts"),
|
|
1214
1216
|
`/**
|
|
1215
1217
|
* @file definitions.ts
|
|
1216
1218
|
* @role component
|
|
@@ -1221,7 +1223,7 @@ export interface ${conceptName}Options {
|
|
|
1221
1223
|
`
|
|
1222
1224
|
);
|
|
1223
1225
|
fs7.writeFileSync(
|
|
1224
|
-
|
|
1226
|
+
path9.join(bLibDir, "functions.ts"),
|
|
1225
1227
|
`/**
|
|
1226
1228
|
* @file functions.ts
|
|
1227
1229
|
* @role component
|
|
@@ -1234,17 +1236,17 @@ export function ${name.toLowerCase()}Transform<T>(data: T, _opts?: ${conceptName
|
|
|
1234
1236
|
`
|
|
1235
1237
|
);
|
|
1236
1238
|
fs7.writeFileSync(
|
|
1237
|
-
|
|
1239
|
+
path9.join(bLibDir, "index.ts"),
|
|
1238
1240
|
`export * from "./definitions.js";
|
|
1239
1241
|
export * from "./functions.js";
|
|
1240
1242
|
`
|
|
1241
1243
|
);
|
|
1242
1244
|
fs7.writeFileSync(
|
|
1243
|
-
|
|
1245
|
+
path9.join(bLibDir, "manifest.json"),
|
|
1244
1246
|
JSON.stringify({ name: conceptName, service: targetService, dependencies: {} }, null, 2)
|
|
1245
1247
|
);
|
|
1246
1248
|
fs7.writeFileSync(
|
|
1247
|
-
|
|
1249
|
+
path9.join(bLibDir, "tests", `${conceptName}.test.ts`),
|
|
1248
1250
|
`import { describe, it, expect } from "vitest";
|
|
1249
1251
|
import { ${name.toLowerCase()}Transform } from "../functions.js";
|
|
1250
1252
|
|
|
@@ -1255,17 +1257,17 @@ describe("${conceptName}", () => {
|
|
|
1255
1257
|
});
|
|
1256
1258
|
`
|
|
1257
1259
|
);
|
|
1258
|
-
const fLibDir =
|
|
1259
|
-
fs7.mkdirSync(
|
|
1260
|
+
const fLibDir = path9.join(frontend, "libraries", conceptName);
|
|
1261
|
+
fs7.mkdirSync(path9.join(fLibDir, "tests"), { recursive: true });
|
|
1260
1262
|
fs7.writeFileSync(
|
|
1261
|
-
|
|
1263
|
+
path9.join(fLibDir, "definitions.ts"),
|
|
1262
1264
|
`export interface ${name}Props {
|
|
1263
1265
|
label?: string;
|
|
1264
1266
|
}
|
|
1265
1267
|
`
|
|
1266
1268
|
);
|
|
1267
1269
|
fs7.writeFileSync(
|
|
1268
|
-
|
|
1270
|
+
path9.join(fLibDir, "components.tsx"),
|
|
1269
1271
|
`import React from "react";
|
|
1270
1272
|
import type { ${name}Props } from "./definitions.js";
|
|
1271
1273
|
import "./styles.css";
|
|
@@ -1276,18 +1278,18 @@ export const ${name}: React.FC<${name}Props> = ({ label = "${name}" }) => {
|
|
|
1276
1278
|
`
|
|
1277
1279
|
);
|
|
1278
1280
|
fs7.writeFileSync(
|
|
1279
|
-
|
|
1281
|
+
path9.join(fLibDir, "styles.css"),
|
|
1280
1282
|
`.krnl-${name.toLowerCase()} {
|
|
1281
1283
|
font-family: inherit;
|
|
1282
1284
|
}
|
|
1283
1285
|
`
|
|
1284
1286
|
);
|
|
1285
1287
|
fs7.writeFileSync(
|
|
1286
|
-
|
|
1288
|
+
path9.join(fLibDir, "manifest.json"),
|
|
1287
1289
|
JSON.stringify({ name: `${conceptName}UI`, dependencies: {} }, null, 2)
|
|
1288
1290
|
);
|
|
1289
1291
|
fs7.writeFileSync(
|
|
1290
|
-
|
|
1292
|
+
path9.join(fLibDir, "tests", `${name}.test.tsx`),
|
|
1291
1293
|
`import { describe, it, expect } from "vitest";
|
|
1292
1294
|
|
|
1293
1295
|
describe("${name} UI Concept", () => {
|
|
@@ -1298,13 +1300,13 @@ describe("${name} UI Concept", () => {
|
|
|
1298
1300
|
`
|
|
1299
1301
|
);
|
|
1300
1302
|
KrnlPackageReconciler.reconcile(projectRoot, true);
|
|
1301
|
-
console.log(`\u2705 Created Service-Owned Library: ${
|
|
1302
|
-
console.log(`\u2705 Created Frontend Concept Library: ${
|
|
1303
|
+
console.log(`\u2705 Created Service-Owned Library: ${path9.relative(projectRoot, bLibDir)}/ (Owner: ${targetService})`);
|
|
1304
|
+
console.log(`\u2705 Created Frontend Concept Library: ${path9.relative(projectRoot, fLibDir)}/`);
|
|
1303
1305
|
}
|
|
1304
1306
|
|
|
1305
1307
|
// src/commands/generators/serviceGenerator.ts
|
|
1306
1308
|
var fs8 = __toESM(require("fs"), 1);
|
|
1307
|
-
var
|
|
1309
|
+
var path10 = __toESM(require("path"), 1);
|
|
1308
1310
|
function generateService(name, projectRoot, defaultFrontend) {
|
|
1309
1311
|
const frontendReference = defaultFrontend?.component ? {
|
|
1310
1312
|
component: defaultFrontend.component,
|
|
@@ -1314,20 +1316,20 @@ function generateService(name, projectRoot, defaultFrontend) {
|
|
|
1314
1316
|
} : void 0;
|
|
1315
1317
|
const frontendConfig = frontendReference ? JSON.stringify(frontendReference, null, 2).replace(/\n/g, "\n ") : void 0;
|
|
1316
1318
|
const { backend } = getPlaneRoots(projectRoot);
|
|
1317
|
-
const serviceDir =
|
|
1318
|
-
const funcsDir =
|
|
1319
|
-
const orchsDir =
|
|
1320
|
-
const libsDir =
|
|
1321
|
-
const testsDir =
|
|
1319
|
+
const serviceDir = path10.join(backend, "services", name);
|
|
1320
|
+
const funcsDir = path10.join(serviceDir, "functionalities");
|
|
1321
|
+
const orchsDir = path10.join(serviceDir, "orchestrations");
|
|
1322
|
+
const libsDir = path10.join(serviceDir, "libraries");
|
|
1323
|
+
const testsDir = path10.join(serviceDir, "tests");
|
|
1322
1324
|
fs8.mkdirSync(funcsDir, { recursive: true });
|
|
1323
1325
|
fs8.mkdirSync(orchsDir, { recursive: true });
|
|
1324
1326
|
fs8.mkdirSync(libsDir, { recursive: true });
|
|
1325
1327
|
fs8.mkdirSync(testsDir, { recursive: true });
|
|
1326
1328
|
const conceptName = `${name}Concepts`;
|
|
1327
|
-
const defaultLibDir =
|
|
1328
|
-
fs8.mkdirSync(
|
|
1329
|
+
const defaultLibDir = path10.join(libsDir, conceptName);
|
|
1330
|
+
fs8.mkdirSync(path10.join(defaultLibDir, "tests"), { recursive: true });
|
|
1329
1331
|
fs8.writeFileSync(
|
|
1330
|
-
|
|
1332
|
+
path10.join(defaultLibDir, "definitions.ts"),
|
|
1331
1333
|
`/**
|
|
1332
1334
|
* @file definitions.ts
|
|
1333
1335
|
* @role component
|
|
@@ -1338,7 +1340,7 @@ export interface ${name}Options {
|
|
|
1338
1340
|
`
|
|
1339
1341
|
);
|
|
1340
1342
|
fs8.writeFileSync(
|
|
1341
|
-
|
|
1343
|
+
path10.join(defaultLibDir, "functions.ts"),
|
|
1342
1344
|
`/**
|
|
1343
1345
|
* @file functions.ts
|
|
1344
1346
|
* @role component
|
|
@@ -1351,17 +1353,17 @@ export function format${name}Name(input: string, _opts?: ${name}Options): string
|
|
|
1351
1353
|
`
|
|
1352
1354
|
);
|
|
1353
1355
|
fs8.writeFileSync(
|
|
1354
|
-
|
|
1356
|
+
path10.join(defaultLibDir, "index.ts"),
|
|
1355
1357
|
`export * from "./definitions.js";
|
|
1356
1358
|
export * from "./functions.js";
|
|
1357
1359
|
`
|
|
1358
1360
|
);
|
|
1359
1361
|
fs8.writeFileSync(
|
|
1360
|
-
|
|
1362
|
+
path10.join(defaultLibDir, "manifest.json"),
|
|
1361
1363
|
JSON.stringify({ name: conceptName, description: `${name} service-owned library`, dependencies: {} }, null, 2)
|
|
1362
1364
|
);
|
|
1363
1365
|
fs8.writeFileSync(
|
|
1364
|
-
|
|
1366
|
+
path10.join(defaultLibDir, "tests", `${conceptName}.test.ts`),
|
|
1365
1367
|
`import { describe, it, expect } from "vitest";
|
|
1366
1368
|
import { format${name}Name } from "../functions.js";
|
|
1367
1369
|
|
|
@@ -1375,7 +1377,7 @@ describe("${conceptName}", () => {
|
|
|
1375
1377
|
const frontendProperty = frontendConfig ? ` defaultFrontend: ${frontendConfig},
|
|
1376
1378
|
` : "";
|
|
1377
1379
|
fs8.writeFileSync(
|
|
1378
|
-
|
|
1380
|
+
path10.join(serviceDir, `${name}ServiceFacade.ts`),
|
|
1379
1381
|
`import { ServiceFacade } from "@ultrst-armada/krnl-core";
|
|
1380
1382
|
import * as ${name.toLowerCase()}Concepts from "./libraries/${conceptName}/index.js";
|
|
1381
1383
|
|
|
@@ -1393,7 +1395,7 @@ export default ${name}ServiceFacade;
|
|
|
1393
1395
|
`
|
|
1394
1396
|
);
|
|
1395
1397
|
fs8.writeFileSync(
|
|
1396
|
-
|
|
1398
|
+
path10.join(testsDir, `${name}ServiceFacade.test.ts`),
|
|
1397
1399
|
`import { describe, it, expect } from "vitest";
|
|
1398
1400
|
import { ${name}ServiceFacade } from "../${name}ServiceFacade.js";
|
|
1399
1401
|
|
|
@@ -1407,7 +1409,7 @@ describe("${name}ServiceFacade", () => {
|
|
|
1407
1409
|
`
|
|
1408
1410
|
);
|
|
1409
1411
|
KrnlPackageReconciler.reconcile(projectRoot, true);
|
|
1410
|
-
console.log(`\u2705 Created Service: ${
|
|
1412
|
+
console.log(`\u2705 Created Service: ${path10.relative(projectRoot, serviceDir)}/`);
|
|
1411
1413
|
}
|
|
1412
1414
|
|
|
1413
1415
|
// src/commands/generate.ts
|
|
@@ -1443,7 +1445,7 @@ async function runGenerate(type, name, parentService, projectRoot = process.cwd(
|
|
|
1443
1445
|
|
|
1444
1446
|
// src/commands/watch.ts
|
|
1445
1447
|
var fs9 = __toESM(require("fs"), 1);
|
|
1446
|
-
var
|
|
1448
|
+
var path11 = __toESM(require("path"), 1);
|
|
1447
1449
|
function generateMagneticDeclarations(projectRoot = process.cwd()) {
|
|
1448
1450
|
const { results: functionalities, libDirs } = scanDirectory(projectRoot);
|
|
1449
1451
|
let dtsContent = `// Automatically generated by Krnl Magnetic Watcher. Do not edit manually.
|
|
@@ -1454,14 +1456,14 @@ function generateMagneticDeclarations(projectRoot = process.cwd()) {
|
|
|
1454
1456
|
`;
|
|
1455
1457
|
const globalDeclarations = [];
|
|
1456
1458
|
for (const func of functionalities) {
|
|
1457
|
-
const helpersDir =
|
|
1459
|
+
const helpersDir = path11.join(func.funcPath, "helper_functions");
|
|
1458
1460
|
if (fs9.existsSync(helpersDir)) {
|
|
1459
1461
|
const files = fs9.readdirSync(helpersDir);
|
|
1460
1462
|
for (const file of files) {
|
|
1461
1463
|
if (file.endsWith(".js") || file.endsWith(".ts")) {
|
|
1462
|
-
const filePath =
|
|
1463
|
-
const baseName =
|
|
1464
|
-
const importPath = `./${
|
|
1464
|
+
const filePath = path11.join(helpersDir, file);
|
|
1465
|
+
const baseName = path11.basename(file, path11.extname(file));
|
|
1466
|
+
const importPath = `./${path11.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
|
|
1465
1467
|
const { named, hasDefault } = parseExports(filePath, baseName);
|
|
1466
1468
|
if (hasDefault) {
|
|
1467
1469
|
globalDeclarations.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
|
|
@@ -1472,14 +1474,14 @@ function generateMagneticDeclarations(projectRoot = process.cwd()) {
|
|
|
1472
1474
|
}
|
|
1473
1475
|
}
|
|
1474
1476
|
}
|
|
1475
|
-
const eventsDir =
|
|
1477
|
+
const eventsDir = path11.join(func.funcPath, "events");
|
|
1476
1478
|
if (fs9.existsSync(eventsDir)) {
|
|
1477
1479
|
const files = fs9.readdirSync(eventsDir);
|
|
1478
1480
|
for (const file of files) {
|
|
1479
1481
|
if (file.endsWith(".js") || file.endsWith(".ts")) {
|
|
1480
|
-
const filePath =
|
|
1481
|
-
const baseName =
|
|
1482
|
-
const importPath = `./${
|
|
1482
|
+
const filePath = path11.join(eventsDir, file);
|
|
1483
|
+
const baseName = path11.basename(file, path11.extname(file));
|
|
1484
|
+
const importPath = `./${path11.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
|
|
1483
1485
|
const { named, hasDefault } = parseExports(filePath, baseName);
|
|
1484
1486
|
if (hasDefault) {
|
|
1485
1487
|
globalDeclarations.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
|
|
@@ -1500,7 +1502,7 @@ ${Array.from(new Set(globalDeclarations)).join("\n")}
|
|
|
1500
1502
|
}
|
|
1501
1503
|
`;
|
|
1502
1504
|
}
|
|
1503
|
-
const outPath =
|
|
1505
|
+
const outPath = path11.join(projectRoot, "krnl-magnetic.d.ts");
|
|
1504
1506
|
fs9.writeFileSync(outPath, dtsContent);
|
|
1505
1507
|
console.log(`[Krnl Watch] Updated ambient declarations: ${outPath}`);
|
|
1506
1508
|
}
|
|
@@ -1508,12 +1510,12 @@ function scanLibFiles(dir, projectRoot, decls) {
|
|
|
1508
1510
|
if (!fs9.existsSync(dir)) return;
|
|
1509
1511
|
for (const entry of fs9.readdirSync(dir, { withFileTypes: true })) {
|
|
1510
1512
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
1511
|
-
const full =
|
|
1513
|
+
const full = path11.join(dir, entry.name);
|
|
1512
1514
|
if (entry.isDirectory()) {
|
|
1513
1515
|
scanLibFiles(full, projectRoot, decls);
|
|
1514
1516
|
} else if ((entry.name.endsWith(".ts") || entry.name.endsWith(".js")) && !entry.name.endsWith(".d.ts")) {
|
|
1515
|
-
const baseName =
|
|
1516
|
-
const importPath = `./${
|
|
1517
|
+
const baseName = path11.basename(entry.name, path11.extname(entry.name));
|
|
1518
|
+
const importPath = `./${path11.relative(projectRoot, full).replace(/\\/g, "/")}`;
|
|
1517
1519
|
const { named, hasDefault } = parseExports(full, baseName);
|
|
1518
1520
|
if (hasDefault) decls.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
|
|
1519
1521
|
for (const n of named) decls.push(` const ${n}: typeof import('${importPath}')['${n}'];`);
|
|
@@ -1526,11 +1528,11 @@ function scanDirectory(dir, results = [], libDirs = []) {
|
|
|
1526
1528
|
for (const entry of list) {
|
|
1527
1529
|
if (entry.isDirectory()) {
|
|
1528
1530
|
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
|
|
1529
|
-
const fullPath =
|
|
1531
|
+
const fullPath = path11.join(dir, entry.name);
|
|
1530
1532
|
if (entry.name === "functionalities") {
|
|
1531
1533
|
const funcs = fs9.readdirSync(fullPath, { withFileTypes: true });
|
|
1532
1534
|
for (const f of funcs) {
|
|
1533
|
-
if (f.isDirectory()) results.push({ funcPath:
|
|
1535
|
+
if (f.isDirectory()) results.push({ funcPath: path11.join(fullPath, f.name), funcName: f.name });
|
|
1534
1536
|
}
|
|
1535
1537
|
} else if (entry.name === "libraries" || entry.name === "library") {
|
|
1536
1538
|
libDirs.push(fullPath);
|
|
@@ -1557,7 +1559,7 @@ function parseExports(filePath, defaultName) {
|
|
|
1557
1559
|
}
|
|
1558
1560
|
|
|
1559
1561
|
// src/commands/build.ts
|
|
1560
|
-
var
|
|
1562
|
+
var path12 = __toESM(require("path"), 1);
|
|
1561
1563
|
var fs10 = __toESM(require("fs"), 1);
|
|
1562
1564
|
var import_child_process = require("child_process");
|
|
1563
1565
|
async function runBuild(projectRoot = process.cwd(), options = {}) {
|
|
@@ -1575,10 +1577,10 @@ async function runBuild(projectRoot = process.cwd(), options = {}) {
|
|
|
1575
1577
|
return { success: false, error: "Validation failed" };
|
|
1576
1578
|
}
|
|
1577
1579
|
generateMagneticDeclarations(projectRoot);
|
|
1578
|
-
const tsConfigPath =
|
|
1580
|
+
const tsConfigPath = path12.join(projectRoot, "tsconfig.json");
|
|
1579
1581
|
if (fs10.existsSync(tsConfigPath)) {
|
|
1580
1582
|
console.log("\u{1F3D7}\uFE0F [Krnl Build] Compiling TypeScript source files to dist/...");
|
|
1581
|
-
const localTsc =
|
|
1583
|
+
const localTsc = path12.join(projectRoot, "node_modules", ".bin", "tsc");
|
|
1582
1584
|
const tscCmd = fs10.existsSync(localTsc) ? localTsc : "tsc";
|
|
1583
1585
|
try {
|
|
1584
1586
|
(0, import_child_process.execSync)(`${tscCmd} -p tsconfig.json`, { cwd: projectRoot, stdio: "inherit" });
|
|
@@ -1595,7 +1597,7 @@ async function runBuild(projectRoot = process.cwd(), options = {}) {
|
|
|
1595
1597
|
|
|
1596
1598
|
// src/commands/dev.ts
|
|
1597
1599
|
var http = __toESM(require("http"), 1);
|
|
1598
|
-
var
|
|
1600
|
+
var path13 = __toESM(require("path"), 1);
|
|
1599
1601
|
var fs11 = __toESM(require("fs"), 1);
|
|
1600
1602
|
async function runDev(projectRoot = process.cwd(), options = {}) {
|
|
1601
1603
|
const port = options.port ?? 8080;
|
|
@@ -1618,7 +1620,7 @@ async function runDev(projectRoot = process.cwd(), options = {}) {
|
|
|
1618
1620
|
return;
|
|
1619
1621
|
}
|
|
1620
1622
|
if (url.pathname === "/manifest") {
|
|
1621
|
-
const pkgPath =
|
|
1623
|
+
const pkgPath = path13.join(projectRoot, "package.json");
|
|
1622
1624
|
const pkg = fs11.existsSync(pkgPath) ? JSON.parse(fs11.readFileSync(pkgPath, "utf8")) : {};
|
|
1623
1625
|
res.writeHead(200);
|
|
1624
1626
|
res.end(JSON.stringify({ name: pkg.name || "krnl-app", version: pkg.version || "1.0.0" }));
|
|
@@ -1666,7 +1668,7 @@ function optionValue(name) {
|
|
|
1666
1668
|
async function main() {
|
|
1667
1669
|
switch (command) {
|
|
1668
1670
|
case "sync": {
|
|
1669
|
-
const targetDir = args[1] && !args[1].startsWith("-") ?
|
|
1671
|
+
const targetDir = args[1] && !args[1].startsWith("-") ? path14.resolve(process.cwd(), args[1]) : process.cwd();
|
|
1670
1672
|
console.log("\u{1F4E6} [Krnl Sync] Reconciling package.json from all manifest.json files...");
|
|
1671
1673
|
const res = KrnlPackageReconciler.reconcile(targetDir, true);
|
|
1672
1674
|
console.log(`\u2705 Reconciled dependencies from ${res.totalManifests} manifest.json file(s).`);
|
|
@@ -1676,7 +1678,7 @@ async function main() {
|
|
|
1676
1678
|
break;
|
|
1677
1679
|
}
|
|
1678
1680
|
case "validate": {
|
|
1679
|
-
const targetDir = args[1] && !args[1].startsWith("-") ?
|
|
1681
|
+
const targetDir = args[1] && !args[1].startsWith("-") ? path14.resolve(process.cwd(), args[1]) : process.cwd();
|
|
1680
1682
|
const valid = await runValidate(targetDir);
|
|
1681
1683
|
process.exit(valid ? 0 : 1);
|
|
1682
1684
|
break;
|
|
@@ -1718,7 +1720,7 @@ async function main() {
|
|
|
1718
1720
|
break;
|
|
1719
1721
|
}
|
|
1720
1722
|
case "build": {
|
|
1721
|
-
const targetDir = args[1] && !args[1].startsWith("-") ?
|
|
1723
|
+
const targetDir = args[1] && !args[1].startsWith("-") ? path14.resolve(process.cwd(), args[1]) : process.cwd();
|
|
1722
1724
|
const serviceArgIdx = args.indexOf("--service") !== -1 ? args.indexOf("--service") : args.indexOf("--orchestration");
|
|
1723
1725
|
const targetService = serviceArgIdx !== -1 ? args[serviceArgIdx + 1] : void 0;
|
|
1724
1726
|
const isAll = args.includes("--all");
|
|
@@ -1727,7 +1729,7 @@ async function main() {
|
|
|
1727
1729
|
break;
|
|
1728
1730
|
}
|
|
1729
1731
|
case "dev": {
|
|
1730
|
-
const targetDir = args[1] && !args[1].startsWith("-") ?
|
|
1732
|
+
const targetDir = args[1] && !args[1].startsWith("-") ? path14.resolve(process.cwd(), args[1]) : process.cwd();
|
|
1731
1733
|
const portArgIdx = args.indexOf("--port");
|
|
1732
1734
|
const port = portArgIdx !== -1 ? parseInt(args[portArgIdx + 1], 10) : 8080;
|
|
1733
1735
|
const serviceArgIdx = args.indexOf("--service") !== -1 ? args.indexOf("--service") : args.indexOf("--orchestration");
|