@zebralabs/context-cli 0.1.5 → 0.1.6
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/src/context.js +29 -1
package/package.json
CHANGED
package/src/context.js
CHANGED
|
@@ -520,6 +520,31 @@ function ensureDir(p) {
|
|
|
520
520
|
fs.mkdirSync(p, { recursive: true });
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
+
/**
|
|
524
|
+
* After pack install: ensure docs/local/ exists and .gitignore has /docs/local/
|
|
525
|
+
* (create .gitignore if missing; append entry if present but pattern not found).
|
|
526
|
+
*/
|
|
527
|
+
function ensureDocsLocalAndGitignore(repoRoot) {
|
|
528
|
+
const docsLocalDir = path.join(repoRoot, "docs", "local");
|
|
529
|
+
ensureDir(docsLocalDir);
|
|
530
|
+
|
|
531
|
+
const gitignorePath = path.join(repoRoot, ".gitignore");
|
|
532
|
+
const entry = "\n# Local-only documentation (excluded from AI context and version control)\n/docs/local/\n";
|
|
533
|
+
const pattern = "/docs/local/";
|
|
534
|
+
|
|
535
|
+
if (!fs.existsSync(gitignorePath)) {
|
|
536
|
+
fs.writeFileSync(gitignorePath, entry.trimStart(), "utf8");
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const content = fs.readFileSync(gitignorePath, "utf8");
|
|
541
|
+
if (content.includes(pattern) || content.includes("docs/local/")) return;
|
|
542
|
+
|
|
543
|
+
const trimmed = content.trimEnd();
|
|
544
|
+
const suffix = trimmed.endsWith("\n") ? entry : "\n" + entry;
|
|
545
|
+
fs.writeFileSync(gitignorePath, trimmed + suffix, "utf8");
|
|
546
|
+
}
|
|
547
|
+
|
|
523
548
|
function writeYamlFile(filePath, obj) {
|
|
524
549
|
const text = YAML.stringify(obj, { indent: 2 });
|
|
525
550
|
fs.writeFileSync(filePath, text.endsWith("\n") ? text : (text + "\n"), "utf8");
|
|
@@ -717,6 +742,9 @@ async function cmdPackInstall(repoRoot, packId, opts) {
|
|
|
717
742
|
const installCmd = `& "${installer}" -TargetRoot "${repoRoot}" -PackId "${packId}" -Mode "${mode}"`;
|
|
718
743
|
runPwsh(installCmd, { cwd: extractDir });
|
|
719
744
|
|
|
745
|
+
// Ensure docs/local/ exists and .gitignore has /docs/local/
|
|
746
|
+
ensureDocsLocalAndGitignore(repoRoot);
|
|
747
|
+
|
|
720
748
|
// Update context.yaml (safe read + repair)
|
|
721
749
|
let ctx2 = readYamlFileSafe(ctxPath);
|
|
722
750
|
if (!ctx2) {
|
|
@@ -772,7 +800,7 @@ async function main() {
|
|
|
772
800
|
|
|
773
801
|
if (cmd === "--version" || cmd === "-v" || cmd === "version") {
|
|
774
802
|
// Make sure package.json has version (or hardcode a constant)
|
|
775
|
-
console.log("0.1.
|
|
803
|
+
console.log("0.1.6");
|
|
776
804
|
return;
|
|
777
805
|
}
|
|
778
806
|
|