sticky-note-cli 3.1.43 → 3.1.44
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/bin/cli.js +36 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -744,6 +744,29 @@ async function cmdInit() {
|
|
|
744
744
|
v3Mode ? "y" : "N"
|
|
745
745
|
);
|
|
746
746
|
wantsCloud = cloudAnswer.toLowerCase() === "y" || cloudAnswer.toLowerCase() === "yes";
|
|
747
|
+
|
|
748
|
+
// Always ask for STICKY_PUSH_TOKEN — needed for data branch push from hook
|
|
749
|
+
// processes regardless of whether cloud backend is configured.
|
|
750
|
+
print("\n A GitHub Personal Access Token (PAT) is needed so sticky-note can push");
|
|
751
|
+
print(" thread data in the background without requiring interactive credential access.");
|
|
752
|
+
print(" Create one at https://github.com/settings/tokens with 'repo' scope (or");
|
|
753
|
+
print(" 'contents: write' for fine-grained tokens).");
|
|
754
|
+
const pushTokenAnswer = await ask(rl, "Enter your STICKY_PUSH_TOKEN (GitHub PAT, leave blank to skip)", "");
|
|
755
|
+
if (pushTokenAnswer.trim()) {
|
|
756
|
+
const envStickyPath = path.join(process.cwd(), ".env.sticky");
|
|
757
|
+
let envContent = "";
|
|
758
|
+
try { envContent = fs.readFileSync(envStickyPath, "utf-8"); } catch (_) {}
|
|
759
|
+
if (!envContent.endsWith("\n") && envContent.length > 0) envContent += "\n";
|
|
760
|
+
if (!/^STICKY_PUSH_TOKEN=/m.test(envContent)) {
|
|
761
|
+
envContent += `STICKY_PUSH_TOKEN=${pushTokenAnswer.trim()}\n`;
|
|
762
|
+
} else {
|
|
763
|
+
envContent = envContent.replace(/^STICKY_PUSH_TOKEN=.+$/m, `STICKY_PUSH_TOKEN=${pushTokenAnswer.trim()}`);
|
|
764
|
+
}
|
|
765
|
+
fs.writeFileSync(envStickyPath, envContent, "utf-8");
|
|
766
|
+
print(" [OK] STICKY_PUSH_TOKEN written to .env.sticky");
|
|
767
|
+
} else {
|
|
768
|
+
print(" ⏭️ No PAT entered — data branch push will rely on system credential helper");
|
|
769
|
+
}
|
|
747
770
|
}
|
|
748
771
|
|
|
749
772
|
rl.close();
|
|
@@ -877,6 +900,19 @@ async function cmdInit() {
|
|
|
877
900
|
print(` wrangler secret put GITHUB_REPO # value: ${repo.trim()}`);
|
|
878
901
|
}
|
|
879
902
|
}
|
|
903
|
+
// Also write STICKY_PUSH_TOKEN to .env.sticky so session-end hook can
|
|
904
|
+
// push the data branch from background processes without a credential helper.
|
|
905
|
+
try {
|
|
906
|
+
const envStickyPath = path.join(process.cwd(), ".env.sticky");
|
|
907
|
+
let envContent = "";
|
|
908
|
+
try { envContent = fs.readFileSync(envStickyPath, "utf-8"); } catch (_) {}
|
|
909
|
+
if (!envContent.endsWith("\n") && envContent.length > 0) envContent += "\n";
|
|
910
|
+
if (!/^STICKY_PUSH_TOKEN=/m.test(envContent)) {
|
|
911
|
+
envContent += `STICKY_PUSH_TOKEN=${pat.trim()}\n`;
|
|
912
|
+
fs.writeFileSync(envStickyPath, envContent, "utf-8");
|
|
913
|
+
print(" ✓ STICKY_PUSH_TOKEN written to .env.sticky (data branch push)");
|
|
914
|
+
}
|
|
915
|
+
} catch (_) {}
|
|
880
916
|
}
|
|
881
917
|
rl2.close();
|
|
882
918
|
|