fix: dsh plugin add 改用 GitHub tar.gz,避免 pnpm 把 zip 当 gzip 解 (#26)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-09-18 22:26:16 +08:00
1 parent b84582e17c
commit 95c7950a3e
3 files changed
+43 -33

No files matched your search

+5 -4
View File
@@ -11,6 +11,7 @@ import { cliInvocation } from "./desktop.js";
const REPO = "YuJunZhiXue/dsh-purge";
const BRANCH = "master";
const ZIP_URL = `https://github.com/${REPO}/archive/refs/heads/${BRANCH}.zip`;
export const TARBALL_URL = `https://github.com/${REPO}/archive/refs/heads/${BRANCH}.tar.gz`;
const GITHUB_SPEC = `github:${REPO}#${BRANCH}`;
const PLUGIN_ROOT = path.resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
const COPY_NAMES = [
@@ -204,15 +205,15 @@ export function runDshPlugin(profile, args) {
});
}
function addSpecFor(spec) {
export function pluginAddSpec(spec) {
const s = String(spec || "");
if (/\.zip(\b|$)/i.test(s) || /^https?:\/\//i.test(s)) return ZIP_URL;
if (/\.(zip|tgz|tar\.gz)(\b|$)/i.test(s) || /^https?:\/\//i.test(s)) return TARBALL_URL;
if (/^github:/i.test(s) || /github\.com\/.+\.git/i.test(s)) return GITHUB_SPEC;
return "";
}
function dshReinstall(profile, spec) {
const addSpec = addSpecFor(spec);
const addSpec = pluginAddSpec(spec);
if (addSpec) {
runDshPlugin(profile, ["add", "--force", addSpec]);
return;
@@ -220,7 +221,7 @@ function dshReinstall(profile, spec) {
try {
runDshPlugin(profile, ["update", "dsh-purge"]);
} catch {
runDshPlugin(profile, ["add", "--force", ZIP_URL]);
runDshPlugin(profile, ["add", "--force", TARBALL_URL]);
}
}