seclaw 0.1.13 → 0.1.14
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/cli.js +4 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1441,7 +1441,6 @@ function getTemplatePath(template, targetDir) {
|
|
|
1441
1441
|
import { resolve as resolve6 } from "path";
|
|
1442
1442
|
import { existsSync as existsSync6 } from "fs";
|
|
1443
1443
|
import { writeFile as writeFile3, mkdir as mkdir3, readFile as readFile3, cp as cp3 } from "fs/promises";
|
|
1444
|
-
import { execSync } from "child_process";
|
|
1445
1444
|
import * as p3 from "@clack/prompts";
|
|
1446
1445
|
import pc3 from "picocolors";
|
|
1447
1446
|
var API_URL = process.env.SECLAW_API || "https://seclawai.com";
|
|
@@ -1450,8 +1449,9 @@ async function add(template, options) {
|
|
|
1450
1449
|
p3.intro(`${pc3.bgCyan(pc3.black(" seclaw "))} Adding template: ${template}`);
|
|
1451
1450
|
const isFree = FREE_TEMPLATES.includes(template);
|
|
1452
1451
|
const s = p3.spinner();
|
|
1452
|
+
const projectDir = findProjectDir() || process.cwd();
|
|
1453
1453
|
const monorepoTemplatesDir = resolve6(import.meta.dirname, "..", "..", "templates", "paid");
|
|
1454
|
-
const templateDir = !isFree && existsSync6(resolve6(import.meta.dirname, "..", "..", "templates")) ? resolve6(monorepoTemplatesDir, template) : resolve6(
|
|
1454
|
+
const templateDir = !isFree && existsSync6(resolve6(import.meta.dirname, "..", "..", "templates")) ? resolve6(monorepoTemplatesDir, template) : resolve6(projectDir, "templates", template);
|
|
1455
1455
|
if (isFree) {
|
|
1456
1456
|
s.start("Setting up free template...");
|
|
1457
1457
|
const bundledPath = resolve6(
|
|
@@ -1512,17 +1512,6 @@ async function add(template, options) {
|
|
|
1512
1512
|
await writeFile3(resolve6(templateDir, filename), content);
|
|
1513
1513
|
}
|
|
1514
1514
|
s.stop(`${Object.keys(data.files).length} files written to ${pc3.dim(templateDir)}`);
|
|
1515
|
-
const cliDir = resolve6(import.meta.dirname, "..");
|
|
1516
|
-
const cliPkgPath = resolve6(cliDir, "package.json");
|
|
1517
|
-
if (existsSync6(cliPkgPath)) {
|
|
1518
|
-
s.start("Rebuilding CLI...");
|
|
1519
|
-
try {
|
|
1520
|
-
execSync("pnpm build", { cwd: cliDir, stdio: "pipe" });
|
|
1521
|
-
s.stop("CLI rebuilt with new template.");
|
|
1522
|
-
} catch {
|
|
1523
|
-
s.stop("CLI rebuild failed \u2014 run `pnpm build` manually.");
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
1515
|
} catch (err) {
|
|
1527
1516
|
s.stop("Failed.");
|
|
1528
1517
|
p3.log.error(`Network error: ${err}`);
|
|
@@ -1532,12 +1521,12 @@ async function add(template, options) {
|
|
|
1532
1521
|
}
|
|
1533
1522
|
let wsHostPath = "shared";
|
|
1534
1523
|
try {
|
|
1535
|
-
const envContent = await readFile3(resolve6(
|
|
1524
|
+
const envContent = await readFile3(resolve6(projectDir, ".env"), "utf-8");
|
|
1536
1525
|
const wsMatch = envContent.match(/WORKSPACE_HOST_PATH=(.+)/);
|
|
1537
1526
|
if (wsMatch?.[1]?.trim()) wsHostPath = wsMatch[1].trim();
|
|
1538
1527
|
} catch {
|
|
1539
1528
|
}
|
|
1540
|
-
const configDir = resolve6(
|
|
1529
|
+
const configDir = resolve6(projectDir, wsHostPath, "config");
|
|
1541
1530
|
if (existsSync6(configDir)) {
|
|
1542
1531
|
const capDir = resolve6(configDir, "capabilities", template);
|
|
1543
1532
|
await mkdir3(capDir, { recursive: true });
|