@cubocicloide/stack-react-django 3.0.4 → 3.1.0
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/dist/index.js +174 -252
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/templates/base/AGENTS.md +42 -0
- package/templates/base/CLAUDE.md.hbs +25 -0
- package/templates/base/docs/docs/cheatsheet.md +28 -0
- package/templates/base/docs/docs/dude.md.hbs +1 -0
- package/templates/base/docs/mkdocs.yml.hbs +1 -0
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import
|
|
2
|
+
import { existsSync as existsSync10, readFileSync as readFileSync10 } from "fs";
|
|
3
|
+
import path15 from "pathe";
|
|
4
4
|
import yaml2 from "yaml";
|
|
5
|
-
import { defineStack, renderTemplateTree } from "@cubocicloide/dude";
|
|
5
|
+
import { defineStack, renderTemplateTree, defineCheatsheetCommand, defineDocsCommand } from "@cubocicloide/dude";
|
|
6
6
|
|
|
7
7
|
// src/commands/api/index.ts
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
|
|
@@ -458,111 +458,14 @@ var superuserCommand = {
|
|
|
458
458
|
}
|
|
459
459
|
};
|
|
460
460
|
|
|
461
|
-
// src/commands/docs/index.ts
|
|
462
|
-
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
463
|
-
import { existsSync as existsSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
464
|
-
import path3 from "pathe";
|
|
465
|
-
async function regenerateApiDoc(projectRoot, docsDir) {
|
|
466
|
-
try {
|
|
467
|
-
const dude = await import("@cubocicloide/dude");
|
|
468
|
-
if (typeof dude.generateApiDoc !== "function") return;
|
|
469
|
-
const md = await dude.generateApiDoc(projectRoot, "md");
|
|
470
|
-
writeFileSync2(path3.join(docsDir, "docs", "api.md"), md);
|
|
471
|
-
process.stdout.write("[docs] Regenerated docs/api.md from the live command catalog.\n");
|
|
472
|
-
} catch (e) {
|
|
473
|
-
process.stderr.write(
|
|
474
|
-
`[docs] Could not regenerate api.md (${e.message}); using the existing file.
|
|
475
|
-
`
|
|
476
|
-
);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
function isDockerRunning() {
|
|
480
|
-
const r = spawnSync2("docker", ["info"], { stdio: "ignore" });
|
|
481
|
-
return r.error == null && r.status === 0;
|
|
482
|
-
}
|
|
483
|
-
function openBrowser(url) {
|
|
484
|
-
if (process.platform === "win32") {
|
|
485
|
-
spawnSync2("cmd", ["/c", "start", "", url], { stdio: "ignore" });
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
const opener = process.platform === "darwin" ? "open" : "xdg-open";
|
|
489
|
-
spawnSync2(opener, [url], { stdio: "ignore" });
|
|
490
|
-
}
|
|
491
|
-
var docsCommand = {
|
|
492
|
-
description: "Serve the project documentation in dev mode (live-reload) at http://localhost:8001.",
|
|
493
|
-
args: {
|
|
494
|
-
port: {
|
|
495
|
-
type: "string",
|
|
496
|
-
description: "Host port to expose the docs site on (default: 8001).",
|
|
497
|
-
default: "8001"
|
|
498
|
-
}
|
|
499
|
-
},
|
|
500
|
-
async run({ projectRoot, args }) {
|
|
501
|
-
const docsDir = path3.join(projectRoot, "docs");
|
|
502
|
-
const port = String(args.port ?? "8001");
|
|
503
|
-
const url = `http://localhost:${port}`;
|
|
504
|
-
if (!existsSync3(docsDir)) {
|
|
505
|
-
process.stderr.write(
|
|
506
|
-
"[docs] No docs/ folder found in the project root. Make sure you ran `dude init`.\n"
|
|
507
|
-
);
|
|
508
|
-
process.exit(1);
|
|
509
|
-
}
|
|
510
|
-
await regenerateApiDoc(projectRoot, docsDir);
|
|
511
|
-
if (!isDockerRunning()) {
|
|
512
|
-
process.stderr.write("[docs] Docker is not running. Start Docker Desktop and retry.\n");
|
|
513
|
-
process.exit(1);
|
|
514
|
-
}
|
|
515
|
-
process.stdout.write(`[docs] Starting MkDocs at ${url} (Ctrl+C to stop)
|
|
516
|
-
`);
|
|
517
|
-
const child = spawn(
|
|
518
|
-
"docker",
|
|
519
|
-
[
|
|
520
|
-
"run",
|
|
521
|
-
"--rm",
|
|
522
|
-
"-i",
|
|
523
|
-
"-p",
|
|
524
|
-
`${port}:8000`,
|
|
525
|
-
"-v",
|
|
526
|
-
`${docsDir}:/docs`,
|
|
527
|
-
"squidfunk/mkdocs-material",
|
|
528
|
-
"serve",
|
|
529
|
-
"--dev-addr=0.0.0.0:8000"
|
|
530
|
-
],
|
|
531
|
-
{ stdio: ["inherit", "pipe", "pipe"] }
|
|
532
|
-
);
|
|
533
|
-
if (child.pid == null) {
|
|
534
|
-
process.stderr.write("[docs] Failed to start Docker container.\n");
|
|
535
|
-
process.exit(1);
|
|
536
|
-
}
|
|
537
|
-
let browserOpened = false;
|
|
538
|
-
function watchChunk(chunk) {
|
|
539
|
-
if (!browserOpened && chunk.toString().includes("Serving on")) {
|
|
540
|
-
browserOpened = true;
|
|
541
|
-
process.stdout.write(`[docs] Opening ${url}
|
|
542
|
-
`);
|
|
543
|
-
openBrowser(url);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
child.stdout?.on("data", (chunk) => {
|
|
547
|
-
process.stdout.write(chunk);
|
|
548
|
-
watchChunk(chunk);
|
|
549
|
-
});
|
|
550
|
-
child.stderr?.on("data", (chunk) => {
|
|
551
|
-
process.stderr.write(chunk);
|
|
552
|
-
watchChunk(chunk);
|
|
553
|
-
});
|
|
554
|
-
await new Promise((resolve) => child.on("close", resolve));
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
|
|
558
461
|
// src/commands/iac/providers/aws-ecs/lib/terraform.ts
|
|
559
|
-
import { existsSync as
|
|
560
|
-
import
|
|
462
|
+
import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync4 } from "fs";
|
|
463
|
+
import path5 from "pathe";
|
|
561
464
|
|
|
562
465
|
// src/commands/iac/shared.ts
|
|
563
|
-
import { spawnSync as
|
|
466
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
564
467
|
import { readFileSync as readFileSync2 } from "fs";
|
|
565
|
-
import
|
|
468
|
+
import path3 from "pathe";
|
|
566
469
|
function shouldUseShell() {
|
|
567
470
|
return process.platform === "win32";
|
|
568
471
|
}
|
|
@@ -570,7 +473,7 @@ function childEnv(profile) {
|
|
|
570
473
|
return profile ? { ...process.env, AWS_PROFILE: profile } : process.env;
|
|
571
474
|
}
|
|
572
475
|
function run(cmd, args, cwd, profile) {
|
|
573
|
-
const r =
|
|
476
|
+
const r = spawnSync2(cmd, args, {
|
|
574
477
|
cwd,
|
|
575
478
|
stdio: "inherit",
|
|
576
479
|
env: childEnv(profile),
|
|
@@ -594,7 +497,7 @@ function run(cmd, args, cwd, profile) {
|
|
|
594
497
|
return r.status ?? 1;
|
|
595
498
|
}
|
|
596
499
|
function capture(cmd, args, cwd, profile) {
|
|
597
|
-
const r =
|
|
500
|
+
const r = spawnSync2(cmd, args, {
|
|
598
501
|
cwd,
|
|
599
502
|
encoding: "utf8",
|
|
600
503
|
env: childEnv(profile),
|
|
@@ -604,7 +507,7 @@ function capture(cmd, args, cwd, profile) {
|
|
|
604
507
|
}
|
|
605
508
|
function readAnswers(projectRoot) {
|
|
606
509
|
try {
|
|
607
|
-
const j = JSON.parse(readFileSync2(
|
|
510
|
+
const j = JSON.parse(readFileSync2(path3.join(projectRoot, "dude.json"), "utf8"));
|
|
608
511
|
return j.answers ?? {};
|
|
609
512
|
} catch {
|
|
610
513
|
return {};
|
|
@@ -623,22 +526,22 @@ function sleepMs(ms) {
|
|
|
623
526
|
}
|
|
624
527
|
|
|
625
528
|
// src/commands/iac/providers/aws-ecs/lib/exec.ts
|
|
626
|
-
import { spawnSync as
|
|
529
|
+
import { spawnSync as spawnSync4 } from "child_process";
|
|
627
530
|
|
|
628
531
|
// src/commands/iac/providers/aws-ecs/lib/runner.ts
|
|
629
|
-
import { spawnSync as
|
|
532
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
630
533
|
import { createHash } from "crypto";
|
|
631
|
-
import { existsSync as
|
|
534
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
632
535
|
import os from "os";
|
|
633
|
-
import
|
|
634
|
-
var RUNNER_DOCKERFILE =
|
|
536
|
+
import path4 from "pathe";
|
|
537
|
+
var RUNNER_DOCKERFILE = path4.join("iac", "runner", "Dockerfile");
|
|
635
538
|
var CONTAINERIZED = /* @__PURE__ */ new Set(["terraform"]);
|
|
636
539
|
function findDockerfile(cwd) {
|
|
637
|
-
let dir =
|
|
540
|
+
let dir = path4.resolve(cwd);
|
|
638
541
|
for (; ; ) {
|
|
639
|
-
const candidate =
|
|
640
|
-
if (
|
|
641
|
-
const parent =
|
|
542
|
+
const candidate = path4.join(dir, RUNNER_DOCKERFILE);
|
|
543
|
+
if (existsSync3(candidate)) return candidate;
|
|
544
|
+
const parent = path4.dirname(dir);
|
|
642
545
|
if (parent === dir) return "";
|
|
643
546
|
dir = parent;
|
|
644
547
|
}
|
|
@@ -651,7 +554,7 @@ var dockerChecked;
|
|
|
651
554
|
var ensured = /* @__PURE__ */ new Set();
|
|
652
555
|
function dockerAvailable() {
|
|
653
556
|
if (dockerChecked !== void 0) return dockerChecked;
|
|
654
|
-
const r =
|
|
557
|
+
const r = spawnSync3("docker", ["version", "--format", "{{.Server.Version}}"], {
|
|
655
558
|
encoding: "utf8"
|
|
656
559
|
});
|
|
657
560
|
dockerChecked = r.status === 0 && !!r.stdout.trim();
|
|
@@ -663,7 +566,7 @@ function useRunner(cwd) {
|
|
|
663
566
|
}
|
|
664
567
|
function ensureImage(dockerfile, tag) {
|
|
665
568
|
if (ensured.has(tag)) return;
|
|
666
|
-
const exists =
|
|
569
|
+
const exists = spawnSync3("docker", ["image", "inspect", tag], { stdio: "ignore" }).status === 0;
|
|
667
570
|
if (!exists) {
|
|
668
571
|
process.stderr.write(
|
|
669
572
|
`
|
|
@@ -671,9 +574,9 @@ function ensureImage(dockerfile, tag) {
|
|
|
671
574
|
|
|
672
575
|
`
|
|
673
576
|
);
|
|
674
|
-
const build =
|
|
577
|
+
const build = spawnSync3(
|
|
675
578
|
"docker",
|
|
676
|
-
["build", "-t", tag, "-f", dockerfile,
|
|
579
|
+
["build", "-t", tag, "-f", dockerfile, path4.dirname(dockerfile)],
|
|
677
580
|
{ stdio: "inherit" }
|
|
678
581
|
);
|
|
679
582
|
if (build.status !== 0) {
|
|
@@ -687,7 +590,7 @@ function baseDockerArgs(cwd, profile, tty) {
|
|
|
687
590
|
const args = ["run", "--rm", tty ? "-it" : "-i"];
|
|
688
591
|
args.push("-v", `${cwd}:/work`, "-w", "/work");
|
|
689
592
|
const home = os.homedir();
|
|
690
|
-
args.push("-v", `${
|
|
593
|
+
args.push("-v", `${path4.join(home, ".aws")}:/root/.aws:ro`);
|
|
691
594
|
if (profile) args.push("-e", `AWS_PROFILE=${profile}`);
|
|
692
595
|
return args;
|
|
693
596
|
}
|
|
@@ -716,7 +619,7 @@ function routed(cmd, cwd) {
|
|
|
716
619
|
function run2(cmd, args, cwd, profile) {
|
|
717
620
|
if (!routed(cmd, cwd)) return run(cmd, args, cwd, profile);
|
|
718
621
|
const dargs = dockerRunArgs(cmd, args, cwd, profile, { tty: !!process.stdin.isTTY });
|
|
719
|
-
const r =
|
|
622
|
+
const r = spawnSync4("docker", dargs, { stdio: "inherit" });
|
|
720
623
|
if (r.error) {
|
|
721
624
|
process.stderr.write(`
|
|
722
625
|
\u2717 failed to run docker: ${r.error.message}
|
|
@@ -729,16 +632,16 @@ function run2(cmd, args, cwd, profile) {
|
|
|
729
632
|
function capture2(cmd, args, cwd, profile) {
|
|
730
633
|
if (!routed(cmd, cwd)) return capture(cmd, args, cwd, profile);
|
|
731
634
|
const dargs = dockerRunArgs(cmd, args, cwd, profile, { tty: false });
|
|
732
|
-
const r =
|
|
635
|
+
const r = spawnSync4("docker", dargs, { encoding: "utf8" });
|
|
733
636
|
return { status: r.status ?? 1, stdout: r.stdout ?? "" };
|
|
734
637
|
}
|
|
735
638
|
|
|
736
639
|
// src/commands/iac/providers/aws-ecs/lib/terraform.ts
|
|
737
|
-
var TF_DIR =
|
|
738
|
-
var TF_BOOTSTRAP_DIR =
|
|
739
|
-
var TF_ENVIRONMENTS_DIR =
|
|
640
|
+
var TF_DIR = path5.join("iac", "terraform");
|
|
641
|
+
var TF_BOOTSTRAP_DIR = path5.join(TF_DIR, "bootstrap");
|
|
642
|
+
var TF_ENVIRONMENTS_DIR = path5.join(TF_DIR, "environments");
|
|
740
643
|
function hasIac(projectRoot) {
|
|
741
|
-
return
|
|
644
|
+
return existsSync4(path5.join(projectRoot, "iac", "terraform"));
|
|
742
645
|
}
|
|
743
646
|
function requireIac(projectRoot) {
|
|
744
647
|
if (!hasIac(projectRoot)) {
|
|
@@ -764,10 +667,10 @@ function varFile(env) {
|
|
|
764
667
|
return `-var-file=environments/${env}/terraform.tfvars`;
|
|
765
668
|
}
|
|
766
669
|
function tfBoot(projectRoot, args, profile) {
|
|
767
|
-
return run2("terraform", args,
|
|
670
|
+
return run2("terraform", args, path5.join(projectRoot, TF_BOOTSTRAP_DIR), profile);
|
|
768
671
|
}
|
|
769
672
|
function captureBootstrap(projectRoot, args, profile) {
|
|
770
|
-
return capture2("terraform", args,
|
|
673
|
+
return capture2("terraform", args, path5.join(projectRoot, TF_BOOTSTRAP_DIR), profile);
|
|
771
674
|
}
|
|
772
675
|
function resolveProfile(projectRoot, args, env) {
|
|
773
676
|
if (args.profile) return String(args.profile);
|
|
@@ -777,7 +680,7 @@ function resolveProfile(projectRoot, args, env) {
|
|
|
777
680
|
function tfvarsValue(projectRoot, env, key) {
|
|
778
681
|
try {
|
|
779
682
|
return hclScalar(
|
|
780
|
-
readFileSync4(
|
|
683
|
+
readFileSync4(path5.join(projectRoot, TF_DIR, "environments", env, "terraform.tfvars"), "utf8"),
|
|
781
684
|
key
|
|
782
685
|
);
|
|
783
686
|
} catch {
|
|
@@ -787,7 +690,7 @@ function tfvarsValue(projectRoot, env, key) {
|
|
|
787
690
|
function readBackend(projectRoot, env) {
|
|
788
691
|
try {
|
|
789
692
|
const txt = readFileSync4(
|
|
790
|
-
|
|
693
|
+
path5.join(projectRoot, TF_DIR, "environments", env, "backend.hcl"),
|
|
791
694
|
"utf8"
|
|
792
695
|
);
|
|
793
696
|
return {
|
|
@@ -811,10 +714,10 @@ var envArg = {
|
|
|
811
714
|
}
|
|
812
715
|
};
|
|
813
716
|
function listEnvironments(projectRoot) {
|
|
814
|
-
const base =
|
|
717
|
+
const base = path5.join(projectRoot, TF_ENVIRONMENTS_DIR);
|
|
815
718
|
try {
|
|
816
719
|
return readdirSync2(base, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).filter(
|
|
817
|
-
(name) =>
|
|
720
|
+
(name) => existsSync4(path5.join(base, name, "backend.hcl")) && existsSync4(path5.join(base, name, "terraform.tfvars"))
|
|
818
721
|
).sort();
|
|
819
722
|
} catch {
|
|
820
723
|
return [];
|
|
@@ -875,8 +778,8 @@ var iacApplyCommand = {
|
|
|
875
778
|
};
|
|
876
779
|
|
|
877
780
|
// src/commands/iac/providers/aws-ecs/commands/bootstrap/index.ts
|
|
878
|
-
import { readFileSync as readFileSync5, writeFileSync as
|
|
879
|
-
import
|
|
781
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
|
|
782
|
+
import path6 from "pathe";
|
|
880
783
|
var iacBootstrapCommand = {
|
|
881
784
|
available: hasIac,
|
|
882
785
|
description: "One-time: create the S3 state bucket + DynamoDB lock table + shared ECR repository, then write the values into backend.hcl.",
|
|
@@ -959,12 +862,12 @@ var iacBootstrapCommand = {
|
|
|
959
862
|
process.stderr.write("\n \u2717 Bootstrap outputs `state_bucket` / `lock_table` not found.\n\n");
|
|
960
863
|
process.exit(1);
|
|
961
864
|
}
|
|
962
|
-
const backendHclPath =
|
|
865
|
+
const backendHclPath = path6.join(projectRoot, TF_DIR, "environments", env, "backend.hcl");
|
|
963
866
|
try {
|
|
964
867
|
let hcl = readFileSync5(backendHclPath, "utf8");
|
|
965
868
|
hcl = hcl.replace(/^bucket\s*=\s*".*"$/m, `bucket = "${stateBucket}"`);
|
|
966
869
|
hcl = hcl.replace(/^dynamodb_table\s*=\s*".*"$/m, `dynamodb_table = "${lockTable}"`);
|
|
967
|
-
|
|
870
|
+
writeFileSync2(backendHclPath, hcl);
|
|
968
871
|
} catch {
|
|
969
872
|
process.stderr.write(`
|
|
970
873
|
\u2717 Could not update ${backendHclPath}.
|
|
@@ -987,9 +890,9 @@ var iacBootstrapCommand = {
|
|
|
987
890
|
};
|
|
988
891
|
|
|
989
892
|
// src/commands/iac/providers/aws-ecs/lib/images.ts
|
|
990
|
-
import { spawnSync as
|
|
991
|
-
import { readFileSync as readFileSync6, writeFileSync as
|
|
992
|
-
import
|
|
893
|
+
import { spawnSync as spawnSync5 } from "child_process";
|
|
894
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
|
|
895
|
+
import path7 from "pathe";
|
|
993
896
|
var tagArg = {
|
|
994
897
|
tag: {
|
|
995
898
|
type: "string",
|
|
@@ -1080,7 +983,7 @@ function dockerLogin(host, region, projectRoot, profile) {
|
|
|
1080
983
|
process.stderr.write("\n \u2717 Could not obtain an ECR login password (check your AWS auth).\n\n");
|
|
1081
984
|
return 1;
|
|
1082
985
|
}
|
|
1083
|
-
const r =
|
|
986
|
+
const r = spawnSync5("docker", ["login", "--username", "AWS", "--password-stdin", host], {
|
|
1084
987
|
cwd: projectRoot,
|
|
1085
988
|
input: pw.stdout.trim(),
|
|
1086
989
|
stdio: ["pipe", "inherit", "inherit"],
|
|
@@ -1135,7 +1038,7 @@ function doPush(projectRoot, profile, tag, target) {
|
|
|
1135
1038
|
return 0;
|
|
1136
1039
|
}
|
|
1137
1040
|
function doDeploy(projectRoot, profile, env, tag, target) {
|
|
1138
|
-
const tfvarsPath =
|
|
1041
|
+
const tfvarsPath = path7.join(projectRoot, TF_DIR, "environments", env, "terraform.tfvars");
|
|
1139
1042
|
try {
|
|
1140
1043
|
let tfvars = readFileSync6(tfvarsPath, "utf8");
|
|
1141
1044
|
if (/^\s*image_tag\s*=/m.test(tfvars)) {
|
|
@@ -1145,7 +1048,7 @@ function doDeploy(projectRoot, profile, env, tag, target) {
|
|
|
1145
1048
|
image_tag = "${tag}"
|
|
1146
1049
|
`;
|
|
1147
1050
|
}
|
|
1148
|
-
|
|
1051
|
+
writeFileSync3(tfvarsPath, tfvars);
|
|
1149
1052
|
} catch {
|
|
1150
1053
|
process.stderr.write(`
|
|
1151
1054
|
\u2717 Could not update ${tfvarsPath}.
|
|
@@ -1634,8 +1537,8 @@ var iacMigrateCommand = {
|
|
|
1634
1537
|
};
|
|
1635
1538
|
|
|
1636
1539
|
// src/commands/iac/providers/aws-ecs/commands/new-env/index.ts
|
|
1637
|
-
import { cpSync, readFileSync as readFileSync7, writeFileSync as
|
|
1638
|
-
import
|
|
1540
|
+
import { cpSync, readFileSync as readFileSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
1541
|
+
import path8 from "pathe";
|
|
1639
1542
|
var iacNewEnvCommand = {
|
|
1640
1543
|
available: hasIac,
|
|
1641
1544
|
description: "Scaffold a new environment (iac/terraform/environments/<name>) by copying an existing one.",
|
|
@@ -1686,16 +1589,16 @@ var iacNewEnvCommand = {
|
|
|
1686
1589
|
`);
|
|
1687
1590
|
process.exit(1);
|
|
1688
1591
|
}
|
|
1689
|
-
const base =
|
|
1690
|
-
const dst =
|
|
1691
|
-
cpSync(
|
|
1692
|
-
const tfvarsPath =
|
|
1693
|
-
|
|
1592
|
+
const base = path8.join(projectRoot, TF_ENVIRONMENTS_DIR);
|
|
1593
|
+
const dst = path8.join(base, name);
|
|
1594
|
+
cpSync(path8.join(base, from), dst, { recursive: true });
|
|
1595
|
+
const tfvarsPath = path8.join(dst, "terraform.tfvars");
|
|
1596
|
+
writeFileSync4(
|
|
1694
1597
|
tfvarsPath,
|
|
1695
1598
|
readFileSync7(tfvarsPath, "utf8").replace(/^(\s*environment\s*=\s*).*$/m, `$1"${name}"`)
|
|
1696
1599
|
);
|
|
1697
|
-
const backendPath =
|
|
1698
|
-
|
|
1600
|
+
const backendPath = path8.join(dst, "backend.hcl");
|
|
1601
|
+
writeFileSync4(
|
|
1699
1602
|
backendPath,
|
|
1700
1603
|
readFileSync7(backendPath, "utf8").replace(
|
|
1701
1604
|
/^(\s*key\s*=\s*).*$/m,
|
|
@@ -1766,7 +1669,7 @@ var iacPushCommand = {
|
|
|
1766
1669
|
};
|
|
1767
1670
|
|
|
1768
1671
|
// src/commands/iac/providers/aws-ecs/commands/shell/index.ts
|
|
1769
|
-
import { spawnSync as
|
|
1672
|
+
import { spawnSync as spawnSync6 } from "child_process";
|
|
1770
1673
|
var iacShellCommand = {
|
|
1771
1674
|
available: hasIac,
|
|
1772
1675
|
description: "Open an interactive shell in the IaC runner container (terraform, aws) scoped to an environment.",
|
|
@@ -1798,7 +1701,7 @@ var iacShellCommand = {
|
|
|
1798
1701
|
|
|
1799
1702
|
`
|
|
1800
1703
|
);
|
|
1801
|
-
const r =
|
|
1704
|
+
const r = spawnSync6("docker", dockerShellArgs(projectRoot, profile), {
|
|
1802
1705
|
stdio: "inherit",
|
|
1803
1706
|
cwd: projectRoot
|
|
1804
1707
|
});
|
|
@@ -1980,9 +1883,9 @@ var provider = activeIacProvider() ?? iacProviders[0];
|
|
|
1980
1883
|
var iacCommands = provider?.commands ?? {};
|
|
1981
1884
|
|
|
1982
1885
|
// src/commands/_docker.ts
|
|
1983
|
-
import { spawnSync as
|
|
1886
|
+
import { spawnSync as spawnSync7 } from "child_process";
|
|
1984
1887
|
function dc(args) {
|
|
1985
|
-
const result =
|
|
1888
|
+
const result = spawnSync7("docker", ["compose", ...args], { stdio: "inherit" });
|
|
1986
1889
|
process.exit(result.status ?? 0);
|
|
1987
1890
|
}
|
|
1988
1891
|
|
|
@@ -1996,18 +1899,18 @@ var downCommand = {
|
|
|
1996
1899
|
};
|
|
1997
1900
|
|
|
1998
1901
|
// src/commands/format/index.ts
|
|
1999
|
-
import { spawnSync as
|
|
2000
|
-
import { existsSync as
|
|
2001
|
-
import
|
|
1902
|
+
import { spawnSync as spawnSync8 } from "child_process";
|
|
1903
|
+
import { existsSync as existsSync5 } from "fs";
|
|
1904
|
+
import path9 from "pathe";
|
|
2002
1905
|
function shouldUseShell2() {
|
|
2003
1906
|
return process.platform === "win32";
|
|
2004
1907
|
}
|
|
2005
1908
|
function isAvailable(cmd) {
|
|
2006
|
-
const r =
|
|
1909
|
+
const r = spawnSync8(cmd, ["--version"], { stdio: "ignore", shell: shouldUseShell2() });
|
|
2007
1910
|
return r.error == null;
|
|
2008
1911
|
}
|
|
2009
1912
|
function exec(cmd, args, cwd) {
|
|
2010
|
-
const result =
|
|
1913
|
+
const result = spawnSync8(cmd, args, { cwd, stdio: "inherit", shell: shouldUseShell2() });
|
|
2011
1914
|
if (result.error) {
|
|
2012
1915
|
process.stderr.write(`error: failed to run ${cmd}: ${result.error.message}
|
|
2013
1916
|
`);
|
|
@@ -2016,12 +1919,12 @@ function exec(cmd, args, cwd) {
|
|
|
2016
1919
|
return result.status === 0;
|
|
2017
1920
|
}
|
|
2018
1921
|
function hasLocalExecutable(dir, executable) {
|
|
2019
|
-
const localBin =
|
|
2020
|
-
return
|
|
1922
|
+
const localBin = path9.join(dir, "node_modules", ".bin", executable);
|
|
1923
|
+
return existsSync5(localBin);
|
|
2021
1924
|
}
|
|
2022
1925
|
function ensureNodeModules(dir, executable) {
|
|
2023
|
-
const nodeModulesDir =
|
|
2024
|
-
const hasDeps =
|
|
1926
|
+
const nodeModulesDir = path9.join(dir, "node_modules");
|
|
1927
|
+
const hasDeps = existsSync5(nodeModulesDir);
|
|
2025
1928
|
const hasExecutable = executable == null || hasLocalExecutable(dir, executable);
|
|
2026
1929
|
if (hasDeps && hasExecutable) return true;
|
|
2027
1930
|
process.stdout.write(
|
|
@@ -2031,13 +1934,13 @@ function ensureNodeModules(dir, executable) {
|
|
|
2031
1934
|
return exec("npm", ["install", "--prefix", dir, "--silent"], dir);
|
|
2032
1935
|
}
|
|
2033
1936
|
function ensureVenv(dir) {
|
|
2034
|
-
const venvRuff =
|
|
2035
|
-
if (
|
|
1937
|
+
const venvRuff = path9.join(dir, ".venv", "bin", "ruff");
|
|
1938
|
+
if (existsSync5(venvRuff)) return true;
|
|
2036
1939
|
process.stdout.write(".venv not found \u2014 running uv sync\u2026\n");
|
|
2037
1940
|
return exec("uv", ["sync"], dir);
|
|
2038
1941
|
}
|
|
2039
1942
|
function isDockerServiceRunning(service, cwd) {
|
|
2040
|
-
const r =
|
|
1943
|
+
const r = spawnSync8("docker", ["compose", "ps", "--status", "running", "-q", service], {
|
|
2041
1944
|
stdio: "pipe",
|
|
2042
1945
|
cwd
|
|
2043
1946
|
});
|
|
@@ -2054,15 +1957,15 @@ var formatCommand = {
|
|
|
2054
1957
|
},
|
|
2055
1958
|
async run({ projectRoot, args }) {
|
|
2056
1959
|
const check = Boolean(args.check);
|
|
2057
|
-
const backendDir =
|
|
2058
|
-
const frontendDir =
|
|
2059
|
-
const e2eDir =
|
|
2060
|
-
const backendExists =
|
|
1960
|
+
const backendDir = path9.join(projectRoot, "backend");
|
|
1961
|
+
const frontendDir = path9.join(projectRoot, "frontend");
|
|
1962
|
+
const e2eDir = path9.join(projectRoot, "e2e");
|
|
1963
|
+
const backendExists = existsSync5(backendDir);
|
|
2061
1964
|
const backendContainerUp = backendExists && isDockerServiceRunning("backend", projectRoot);
|
|
2062
1965
|
const missing = [];
|
|
2063
1966
|
if (backendExists && !backendContainerUp && !isAvailable("uv"))
|
|
2064
1967
|
missing.push("uv \u2192 https://docs.astral.sh/uv/getting-started/installation/");
|
|
2065
|
-
if ((
|
|
1968
|
+
if ((existsSync5(frontendDir) || existsSync5(e2eDir)) && !isAvailable("pnpm"))
|
|
2066
1969
|
missing.push("pnpm \u2192 https://pnpm.io/installation");
|
|
2067
1970
|
if (missing.length > 0) {
|
|
2068
1971
|
process.stderr.write(
|
|
@@ -2125,26 +2028,26 @@ var formatCommand = {
|
|
|
2125
2028
|
}
|
|
2126
2029
|
}
|
|
2127
2030
|
}
|
|
2128
|
-
if (
|
|
2031
|
+
if (existsSync5(frontendDir)) {
|
|
2129
2032
|
process.stdout.write(check ? "Checking frontend formatting\u2026\n" : "Formatting frontend\u2026\n");
|
|
2130
|
-
const prettierBin =
|
|
2131
|
-
if (!
|
|
2033
|
+
const prettierBin = path9.join(frontendDir, "node_modules", ".bin", "prettier");
|
|
2034
|
+
if (!existsSync5(prettierBin)) {
|
|
2132
2035
|
ensureNodeModules(frontendDir, "prettier");
|
|
2133
2036
|
}
|
|
2134
|
-
if (!
|
|
2037
|
+
if (!existsSync5(prettierBin)) {
|
|
2135
2038
|
process.stderr.write(" prettier not found \u2014 run: cd frontend && npm install\n");
|
|
2136
2039
|
ok = false;
|
|
2137
2040
|
} else {
|
|
2138
2041
|
ok = exec(prettierBin, [...check ? ["--check"] : ["--write"], "src/"], frontendDir) && ok;
|
|
2139
2042
|
}
|
|
2140
2043
|
}
|
|
2141
|
-
if (
|
|
2044
|
+
if (existsSync5(e2eDir)) {
|
|
2142
2045
|
process.stdout.write(check ? "Checking e2e formatting\u2026\n" : "Formatting e2e\u2026\n");
|
|
2143
|
-
const prettierBin =
|
|
2144
|
-
if (!
|
|
2046
|
+
const prettierBin = path9.join(e2eDir, "node_modules", ".bin", "prettier");
|
|
2047
|
+
if (!existsSync5(prettierBin)) {
|
|
2145
2048
|
ensureNodeModules(e2eDir, "prettier");
|
|
2146
2049
|
}
|
|
2147
|
-
if (!
|
|
2050
|
+
if (!existsSync5(prettierBin)) {
|
|
2148
2051
|
process.stderr.write(" prettier not found \u2014 run: cd e2e && npm install\n");
|
|
2149
2052
|
ok = false;
|
|
2150
2053
|
} else {
|
|
@@ -2185,19 +2088,19 @@ var logsCommand = {
|
|
|
2185
2088
|
};
|
|
2186
2089
|
|
|
2187
2090
|
// src/commands/review/index.ts
|
|
2188
|
-
import { spawnSync as
|
|
2189
|
-
import { existsSync as
|
|
2190
|
-
import
|
|
2091
|
+
import { spawnSync as spawnSync9 } from "child_process";
|
|
2092
|
+
import { existsSync as existsSync6 } from "fs";
|
|
2093
|
+
import path10 from "pathe";
|
|
2191
2094
|
import { runLint, formatDiagnostic } from "@cubocicloide/dude";
|
|
2192
2095
|
function shouldUseShell3() {
|
|
2193
2096
|
return process.platform === "win32";
|
|
2194
2097
|
}
|
|
2195
2098
|
function isAvailable2(cmd) {
|
|
2196
|
-
const r =
|
|
2099
|
+
const r = spawnSync9(cmd, ["--version"], { stdio: "ignore", shell: shouldUseShell3() });
|
|
2197
2100
|
return r.error == null;
|
|
2198
2101
|
}
|
|
2199
2102
|
function exec2(cmd, args, cwd) {
|
|
2200
|
-
const r =
|
|
2103
|
+
const r = spawnSync9(cmd, args, { cwd, stdio: "inherit", shell: shouldUseShell3() });
|
|
2201
2104
|
if (r.error) {
|
|
2202
2105
|
process.stderr.write(`error: failed to run ${cmd}: ${r.error.message}
|
|
2203
2106
|
`);
|
|
@@ -2218,12 +2121,12 @@ ${header}
|
|
|
2218
2121
|
var reviewCommand2 = {
|
|
2219
2122
|
description: "Run all checks: custom lint, ESLint, and API contract review.",
|
|
2220
2123
|
async run({ projectRoot, stackRoot }) {
|
|
2221
|
-
const frontendDir =
|
|
2222
|
-
const e2eDir =
|
|
2124
|
+
const frontendDir = path10.join(projectRoot, "frontend");
|
|
2125
|
+
const e2eDir = path10.join(projectRoot, "e2e");
|
|
2223
2126
|
const isTTY = process.stdout.isTTY;
|
|
2224
2127
|
let ok = true;
|
|
2225
2128
|
const missing = [];
|
|
2226
|
-
if ((
|
|
2129
|
+
if ((existsSync6(frontendDir) || existsSync6(e2eDir)) && !isAvailable2("pnpm"))
|
|
2227
2130
|
missing.push("pnpm \u2192 https://pnpm.io/installation");
|
|
2228
2131
|
if (missing.length > 0) {
|
|
2229
2132
|
process.stderr.write("error: required tools not found on your PATH:\n\n");
|
|
@@ -2243,20 +2146,20 @@ var reviewCommand2 = {
|
|
|
2243
2146
|
}
|
|
2244
2147
|
}
|
|
2245
2148
|
ok = errorCount === 0 && ok;
|
|
2246
|
-
if (
|
|
2149
|
+
if (existsSync6(frontendDir)) {
|
|
2247
2150
|
section("eslint");
|
|
2248
|
-
const eslintBin =
|
|
2249
|
-
if (!
|
|
2151
|
+
const eslintBin = path10.join(frontendDir, "node_modules", ".bin", "eslint");
|
|
2152
|
+
if (!existsSync6(eslintBin)) {
|
|
2250
2153
|
process.stderr.write(" eslint not found \u2014 run: cd frontend && pnpm install\n");
|
|
2251
2154
|
ok = false;
|
|
2252
2155
|
} else {
|
|
2253
2156
|
ok = exec2(eslintBin, ["src/"], frontendDir) && ok;
|
|
2254
2157
|
}
|
|
2255
2158
|
}
|
|
2256
|
-
if (
|
|
2159
|
+
if (existsSync6(e2eDir)) {
|
|
2257
2160
|
section("eslint (e2e)");
|
|
2258
|
-
const eslintBin =
|
|
2259
|
-
if (!
|
|
2161
|
+
const eslintBin = path10.join(e2eDir, "node_modules", ".bin", "eslint");
|
|
2162
|
+
if (!existsSync6(eslintBin)) {
|
|
2260
2163
|
process.stderr.write(" eslint not found \u2014 run: cd e2e && pnpm install\n");
|
|
2261
2164
|
ok = false;
|
|
2262
2165
|
} else {
|
|
@@ -2276,9 +2179,9 @@ var reviewCommand2 = {
|
|
|
2276
2179
|
};
|
|
2277
2180
|
|
|
2278
2181
|
// src/commands/security/index.ts
|
|
2279
|
-
import { spawnSync as
|
|
2280
|
-
import { cpSync as cpSync2, existsSync as
|
|
2281
|
-
import
|
|
2182
|
+
import { spawnSync as spawnSync10 } from "child_process";
|
|
2183
|
+
import { cpSync as cpSync2, existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync9, rmSync, writeFileSync as writeFileSync6 } from "fs";
|
|
2184
|
+
import path13 from "pathe";
|
|
2282
2185
|
|
|
2283
2186
|
// src/commands/security/models.ts
|
|
2284
2187
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -2310,15 +2213,15 @@ function findingToRecord(f) {
|
|
|
2310
2213
|
}
|
|
2311
2214
|
|
|
2312
2215
|
// src/commands/security/baseline.ts
|
|
2313
|
-
import { existsSync as
|
|
2314
|
-
import
|
|
2216
|
+
import { existsSync as existsSync7, readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync2 } from "fs";
|
|
2217
|
+
import path11 from "pathe";
|
|
2315
2218
|
var Baseline = class _Baseline {
|
|
2316
2219
|
constructor(entries = /* @__PURE__ */ new Map()) {
|
|
2317
2220
|
this.entries = entries;
|
|
2318
2221
|
}
|
|
2319
2222
|
entries;
|
|
2320
2223
|
static load(filePath) {
|
|
2321
|
-
if (!
|
|
2224
|
+
if (!existsSync7(filePath)) return new _Baseline();
|
|
2322
2225
|
const raw = readFileSync8(filePath, "utf8") || "{}";
|
|
2323
2226
|
const data = JSON.parse(raw);
|
|
2324
2227
|
const entries = /* @__PURE__ */ new Map();
|
|
@@ -2337,7 +2240,7 @@ var Baseline = class _Baseline {
|
|
|
2337
2240
|
return new _Baseline(entries);
|
|
2338
2241
|
}
|
|
2339
2242
|
save(filePath) {
|
|
2340
|
-
mkdirSync2(
|
|
2243
|
+
mkdirSync2(path11.dirname(filePath), { recursive: true });
|
|
2341
2244
|
const sorted = [...this.entries.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
2342
2245
|
const payload = {
|
|
2343
2246
|
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2356,7 +2259,7 @@ var Baseline = class _Baseline {
|
|
|
2356
2259
|
])
|
|
2357
2260
|
)
|
|
2358
2261
|
};
|
|
2359
|
-
|
|
2262
|
+
writeFileSync5(filePath, JSON.stringify(payload, null, 2) + "\n");
|
|
2360
2263
|
}
|
|
2361
2264
|
updateFrom(findings) {
|
|
2362
2265
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -2385,9 +2288,9 @@ var Baseline = class _Baseline {
|
|
|
2385
2288
|
};
|
|
2386
2289
|
|
|
2387
2290
|
// src/commands/security/adapters.ts
|
|
2388
|
-
import
|
|
2291
|
+
import path12 from "pathe";
|
|
2389
2292
|
function reportInContainer(projectRoot, runDir, name) {
|
|
2390
|
-
return `/src/${
|
|
2293
|
+
return `/src/${path12.relative(projectRoot, path12.join(runDir, `${name}.json`))}`;
|
|
2391
2294
|
}
|
|
2392
2295
|
var BANDIT_SEV = {
|
|
2393
2296
|
UNDEFINED: 0 /* UNKNOWN */,
|
|
@@ -2757,7 +2660,7 @@ function parseSeverityArg(value, fallback) {
|
|
|
2757
2660
|
return map[value.trim().toUpperCase()] ?? fallback;
|
|
2758
2661
|
}
|
|
2759
2662
|
function ensureDocker() {
|
|
2760
|
-
const r =
|
|
2663
|
+
const r = spawnSync10("docker", ["info"], { stdio: "ignore" });
|
|
2761
2664
|
if (r.error != null || r.status !== 0) {
|
|
2762
2665
|
process.stderr.write(
|
|
2763
2666
|
"[security] docker is required but is not available or the daemon is not running.\n"
|
|
@@ -2771,13 +2674,13 @@ function truncate(text) {
|
|
|
2771
2674
|
return cleaned.length > MAX_MESSAGE_LEN ? cleaned.slice(0, MAX_MESSAGE_LEN - 1) + "\u2026" : cleaned;
|
|
2772
2675
|
}
|
|
2773
2676
|
function writeFindingsJson(findings, filePath) {
|
|
2774
|
-
mkdirSync3(
|
|
2677
|
+
mkdirSync3(path13.dirname(filePath), { recursive: true });
|
|
2775
2678
|
const payload = {
|
|
2776
2679
|
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2777
2680
|
count: findings.length,
|
|
2778
2681
|
findings: findings.map(findingToRecord)
|
|
2779
2682
|
};
|
|
2780
|
-
|
|
2683
|
+
writeFileSync6(filePath, JSON.stringify(payload, null, 2) + "\n");
|
|
2781
2684
|
}
|
|
2782
2685
|
function writeMarkdownSummary(newFindings, knownFindings, resolved, filePath, minSeverity) {
|
|
2783
2686
|
const lines = [];
|
|
@@ -2845,18 +2748,18 @@ function writeMarkdownSummary(newFindings, knownFindings, resolved, filePath, mi
|
|
|
2845
2748
|
for (const fp of resolved.slice(0, 50)) lines.push(`- \`${fp}\``);
|
|
2846
2749
|
if (resolved.length > 50) lines.push(`- \u2026 and ${resolved.length - 50} more`);
|
|
2847
2750
|
}
|
|
2848
|
-
mkdirSync3(
|
|
2849
|
-
|
|
2751
|
+
mkdirSync3(path13.dirname(filePath), { recursive: true });
|
|
2752
|
+
writeFileSync6(filePath, lines.join("\n").trimEnd() + "\n");
|
|
2850
2753
|
}
|
|
2851
2754
|
function runScan(config) {
|
|
2852
2755
|
ensureDocker();
|
|
2853
2756
|
const now = /* @__PURE__ */ new Date();
|
|
2854
2757
|
const pad = (n) => String(n).padStart(2, "0");
|
|
2855
2758
|
const timestamp = `${now.getUTCFullYear()}${pad(now.getUTCMonth() + 1)}${pad(now.getUTCDate())}T${pad(now.getUTCHours())}${pad(now.getUTCMinutes())}${pad(now.getUTCSeconds())}Z`;
|
|
2856
|
-
const runDir =
|
|
2857
|
-
const latestDir =
|
|
2759
|
+
const runDir = path13.join(config.reportsRoot, timestamp);
|
|
2760
|
+
const latestDir = path13.join(config.reportsRoot, "latest");
|
|
2858
2761
|
mkdirSync3(runDir, { recursive: true });
|
|
2859
|
-
const cachePrefix =
|
|
2762
|
+
const cachePrefix = path13.basename(config.projectRoot);
|
|
2860
2763
|
const opts = { cachePrefix };
|
|
2861
2764
|
const findings = [];
|
|
2862
2765
|
for (const name of config.adapterNames) {
|
|
@@ -2872,12 +2775,12 @@ function runScan(config) {
|
|
|
2872
2775
|
const [bin, ...cmdArgs] = cmd;
|
|
2873
2776
|
process.stderr.write(`[security] running ${name}: ${cmd.join(" ")}
|
|
2874
2777
|
`);
|
|
2875
|
-
const result =
|
|
2778
|
+
const result = spawnSync10(bin ?? "docker", cmdArgs, {
|
|
2876
2779
|
cwd: config.projectRoot,
|
|
2877
2780
|
stdio: ["ignore", "pipe", "pipe"]
|
|
2878
2781
|
});
|
|
2879
|
-
const reportPath =
|
|
2880
|
-
if (!
|
|
2782
|
+
const reportPath = path13.join(runDir, `${name}.json`);
|
|
2783
|
+
if (!existsSync8(reportPath)) {
|
|
2881
2784
|
const stdout = result.stdout?.toString() ?? "";
|
|
2882
2785
|
const stderr = result.stderr?.toString() ?? "";
|
|
2883
2786
|
process.stderr.write(
|
|
@@ -2898,16 +2801,16 @@ function runScan(config) {
|
|
|
2898
2801
|
}
|
|
2899
2802
|
const baseline = Baseline.load(config.baselinePath);
|
|
2900
2803
|
const { newFindings, knownFindings, resolved } = baseline.classify(findings);
|
|
2901
|
-
writeFindingsJson(findings,
|
|
2902
|
-
writeFindingsJson(newFindings,
|
|
2804
|
+
writeFindingsJson(findings, path13.join(runDir, "findings.json"));
|
|
2805
|
+
writeFindingsJson(newFindings, path13.join(runDir, "findings.new.json"));
|
|
2903
2806
|
writeMarkdownSummary(
|
|
2904
2807
|
newFindings,
|
|
2905
2808
|
knownFindings,
|
|
2906
2809
|
resolved,
|
|
2907
|
-
|
|
2810
|
+
path13.join(runDir, "summary.md"),
|
|
2908
2811
|
config.minSeverity
|
|
2909
2812
|
);
|
|
2910
|
-
if (
|
|
2813
|
+
if (existsSync8(latestDir)) rmSync(latestDir, { recursive: true, force: true });
|
|
2911
2814
|
cpSync2(runDir, latestDir, { recursive: true });
|
|
2912
2815
|
if (config.updateBaseline) {
|
|
2913
2816
|
baseline.updateFrom(findings);
|
|
@@ -2951,8 +2854,8 @@ var securityScanCommand = {
|
|
|
2951
2854
|
}
|
|
2952
2855
|
},
|
|
2953
2856
|
async run({ projectRoot, args }) {
|
|
2954
|
-
const reportsRoot =
|
|
2955
|
-
const baselinePath =
|
|
2857
|
+
const reportsRoot = path13.join(projectRoot, "private", "sast-reports");
|
|
2858
|
+
const baselinePath = path13.join(projectRoot, "security", "baseline.json");
|
|
2956
2859
|
section2("security scan");
|
|
2957
2860
|
const result = runScan({
|
|
2958
2861
|
projectRoot,
|
|
@@ -2967,8 +2870,8 @@ var securityScanCommand = {
|
|
|
2967
2870
|
`[security] done. run_dir=${result.runDir} total=${result.findings.length} new=${result.newFindings.length} known=${result.knownFindings.length} resolved=${result.resolved.length}
|
|
2968
2871
|
`
|
|
2969
2872
|
);
|
|
2970
|
-
const summaryPath =
|
|
2971
|
-
if (
|
|
2873
|
+
const summaryPath = path13.join(result.latestDir, "summary.md");
|
|
2874
|
+
if (existsSync8(summaryPath)) {
|
|
2972
2875
|
process.stdout.write(readFileSync9(summaryPath, "utf8"));
|
|
2973
2876
|
}
|
|
2974
2877
|
if (result.exitCode !== 0) process.exit(result.exitCode);
|
|
@@ -2983,8 +2886,8 @@ var securityAcceptCommand = {
|
|
|
2983
2886
|
}
|
|
2984
2887
|
},
|
|
2985
2888
|
async run({ projectRoot, args }) {
|
|
2986
|
-
const reportsRoot =
|
|
2987
|
-
const baselinePath =
|
|
2889
|
+
const reportsRoot = path13.join(projectRoot, "private", "sast-reports");
|
|
2890
|
+
const baselinePath = path13.join(projectRoot, "security", "baseline.json");
|
|
2988
2891
|
section2("security accept");
|
|
2989
2892
|
const result = runScan({
|
|
2990
2893
|
projectRoot,
|
|
@@ -3022,8 +2925,8 @@ var securityVerifyCommand = {
|
|
|
3022
2925
|
}
|
|
3023
2926
|
},
|
|
3024
2927
|
async run({ projectRoot, args }) {
|
|
3025
|
-
const reportsRoot =
|
|
3026
|
-
const baselinePath =
|
|
2928
|
+
const reportsRoot = path13.join(projectRoot, "private", "sast-reports");
|
|
2929
|
+
const baselinePath = path13.join(projectRoot, "security", "baseline.json");
|
|
3027
2930
|
const isTTY = process.stdout.isTTY;
|
|
3028
2931
|
section2("security verify");
|
|
3029
2932
|
const result = runScan({
|
|
@@ -3100,7 +3003,7 @@ Review and commit the change.
|
|
|
3100
3003
|
};
|
|
3101
3004
|
|
|
3102
3005
|
// src/commands/shell/index.ts
|
|
3103
|
-
import { spawnSync as
|
|
3006
|
+
import { spawnSync as spawnSync11 } from "child_process";
|
|
3104
3007
|
var shellCommand = {
|
|
3105
3008
|
description: "Open an interactive shell in a service container.",
|
|
3106
3009
|
args: {
|
|
@@ -3112,7 +3015,7 @@ var shellCommand = {
|
|
|
3112
3015
|
},
|
|
3113
3016
|
async run({ args }) {
|
|
3114
3017
|
const svc = String(args.service);
|
|
3115
|
-
const bash =
|
|
3018
|
+
const bash = spawnSync11("docker", ["compose", "exec", svc, "/bin/bash"], { stdio: "inherit" });
|
|
3116
3019
|
if (bash.status !== 0) {
|
|
3117
3020
|
dc(["exec", svc, "/bin/sh"]);
|
|
3118
3021
|
} else {
|
|
@@ -3122,18 +3025,18 @@ var shellCommand = {
|
|
|
3122
3025
|
};
|
|
3123
3026
|
|
|
3124
3027
|
// src/commands/test/index.ts
|
|
3125
|
-
import { spawnSync as
|
|
3126
|
-
import { existsSync as
|
|
3127
|
-
import
|
|
3028
|
+
import { spawnSync as spawnSync12 } from "child_process";
|
|
3029
|
+
import { existsSync as existsSync9 } from "fs";
|
|
3030
|
+
import path14 from "pathe";
|
|
3128
3031
|
function shouldUseShell4() {
|
|
3129
3032
|
return process.platform === "win32";
|
|
3130
3033
|
}
|
|
3131
3034
|
function isAvailable3(cmd) {
|
|
3132
|
-
const r =
|
|
3035
|
+
const r = spawnSync12(cmd, ["--version"], { stdio: "ignore", shell: shouldUseShell4() });
|
|
3133
3036
|
return r.error == null;
|
|
3134
3037
|
}
|
|
3135
3038
|
function exec3(cmd, args, cwd, env) {
|
|
3136
|
-
const r =
|
|
3039
|
+
const r = spawnSync12(cmd, args, {
|
|
3137
3040
|
cwd,
|
|
3138
3041
|
stdio: "inherit",
|
|
3139
3042
|
env: { ...process.env, ...env },
|
|
@@ -3181,8 +3084,8 @@ var testCommand = {
|
|
|
3181
3084
|
}
|
|
3182
3085
|
},
|
|
3183
3086
|
async run({ projectRoot, args }) {
|
|
3184
|
-
const backendDir =
|
|
3185
|
-
const e2eDir =
|
|
3087
|
+
const backendDir = path14.join(projectRoot, "backend");
|
|
3088
|
+
const e2eDir = path14.join(projectRoot, "e2e");
|
|
3186
3089
|
const flagBackend = Boolean(args.backend);
|
|
3187
3090
|
const flagE2e = Boolean(args.e2e);
|
|
3188
3091
|
const headed = Boolean(args.headed);
|
|
@@ -3190,8 +3093,8 @@ var testCommand = {
|
|
|
3190
3093
|
const runAll = !flagBackend && !flagE2e;
|
|
3191
3094
|
const runBackend = flagBackend || runAll;
|
|
3192
3095
|
const runE2e = flagE2e || runAll;
|
|
3193
|
-
const hasBackend =
|
|
3194
|
-
const hasE2e =
|
|
3096
|
+
const hasBackend = existsSync9(backendDir);
|
|
3097
|
+
const hasE2e = existsSync9(e2eDir);
|
|
3195
3098
|
const missing = [];
|
|
3196
3099
|
if (runBackend && hasBackend && !isAvailable3("uv"))
|
|
3197
3100
|
missing.push("uv \u2192 https://docs.astral.sh/uv/getting-started/installation/");
|
|
@@ -3220,8 +3123,8 @@ var testCommand = {
|
|
|
3220
3123
|
if (runE2e && hasE2e) {
|
|
3221
3124
|
const script = report ? "test:report" : "test";
|
|
3222
3125
|
section3(`cucumber${headed ? " (headed)" : ""}${report ? " + report" : ""}`);
|
|
3223
|
-
const nmDir =
|
|
3224
|
-
if (!
|
|
3126
|
+
const nmDir = path14.join(e2eDir, "node_modules");
|
|
3127
|
+
if (!existsSync9(nmDir)) {
|
|
3225
3128
|
process.stdout.write("node_modules not found \u2014 running pnpm install\u2026\n");
|
|
3226
3129
|
const installed = exec3("pnpm", ["install"], e2eDir);
|
|
3227
3130
|
if (!installed) {
|
|
@@ -3315,6 +3218,24 @@ var src_default = defineStack({
|
|
|
3315
3218
|
default: "none"
|
|
3316
3219
|
}
|
|
3317
3220
|
],
|
|
3221
|
+
docs: {
|
|
3222
|
+
tagline: "React (Vite) frontend with a Django REST Framework backend \u2014 optional S3 storage and AWS ECS Fargate IaC.",
|
|
3223
|
+
useCases: [
|
|
3224
|
+
"A CRUD/admin-heavy web app that benefits from Django's batteries (admin, ORM, auth)",
|
|
3225
|
+
"An API that needs auto-generated OpenAPI docs (drf-spectacular) behind a React frontend",
|
|
3226
|
+
"S3-compatible file storage (MinIO locally) with a straightforward path to AWS ECS Fargate"
|
|
3227
|
+
],
|
|
3228
|
+
technologies: ["React 19", "Vite", "Django REST Framework", "drf-spectacular", "Celery"],
|
|
3229
|
+
iac: { provider: "aws-ecs", flag: "--iac aws-ecs" },
|
|
3230
|
+
pages: [
|
|
3231
|
+
{ file: "index.md", title: "Home" },
|
|
3232
|
+
{ file: "dude.md", title: "Working with dude" },
|
|
3233
|
+
{ file: "api.md", title: "Command reference" },
|
|
3234
|
+
{ file: "cheatsheet.md", title: "Cheatsheet" },
|
|
3235
|
+
{ file: "mkdocs.md", title: "Writing docs" },
|
|
3236
|
+
{ file: "deploy.md", title: "Deploy (AWS ECS)", when: "withIac" }
|
|
3237
|
+
]
|
|
3238
|
+
},
|
|
3318
3239
|
async scaffold(ctx) {
|
|
3319
3240
|
const { answers, dest, stackRoot, dudeVersion, stackVersion } = ctx;
|
|
3320
3241
|
const withPostgres = answers.database === "postgres";
|
|
@@ -3334,27 +3255,27 @@ var src_default = defineStack({
|
|
|
3334
3255
|
dudeVersion,
|
|
3335
3256
|
stackVersion
|
|
3336
3257
|
};
|
|
3337
|
-
const templates =
|
|
3338
|
-
await renderTemplateTree({ src:
|
|
3258
|
+
const templates = path15.join(stackRoot, "templates");
|
|
3259
|
+
await renderTemplateTree({ src: path15.join(templates, "base"), dest, data });
|
|
3339
3260
|
if (withPostgres) {
|
|
3340
|
-
await renderTemplateTree({ src:
|
|
3261
|
+
await renderTemplateTree({ src: path15.join(templates, "postgres"), dest, data });
|
|
3341
3262
|
}
|
|
3342
3263
|
if (withS3) {
|
|
3343
|
-
await renderTemplateTree({ src:
|
|
3264
|
+
await renderTemplateTree({ src: path15.join(templates, "s3"), dest, data });
|
|
3344
3265
|
}
|
|
3345
3266
|
if (withCelery) {
|
|
3346
|
-
await renderTemplateTree({ src:
|
|
3267
|
+
await renderTemplateTree({ src: path15.join(templates, "celery"), dest, data });
|
|
3347
3268
|
}
|
|
3348
3269
|
if (withCeleryBeat) {
|
|
3349
|
-
await renderTemplateTree({ src:
|
|
3270
|
+
await renderTemplateTree({ src: path15.join(templates, "celerybeat"), dest, data });
|
|
3350
3271
|
}
|
|
3351
3272
|
if (withIac) {
|
|
3352
|
-
await renderTemplateTree({ src:
|
|
3273
|
+
await renderTemplateTree({ src: path15.join(templates, "aws-ecs"), dest, data });
|
|
3353
3274
|
}
|
|
3354
|
-
const openapiYamlPath =
|
|
3355
|
-
if (
|
|
3275
|
+
const openapiYamlPath = path15.join(dest, "frontend", "src", "openapi", "utils", "openapi.yaml");
|
|
3276
|
+
if (existsSync10(openapiYamlPath)) {
|
|
3356
3277
|
const spec = yaml2.parse(readFileSync10(openapiYamlPath, "utf8"));
|
|
3357
|
-
await generateClientFromSpec(spec,
|
|
3278
|
+
await generateClientFromSpec(spec, path15.join(dest, "frontend", "src", "openapi"), dest);
|
|
3358
3279
|
}
|
|
3359
3280
|
},
|
|
3360
3281
|
hooks: {
|
|
@@ -3403,6 +3324,7 @@ var src_default = defineStack({
|
|
|
3403
3324
|
},
|
|
3404
3325
|
rules: [],
|
|
3405
3326
|
commands: {
|
|
3327
|
+
cheatsheet: defineCheatsheetCommand(),
|
|
3406
3328
|
up: upCommand,
|
|
3407
3329
|
down: downCommand,
|
|
3408
3330
|
logs: logsCommand,
|
|
@@ -3411,7 +3333,7 @@ var src_default = defineStack({
|
|
|
3411
3333
|
format: formatCommand,
|
|
3412
3334
|
review: reviewCommand2,
|
|
3413
3335
|
test: testCommand,
|
|
3414
|
-
docs:
|
|
3336
|
+
docs: defineDocsCommand(),
|
|
3415
3337
|
security: {
|
|
3416
3338
|
scan: securityScanCommand,
|
|
3417
3339
|
accept: securityAcceptCommand,
|