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