完善预编译插件自动下载工具
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@yizhi/ai",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"releaseVersion": "1.0.6",
|
||||
"main": "dist/index.js",
|
||||
"types": "typing/index.d.ts",
|
||||
|
@ -5,41 +5,33 @@ import { getConfig } from "./config";
|
||||
|
||||
|
||||
const URLS = {
|
||||
GITHUB: "https://github.com/kangkang520/node-addons/releases/download/ai{{version}}/{{backend}}_{{platform}}_{{arch}}.node",
|
||||
XXXXX: `http://git.urnas.cn:5200/yizhi-js-lib/ai-box/releases/download/{{version}}/{{backend}}_{{platform}}_{{arch}}.node`,
|
||||
GITHUB: "https://github.com/kangkang520/node-addons/releases/download/ai{{version}}/{{filename}}",
|
||||
XXXXX: "http://git.urnas.cn:5200/yizhi-js-lib/ai-box/releases/download/{{version}}/{{filename}}",
|
||||
}
|
||||
|
||||
function releaseVersion() { return require("../../package.json").releaseVersion }
|
||||
|
||||
function getURL(backend: "ort" | "mnn", template: string) {
|
||||
|
||||
let platform = "";
|
||||
let arch = "";
|
||||
switch (os.platform()) {
|
||||
case "win32":
|
||||
platform = "windows";
|
||||
break;
|
||||
case "linux":
|
||||
platform = "linux";
|
||||
break;
|
||||
case "darwin":
|
||||
platform = "macos";
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported platform: ${os.platform()}, Please compile the addon yourself.`);
|
||||
}
|
||||
switch (os.arch()) {
|
||||
case "x64":
|
||||
arch = "x64";
|
||||
break;
|
||||
case "arm64":
|
||||
arch = "arm64";
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported architecture: ${os.arch()}, Please compile the addon yourself.`);
|
||||
const URL_DICT: Record<string, Record<string, string>> = {
|
||||
"win32": {
|
||||
"x64": `${backend}_windows_x64.node`
|
||||
},
|
||||
"linux": {
|
||||
"x64": `${backend}_linux_x64.node`,
|
||||
"arm64": `${backend}_linux_arm64.node`,
|
||||
},
|
||||
"darwin": {
|
||||
"arm64": `${backend}_macos_arm64.node`,
|
||||
}
|
||||
}
|
||||
|
||||
return template.replaceAll("{{backend}}", backend).replaceAll("{{version}}", releaseVersion()).replaceAll("{{platform}}", platform).replaceAll("{{arch}}", arch);
|
||||
const archConfig = URL_DICT[os.platform()];
|
||||
if (!archConfig) throw new Error(`Unsupported platform: ${os.platform()}`);
|
||||
const downloadName = archConfig[os.arch()];
|
||||
if (!downloadName) throw new Error(`Unsupported arch: ${os.arch()}`);
|
||||
|
||||
return template.replaceAll("{{version}}", releaseVersion()).replaceAll("{{filename}}", downloadName);
|
||||
}
|
||||
|
||||
async function getStream(backend: "mnn" | "ort") {
|
||||
|
Reference in New Issue
Block a user