mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 10:30:24 +08:00
fix: dsh plugin add 改用 GitHub tar.gz,避免 pnpm 把 zip 当 gzip 解 (#26)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e84671d20a
commit
f5f57b4669
3 files changed
+43
-33
No files matched your search
+5
-4
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user