@cannbot-ai/install-helper 0.0.2-beta.41 → 0.0.2-beta.43
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/bin/install-helper.js +49 -0
- package/bin/package.json +3 -0
- package/dist/config/repository.yaml +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/package.json +14 -5
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require("child_process");
|
|
4
|
+
const { existsSync } = require("fs");
|
|
5
|
+
const { join, dirname } = require("path");
|
|
6
|
+
|
|
7
|
+
const PLATFORM_MAP = {
|
|
8
|
+
"linux-x64": "@cannbot-ai/install-helper-linux-x64",
|
|
9
|
+
"linux-arm64": "@cannbot-ai/install-helper-linux-arm64",
|
|
10
|
+
"darwin-x64": "@cannbot-ai/install-helper-darwin-x64",
|
|
11
|
+
"darwin-arm64": "@cannbot-ai/install-helper-darwin-arm64",
|
|
12
|
+
"win32-x64": "@cannbot-ai/install-helper-windows-x64",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const key = `${process.platform}-${process.arch}`;
|
|
16
|
+
const pkgName = PLATFORM_MAP[key];
|
|
17
|
+
const binaryName = process.platform === "win32" ? "install-helper.exe" : "install-helper";
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
|
|
20
|
+
if (pkgName) {
|
|
21
|
+
try {
|
|
22
|
+
const pkgPath = require.resolve(`${pkgName}/package.json`);
|
|
23
|
+
const binaryPath = join(dirname(pkgPath), binaryName);
|
|
24
|
+
if (existsSync(binaryPath)) {
|
|
25
|
+
const child = spawn(binaryPath, args, { stdio: "inherit" });
|
|
26
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
27
|
+
child.on("error", () => runJSFallback());
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
} catch {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
runJSFallback();
|
|
34
|
+
|
|
35
|
+
function runJSFallback() {
|
|
36
|
+
const jsPath = join(__dirname, "..", "dist", "index.js");
|
|
37
|
+
if (existsSync(jsPath)) {
|
|
38
|
+
const child = spawn(process.execPath, [jsPath, ...args], { stdio: "inherit" });
|
|
39
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
40
|
+
child.on("error", () => {
|
|
41
|
+
console.error("install-helper: failed to run");
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
console.error(`install-helper binary not found for ${key}`);
|
|
47
|
+
console.error("Try: npm install -g @cannbot-ai/install-helper");
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
package/bin/package.json
ADDED
package/dist/index.js
CHANGED
|
@@ -1928,9 +1928,9 @@ function loadRepoUrl() {
|
|
|
1928
1928
|
const configPath = join8(__dirname4, "config", "repository.yaml");
|
|
1929
1929
|
try {
|
|
1930
1930
|
const config = parseYaml3(readFileSync6(configPath, "utf-8"));
|
|
1931
|
-
return config.repository?.url || "https://gitcode.com/
|
|
1931
|
+
return config.repository?.url || "https://gitcode.com/yanhf/cann_skills.git";
|
|
1932
1932
|
} catch {
|
|
1933
|
-
return "https://gitcode.com/
|
|
1933
|
+
return "https://gitcode.com/yanhf/cann_skills.git";
|
|
1934
1934
|
}
|
|
1935
1935
|
}
|
|
1936
1936
|
var REPO_URL = loadRepoUrl();
|
|
@@ -4094,6 +4094,12 @@ import { readFileSync as readFileSync10, existsSync as existsSync19 } from "fs";
|
|
|
4094
4094
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
4095
4095
|
import { dirname as dirname8, join as join17 } from "path";
|
|
4096
4096
|
function readVersion() {
|
|
4097
|
+
try {
|
|
4098
|
+
if (typeof INSTALL_HELPER_VERSION !== "undefined" && INSTALL_HELPER_VERSION) {
|
|
4099
|
+
return INSTALL_HELPER_VERSION;
|
|
4100
|
+
}
|
|
4101
|
+
} catch {
|
|
4102
|
+
}
|
|
4097
4103
|
try {
|
|
4098
4104
|
const __filename5 = fileURLToPath5(import.meta.url);
|
|
4099
4105
|
const __dirname5 = dirname8(__filename5);
|
|
@@ -4105,7 +4111,7 @@ function readVersion() {
|
|
|
4105
4111
|
for (const pkgPath of candidates) {
|
|
4106
4112
|
if (existsSync19(pkgPath)) {
|
|
4107
4113
|
const pkg = JSON.parse(readFileSync10(pkgPath, "utf-8"));
|
|
4108
|
-
if (pkg.name === "@cannbot-ai/install-helper"
|
|
4114
|
+
if (pkg.version && (pkg.name === "@cannbot-ai/install-helper" || pkg.name?.startsWith("@cannbot-ai/install-helper-"))) {
|
|
4109
4115
|
return pkg.version;
|
|
4110
4116
|
}
|
|
4111
4117
|
}
|