opencode-hub 1.0.1 → 1.0.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/README.md +7 -1
- package/oc-tui.js +22 -5
- package/package.json +29 -29
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# opencode-hub
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/opencode-hub)
|
|
5
|
+
[](https://www.npmjs.com/package/opencode-hub)
|
|
6
|
+
[](https://github.com/intisy/opencode-hub/actions/workflows/publish.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
3
9
|
TUI launcher and `oc` shell command for [OpenCode](https://github.com/sst/opencode).
|
|
4
10
|
|
|
5
11
|
When loaded as an OpenCode plugin, it installs the `oc` command into your shell. Running `oc` opens an interactive TUI for switching between projects and managing plugins.
|
|
@@ -116,4 +122,4 @@ oc myproject # Open first project matching "myproject"
|
|
|
116
122
|
## License
|
|
117
123
|
|
|
118
124
|
MIT
|
|
119
|
-
|
|
125
|
+
|
package/oc-tui.js
CHANGED
|
@@ -9,11 +9,12 @@ var HOME = homedir();
|
|
|
9
9
|
var CONFIG_DIR = join(HOME, ".config", "opencode");
|
|
10
10
|
var DB_PATH = join(HOME, ".local", "share", "opencode", "opencode.db");
|
|
11
11
|
var CONFIG_FOLDER = join(CONFIG_DIR, "config");
|
|
12
|
+
var CACHE_DIR = join(CONFIG_DIR, "cache");
|
|
12
13
|
var CONFIG_PATH = join(CONFIG_FOLDER, "oc-config.json");
|
|
13
|
-
var UPDATE_CHECK_PATH = join(
|
|
14
|
+
var UPDATE_CHECK_PATH = join(CACHE_DIR, "oc-last-update-check");
|
|
14
15
|
var PLUGINS_JSON = join(CONFIG_FOLDER, "plugins.json");
|
|
15
16
|
var REPOS_DIR = join(CONFIG_DIR, "repos");
|
|
16
|
-
var PLUGINS_DIR = join(CONFIG_DIR, "
|
|
17
|
+
var PLUGINS_DIR = join(CONFIG_DIR, "plugin");
|
|
17
18
|
|
|
18
19
|
// ---------------------------------------------------------------------------
|
|
19
20
|
// Folder name helper: <creator>/<repo-name> to avoid collisions
|
|
@@ -49,12 +50,19 @@ migrateConfigs();
|
|
|
49
50
|
|
|
50
51
|
function checkForUpdates() {
|
|
51
52
|
try {
|
|
53
|
+
var legacyCheck = join(CONFIG_DIR, "oc-last-update-check");
|
|
54
|
+
if (!existsSync(UPDATE_CHECK_PATH) && existsSync(legacyCheck)) {
|
|
55
|
+
try {
|
|
56
|
+
if (!existsSync(CACHE_DIR)) mkdirSync(CACHE_DIR, { recursive: true });
|
|
57
|
+
copyFileSync(legacyCheck, UPDATE_CHECK_PATH);
|
|
58
|
+
} catch {}
|
|
59
|
+
}
|
|
52
60
|
if (existsSync(UPDATE_CHECK_PATH)) {
|
|
53
61
|
var lastCheck = parseInt(readFileSync(UPDATE_CHECK_PATH, "utf-8").trim(), 10);
|
|
54
62
|
if (Date.now() - lastCheck < 86400000) return;
|
|
55
63
|
}
|
|
56
64
|
|
|
57
|
-
if (!existsSync(
|
|
65
|
+
if (!existsSync(CACHE_DIR)) mkdirSync(CACHE_DIR, { recursive: true });
|
|
58
66
|
writeFileSync(UPDATE_CHECK_PATH, String(Date.now()));
|
|
59
67
|
|
|
60
68
|
var installed = execSync("opencode --version", { encoding: "utf-8", timeout: 10000 }).trim();
|
|
@@ -252,11 +260,20 @@ function runPluginUpdate(pluginItem) {
|
|
|
252
260
|
var parentDir = dirname(dir);
|
|
253
261
|
if (!existsSync(parentDir)) try { mkdirSync(parentDir, { recursive: true }); } catch {}
|
|
254
262
|
try {
|
|
255
|
-
|
|
263
|
+
var cloneCmd = "git clone " + repo.url + (repo.branch ? " --branch " + repo.branch : "") + " " + folderName;
|
|
264
|
+
execSync(cloneCmd, { cwd: REPOS_DIR, timeout: 60000, stdio: "ignore" });
|
|
256
265
|
} catch (e) { return "Clone failed: " + (e.message || e); }
|
|
257
266
|
}
|
|
258
267
|
|
|
259
|
-
try {
|
|
268
|
+
try {
|
|
269
|
+
if (repo.branch) {
|
|
270
|
+
execSync("git fetch origin", { cwd: dir, timeout: 30000, stdio: "ignore" });
|
|
271
|
+
execSync("git checkout " + repo.branch, { cwd: dir, timeout: 10000, stdio: "ignore" });
|
|
272
|
+
execSync("git pull --ff-only origin " + repo.branch, { cwd: dir, timeout: 30000, stdio: "ignore" });
|
|
273
|
+
} else {
|
|
274
|
+
execSync("git pull --ff-only", { cwd: dir, timeout: 30000, stdio: "ignore" });
|
|
275
|
+
}
|
|
276
|
+
} catch {}
|
|
260
277
|
|
|
261
278
|
if (repo.install) {
|
|
262
279
|
try { execSync(repo.install.join(" "), { cwd: dir, timeout: 120000, stdio: "ignore" }); }
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name":
|
|
3
|
-
"version":
|
|
4
|
-
"description":
|
|
5
|
-
"main":
|
|
6
|
-
"type":
|
|
7
|
-
"license":
|
|
8
|
-
"author":
|
|
9
|
-
"repository":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"homepage":
|
|
14
|
-
"keywords":
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"engines":
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"files":
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "opencode-hub",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "TUI launcher for OpenCode - project switcher and plugin manager with oc command",
|
|
5
|
+
"main": "plugin.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "intisy",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/intisy/opencode-hub.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/intisy/opencode-hub#readme",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"opencode",
|
|
16
|
+
"launcher",
|
|
17
|
+
"tui",
|
|
18
|
+
"project-switcher",
|
|
19
|
+
"plugin"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20.0.0"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"plugin.js",
|
|
26
|
+
"oc-tui.js",
|
|
27
|
+
"README.md"
|
|
28
|
+
]
|
|
29
|
+
}
|