@cubocicloide/stack-frappe 2.0.5 → 2.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 +89 -165
- 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,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import
|
|
3
|
-
import { defineStack, renderTemplateTree } from "@cubocicloide/dude";
|
|
2
|
+
import path8 from "pathe";
|
|
3
|
+
import { defineStack, renderTemplateTree, defineCheatsheetCommand, defineDocsCommand } from "@cubocicloide/dude";
|
|
4
4
|
|
|
5
5
|
// src/commands/_docker.ts
|
|
6
6
|
import { spawnSync } from "child_process";
|
|
@@ -76,103 +76,6 @@ var benchCommand = {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
// src/commands/docs/index.ts
|
|
80
|
-
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
81
|
-
import { existsSync, writeFileSync } from "fs";
|
|
82
|
-
import path from "pathe";
|
|
83
|
-
async function regenerateApiDoc(projectRoot, docsDir) {
|
|
84
|
-
try {
|
|
85
|
-
const dude = await import("@cubocicloide/dude");
|
|
86
|
-
if (typeof dude.generateApiDoc !== "function") return;
|
|
87
|
-
const md = await dude.generateApiDoc(projectRoot, "md");
|
|
88
|
-
writeFileSync(path.join(docsDir, "docs", "api.md"), md);
|
|
89
|
-
process.stdout.write("[docs] Regenerated docs/api.md from the live command catalog.\n");
|
|
90
|
-
} catch (e) {
|
|
91
|
-
process.stderr.write(
|
|
92
|
-
`[docs] Could not regenerate api.md (${e.message}); using the existing file.
|
|
93
|
-
`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function isDockerRunning2() {
|
|
98
|
-
const r = spawnSync2("docker", ["info"], { stdio: "ignore" });
|
|
99
|
-
return r.error == null && r.status === 0;
|
|
100
|
-
}
|
|
101
|
-
function openBrowser(url) {
|
|
102
|
-
if (process.platform === "win32") {
|
|
103
|
-
spawnSync2("cmd", ["/c", "start", "", url], { stdio: "ignore" });
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
const opener = process.platform === "darwin" ? "open" : "xdg-open";
|
|
107
|
-
spawnSync2(opener, [url], { stdio: "ignore" });
|
|
108
|
-
}
|
|
109
|
-
var docsCommand = {
|
|
110
|
-
description: "Serve the project documentation in dev mode (live-reload) at http://localhost:8001.",
|
|
111
|
-
args: {
|
|
112
|
-
port: {
|
|
113
|
-
type: "string",
|
|
114
|
-
description: "Host port to expose the docs site on (default: 8001).",
|
|
115
|
-
default: "8001"
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
async run({ projectRoot, args }) {
|
|
119
|
-
const docsDir = path.join(projectRoot, "docs");
|
|
120
|
-
const port = String(args.port ?? "8001");
|
|
121
|
-
const url = `http://localhost:${port}`;
|
|
122
|
-
if (!existsSync(docsDir)) {
|
|
123
|
-
process.stderr.write(
|
|
124
|
-
"[docs] No docs/ folder found in the project root. Make sure you ran `dude init`.\n"
|
|
125
|
-
);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
await regenerateApiDoc(projectRoot, docsDir);
|
|
129
|
-
if (!isDockerRunning2()) {
|
|
130
|
-
process.stderr.write("[docs] Docker is not running. Start Docker Desktop and retry.\n");
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
process.stdout.write(`[docs] Starting MkDocs at ${url} (Ctrl+C to stop)
|
|
134
|
-
`);
|
|
135
|
-
const child = spawn(
|
|
136
|
-
"docker",
|
|
137
|
-
[
|
|
138
|
-
"run",
|
|
139
|
-
"--rm",
|
|
140
|
-
"-i",
|
|
141
|
-
"-p",
|
|
142
|
-
`${port}:8000`,
|
|
143
|
-
"-v",
|
|
144
|
-
`${docsDir}:/docs`,
|
|
145
|
-
"squidfunk/mkdocs-material",
|
|
146
|
-
"serve",
|
|
147
|
-
"--dev-addr=0.0.0.0:8000"
|
|
148
|
-
],
|
|
149
|
-
{ stdio: ["inherit", "pipe", "pipe"] }
|
|
150
|
-
);
|
|
151
|
-
if (child.pid == null) {
|
|
152
|
-
process.stderr.write("[docs] Failed to start Docker container.\n");
|
|
153
|
-
process.exit(1);
|
|
154
|
-
}
|
|
155
|
-
let browserOpened = false;
|
|
156
|
-
function watchChunk(chunk) {
|
|
157
|
-
if (!browserOpened && chunk.toString().includes("Serving on")) {
|
|
158
|
-
browserOpened = true;
|
|
159
|
-
process.stdout.write(`[docs] Opening ${url}
|
|
160
|
-
`);
|
|
161
|
-
openBrowser(url);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
child.stdout?.on("data", (chunk) => {
|
|
165
|
-
process.stdout.write(chunk);
|
|
166
|
-
watchChunk(chunk);
|
|
167
|
-
});
|
|
168
|
-
child.stderr?.on("data", (chunk) => {
|
|
169
|
-
process.stderr.write(chunk);
|
|
170
|
-
watchChunk(chunk);
|
|
171
|
-
});
|
|
172
|
-
await new Promise((resolve) => child.on("close", resolve));
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
|
|
176
79
|
// src/commands/down/index.ts
|
|
177
80
|
var downCommand = {
|
|
178
81
|
description: "Stop and remove all service containers (docker compose down).",
|
|
@@ -189,11 +92,11 @@ var downCommand = {
|
|
|
189
92
|
};
|
|
190
93
|
|
|
191
94
|
// src/commands/format/index.ts
|
|
192
|
-
import { spawnSync as
|
|
193
|
-
import
|
|
95
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
96
|
+
import path from "pathe";
|
|
194
97
|
function ruff(projectRoot, ruffArgs) {
|
|
195
|
-
const appsDir =
|
|
196
|
-
const r =
|
|
98
|
+
const appsDir = path.join(projectRoot, "apps");
|
|
99
|
+
const r = spawnSync2(
|
|
197
100
|
"docker",
|
|
198
101
|
["run", "--rm", "-v", `${appsDir}:/apps`, "-w", "/apps", "ghcr.io/astral-sh/ruff:latest", ...ruffArgs],
|
|
199
102
|
{ stdio: "inherit" }
|
|
@@ -215,13 +118,13 @@ var formatCommand = {
|
|
|
215
118
|
};
|
|
216
119
|
|
|
217
120
|
// src/commands/iac/providers/aws-ecs/lib/terraform.ts
|
|
218
|
-
import { existsSync as
|
|
219
|
-
import
|
|
121
|
+
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync3 } from "fs";
|
|
122
|
+
import path4 from "pathe";
|
|
220
123
|
|
|
221
124
|
// src/commands/iac/shared.ts
|
|
222
|
-
import { spawnSync as
|
|
125
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
223
126
|
import { readFileSync } from "fs";
|
|
224
|
-
import
|
|
127
|
+
import path2 from "pathe";
|
|
225
128
|
function shouldUseShell() {
|
|
226
129
|
return process.platform === "win32";
|
|
227
130
|
}
|
|
@@ -229,7 +132,7 @@ function childEnv(profile) {
|
|
|
229
132
|
return profile ? { ...process.env, AWS_PROFILE: profile } : process.env;
|
|
230
133
|
}
|
|
231
134
|
function run(cmd, args, cwd, profile) {
|
|
232
|
-
const r =
|
|
135
|
+
const r = spawnSync3(cmd, args, {
|
|
233
136
|
cwd,
|
|
234
137
|
stdio: "inherit",
|
|
235
138
|
env: childEnv(profile),
|
|
@@ -253,7 +156,7 @@ function run(cmd, args, cwd, profile) {
|
|
|
253
156
|
return r.status ?? 1;
|
|
254
157
|
}
|
|
255
158
|
function capture(cmd, args, cwd, profile) {
|
|
256
|
-
const r =
|
|
159
|
+
const r = spawnSync3(cmd, args, {
|
|
257
160
|
cwd,
|
|
258
161
|
encoding: "utf8",
|
|
259
162
|
env: childEnv(profile),
|
|
@@ -263,7 +166,7 @@ function capture(cmd, args, cwd, profile) {
|
|
|
263
166
|
}
|
|
264
167
|
function readAnswers(projectRoot) {
|
|
265
168
|
try {
|
|
266
|
-
const j = JSON.parse(readFileSync(
|
|
169
|
+
const j = JSON.parse(readFileSync(path2.join(projectRoot, "dude.json"), "utf8"));
|
|
267
170
|
return j.answers ?? {};
|
|
268
171
|
} catch {
|
|
269
172
|
return {};
|
|
@@ -282,22 +185,22 @@ function sleepMs(ms) {
|
|
|
282
185
|
}
|
|
283
186
|
|
|
284
187
|
// src/commands/iac/providers/aws-ecs/lib/exec.ts
|
|
285
|
-
import { spawnSync as
|
|
188
|
+
import { spawnSync as spawnSync5 } from "child_process";
|
|
286
189
|
|
|
287
190
|
// src/commands/iac/providers/aws-ecs/lib/runner.ts
|
|
288
|
-
import { spawnSync as
|
|
191
|
+
import { spawnSync as spawnSync4 } from "child_process";
|
|
289
192
|
import { createHash } from "crypto";
|
|
290
|
-
import { existsSync
|
|
193
|
+
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
291
194
|
import os from "os";
|
|
292
|
-
import
|
|
293
|
-
var RUNNER_DOCKERFILE =
|
|
195
|
+
import path3 from "pathe";
|
|
196
|
+
var RUNNER_DOCKERFILE = path3.join("iac", "runner", "Dockerfile");
|
|
294
197
|
var CONTAINERIZED = /* @__PURE__ */ new Set(["terraform"]);
|
|
295
198
|
function findDockerfile(cwd) {
|
|
296
|
-
let dir =
|
|
199
|
+
let dir = path3.resolve(cwd);
|
|
297
200
|
for (; ; ) {
|
|
298
|
-
const candidate =
|
|
299
|
-
if (
|
|
300
|
-
const parent =
|
|
201
|
+
const candidate = path3.join(dir, RUNNER_DOCKERFILE);
|
|
202
|
+
if (existsSync(candidate)) return candidate;
|
|
203
|
+
const parent = path3.dirname(dir);
|
|
301
204
|
if (parent === dir) return "";
|
|
302
205
|
dir = parent;
|
|
303
206
|
}
|
|
@@ -310,7 +213,7 @@ var dockerChecked;
|
|
|
310
213
|
var ensured = /* @__PURE__ */ new Set();
|
|
311
214
|
function dockerAvailable() {
|
|
312
215
|
if (dockerChecked !== void 0) return dockerChecked;
|
|
313
|
-
const r =
|
|
216
|
+
const r = spawnSync4("docker", ["version", "--format", "{{.Server.Version}}"], {
|
|
314
217
|
encoding: "utf8"
|
|
315
218
|
});
|
|
316
219
|
dockerChecked = r.status === 0 && !!r.stdout.trim();
|
|
@@ -322,7 +225,7 @@ function useRunner(cwd) {
|
|
|
322
225
|
}
|
|
323
226
|
function ensureImage(dockerfile, tag) {
|
|
324
227
|
if (ensured.has(tag)) return;
|
|
325
|
-
const exists =
|
|
228
|
+
const exists = spawnSync4("docker", ["image", "inspect", tag], { stdio: "ignore" }).status === 0;
|
|
326
229
|
if (!exists) {
|
|
327
230
|
process.stderr.write(
|
|
328
231
|
`
|
|
@@ -330,9 +233,9 @@ function ensureImage(dockerfile, tag) {
|
|
|
330
233
|
|
|
331
234
|
`
|
|
332
235
|
);
|
|
333
|
-
const build =
|
|
236
|
+
const build = spawnSync4(
|
|
334
237
|
"docker",
|
|
335
|
-
["build", "-t", tag, "-f", dockerfile,
|
|
238
|
+
["build", "-t", tag, "-f", dockerfile, path3.dirname(dockerfile)],
|
|
336
239
|
{ stdio: "inherit" }
|
|
337
240
|
);
|
|
338
241
|
if (build.status !== 0) {
|
|
@@ -346,7 +249,7 @@ function baseDockerArgs(cwd, profile, tty) {
|
|
|
346
249
|
const args = ["run", "--rm", tty ? "-it" : "-i"];
|
|
347
250
|
args.push("-v", `${cwd}:/work`, "-w", "/work");
|
|
348
251
|
const home = os.homedir();
|
|
349
|
-
args.push("-v", `${
|
|
252
|
+
args.push("-v", `${path3.join(home, ".aws")}:/root/.aws:ro`);
|
|
350
253
|
if (profile) args.push("-e", `AWS_PROFILE=${profile}`);
|
|
351
254
|
return args;
|
|
352
255
|
}
|
|
@@ -375,7 +278,7 @@ function routed(cmd, cwd) {
|
|
|
375
278
|
function run2(cmd, args, cwd, profile) {
|
|
376
279
|
if (!routed(cmd, cwd)) return run(cmd, args, cwd, profile);
|
|
377
280
|
const dargs = dockerRunArgs(cmd, args, cwd, profile, { tty: !!process.stdin.isTTY });
|
|
378
|
-
const r =
|
|
281
|
+
const r = spawnSync5("docker", dargs, { stdio: "inherit" });
|
|
379
282
|
if (r.error) {
|
|
380
283
|
process.stderr.write(`
|
|
381
284
|
\u2717 failed to run docker: ${r.error.message}
|
|
@@ -388,16 +291,16 @@ function run2(cmd, args, cwd, profile) {
|
|
|
388
291
|
function capture2(cmd, args, cwd, profile) {
|
|
389
292
|
if (!routed(cmd, cwd)) return capture(cmd, args, cwd, profile);
|
|
390
293
|
const dargs = dockerRunArgs(cmd, args, cwd, profile, { tty: false });
|
|
391
|
-
const r =
|
|
294
|
+
const r = spawnSync5("docker", dargs, { encoding: "utf8" });
|
|
392
295
|
return { status: r.status ?? 1, stdout: r.stdout ?? "" };
|
|
393
296
|
}
|
|
394
297
|
|
|
395
298
|
// src/commands/iac/providers/aws-ecs/lib/terraform.ts
|
|
396
|
-
var TF_DIR =
|
|
397
|
-
var TF_BOOTSTRAP_DIR =
|
|
398
|
-
var TF_ENVIRONMENTS_DIR =
|
|
299
|
+
var TF_DIR = path4.join("iac", "terraform");
|
|
300
|
+
var TF_BOOTSTRAP_DIR = path4.join(TF_DIR, "bootstrap");
|
|
301
|
+
var TF_ENVIRONMENTS_DIR = path4.join(TF_DIR, "environments");
|
|
399
302
|
function hasIac(projectRoot) {
|
|
400
|
-
return
|
|
303
|
+
return existsSync2(path4.join(projectRoot, "iac", "terraform"));
|
|
401
304
|
}
|
|
402
305
|
function requireIac(projectRoot) {
|
|
403
306
|
if (!hasIac(projectRoot)) {
|
|
@@ -423,10 +326,10 @@ function varFile(env) {
|
|
|
423
326
|
return `-var-file=environments/${env}/terraform.tfvars`;
|
|
424
327
|
}
|
|
425
328
|
function tfBoot(projectRoot, args, profile) {
|
|
426
|
-
return run2("terraform", args,
|
|
329
|
+
return run2("terraform", args, path4.join(projectRoot, TF_BOOTSTRAP_DIR), profile);
|
|
427
330
|
}
|
|
428
331
|
function captureBootstrap(projectRoot, args, profile) {
|
|
429
|
-
return capture2("terraform", args,
|
|
332
|
+
return capture2("terraform", args, path4.join(projectRoot, TF_BOOTSTRAP_DIR), profile);
|
|
430
333
|
}
|
|
431
334
|
function resolveProfile(projectRoot, args, env) {
|
|
432
335
|
if (args.profile) return String(args.profile);
|
|
@@ -436,7 +339,7 @@ function resolveProfile(projectRoot, args, env) {
|
|
|
436
339
|
function tfvarsValue(projectRoot, env, key) {
|
|
437
340
|
try {
|
|
438
341
|
return hclScalar(
|
|
439
|
-
readFileSync3(
|
|
342
|
+
readFileSync3(path4.join(projectRoot, TF_DIR, "environments", env, "terraform.tfvars"), "utf8"),
|
|
440
343
|
key
|
|
441
344
|
);
|
|
442
345
|
} catch {
|
|
@@ -446,7 +349,7 @@ function tfvarsValue(projectRoot, env, key) {
|
|
|
446
349
|
function readBackend(projectRoot, env) {
|
|
447
350
|
try {
|
|
448
351
|
const txt = readFileSync3(
|
|
449
|
-
|
|
352
|
+
path4.join(projectRoot, TF_DIR, "environments", env, "backend.hcl"),
|
|
450
353
|
"utf8"
|
|
451
354
|
);
|
|
452
355
|
return {
|
|
@@ -470,10 +373,10 @@ var envArg = {
|
|
|
470
373
|
}
|
|
471
374
|
};
|
|
472
375
|
function listEnvironments(projectRoot) {
|
|
473
|
-
const base =
|
|
376
|
+
const base = path4.join(projectRoot, TF_ENVIRONMENTS_DIR);
|
|
474
377
|
try {
|
|
475
378
|
return readdirSync(base, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).filter(
|
|
476
|
-
(name) =>
|
|
379
|
+
(name) => existsSync2(path4.join(base, name, "backend.hcl")) && existsSync2(path4.join(base, name, "terraform.tfvars"))
|
|
477
380
|
).sort();
|
|
478
381
|
} catch {
|
|
479
382
|
return [];
|
|
@@ -534,8 +437,8 @@ var iacApplyCommand = {
|
|
|
534
437
|
};
|
|
535
438
|
|
|
536
439
|
// src/commands/iac/providers/aws-ecs/commands/bootstrap/index.ts
|
|
537
|
-
import { readFileSync as readFileSync4, writeFileSync
|
|
538
|
-
import
|
|
440
|
+
import { readFileSync as readFileSync4, writeFileSync } from "fs";
|
|
441
|
+
import path5 from "pathe";
|
|
539
442
|
var iacBootstrapCommand = {
|
|
540
443
|
available: hasIac,
|
|
541
444
|
description: "One-time: create the S3 state bucket + DynamoDB lock table + shared ECR repository, then write the values into backend.hcl.",
|
|
@@ -618,12 +521,12 @@ var iacBootstrapCommand = {
|
|
|
618
521
|
process.stderr.write("\n \u2717 Bootstrap outputs `state_bucket` / `lock_table` not found.\n\n");
|
|
619
522
|
process.exit(1);
|
|
620
523
|
}
|
|
621
|
-
const backendHclPath =
|
|
524
|
+
const backendHclPath = path5.join(projectRoot, TF_DIR, "environments", env, "backend.hcl");
|
|
622
525
|
try {
|
|
623
526
|
let hcl = readFileSync4(backendHclPath, "utf8");
|
|
624
527
|
hcl = hcl.replace(/^bucket\s*=\s*".*"$/m, `bucket = "${stateBucket}"`);
|
|
625
528
|
hcl = hcl.replace(/^dynamodb_table\s*=\s*".*"$/m, `dynamodb_table = "${lockTable}"`);
|
|
626
|
-
|
|
529
|
+
writeFileSync(backendHclPath, hcl);
|
|
627
530
|
} catch {
|
|
628
531
|
process.stderr.write(`
|
|
629
532
|
\u2717 Could not update ${backendHclPath}.
|
|
@@ -646,9 +549,9 @@ var iacBootstrapCommand = {
|
|
|
646
549
|
};
|
|
647
550
|
|
|
648
551
|
// src/commands/iac/providers/aws-ecs/lib/images.ts
|
|
649
|
-
import { spawnSync as
|
|
650
|
-
import { readFileSync as readFileSync5, writeFileSync as
|
|
651
|
-
import
|
|
552
|
+
import { spawnSync as spawnSync6 } from "child_process";
|
|
553
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
|
|
554
|
+
import path6 from "pathe";
|
|
652
555
|
var tagArg = {
|
|
653
556
|
tag: {
|
|
654
557
|
type: "string",
|
|
@@ -734,7 +637,7 @@ function dockerLogin(host, region, projectRoot, profile) {
|
|
|
734
637
|
process.stderr.write("\n \u2717 Could not obtain an ECR login password (check your AWS auth).\n\n");
|
|
735
638
|
return 1;
|
|
736
639
|
}
|
|
737
|
-
const r =
|
|
640
|
+
const r = spawnSync6("docker", ["login", "--username", "AWS", "--password-stdin", host], {
|
|
738
641
|
cwd: projectRoot,
|
|
739
642
|
input: pw.stdout.trim(),
|
|
740
643
|
stdio: ["pipe", "inherit", "inherit"],
|
|
@@ -782,7 +685,7 @@ function doPush(projectRoot, profile, tag, target) {
|
|
|
782
685
|
return run2("docker", ["push", `${target.image.repository}:${tag}`], projectRoot, profile);
|
|
783
686
|
}
|
|
784
687
|
function doDeploy(projectRoot, profile, env, tag, target) {
|
|
785
|
-
const tfvarsPath =
|
|
688
|
+
const tfvarsPath = path6.join(projectRoot, TF_DIR, "environments", env, "terraform.tfvars");
|
|
786
689
|
try {
|
|
787
690
|
let tfvars = readFileSync5(tfvarsPath, "utf8");
|
|
788
691
|
if (/^\s*image_tag\s*=/m.test(tfvars)) {
|
|
@@ -792,7 +695,7 @@ function doDeploy(projectRoot, profile, env, tag, target) {
|
|
|
792
695
|
image_tag = "${tag}"
|
|
793
696
|
`;
|
|
794
697
|
}
|
|
795
|
-
|
|
698
|
+
writeFileSync2(tfvarsPath, tfvars);
|
|
796
699
|
} catch {
|
|
797
700
|
process.stderr.write(`
|
|
798
701
|
\u2717 Could not update ${tfvarsPath}.
|
|
@@ -1286,10 +1189,10 @@ var iacLoginCommand = {
|
|
|
1286
1189
|
};
|
|
1287
1190
|
|
|
1288
1191
|
// src/commands/iac/providers/aws-ecs/commands/logs/index.ts
|
|
1289
|
-
import { spawnSync as
|
|
1192
|
+
import { spawnSync as spawnSync7 } from "child_process";
|
|
1290
1193
|
var SERVICES = ["backend", "frontend", "websocket", "worker", "scheduler"];
|
|
1291
1194
|
function awsCliMajorVersion() {
|
|
1292
|
-
const r =
|
|
1195
|
+
const r = spawnSync7("aws", ["--version"], { encoding: "utf8" });
|
|
1293
1196
|
const m = /aws-cli\/(\d+)\./.exec(`${r.stdout ?? ""}${r.stderr ?? ""}`);
|
|
1294
1197
|
return m ? Number(m[1]) : void 0;
|
|
1295
1198
|
}
|
|
@@ -1378,8 +1281,8 @@ var iacMigrateCommand = {
|
|
|
1378
1281
|
};
|
|
1379
1282
|
|
|
1380
1283
|
// src/commands/iac/providers/aws-ecs/commands/new-env/index.ts
|
|
1381
|
-
import { cpSync, readFileSync as readFileSync6, writeFileSync as
|
|
1382
|
-
import
|
|
1284
|
+
import { cpSync, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
|
|
1285
|
+
import path7 from "pathe";
|
|
1383
1286
|
var iacNewEnvCommand = {
|
|
1384
1287
|
available: hasIac,
|
|
1385
1288
|
description: "Scaffold a new environment (iac/terraform/environments/<name>) by copying an existing one.",
|
|
@@ -1430,16 +1333,16 @@ var iacNewEnvCommand = {
|
|
|
1430
1333
|
`);
|
|
1431
1334
|
process.exit(1);
|
|
1432
1335
|
}
|
|
1433
|
-
const base =
|
|
1434
|
-
const dst =
|
|
1435
|
-
cpSync(
|
|
1436
|
-
const tfvarsPath =
|
|
1437
|
-
|
|
1336
|
+
const base = path7.join(projectRoot, TF_ENVIRONMENTS_DIR);
|
|
1337
|
+
const dst = path7.join(base, name);
|
|
1338
|
+
cpSync(path7.join(base, from), dst, { recursive: true });
|
|
1339
|
+
const tfvarsPath = path7.join(dst, "terraform.tfvars");
|
|
1340
|
+
writeFileSync3(
|
|
1438
1341
|
tfvarsPath,
|
|
1439
1342
|
readFileSync6(tfvarsPath, "utf8").replace(/^(\s*environment\s*=\s*).*$/m, `$1"${name}"`)
|
|
1440
1343
|
);
|
|
1441
|
-
const backendPath =
|
|
1442
|
-
|
|
1344
|
+
const backendPath = path7.join(dst, "backend.hcl");
|
|
1345
|
+
writeFileSync3(
|
|
1443
1346
|
backendPath,
|
|
1444
1347
|
readFileSync6(backendPath, "utf8").replace(
|
|
1445
1348
|
/^(\s*key\s*=\s*).*$/m,
|
|
@@ -1510,7 +1413,7 @@ var iacPushCommand = {
|
|
|
1510
1413
|
};
|
|
1511
1414
|
|
|
1512
1415
|
// src/commands/iac/providers/aws-ecs/commands/shell/index.ts
|
|
1513
|
-
import { spawnSync as
|
|
1416
|
+
import { spawnSync as spawnSync8 } from "child_process";
|
|
1514
1417
|
var iacShellCommand = {
|
|
1515
1418
|
available: hasIac,
|
|
1516
1419
|
description: "Open an interactive shell in the IaC runner container (terraform, aws) scoped to an environment.",
|
|
@@ -1542,7 +1445,7 @@ var iacShellCommand = {
|
|
|
1542
1445
|
|
|
1543
1446
|
`
|
|
1544
1447
|
);
|
|
1545
|
-
const r =
|
|
1448
|
+
const r = spawnSync8("docker", dockerShellArgs(projectRoot, profile), {
|
|
1546
1449
|
stdio: "inherit",
|
|
1547
1450
|
cwd: projectRoot
|
|
1548
1451
|
});
|
|
@@ -1769,7 +1672,7 @@ var reviewCommand = {
|
|
|
1769
1672
|
};
|
|
1770
1673
|
|
|
1771
1674
|
// src/commands/shell/index.ts
|
|
1772
|
-
import { spawnSync as
|
|
1675
|
+
import { spawnSync as spawnSync9 } from "child_process";
|
|
1773
1676
|
var shellCommand = {
|
|
1774
1677
|
description: "Open an interactive shell in a service container (default: bench, inside the frappe-bench directory).",
|
|
1775
1678
|
args: {
|
|
@@ -1785,7 +1688,7 @@ var shellCommand = {
|
|
|
1785
1688
|
dc(["exec", "-w", "/home/frappe/frappe-bench", "bench", "/bin/bash"]);
|
|
1786
1689
|
return;
|
|
1787
1690
|
}
|
|
1788
|
-
const bash =
|
|
1691
|
+
const bash = spawnSync9("docker", ["compose", "exec", svc, "/bin/bash"], { stdio: "inherit" });
|
|
1789
1692
|
if (bash.status !== 0) {
|
|
1790
1693
|
dc(["exec", svc, "/bin/sh"]);
|
|
1791
1694
|
} else {
|
|
@@ -1901,6 +1804,26 @@ var src_default = defineStack({
|
|
|
1901
1804
|
default: "none"
|
|
1902
1805
|
}
|
|
1903
1806
|
],
|
|
1807
|
+
docs: {
|
|
1808
|
+
tagline: "A Frappe Framework ticketing system (Frappe Helpdesk) with a worked custom-app example and optional AWS ECS Fargate IaC.",
|
|
1809
|
+
useCases: [
|
|
1810
|
+
"A ticketing/helpdesk system running Frappe Helpdesk out of the box",
|
|
1811
|
+
"A team learning Frappe's core building blocks via a worked custom-app example",
|
|
1812
|
+
"A DocType/workflow-driven backend with a straightforward path to AWS ECS Fargate"
|
|
1813
|
+
],
|
|
1814
|
+
technologies: ["Frappe Framework", "Frappe Helpdesk", "MariaDB"],
|
|
1815
|
+
iac: { provider: "aws-ecs", flag: "--iac aws-ecs" },
|
|
1816
|
+
pages: [
|
|
1817
|
+
{ file: "index.md", title: "Home" },
|
|
1818
|
+
{ file: "frappe.md", title: "Frappe core concepts" },
|
|
1819
|
+
{ file: "extending.md", title: "Extending the app" },
|
|
1820
|
+
{ file: "dude.md", title: "Working with dude" },
|
|
1821
|
+
{ file: "api.md", title: "Command reference" },
|
|
1822
|
+
{ file: "cheatsheet.md", title: "Cheatsheet" },
|
|
1823
|
+
{ file: "mkdocs.md", title: "Writing docs" },
|
|
1824
|
+
{ file: "deploy.md", title: "Deploy (AWS ECS)", when: "withIac" }
|
|
1825
|
+
]
|
|
1826
|
+
},
|
|
1904
1827
|
async scaffold(ctx) {
|
|
1905
1828
|
const { answers, dest, stackRoot, dudeVersion, stackVersion } = ctx;
|
|
1906
1829
|
const withHelpdesk = answers.helpdesk !== false;
|
|
@@ -1912,10 +1835,10 @@ var src_default = defineStack({
|
|
|
1912
1835
|
dudeVersion,
|
|
1913
1836
|
stackVersion
|
|
1914
1837
|
};
|
|
1915
|
-
const templates =
|
|
1916
|
-
await renderTemplateTree({ src:
|
|
1838
|
+
const templates = path8.join(stackRoot, "templates");
|
|
1839
|
+
await renderTemplateTree({ src: path8.join(templates, "base"), dest, data });
|
|
1917
1840
|
if (withIac) {
|
|
1918
|
-
await renderTemplateTree({ src:
|
|
1841
|
+
await renderTemplateTree({ src: path8.join(templates, "aws-ecs"), dest, data });
|
|
1919
1842
|
}
|
|
1920
1843
|
},
|
|
1921
1844
|
hooks: {
|
|
@@ -1957,6 +1880,7 @@ var src_default = defineStack({
|
|
|
1957
1880
|
},
|
|
1958
1881
|
rules: [],
|
|
1959
1882
|
commands: {
|
|
1883
|
+
cheatsheet: defineCheatsheetCommand(),
|
|
1960
1884
|
up: upCommand,
|
|
1961
1885
|
down: downCommand,
|
|
1962
1886
|
logs: logsCommand,
|
|
@@ -1966,7 +1890,7 @@ var src_default = defineStack({
|
|
|
1966
1890
|
format: formatCommand,
|
|
1967
1891
|
review: reviewCommand,
|
|
1968
1892
|
test: testCommand,
|
|
1969
|
-
docs:
|
|
1893
|
+
docs: defineDocsCommand(),
|
|
1970
1894
|
site: {
|
|
1971
1895
|
migrate: migrateCommand,
|
|
1972
1896
|
console: consoleCommand,
|