qdmp-cli 0.1.17 → 0.1.19
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/README.md +5 -0
- package/actions.js +6 -3
- package/api.js +20 -0
- package/npm-shrinkwrap.json +4487 -0
- package/package.json +13 -4
- package/utils/compilerRuntime.js +45 -0
- package/.claude/settings.local.json +0 -9
package/package.json
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qdmp-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "qdmp-cli",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"actions.js",
|
|
9
|
+
"api.js",
|
|
10
|
+
"constants.js",
|
|
11
|
+
"index.js",
|
|
12
|
+
"npm-shrinkwrap.json",
|
|
13
|
+
"utils/"
|
|
14
|
+
],
|
|
7
15
|
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
17
|
+
"postinstall": "node utils/compilerRuntime.js"
|
|
9
18
|
},
|
|
10
19
|
"bin": {
|
|
11
20
|
"qdmp": "index.js",
|
|
@@ -18,7 +27,7 @@
|
|
|
18
27
|
"author": "zhangyanran",
|
|
19
28
|
"license": "ISC",
|
|
20
29
|
"dependencies": {
|
|
21
|
-
"@dimina/compiler": "
|
|
30
|
+
"@dimina/compiler": "1.1.1",
|
|
22
31
|
"adm-zip": "^0.5.16",
|
|
23
32
|
"chalk": "^5.4.1",
|
|
24
33
|
"commander": "^14.0.0",
|
|
@@ -30,6 +39,6 @@
|
|
|
30
39
|
"table": "^6.9.0"
|
|
31
40
|
},
|
|
32
41
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
42
|
+
"node": "^22.12.0 || ^24.11.0 || >=26.0.0"
|
|
34
43
|
}
|
|
35
44
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
|
|
5
|
+
const supportedNodeVersion = (version) => {
|
|
6
|
+
const [major, minor] = version.split(".").map(Number);
|
|
7
|
+
return (
|
|
8
|
+
(major === 22 && minor >= 12) ||
|
|
9
|
+
(major === 24 && minor >= 11) ||
|
|
10
|
+
major >= 26
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const assertCompilerRuntime = async (version = process.versions.node) => {
|
|
15
|
+
if (!supportedNodeVersion(version)) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`当前 Node.js ${version} 不受 EMP 编译器支持,请先切换到 Node.js 22.12+、24.11+ 或 26+,再重新安装 qdmp-cli`,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
const compilerRequire = createRequire(require.resolve("@dimina/compiler"));
|
|
24
|
+
const parserPath = compilerRequire.resolve("oxc-parser");
|
|
25
|
+
await import(pathToFileURL(parserPath).href);
|
|
26
|
+
} catch (cause) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`EMP 编译器原生依赖安装不完整。请在当前 Node.js ${version} 环境下卸载并重新安装 qdmp-cli(npm uninstall -g qdmp-cli && npm install -g qdmp-cli@latest --include=optional)`,
|
|
29
|
+
{ cause },
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const isDirectExecution =
|
|
35
|
+
process.argv[1] &&
|
|
36
|
+
realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
|
|
37
|
+
|
|
38
|
+
if (isDirectExecution) {
|
|
39
|
+
try {
|
|
40
|
+
await assertCompilerRuntime();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error(`qdmp-cli 安装失败:${error.message}`);
|
|
43
|
+
process.exitCode = 1;
|
|
44
|
+
}
|
|
45
|
+
}
|