@keepgoingdev/cli 0.3.1 → 0.3.3
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/README.md +4 -4
- package/dist/index.js +42 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @keepgoingdev/cli
|
|
2
2
|
|
|
3
3
|
Terminal CLI for [KeepGoing](https://keepgoing.dev) — resume side projects without the mental friction.
|
|
4
4
|
|
|
@@ -6,13 +6,13 @@ Terminal CLI for [KeepGoing](https://keepgoing.dev) — resume side projects wit
|
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
# Run without installing
|
|
9
|
-
npx @
|
|
9
|
+
npx @keepgoingdev/cli status
|
|
10
10
|
|
|
11
11
|
# Install globally
|
|
12
|
-
npm install -g @
|
|
12
|
+
npm install -g @keepgoingdev/cli
|
|
13
13
|
|
|
14
14
|
# Or add to a project
|
|
15
|
-
npm install --save-dev @
|
|
15
|
+
npm install --save-dev @keepgoingdev/cli
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Commands
|
package/dist/index.js
CHANGED
|
@@ -632,7 +632,7 @@ import { spawn } from "child_process";
|
|
|
632
632
|
import { readFileSync, existsSync } from "fs";
|
|
633
633
|
import path6 from "path";
|
|
634
634
|
import os2 from "os";
|
|
635
|
-
var CLI_VERSION = "0.3.
|
|
635
|
+
var CLI_VERSION = "0.3.3";
|
|
636
636
|
var NPM_REGISTRY_URL = "https://registry.npmjs.org/@keepgoingdev/cli/latest";
|
|
637
637
|
var FETCH_TIMEOUT_MS = 5e3;
|
|
638
638
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -654,7 +654,7 @@ function getCachedUpdateInfo() {
|
|
|
654
654
|
const cache = JSON.parse(raw);
|
|
655
655
|
if (!cache.latest || !cache.checkedAt) return null;
|
|
656
656
|
const age = Date.now() - new Date(cache.checkedAt).getTime();
|
|
657
|
-
if (age > CHECK_INTERVAL_MS) return null;
|
|
657
|
+
if (age > CHECK_INTERVAL_MS || cache.current !== CLI_VERSION) return null;
|
|
658
658
|
return {
|
|
659
659
|
current: CLI_VERSION,
|
|
660
660
|
latest: cache.latest,
|
|
@@ -670,7 +670,7 @@ function spawnBackgroundCheck() {
|
|
|
670
670
|
const raw = readFileSync(CACHE_PATH, "utf-8");
|
|
671
671
|
const cache = JSON.parse(raw);
|
|
672
672
|
const age = Date.now() - new Date(cache.checkedAt).getTime();
|
|
673
|
-
if (age < CHECK_INTERVAL_MS) return;
|
|
673
|
+
if (age < CHECK_INTERVAL_MS && cache.current === CLI_VERSION) return;
|
|
674
674
|
}
|
|
675
675
|
} catch {
|
|
676
676
|
}
|
|
@@ -807,6 +807,7 @@ async function saveCommand(opts) {
|
|
|
807
807
|
import fs5 from "fs";
|
|
808
808
|
import path8 from "path";
|
|
809
809
|
import os3 from "os";
|
|
810
|
+
import { execSync } from "child_process";
|
|
810
811
|
var HOOK_MARKER_START = "# keepgoing-hook-start";
|
|
811
812
|
var HOOK_MARKER_END = "# keepgoing-hook-end";
|
|
812
813
|
var ZSH_HOOK = `${HOOK_MARKER_START}
|
|
@@ -840,23 +841,43 @@ if command -v keepgoing >/dev/null 2>&1
|
|
|
840
841
|
end
|
|
841
842
|
end
|
|
842
843
|
${HOOK_MARKER_END}`;
|
|
843
|
-
function detectShellRcFile() {
|
|
844
|
-
const shellEnv = process.env["SHELL"] ?? "";
|
|
844
|
+
function detectShellRcFile(shellOverride) {
|
|
845
845
|
const home = os3.homedir();
|
|
846
|
-
|
|
846
|
+
let shell;
|
|
847
|
+
if (shellOverride) {
|
|
848
|
+
shell = shellOverride.toLowerCase();
|
|
849
|
+
} else {
|
|
850
|
+
try {
|
|
851
|
+
const parentComm = execSync(`ps -o comm= -p ${process.ppid}`, {
|
|
852
|
+
encoding: "utf-8",
|
|
853
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
854
|
+
}).trim();
|
|
855
|
+
if (parentComm.includes("fish")) shell = "fish";
|
|
856
|
+
else if (parentComm.includes("zsh")) shell = "zsh";
|
|
857
|
+
else if (parentComm.includes("bash")) shell = "bash";
|
|
858
|
+
} catch {
|
|
859
|
+
}
|
|
860
|
+
if (!shell) {
|
|
861
|
+
const shellEnv = process.env["SHELL"] ?? "";
|
|
862
|
+
if (shellEnv.endsWith("fish")) shell = "fish";
|
|
863
|
+
else if (shellEnv.endsWith("zsh")) shell = "zsh";
|
|
864
|
+
else if (shellEnv.endsWith("bash")) shell = "bash";
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
if (shell === "zsh") {
|
|
847
868
|
return { shell: "zsh", rcFile: path8.join(home, ".zshrc") };
|
|
848
869
|
}
|
|
849
|
-
if (
|
|
870
|
+
if (shell === "bash") {
|
|
850
871
|
return { shell: "bash", rcFile: path8.join(home, ".bashrc") };
|
|
851
872
|
}
|
|
852
|
-
if (
|
|
873
|
+
if (shell === "fish") {
|
|
853
874
|
const xdgConfig = process.env["XDG_CONFIG_HOME"] || path8.join(home, ".config");
|
|
854
875
|
return { shell: "fish", rcFile: path8.join(xdgConfig, "fish", "config.fish") };
|
|
855
876
|
}
|
|
856
877
|
return void 0;
|
|
857
878
|
}
|
|
858
|
-
function hookInstallCommand() {
|
|
859
|
-
const detected = detectShellRcFile();
|
|
879
|
+
function hookInstallCommand(shellOverride) {
|
|
880
|
+
const detected = detectShellRcFile(shellOverride);
|
|
860
881
|
if (!detected) {
|
|
861
882
|
console.error(
|
|
862
883
|
'Could not detect your shell. Set $SHELL to "zsh", "bash", or "fish" and try again.'
|
|
@@ -882,8 +903,8 @@ ${hookBlock}
|
|
|
882
903
|
`);
|
|
883
904
|
console.log(` source ${rcFile}`);
|
|
884
905
|
}
|
|
885
|
-
function hookUninstallCommand() {
|
|
886
|
-
const detected = detectShellRcFile();
|
|
906
|
+
function hookUninstallCommand(shellOverride) {
|
|
907
|
+
const detected = detectShellRcFile(shellOverride);
|
|
887
908
|
if (!detected) {
|
|
888
909
|
console.error(
|
|
889
910
|
'Could not detect your shell. Set $SHELL to "zsh", "bash", or "fish" and try again.'
|
|
@@ -1021,6 +1042,7 @@ Options:
|
|
|
1021
1042
|
--cwd <path> Override the working directory (default: current directory)
|
|
1022
1043
|
--json Output raw JSON (status only)
|
|
1023
1044
|
--quiet Output a single summary line (status only)
|
|
1045
|
+
--shell <name> Override shell detection (zsh, bash, fish) for hook commands
|
|
1024
1046
|
-v, --version Show the CLI version
|
|
1025
1047
|
-h, --help Show this help text
|
|
1026
1048
|
|
|
@@ -1035,10 +1057,13 @@ function parseArgs(argv) {
|
|
|
1035
1057
|
let cwd = process.cwd();
|
|
1036
1058
|
let json = false;
|
|
1037
1059
|
let quiet = false;
|
|
1060
|
+
let shell = "";
|
|
1038
1061
|
for (let i = 0; i < args.length; i++) {
|
|
1039
1062
|
const arg = args[i];
|
|
1040
1063
|
if (arg === "--cwd" && i + 1 < args.length) {
|
|
1041
1064
|
cwd = args[++i];
|
|
1065
|
+
} else if (arg === "--shell" && i + 1 < args.length) {
|
|
1066
|
+
shell = args[++i];
|
|
1042
1067
|
} else if (arg === "--json") {
|
|
1043
1068
|
json = true;
|
|
1044
1069
|
} else if (arg === "--quiet") {
|
|
@@ -1054,10 +1079,10 @@ function parseArgs(argv) {
|
|
|
1054
1079
|
}
|
|
1055
1080
|
}
|
|
1056
1081
|
cwd = findGitRoot(cwd);
|
|
1057
|
-
return { command, subcommand, cwd, json, quiet };
|
|
1082
|
+
return { command, subcommand, cwd, json, quiet, shell };
|
|
1058
1083
|
}
|
|
1059
1084
|
async function main() {
|
|
1060
|
-
const { command, subcommand, cwd, json, quiet } = parseArgs(process.argv);
|
|
1085
|
+
const { command, subcommand, cwd, json, quiet, shell } = parseArgs(process.argv);
|
|
1061
1086
|
switch (command) {
|
|
1062
1087
|
case "status":
|
|
1063
1088
|
await statusCommand({ cwd, json, quiet });
|
|
@@ -1067,9 +1092,9 @@ async function main() {
|
|
|
1067
1092
|
break;
|
|
1068
1093
|
case "hook":
|
|
1069
1094
|
if (subcommand === "install") {
|
|
1070
|
-
hookInstallCommand();
|
|
1095
|
+
hookInstallCommand(shell || void 0);
|
|
1071
1096
|
} else if (subcommand === "uninstall") {
|
|
1072
|
-
hookUninstallCommand();
|
|
1097
|
+
hookUninstallCommand(shell || void 0);
|
|
1073
1098
|
} else {
|
|
1074
1099
|
console.error(
|
|
1075
1100
|
`Unknown hook subcommand: "${subcommand}". Use "install" or "uninstall".`
|
|
@@ -1078,7 +1103,7 @@ async function main() {
|
|
|
1078
1103
|
}
|
|
1079
1104
|
break;
|
|
1080
1105
|
case "version":
|
|
1081
|
-
console.log(`keepgoing v${"0.3.
|
|
1106
|
+
console.log(`keepgoing v${"0.3.3"}`);
|
|
1082
1107
|
break;
|
|
1083
1108
|
case "activate":
|
|
1084
1109
|
await activateCommand({ licenseKey: subcommand });
|