@lingxia/cli 0.1.1 → 0.1.3
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/package.json +3 -4
- package/scripts/install.cjs +35 -15
- package/vendor/lingxia +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxia/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "LingXia CLI for scaffolding, building, and packaging mini-apps with LingXia templates and builders.",
|
|
6
6
|
"type": "module",
|
|
@@ -37,9 +37,8 @@
|
|
|
37
37
|
"vite": "^6.0.7"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"@lingxia/cli-darwin-arm64": "0.1.
|
|
41
|
-
"@lingxia/cli-darwin-x64": "0.1.
|
|
42
|
-
"@lingxia/cli-win32-x64": "0.1.1"
|
|
40
|
+
"@lingxia/cli-darwin-arm64": "0.1.3",
|
|
41
|
+
"@lingxia/cli-darwin-x64": "0.1.3"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@types/node": "^20.19.7",
|
package/scripts/install.cjs
CHANGED
|
@@ -5,23 +5,26 @@ const fs = require("node:fs");
|
|
|
5
5
|
const path = require("node:path");
|
|
6
6
|
const { createRequire } = require("node:module");
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (platform === "darwin" && arch === "arm64") return "@lingxia/cli-darwin-arm64";
|
|
13
|
-
if (platform === "darwin" && arch === "x64") return "@lingxia/cli-darwin-x64";
|
|
8
|
+
const PLATFORM_PACKAGE_MAP = {
|
|
9
|
+
"darwin-arm64": "@lingxia/cli-darwin-arm64",
|
|
10
|
+
"darwin-x64": "@lingxia/cli-darwin-x64",
|
|
11
|
+
};
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
function resolvePlatformPackage() {
|
|
14
|
+
return PLATFORM_PACKAGE_MAP[`${process.platform}-${process.arch}`] || null;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
async function main() {
|
|
19
18
|
if (process.env.LINGXIA_CLI_SKIP_DOWNLOAD === "1") return;
|
|
20
19
|
|
|
20
|
+
const wrapperPkg = JSON.parse(
|
|
21
|
+
fs.readFileSync(path.resolve(__dirname, "..", "package.json"), "utf8")
|
|
22
|
+
);
|
|
21
23
|
const platformPackage = resolvePlatformPackage();
|
|
22
24
|
if (!platformPackage) {
|
|
25
|
+
const supported = Object.keys(PLATFORM_PACKAGE_MAP).join(", ");
|
|
23
26
|
throw new Error(
|
|
24
|
-
`Unsupported platform: ${process.platform}-${process.arch}. Supported:
|
|
27
|
+
`Unsupported platform: ${process.platform}-${process.arch}. Supported: ${supported}.`
|
|
25
28
|
);
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -29,18 +32,37 @@ async function main() {
|
|
|
29
32
|
const vendorDir = path.join(pkgRoot, "vendor");
|
|
30
33
|
fs.mkdirSync(vendorDir, { recursive: true });
|
|
31
34
|
|
|
32
|
-
const binName =
|
|
35
|
+
const binName = "lingxia";
|
|
33
36
|
const dest = path.join(vendorDir, binName);
|
|
34
37
|
|
|
35
|
-
if (fs.existsSync(dest)) return;
|
|
36
|
-
|
|
37
38
|
const requireFromHere = createRequire(__filename);
|
|
38
39
|
let platformPkgRoot;
|
|
39
40
|
try {
|
|
40
41
|
platformPkgRoot = path.dirname(requireFromHere.resolve(`${platformPackage}/package.json`));
|
|
41
42
|
} catch (err) {
|
|
43
|
+
const registry =
|
|
44
|
+
process.env.npm_config_registry || process.env.NPM_CONFIG_REGISTRY || "https://registry.npmjs.org/";
|
|
42
45
|
throw new Error(
|
|
43
|
-
|
|
46
|
+
[
|
|
47
|
+
`Platform package ${platformPackage} not found for ${process.platform}-${process.arch}.`,
|
|
48
|
+
`Current npm registry: ${registry}`,
|
|
49
|
+
"Possible causes:",
|
|
50
|
+
"1) Platform package for this version is not published yet.",
|
|
51
|
+
"2) Your mirror/registry is stale or missing @lingxia scoped packages.",
|
|
52
|
+
"Fix: npm config set registry https://registry.npmjs.org/ && npm install -g @lingxia/cli@latest",
|
|
53
|
+
].join("\n")
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const platformPkg = JSON.parse(
|
|
57
|
+
fs.readFileSync(path.join(platformPkgRoot, "package.json"), "utf8")
|
|
58
|
+
);
|
|
59
|
+
if (platformPkg.version !== wrapperPkg.version) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
[
|
|
62
|
+
`Version mismatch: @lingxia/cli@${wrapperPkg.version} requires ${platformPackage}@${wrapperPkg.version},`,
|
|
63
|
+
`but found ${platformPackage}@${platformPkg.version}.`,
|
|
64
|
+
"Fix: npm install -g @lingxia/cli@latest",
|
|
65
|
+
].join("\n")
|
|
44
66
|
);
|
|
45
67
|
}
|
|
46
68
|
|
|
@@ -50,9 +72,7 @@ async function main() {
|
|
|
50
72
|
}
|
|
51
73
|
|
|
52
74
|
fs.copyFileSync(candidate, dest);
|
|
53
|
-
|
|
54
|
-
fs.chmodSync(dest, 0o755);
|
|
55
|
-
}
|
|
75
|
+
fs.chmodSync(dest, 0o755);
|
|
56
76
|
}
|
|
57
77
|
|
|
58
78
|
main().catch((err) => {
|
package/vendor/lingxia
CHANGED
|
Binary file
|