@cubocicloide/stack-react-fastapi 13.2.0 → 13.3.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 +82 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/aws-eks/backend/Dockerfile.prod.hbs +11 -4
- package/templates/aws-eks/docs/docs/deploy.md.hbs +29 -0
- package/templates/aws-eks/frontend/Dockerfile.prod +7 -3
- package/templates/aws-eks/frontend/nginx.conf +2 -1
- package/templates/aws-eks/iac/helm/app/values.yaml.hbs +3 -2
- package/templates/aws-eks/iac/terraform/bootstrap/main.tf.hbs +23 -3
- package/templates/aws-eks/iac/terraform/main.tf.hbs +10 -1
- package/templates/base/docs/docs/dude.md.hbs +19 -0
- package/templates/base/frontend/src/pages/index.tsx +2 -2
- package/templates/base/security/_trivyignore.yaml +49 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { existsSync as
|
|
2
|
+
import { existsSync as existsSync13, readFileSync as readFileSync9 } from "fs";
|
|
3
3
|
import path15 from "pathe";
|
|
4
4
|
import yaml2 from "yaml";
|
|
5
5
|
import { defineStack, renderTemplateTree, defineCheatsheetCommand, defineDocsCommand } from "@cubocicloide/dude";
|
|
@@ -876,12 +876,13 @@ var iacBootstrapCommand = {
|
|
|
876
876
|
|
|
877
877
|
// src/commands/iac/providers/aws-eks/lib/images.ts
|
|
878
878
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
879
|
+
import { createHash as createHash2 } from "crypto";
|
|
879
880
|
import { existsSync as existsSync5 } from "fs";
|
|
880
881
|
import path7 from "pathe";
|
|
881
882
|
var tagArg = {
|
|
882
883
|
tag: {
|
|
883
884
|
type: "string",
|
|
884
|
-
description: "Image tag (default: git short SHA,
|
|
885
|
+
description: "Image tag (default: git short SHA, plus -dirty-<hash> if there are uncommitted changes)."
|
|
885
886
|
}
|
|
886
887
|
};
|
|
887
888
|
var platformArg = {
|
|
@@ -941,10 +942,38 @@ function resolveTag(projectRoot, args) {
|
|
|
941
942
|
);
|
|
942
943
|
return null;
|
|
943
944
|
}
|
|
944
|
-
|
|
945
|
+
const tag = sha.stdout.trim();
|
|
946
|
+
const dirt = workingTreeDigest(projectRoot);
|
|
947
|
+
return dirt ? `${tag}-dirty-${dirt}` : tag;
|
|
948
|
+
}
|
|
949
|
+
function workingTreeDigest(projectRoot) {
|
|
945
950
|
const status = capture2("git", ["status", "--porcelain"], projectRoot);
|
|
946
|
-
if (status.status
|
|
947
|
-
|
|
951
|
+
if (status.status !== 0 || status.stdout.trim() === "") return null;
|
|
952
|
+
const diff = capture2("git", ["diff", "HEAD"], projectRoot);
|
|
953
|
+
return createHash2("sha256").update(status.stdout).update(diff.status === 0 ? diff.stdout : "").digest("hex").slice(0, 8);
|
|
954
|
+
}
|
|
955
|
+
function repoName(repositoryUrl) {
|
|
956
|
+
return repositoryUrl.split("/").slice(1).join("/");
|
|
957
|
+
}
|
|
958
|
+
function ecrTagExists(projectRoot, profile, repositoryUrl, tag, region) {
|
|
959
|
+
const r = capture2(
|
|
960
|
+
"aws",
|
|
961
|
+
[
|
|
962
|
+
"ecr",
|
|
963
|
+
"describe-images",
|
|
964
|
+
"--repository-name",
|
|
965
|
+
repoName(repositoryUrl),
|
|
966
|
+
"--image-ids",
|
|
967
|
+
`imageTag=${tag}`,
|
|
968
|
+
"--region",
|
|
969
|
+
region,
|
|
970
|
+
"--output",
|
|
971
|
+
"json"
|
|
972
|
+
],
|
|
973
|
+
projectRoot,
|
|
974
|
+
profile
|
|
975
|
+
);
|
|
976
|
+
return r.status === 0 && r.stdout.includes("imageDigest");
|
|
948
977
|
}
|
|
949
978
|
function dockerLogin(host, region, projectRoot, profile) {
|
|
950
979
|
const pw = capture2("aws", ["ecr", "get-login-password", "--region", region], projectRoot, profile);
|
|
@@ -1003,7 +1032,28 @@ function doBuild(projectRoot, profile, tag, repos, project, platform) {
|
|
|
1003
1032
|
);
|
|
1004
1033
|
return code;
|
|
1005
1034
|
}
|
|
1006
|
-
function
|
|
1035
|
+
function tagAlreadyPushed(projectRoot, profile, tag, repos, env) {
|
|
1036
|
+
for (const repo of [repos.backend, repos.frontend]) {
|
|
1037
|
+
if (!ecrTagExists(projectRoot, profile, repo, tag, repos.region)) continue;
|
|
1038
|
+
process.stderr.write(
|
|
1039
|
+
`
|
|
1040
|
+
\u2717 ${repo}:${tag} already exists, and the repository is immutable.
|
|
1041
|
+
|
|
1042
|
+
The default tag is derived from your git state, so the same commit with
|
|
1043
|
+
the same uncommitted changes always resolves to the same tag. Either:
|
|
1044
|
+
|
|
1045
|
+
\u2022 commit your work and re-run \u2014 a new SHA gives a new tag;
|
|
1046
|
+
\u2022 push under a different tag: dude iac push --env ${env} --tag ${tag}.1
|
|
1047
|
+
\u2022 or deploy what is already there: dude iac deploy --env ${env} --tag ${tag}
|
|
1048
|
+
|
|
1049
|
+
`
|
|
1050
|
+
);
|
|
1051
|
+
return true;
|
|
1052
|
+
}
|
|
1053
|
+
return false;
|
|
1054
|
+
}
|
|
1055
|
+
function doPush(projectRoot, profile, tag, repos, env) {
|
|
1056
|
+
if (tagAlreadyPushed(projectRoot, profile, tag, repos, env)) return 1;
|
|
1007
1057
|
let code = dockerLogin(repos.registryHost, repos.region, projectRoot, profile);
|
|
1008
1058
|
if (code !== 0) return code;
|
|
1009
1059
|
process.stdout.write(`
|
|
@@ -1801,7 +1851,7 @@ var iacPushCommand = {
|
|
|
1801
1851
|
const tag = resolveTag(projectRoot, args);
|
|
1802
1852
|
if (!tag) process.exit(1);
|
|
1803
1853
|
const repos = requireEcrRepos(projectRoot, profile);
|
|
1804
|
-
process.exit(doPush(projectRoot, profile, tag, repos));
|
|
1854
|
+
process.exit(doPush(projectRoot, profile, tag, repos, env));
|
|
1805
1855
|
}
|
|
1806
1856
|
};
|
|
1807
1857
|
|
|
@@ -1869,9 +1919,10 @@ var iacShipCommand = {
|
|
|
1869
1919
|
const ns = String(args.namespace ?? env);
|
|
1870
1920
|
const platform = String(args.platform ?? "linux/amd64");
|
|
1871
1921
|
const project = projectName(projectRoot);
|
|
1922
|
+
if (tagAlreadyPushed(projectRoot, profile, tag, repos, env)) process.exit(1);
|
|
1872
1923
|
let code = doBuild(projectRoot, profile, tag, repos, project, platform);
|
|
1873
1924
|
if (code !== 0) process.exit(code);
|
|
1874
|
-
code = doPush(projectRoot, profile, tag, repos);
|
|
1925
|
+
code = doPush(projectRoot, profile, tag, repos, env);
|
|
1875
1926
|
if (code !== 0) process.exit(code);
|
|
1876
1927
|
code = doDeploy(projectRoot, profile, env, ns, tag, repos);
|
|
1877
1928
|
if (code === 0) {
|
|
@@ -2247,11 +2298,11 @@ var reviewCommand2 = {
|
|
|
2247
2298
|
|
|
2248
2299
|
// src/commands/security/index.ts
|
|
2249
2300
|
import { spawnSync as spawnSync10 } from "child_process";
|
|
2250
|
-
import { cpSync as cpSync2, existsSync as
|
|
2301
|
+
import { cpSync as cpSync2, existsSync as existsSync11, mkdirSync as mkdirSync3, readFileSync as readFileSync8, rmSync, writeFileSync as writeFileSync5 } from "fs";
|
|
2251
2302
|
import path13 from "pathe";
|
|
2252
2303
|
|
|
2253
2304
|
// src/commands/security/models.ts
|
|
2254
|
-
import { createHash as
|
|
2305
|
+
import { createHash as createHash3 } from "crypto";
|
|
2255
2306
|
var SEV_LABEL = {
|
|
2256
2307
|
[0 /* UNKNOWN */]: "UNKNOWN",
|
|
2257
2308
|
[1 /* INFO */]: "INFO",
|
|
@@ -2262,7 +2313,7 @@ var SEV_LABEL = {
|
|
|
2262
2313
|
};
|
|
2263
2314
|
function fingerprint(f) {
|
|
2264
2315
|
const raw = [f.tool, f.ruleId, f.file, f.title.trim().toLowerCase()].join("|");
|
|
2265
|
-
return
|
|
2316
|
+
return createHash3("sha256").update(raw, "utf8").digest("hex").slice(0, 16);
|
|
2266
2317
|
}
|
|
2267
2318
|
function findingToRecord(f) {
|
|
2268
2319
|
return {
|
|
@@ -2355,6 +2406,7 @@ var Baseline = class _Baseline {
|
|
|
2355
2406
|
};
|
|
2356
2407
|
|
|
2357
2408
|
// src/commands/security/adapters.ts
|
|
2409
|
+
import { existsSync as existsSync10 } from "fs";
|
|
2358
2410
|
import path12 from "pathe";
|
|
2359
2411
|
function reportInContainer(projectRoot, runDir, name) {
|
|
2360
2412
|
return `/src/${path12.relative(projectRoot, path12.join(runDir, `${name}.json`))}`;
|
|
@@ -2529,10 +2581,13 @@ function trivyComponent(filePath) {
|
|
|
2529
2581
|
if (filePath.endsWith("Dockerfile") || filePath.includes("docker-compose")) return "docker";
|
|
2530
2582
|
return "deps";
|
|
2531
2583
|
}
|
|
2584
|
+
var TRIVY_SKIP_DIRS = "node_modules,private,staticfiles,e2e/reports,.venv,.terraform";
|
|
2585
|
+
var TRIVY_IGNORE_FILE = "security/.trivyignore.yaml";
|
|
2532
2586
|
var trivyFsAdapter = {
|
|
2533
2587
|
name: "trivy-fs",
|
|
2534
2588
|
buildCommand(projectRoot, runDir, opts) {
|
|
2535
2589
|
const report = reportInContainer(projectRoot, runDir, "trivy-fs");
|
|
2590
|
+
const ignoreFile = existsSync10(path12.join(projectRoot, TRIVY_IGNORE_FILE)) ? ["--ignorefile", TRIVY_IGNORE_FILE] : [];
|
|
2536
2591
|
return [
|
|
2537
2592
|
"docker",
|
|
2538
2593
|
"run",
|
|
@@ -2552,7 +2607,14 @@ var trivyFsAdapter = {
|
|
|
2552
2607
|
"--output",
|
|
2553
2608
|
report,
|
|
2554
2609
|
"--skip-dirs",
|
|
2555
|
-
|
|
2610
|
+
TRIVY_SKIP_DIRS,
|
|
2611
|
+
// Terraform misconfigurations are reported against the module's *source*
|
|
2612
|
+
// (`git::https:/github.com/terraform-aws-modules/…`), not the local path
|
|
2613
|
+
// it was vendored to — so --skip-dirs cannot suppress them. Without this
|
|
2614
|
+
// flag the report is dominated by findings inside the upstream VPC/EKS
|
|
2615
|
+
// modules (AVD-AWS-0104, AVD-AWS-0130), which nobody here can act on.
|
|
2616
|
+
"--tf-exclude-downloaded-modules",
|
|
2617
|
+
...ignoreFile,
|
|
2556
2618
|
"."
|
|
2557
2619
|
];
|
|
2558
2620
|
},
|
|
@@ -2846,7 +2908,7 @@ function runScan(config) {
|
|
|
2846
2908
|
stdio: ["ignore", "pipe", "pipe"]
|
|
2847
2909
|
});
|
|
2848
2910
|
const reportPath = path13.join(runDir, `${name}.json`);
|
|
2849
|
-
if (!
|
|
2911
|
+
if (!existsSync11(reportPath)) {
|
|
2850
2912
|
const stdout = result.stdout?.toString() ?? "";
|
|
2851
2913
|
const stderr = result.stderr?.toString() ?? "";
|
|
2852
2914
|
process.stderr.write(
|
|
@@ -2876,7 +2938,7 @@ function runScan(config) {
|
|
|
2876
2938
|
path13.join(runDir, "summary.md"),
|
|
2877
2939
|
config.minSeverity
|
|
2878
2940
|
);
|
|
2879
|
-
if (
|
|
2941
|
+
if (existsSync11(latestDir)) rmSync(latestDir, { recursive: true, force: true });
|
|
2880
2942
|
cpSync2(runDir, latestDir, { recursive: true });
|
|
2881
2943
|
if (config.updateBaseline) {
|
|
2882
2944
|
baseline.updateFrom(findings);
|
|
@@ -2937,7 +2999,7 @@ var securityScanCommand = {
|
|
|
2937
2999
|
`
|
|
2938
3000
|
);
|
|
2939
3001
|
const summaryPath = path13.join(result.latestDir, "summary.md");
|
|
2940
|
-
if (
|
|
3002
|
+
if (existsSync11(summaryPath)) {
|
|
2941
3003
|
process.stdout.write(readFileSync8(summaryPath, "utf8"));
|
|
2942
3004
|
}
|
|
2943
3005
|
if (result.exitCode !== 0) process.exit(result.exitCode);
|
|
@@ -3092,7 +3154,7 @@ var shellCommand = {
|
|
|
3092
3154
|
|
|
3093
3155
|
// src/commands/test/index.ts
|
|
3094
3156
|
import { spawnSync as spawnSync12 } from "child_process";
|
|
3095
|
-
import { existsSync as
|
|
3157
|
+
import { existsSync as existsSync12 } from "fs";
|
|
3096
3158
|
import path14 from "pathe";
|
|
3097
3159
|
function shouldUseShell4() {
|
|
3098
3160
|
return process.platform === "win32";
|
|
@@ -3159,8 +3221,8 @@ var testCommand = {
|
|
|
3159
3221
|
const runAll = !flagBackend && !flagE2e;
|
|
3160
3222
|
const runBackend = flagBackend || runAll;
|
|
3161
3223
|
const runE2e = flagE2e || runAll;
|
|
3162
|
-
const hasBackend =
|
|
3163
|
-
const hasE2e =
|
|
3224
|
+
const hasBackend = existsSync12(backendDir);
|
|
3225
|
+
const hasE2e = existsSync12(e2eDir);
|
|
3164
3226
|
const missing = [];
|
|
3165
3227
|
if (runBackend && hasBackend && !isAvailable3("uv"))
|
|
3166
3228
|
missing.push("uv \u2192 https://docs.astral.sh/uv/getting-started/installation/");
|
|
@@ -3190,7 +3252,7 @@ var testCommand = {
|
|
|
3190
3252
|
const script = report ? "test:report" : "test";
|
|
3191
3253
|
section3(`cucumber${headed ? " (headed)" : ""}${report ? " + report" : ""}`);
|
|
3192
3254
|
const nmDir = path14.join(e2eDir, "node_modules");
|
|
3193
|
-
if (!
|
|
3255
|
+
if (!existsSync12(nmDir)) {
|
|
3194
3256
|
process.stdout.write("node_modules not found \u2014 running pnpm install\u2026\n");
|
|
3195
3257
|
const installed = exec3("pnpm", ["install"], e2eDir);
|
|
3196
3258
|
if (!installed) {
|
|
@@ -3327,7 +3389,7 @@ var src_default = defineStack({
|
|
|
3327
3389
|
await renderTemplateTree({ src: path15.join(templates, "aws-eks"), dest, data });
|
|
3328
3390
|
}
|
|
3329
3391
|
const openapiYamlPath = path15.join(dest, "frontend", "src", "openapi", "utils", "openapi.yaml");
|
|
3330
|
-
if (
|
|
3392
|
+
if (existsSync13(openapiYamlPath)) {
|
|
3331
3393
|
const spec = yaml2.parse(readFileSync9(openapiYamlPath, "utf8"));
|
|
3332
3394
|
await generateClientFromSpec(spec, path15.join(dest, "frontend", "src", "openapi"), dest);
|
|
3333
3395
|
}
|