Compare commits
4 Commits
fc20a736c4
...
fa83d5095f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa83d5095f | ||
|
|
38c0aeb516 | ||
|
|
ea56258dee | ||
|
|
839d208029 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -132,3 +132,7 @@ ndist
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
# test files
|
||||
*.zip
|
||||
*.mrpack
|
||||
instance/
|
||||
333
package-lock.json
generated
333
package-lock.json
generated
@@ -9,16 +9,26 @@
|
||||
"version": "2.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.5.16",
|
||||
"chalk": "^5.4.1",
|
||||
"cli-progress": "^3.12.0",
|
||||
"dotenv": "^17.0.1",
|
||||
"fs-extra": "^11.3.0",
|
||||
"got": "^14.4.7",
|
||||
"inquirer": "^12.6.3",
|
||||
"minizlib": "^3.0.2",
|
||||
"p-map": "^7.0.3",
|
||||
"p-retry": "^6.2.1"
|
||||
"p-retry": "^6.2.1",
|
||||
"toml": "^3.0.0",
|
||||
"yauzl": "^3.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^28.0.6",
|
||||
"@rollup/plugin-json": "^6.1.0",
|
||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/cli-progress": "^3.11.6",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/yauzl": "^2.10.3",
|
||||
"nexe": "^5.0.0-beta.4",
|
||||
"rollup": "^4.44.1",
|
||||
"typescript": "^5.8.3"
|
||||
@@ -445,6 +455,143 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-commonjs": {
|
||||
"version": "28.0.6",
|
||||
"resolved": "https://registry.npmmirror.com/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.6.tgz",
|
||||
"integrity": "sha512-XSQB1K7FUU5QP+3lOQmVCE3I0FcbbNvmNT4VJSj93iUjayaARrTQeoRdiYQoftAJBLrR9t2agwAd3ekaTgHNlw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^5.0.1",
|
||||
"commondir": "^1.0.1",
|
||||
"estree-walker": "^2.0.2",
|
||||
"fdir": "^6.2.0",
|
||||
"is-reference": "1.2.1",
|
||||
"magic-string": "^0.30.3",
|
||||
"picomatch": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0 || 14 >= 14.17"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.68.0||^3.0.0||^4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"rollup": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-commonjs/node_modules/fdir": {
|
||||
"version": "6.4.6",
|
||||
"resolved": "https://registry.npmmirror.com/fdir/-/fdir-6.4.6.tgz",
|
||||
"integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"picomatch": "^3 || ^4"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"picomatch": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-commonjs/node_modules/picomatch": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.2.tgz",
|
||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-json": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/@rollup/plugin-json/-/plugin-json-6.1.0.tgz",
|
||||
"integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^5.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"rollup": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-node-resolve": {
|
||||
"version": "16.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.1.tgz",
|
||||
"integrity": "sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^5.0.1",
|
||||
"@types/resolve": "1.20.2",
|
||||
"deepmerge": "^4.2.2",
|
||||
"is-module": "^1.0.0",
|
||||
"resolve": "^1.22.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.78.0||^3.0.0||^4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"rollup": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/pluginutils": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-5.2.0.tgz",
|
||||
"integrity": "sha512-qWJ2ZTbmumwiLFomfzTyt5Kng4hwPi9rwCYN4SHb6eaRU1KNO4ccxINHr/VhH4GgPlt1XfSTLX2LBTme8ne4Zw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "^1.0.0",
|
||||
"estree-walker": "^2.0.2",
|
||||
"picomatch": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"rollup": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/pluginutils/node_modules/picomatch": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.2.tgz",
|
||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||
"version": "4.44.1",
|
||||
"resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.44.1.tgz",
|
||||
@@ -755,6 +902,26 @@
|
||||
"node": ">=14.16"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/adm-zip": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmmirror.com/@types/adm-zip/-/adm-zip-0.5.7.tgz",
|
||||
"integrity": "sha512-DNEs/QvmyRLurdQPChqq0Md4zGvPwHerAJYWk9l2jCbD1VPpnzRJorOdiq4zsw09NFbYnhfsoEhWtxIzXpn2yw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/cli-progress": {
|
||||
"version": "3.11.6",
|
||||
"resolved": "https://registry.npmmirror.com/@types/cli-progress/-/cli-progress-3.11.6.tgz",
|
||||
"integrity": "sha512-cE3+jb9WRlu+uOSAugewNpITJDt1VF8dHOopPO4IABFc3SXYL5WE/+PTz/FCdZRRfIujiWW3n3aMbv1eIGVRWA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/emscripten": {
|
||||
"version": "1.40.1",
|
||||
"resolved": "https://registry.npmmirror.com/@types/emscripten/-/emscripten-1.40.1.tgz",
|
||||
@@ -791,6 +958,17 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/fs-extra": {
|
||||
"version": "11.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@types/fs-extra/-/fs-extra-11.0.4.tgz",
|
||||
"integrity": "sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/jsonfile": "*",
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/http-cache-semantics": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz",
|
||||
@@ -804,6 +982,16 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/jsonfile": {
|
||||
"version": "6.1.4",
|
||||
"resolved": "https://registry.npmmirror.com/@types/jsonfile/-/jsonfile-6.1.4.tgz",
|
||||
"integrity": "sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.0.8",
|
||||
"resolved": "https://registry.npmmirror.com/@types/node/-/node-24.0.8.tgz",
|
||||
@@ -814,6 +1002,13 @@
|
||||
"undici-types": "~7.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/resolve": {
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmmirror.com/@types/resolve/-/resolve-1.20.2.tgz",
|
||||
"integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/retry": {
|
||||
"version": "0.12.2",
|
||||
"resolved": "https://registry.npmmirror.com/@types/retry/-/retry-0.12.2.tgz",
|
||||
@@ -881,6 +1076,16 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/yauzl": {
|
||||
"version": "2.10.3",
|
||||
"resolved": "https://registry.npmmirror.com/@types/yauzl/-/yauzl-2.10.3.tgz",
|
||||
"integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@webassemblyjs/ast": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmmirror.com/@webassemblyjs/ast/-/ast-1.14.1.tgz",
|
||||
@@ -1147,6 +1352,15 @@
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/adm-zip": {
|
||||
"version": "0.5.16",
|
||||
"resolved": "https://registry.npmmirror.com/adm-zip/-/adm-zip-0.5.16.tgz",
|
||||
"integrity": "sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.17.1.tgz",
|
||||
@@ -1540,7 +1754,6 @@
|
||||
"version": "0.2.13",
|
||||
"resolved": "https://registry.npmmirror.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
|
||||
"integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
@@ -1825,6 +2038,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/commondir": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/commondir/-/commondir-1.0.1.tgz",
|
||||
"integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/compress-commons": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/compress-commons/-/compress-commons-4.1.2.tgz",
|
||||
@@ -2198,6 +2418,17 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/decompress-unzip/node_modules/yauzl": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmmirror.com/yauzl/-/yauzl-2.10.0.tgz",
|
||||
"integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"buffer-crc32": "~0.2.3",
|
||||
"fd-slicer": "~1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/decompress/node_modules/make-dir": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-1.3.0.tgz",
|
||||
@@ -2231,6 +2462,16 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/deepmerge": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/deepmerge/-/deepmerge-4.3.1.tgz",
|
||||
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/defaults": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/defaults/-/defaults-1.0.4.tgz",
|
||||
@@ -2284,6 +2525,18 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "17.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/dotenv/-/dotenv-17.0.1.tgz",
|
||||
"integrity": "sha512-GLjkduuAL7IMJg/ZnOPm9AnWKJ82mSE2tzXLaJ/6hD6DhwGfZaXG77oB8qbReyiczNxnbxQKyh0OE5mXq0bAHA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/download": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/download/-/download-8.0.0.tgz",
|
||||
@@ -2699,6 +2952,13 @@
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/estree-walker": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/events": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/events/-/events-3.3.0.tgz",
|
||||
@@ -3510,6 +3770,13 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-module": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/is-module/-/is-module-1.0.0.tgz",
|
||||
"integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/is-natural-number": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/is-natural-number/-/is-natural-number-4.0.1.tgz",
|
||||
@@ -3572,6 +3839,16 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-reference": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/is-reference/-/is-reference-1.2.1.tgz",
|
||||
"integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/is-retry-allowed": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz",
|
||||
@@ -3891,6 +4168,16 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "0.30.17",
|
||||
"resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.30.17.tgz",
|
||||
"integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/make-dir": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-2.1.0.tgz",
|
||||
@@ -4034,27 +4321,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/minipass": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/minipass/-/minipass-7.1.2.tgz",
|
||||
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/minizlib": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/minizlib/-/minizlib-3.0.2.tgz",
|
||||
"integrity": "sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"minipass": "^7.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/mkdirp": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
@@ -4551,7 +4817,6 @@
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/pend/-/pend-1.2.0.tgz",
|
||||
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
@@ -5523,6 +5788,12 @@
|
||||
"node": ">=8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/toml": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/toml/-/toml-3.0.0.tgz",
|
||||
"integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/trim-repeated": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/trim-repeated/-/trim-repeated-1.0.0.tgz",
|
||||
@@ -6104,14 +6375,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/yauzl": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmmirror.com/yauzl/-/yauzl-2.10.0.tgz",
|
||||
"integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==",
|
||||
"dev": true,
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/yauzl/-/yauzl-3.2.0.tgz",
|
||||
"integrity": "sha512-Ow9nuGZE+qp1u4JIPvg+uCiUr7xGQWdff7JQSk5VGYTAZMDe2q8lxJ10ygv10qmSj031Ty/6FNJpLO4o1Sgc+w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"buffer-crc32": "~0.2.3",
|
||||
"fd-slicer": "~1.1.0"
|
||||
"pend": "~1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/yoctocolors-cjs": {
|
||||
|
||||
16
package.json
16
package.json
@@ -8,23 +8,33 @@
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"tsbuild": "tsc",
|
||||
"rollup":"rollup",
|
||||
"rollup": "rollup -c rollup.config.js",
|
||||
"nexe": "nexe -i ./ndist/main.js --ico Dex.ico --build -t x86-22.13.0 --output ./ndist/main.exe",
|
||||
"upx": ".\\.dist_modules\\upx.exe .\\ndist\\main.exe",
|
||||
"build": "npm run tsbuild&&npm run rollup&&npm run nexe&&npm run upx",
|
||||
"test": "tsc&&node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.5.16",
|
||||
"chalk": "^5.4.1",
|
||||
"cli-progress": "^3.12.0",
|
||||
"dotenv": "^17.0.1",
|
||||
"fs-extra": "^11.3.0",
|
||||
"got": "^14.4.7",
|
||||
"inquirer": "^12.6.3",
|
||||
"minizlib": "^3.0.2",
|
||||
"p-map": "^7.0.3",
|
||||
"p-retry": "^6.2.1"
|
||||
"p-retry": "^6.2.1",
|
||||
"toml": "^3.0.0",
|
||||
"yauzl": "^3.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^28.0.6",
|
||||
"@rollup/plugin-json": "^6.1.0",
|
||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/cli-progress": "^3.11.6",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/yauzl": "^2.10.3",
|
||||
"nexe": "^5.0.0-beta.4",
|
||||
"rollup": "^4.44.1",
|
||||
"typescript": "^5.8.3"
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import json from '@rollup/plugin-json';
|
||||
/** @type {import('rollup').RollupOptions} */
|
||||
// ---cut---
|
||||
export default {
|
||||
input: 'dist/main.js',
|
||||
output: {
|
||||
file: 'bundle.js',
|
||||
file: 'ndist/bundle.js',
|
||||
format: 'es'
|
||||
}
|
||||
},
|
||||
plugins:[
|
||||
resolve({preferBuiltins: false}),
|
||||
commonjs(),
|
||||
json()
|
||||
]
|
||||
};
|
||||
112
src/main.ts
Normal file
112
src/main.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import inquirer from "inquirer";
|
||||
import yauzl from "yauzl";
|
||||
import process from "node:process";
|
||||
import fse from "fs-extra";
|
||||
import { join, basename, dirname } from "node:path";
|
||||
import { platform, what_platform } from "./platform/index.js";
|
||||
import { isDevelopment, readzipentry } from "./utils/utils.js";
|
||||
import fabric from "./ml_install/fabric.js"
|
||||
import forge from "./ml_install/forge.js"
|
||||
import neoforge from "./ml_install/neoforge.js"
|
||||
import { DeEarthMain } from "./utils/DeEarth.js";
|
||||
import { LOGGER } from "./utils/logger.js";
|
||||
import { fileURLToPath } from "node:url";
|
||||
interface Answers {
|
||||
modpack_path: string | undefined;
|
||||
}
|
||||
let unzip_path:string = ""
|
||||
if(isDevelopment){
|
||||
unzip_path = join("./","instance")
|
||||
}else{
|
||||
unzip_path = join(getCurrnetDir(),"instance")
|
||||
}
|
||||
let zipnamew: string = ""
|
||||
const argv = process.argv.slice(2)[0];
|
||||
|
||||
if (!argv) {
|
||||
const answer: Answers = await inquirer.prompt([
|
||||
{ type: "input", name: "modpack_path", message: "请输入整合包路径" },
|
||||
]);
|
||||
if (answer.modpack_path) {
|
||||
initdir()
|
||||
await main(answer.modpack_path);
|
||||
}
|
||||
} else {
|
||||
initdir()
|
||||
await main(argv);
|
||||
}
|
||||
|
||||
function initdir(){
|
||||
if(!fse.existsSync(unzip_path)){
|
||||
fse.ensureDirSync(join(unzip_path,"rubbish"))
|
||||
}
|
||||
}
|
||||
|
||||
async function main(modpack_path: string) {
|
||||
const zipname= basename(modpack_path)
|
||||
.replace(".zip", "")
|
||||
.replace(".mrpack", "");
|
||||
zipnamew=zipname
|
||||
let dud_files: Array<string> = [];
|
||||
let pack_info: object;
|
||||
//unzip
|
||||
yauzl.open(modpack_path, { lazyEntries: true }, (err, zipfile) => {
|
||||
zipfile.readEntry(); //首次读取
|
||||
zipfile.on("entry", async (entry) => {
|
||||
if (/\/$/.test(entry.fileName)) {
|
||||
} else if (entry.fileName.includes("overrides/")) {
|
||||
const zipfilex = join(unzip_path, zipname,entry.fileName.replace("overrides/",""))
|
||||
if(!fse.existsSync(zipfilex)){
|
||||
zipfile.openReadStream(entry,(err,stream)=>{ //读取overrides文件夹下的所有文件和文件夹
|
||||
const dir = dirname(zipfilex)
|
||||
fse.ensureDirSync(dir);
|
||||
stream.pipe(fse.createWriteStream(zipfilex))
|
||||
})
|
||||
//console.log(entry.fileName)
|
||||
}
|
||||
} else {
|
||||
const name: string = entry.fileName;
|
||||
dud_files.push(name);
|
||||
if (name && name.endsWith(".json")) {
|
||||
pack_info = JSON.parse(
|
||||
(await readzipentry(zipfile, entry)).toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
zipfile.readEntry();
|
||||
});
|
||||
zipfile.on("end", async () => {
|
||||
//zip
|
||||
const dirx = join(unzip_path,zipname)
|
||||
const plat = platform(what_platform(dud_files))
|
||||
const info = await plat.getinfo(pack_info);
|
||||
await plat.downloadfile(pack_info,dirx)
|
||||
await install(info.loader,info.minecraft,info.loader_version,dirx)
|
||||
await DeEarthMain(join(dirx,"mods"),join(unzip_path,"rubbish"))
|
||||
LOGGER.info("DeEarthX已将服务端制作完成!");
|
||||
zipfile.close();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function install(type: string,minecraft:string,loaderver:string,path:string){
|
||||
switch(type){
|
||||
case "fabric":
|
||||
await fabric(minecraft,loaderver,path)
|
||||
break;
|
||||
case "fabric-loader":
|
||||
await fabric(minecraft,loaderver,path)
|
||||
break;
|
||||
case "forge":
|
||||
await forge(minecraft,loaderver,path)
|
||||
break;
|
||||
case "neoforge":
|
||||
await neoforge(minecraft,loaderver,path)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrnetDir () {
|
||||
const url = new URL(".", import.meta.url);
|
||||
return fileURLToPath(url);
|
||||
}
|
||||
19
src/ml_install/fabric.ts
Normal file
19
src/ml_install/fabric.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import cp from "child_process";
|
||||
import fsExtra from "fs-extra/esm";
|
||||
import got from "got";
|
||||
export default async function install(
|
||||
mcver: string,
|
||||
fabricver: string,
|
||||
path: string
|
||||
) {
|
||||
const data = (
|
||||
await got.get(
|
||||
`https://maven.fabricmc.net/net/fabricmc/fabric-installer/1.0.1/fabric-installer-1.0.1.jar`
|
||||
)
|
||||
).rawBody;
|
||||
fsExtra.outputFileSync(path+"/fabric-installer-1.0.1.jar", data);
|
||||
cp.execSync(
|
||||
`java -jar fabric-installer-1.0.1.jar server -mcver ${mcver} -loader ${fabricver}`,
|
||||
{ cwd: path, stdio: "ignore" }
|
||||
);
|
||||
}
|
||||
125
src/ml_install/forge.ts
Normal file
125
src/ml_install/forge.ts
Normal file
@@ -0,0 +1,125 @@
|
||||
import got from "got";
|
||||
import fse from "fs-extra";
|
||||
import AdmZip from "adm-zip";
|
||||
import pMap from "p-map";
|
||||
import pRetry from "p-retry";
|
||||
import cp from "child_process";
|
||||
import { xfastdownload } from "../utils/utils.js";
|
||||
import { LOGGER } from "../utils/logger.js";
|
||||
|
||||
const gotx = got.extend({
|
||||
prefixUrl: "https://bmclapi2.bangbang93.com",
|
||||
headers: { "User-Agent": "DeEarthX V2" },
|
||||
});
|
||||
|
||||
interface mcinfoX {
|
||||
libraries: Array<any>;
|
||||
downloads: any;
|
||||
}
|
||||
|
||||
export default async function install(
|
||||
minecraftversion: string,
|
||||
loaderversion: string,
|
||||
path: string
|
||||
) {
|
||||
//instance
|
||||
const mcinfo = (await gotx
|
||||
.get(`version/${minecraftversion}/json`)
|
||||
.json()) as mcinfoX; //获取Minecraft版本JSON
|
||||
const forgepath = path;
|
||||
console.log(loaderversion)
|
||||
const forgedata = (
|
||||
await gotx.get(
|
||||
`forge/download?mcversion=${minecraftversion}&version=${loaderversion}&category=installer&format=jar`
|
||||
)
|
||||
).rawBody;
|
||||
fse.outputFileSync(
|
||||
`${forgepath}/Forge-${minecraftversion}-${loaderversion}.jar`,
|
||||
forgedata
|
||||
); //下载Installer.jar
|
||||
LOGGER.info(`下载Forge-${minecraftversion}-${loaderversion}.jar完成!`);
|
||||
const zip = new AdmZip(
|
||||
`${forgepath}/Forge-${minecraftversion}-${loaderversion}.jar`
|
||||
).getEntries();
|
||||
for (let x = 0; x < zip.length; x++) {
|
||||
//获取ZIP里的version.json信息
|
||||
const e = zip[x];
|
||||
if (e.entryName == "version.json") {
|
||||
const fvdata = JSON.parse(e.getData().toString("utf-8")).libraries;
|
||||
for (let c = 0; c < fvdata.length; c++) {
|
||||
//下载依赖1
|
||||
const t = fvdata[c].downloads.artifact;
|
||||
await xfastdownload(
|
||||
`https://bmclapi2.bangbang93.com/maven${new URL(t.url).pathname}`,
|
||||
`${forgepath}/libraries/${t.path}`,
|
||||
16
|
||||
);
|
||||
}
|
||||
} else if (e.entryName == "install_profile.json") {
|
||||
const json = JSON.parse(e.getData().toString("utf-8"));
|
||||
const fvdata = json.libraries;
|
||||
for (let c = 0; c < fvdata.length; c++) {
|
||||
//下载依赖2
|
||||
const t = fvdata[c].downloads.artifact;
|
||||
await xfastdownload(
|
||||
`https://bmclapi2.bangbang93.com/maven${new URL(t.url).pathname}`,
|
||||
`${forgepath}/libraries/${t.path}`,
|
||||
16
|
||||
);
|
||||
}
|
||||
//下载MAPPING与MOJMAPS
|
||||
/*MOJMAPS*/
|
||||
await xfastdownload(
|
||||
`https://bmclapi2.bangbang93.com${new URL(mcinfo.downloads.server_mappings.url).pathname}`,
|
||||
`${forgepath}/libraries/${mavenToUrl(
|
||||
json.data.MOJMAPS.server.replace(/[[\]]/g, ""),
|
||||
""
|
||||
)}`
|
||||
);
|
||||
/*MAPPING*/
|
||||
const tmp = `de/oceanlabs/mcp/mcp_config/${minecraftversion}-${json.data.MCP_VERSION.server.replace(
|
||||
/['"]/g,
|
||||
""
|
||||
)}/mcp_config-${minecraftversion}-${json.data.MCP_VERSION.server.replace(
|
||||
/['"]/g,
|
||||
""
|
||||
)}.zip`;
|
||||
await xfastdownload(`https://bmclapi2.bangbang93.com/maven/${tmp}`, `${forgepath}/libraries/${tmp}`);
|
||||
LOGGER.info("下载MAPPING与MOJMAPS完成!");
|
||||
}
|
||||
}
|
||||
LOGGER.info(`下载Forge的libraries完成!`);
|
||||
for (let d = 0; d < mcinfo.libraries.length; d++) {
|
||||
const g = mcinfo.libraries[d].downloads.artifact;
|
||||
await xfastdownload(
|
||||
`https://bmclapi2.bangbang93.com/maven${new URL(g.url).pathname}`,
|
||||
`${forgepath}/libraries/${g.path}`,
|
||||
16
|
||||
);
|
||||
}
|
||||
LOGGER.info(`下载Minecraft的Maven完成!`);
|
||||
await xfastdownload(
|
||||
`https://bmclapi2.bangbang93.com/version/${minecraftversion}/server`,
|
||||
`${forgepath}/libraries/net/minecraft/server/${minecraftversion}/server-${minecraftversion}.jar`,
|
||||
1
|
||||
);
|
||||
try {
|
||||
cp.execSync(
|
||||
`java -jar Forge-${minecraftversion}-${loaderversion}.jar --installServer`,
|
||||
{ cwd: forgepath, stdio: "ignore" }
|
||||
); //执行Forge安装命令
|
||||
} catch (e) {}
|
||||
LOGGER.info("Forge安装完成!!!");
|
||||
}
|
||||
|
||||
function mavenToUrl(
|
||||
coordinate: { split: (arg0: string) => [any, any, any, any] },
|
||||
base = "maven"
|
||||
) {
|
||||
const [g, a, v, ce] = coordinate.split(":");
|
||||
const [c, e = "jar"] = (ce || "").split("@");
|
||||
return `${base.replace(/\/$/, "")}/${g.replace(
|
||||
/\./g,
|
||||
"/"
|
||||
)}/${a}/${v}/${a}-${v}${c ? "-" + c : ""}.${e}`;
|
||||
}
|
||||
76
src/ml_install/neoforge.ts
Normal file
76
src/ml_install/neoforge.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import AdmZip from "adm-zip";
|
||||
import fsExtra from "fs-extra/esm";
|
||||
import gotx from "got";
|
||||
import { xfastdownload } from "../utils/utils.js";
|
||||
import { LOGGER } from "../utils/logger.js";
|
||||
import cp from "child_process";
|
||||
const got = gotx.extend({
|
||||
prefixUrl: "https://bmclapi2.bangbang93.com",
|
||||
headers: { "User-Agent": "DeEarthX V2" },
|
||||
});
|
||||
|
||||
interface mcinfoX {
|
||||
libraries: Array<any>;
|
||||
downloads: any;
|
||||
}
|
||||
|
||||
export default async function install(
|
||||
minecraft: string,
|
||||
neoforge: string,
|
||||
path: string
|
||||
) {
|
||||
const mcinfo = (await gotx
|
||||
.get(`version/${minecraft}/json`)
|
||||
.json()) as mcinfoX; //获取Minecraft版本JSON
|
||||
const installer = (
|
||||
await got.get(`neoforge/version/${neoforge}/download/installer.jar`)
|
||||
).rawBody;
|
||||
fsExtra.outputFileSync(path + `/installer.jar`, installer);
|
||||
const zip = new AdmZip(path + `/installer.jar`).getEntries();
|
||||
for (let i = 0; i < zip.length; i++) {
|
||||
const e = zip[i];
|
||||
if (e.entryName == "version.json") {
|
||||
const fvdata = JSON.parse(e.getData().toString("utf-8")).libraries;
|
||||
for (let c = 0; c < fvdata.length; c++) {
|
||||
//下载依赖1
|
||||
const t = fvdata[c].downloads.artifact;
|
||||
await xfastdownload(
|
||||
`maven${new URL(t.url).pathname}`,
|
||||
`${path}/libraries/${t.path}`,
|
||||
16
|
||||
);
|
||||
}
|
||||
} else if (e.entryName == "install_profile.json") {
|
||||
const json = JSON.parse(e.getData().toString("utf-8"));
|
||||
const fvdata = json.libraries;
|
||||
for (let c = 0; c < fvdata.length; c++) {
|
||||
//下载依赖2
|
||||
const t = fvdata[c].downloads.artifact;
|
||||
await xfastdownload(
|
||||
`maven${new URL(t.url).pathname}`,
|
||||
`${path}/libraries/${t.path}`,
|
||||
16
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let d = 0; d < mcinfo.libraries.length; d++) {
|
||||
const g = mcinfo.libraries[d].downloads.artifact;
|
||||
await xfastdownload(
|
||||
`maven${new URL(g.url).pathname}`,
|
||||
`${path}/libraries/${g.path}`,
|
||||
16
|
||||
);
|
||||
}
|
||||
await xfastdownload(
|
||||
`version/${minecraft}/server`,
|
||||
`${path}/libraries/net/minecraft/server/${minecraft}/server-${minecraft}.jar`,
|
||||
1
|
||||
);
|
||||
LOGGER.info("下载NeoForge完成!");
|
||||
cp.execSync(`java -jar ${path}/installer.jar --installServer`, {
|
||||
cwd: path,
|
||||
stdio: "ignore",
|
||||
});
|
||||
LOGGER.info("安装NeoForge完成!");
|
||||
}
|
||||
55
src/platform/curseforge.ts
Normal file
55
src/platform/curseforge.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import got from "got";
|
||||
import { fastdownload, usemirror } from "../utils/utils.js";
|
||||
import { modpack_info, XPlatform } from "./index.js";
|
||||
|
||||
const cf_url = (()=>{if(usemirror){return "https://mod.mcimirror.top/curseforge"}else{return "https://api.curseforge.com"}})()
|
||||
export interface CurseForgeManifest {
|
||||
minecraft: {
|
||||
version: string;
|
||||
modLoaders: Array<{ id: string }>;
|
||||
};
|
||||
files: Array<{ projectID: number; fileID: number }>;
|
||||
}
|
||||
|
||||
export class CurseForge implements XPlatform {
|
||||
async getinfo(manifest: object): Promise<modpack_info> {
|
||||
let result: modpack_info = Object.create({});
|
||||
const local_manifest = manifest as CurseForgeManifest;
|
||||
if (result && local_manifest)
|
||||
result.minecraft = local_manifest.minecraft.version;
|
||||
const id = local_manifest.minecraft.modLoaders[0].id;
|
||||
const loader_all = id.match(
|
||||
/(.*)-/
|
||||
) as RegExpMatchArray;
|
||||
result.loader = loader_all[1];
|
||||
result.loader_version = id.replace(loader_all[0],"");
|
||||
return result;
|
||||
}
|
||||
|
||||
async downloadfile(manifest: object,path:string): Promise<void> {
|
||||
const local_manifest = manifest as CurseForgeManifest;
|
||||
const FileID = JSON.stringify({
|
||||
fileIds: local_manifest.files.map((file: { fileID: number; }) => file.fileID),
|
||||
});
|
||||
let tmp: [string, string] | string[][] = [];
|
||||
await got.post(cf_url+"/v1/mods/files",{
|
||||
body: FileID,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key":"$2a$10$ydk0TLDG/Gc6uPMdz7mad.iisj2TaMDytVcIW4gcVP231VKngLBKy"
|
||||
}
|
||||
}).json().then((res:any)=>{
|
||||
res.data.forEach((e: { fileName: string; downloadUrl: null|string; }) => {
|
||||
if (e.fileName.endsWith(".zip")||e.downloadUrl == null) {
|
||||
return;
|
||||
}
|
||||
if (usemirror){
|
||||
tmp.push(["https://mod.mcimirror.top"+new URL(e.downloadUrl).pathname,path+"/mods/" + e.fileName])
|
||||
}else{
|
||||
tmp.push([e.downloadUrl,path+"/mods/" + e.fileName])
|
||||
}
|
||||
});
|
||||
})
|
||||
await fastdownload(tmp as unknown as [string, string]) //下载文件
|
||||
}
|
||||
}
|
||||
40
src/platform/index.ts
Normal file
40
src/platform/index.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { CurseForge } from "./curseforge.js";
|
||||
import { MCBBS } from "./mcbbs.js";
|
||||
import { Modrinth } from "./modrinth.js";
|
||||
|
||||
export interface XPlatform {
|
||||
getinfo(manifest: object): Promise<modpack_info>;
|
||||
downloadfile(manifest: object,path:string): Promise<void>;
|
||||
}
|
||||
|
||||
export interface modpack_info {
|
||||
minecraft: string;
|
||||
loader: string;
|
||||
loader_version: string;
|
||||
}
|
||||
|
||||
export function platform(plat: string | undefined): XPlatform {
|
||||
let platform: XPlatform = Object.create({});
|
||||
switch (plat) {
|
||||
case "curseforge":
|
||||
platform = new CurseForge();
|
||||
break;
|
||||
case "modrinth":
|
||||
platform = new Modrinth();
|
||||
case "mcbbs":
|
||||
platform = new MCBBS();
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
|
||||
export function what_platform(dud_files: Array<string>) {
|
||||
if (dud_files.includes("mcbbs.packmeta")) {
|
||||
return "mcbbs";
|
||||
} else if (dud_files.includes("manifest.json")) {
|
||||
return "curseforge";
|
||||
} else if (dud_files.includes("modrinth.index.json")) {
|
||||
return "modrinth";
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
21
src/platform/mcbbs.ts
Normal file
21
src/platform/mcbbs.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { CurseForgeManifest } from "./curseforge.js";
|
||||
import { modpack_info, XPlatform } from "./index.js";
|
||||
|
||||
interface MCBBSManifest extends CurseForgeManifest {}
|
||||
|
||||
export class MCBBS implements XPlatform {
|
||||
async getinfo(manifest: object): Promise<modpack_info> {
|
||||
const result: modpack_info = Object.create({});
|
||||
const local_manifest = manifest as MCBBSManifest;
|
||||
if (result && local_manifest)
|
||||
result.minecraft = local_manifest.minecraft.version;
|
||||
const loader_all = local_manifest.minecraft.modLoaders[0].id.match(
|
||||
/(.*)-/
|
||||
) as RegExpMatchArray;
|
||||
result.loader = loader_all[1];
|
||||
result.loader_version = loader_all[0];
|
||||
return result;
|
||||
}
|
||||
|
||||
async downloadfile(urls: [string, string]): Promise<void> {}
|
||||
}
|
||||
47
src/platform/modrinth.ts
Normal file
47
src/platform/modrinth.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import fs from "node:fs";
|
||||
import { mr_fastdownload, usemirror } from "../utils/utils.js";
|
||||
import { modpack_info, XPlatform } from "./index.js";
|
||||
|
||||
interface ModrinthManifest {
|
||||
files: Array<{ path: string; downloads: string[]; fileSize: number; }>;
|
||||
dependencies: {
|
||||
minecraft: string;
|
||||
forge: string;
|
||||
neoforge: string;
|
||||
"fabric-loader": string;
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
export class Modrinth implements XPlatform {
|
||||
async getinfo(manifest: object): Promise<modpack_info> {
|
||||
let result: modpack_info = Object.create({});
|
||||
const local_manifest = manifest as ModrinthManifest;
|
||||
const depkey = Object.keys(local_manifest.dependencies);
|
||||
const loader = ["forge", "neoforge", "fabric-loader"];
|
||||
result.minecraft = local_manifest.dependencies.minecraft;
|
||||
for (let i = 0; i < depkey.length; i++) {
|
||||
const key = depkey[i];
|
||||
if (key !== "minecraft" && loader.includes(key)) {
|
||||
result.loader = key;
|
||||
result.loader_version = local_manifest.dependencies[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async downloadfile(manifest: object,path:string): Promise<void> {
|
||||
const index = manifest as ModrinthManifest;
|
||||
let tmp: [string, string, string][] = []
|
||||
index.files.forEach(async (e: { path: string; downloads: string[]; fileSize: number;}) => {
|
||||
if (e.path.endsWith(".zip")) {
|
||||
return;
|
||||
}
|
||||
if (usemirror){
|
||||
tmp.push(["https://mod.mcimirror.top"+new URL(e.downloads[0]).pathname,path+e.path,String(e.fileSize)])
|
||||
}else{
|
||||
tmp.push([e.downloads[0],path + e.path,String(e.fileSize)])
|
||||
}
|
||||
});
|
||||
await mr_fastdownload(tmp as unknown as [string, string, string])
|
||||
}
|
||||
}
|
||||
165
src/utils/DeEarth.ts
Normal file
165
src/utils/DeEarth.ts
Normal file
@@ -0,0 +1,165 @@
|
||||
/* Power by.Tianpao
|
||||
* 本工具可能会判断失误,但也能为您节省不少时间!
|
||||
* DeEarth V2 From StarNet.X
|
||||
* Writing in 03.29.2025(latest)
|
||||
* ©2024-2025
|
||||
*/
|
||||
import AdmZip from "adm-zip";
|
||||
import got from "got";
|
||||
import fs from "fs";
|
||||
import toml from 'toml';
|
||||
import path from 'path';
|
||||
import pMap from "p-map";
|
||||
import { LOGGER } from "./logger.js";
|
||||
import { MultiBar } from "cli-progress";
|
||||
|
||||
export async function DeEarthMain(modspath: string, movepath: any) {
|
||||
if(!fs.existsSync(movepath)){
|
||||
fs.mkdirSync(movepath)
|
||||
}
|
||||
LOGGER.info(`DeEarth V1.0.0`)
|
||||
LOGGER.info(`如有无法筛选的mods,请前往 https://dearth.0771010.xyz/ 提交未成功筛选的模组的modid`)
|
||||
LOGGER.info(`Probejs 7.0.0以上版本为非客户端mod,如rubbish中有请自行添加回去`)
|
||||
const resaddr = fs.readdirSync(modspath)
|
||||
LOGGER.info(`获取目录列表,一共${resaddr.length}个jar文件。`)
|
||||
const totalBar = multibar.create(resaddr.length, 0, { filename: '总文件数' })
|
||||
for (let i = 0; i < resaddr.length; i++) {
|
||||
const e = `${modspath}/${resaddr[i]}`
|
||||
if (e.endsWith(".jar") && fs.statSync(e).isFile()) { //判断是否以.jar结尾并且是文件
|
||||
//console.log(e)
|
||||
await DeEarth(e, movepath) //使用DeEarth进行审查mod并移动
|
||||
totalBar.increment()
|
||||
}
|
||||
}
|
||||
multibar.stop()
|
||||
}
|
||||
|
||||
export async function DeEarth(modpath: string, movepath: string) {
|
||||
const zip = new AdmZip(modpath).getEntries();
|
||||
//for (let i = 0; i < zip.length; i++) {
|
||||
//const e = zip[i]
|
||||
try { //Modrinth
|
||||
for (let i = 0; i < zip.length; i++) {
|
||||
const e = zip[i]
|
||||
if (e.entryName == "META-INF/mods.toml") { //Forge,NeoForge
|
||||
const modid = toml.parse(e.getData().toString('utf-8')).mods[0].modId
|
||||
//const body = await got.get(`https://api.modrinth.com/v2/project/${modid}`, { headers: { "User-Agent": "DeEarth" } }).json()
|
||||
const body = JSON.parse(await FastGot(`https://api.modrinth.com/v2/project/${modid}`))
|
||||
if (body.client_side == "required" && body.server_side == "unsupported") {
|
||||
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||
}
|
||||
} else if (e.entryName == "fabric.mod.json") { //Fabric
|
||||
const modid = JSON.parse(e.getData().toString('utf-8')).id
|
||||
//const body = await got.get(`https://api.modrinth.com/v2/project/${modid}`, { headers: { "User-Agent": "DeEarth" } }).json()
|
||||
const body = JSON.parse(await FastGot(`https://api.modrinth.com/v2/project/${modid}`))
|
||||
if (body.client_side == "required" && body.server_side == "unsupported") {
|
||||
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) { //mods.toml或fabric.mod.json判断
|
||||
try{//DeEarthPublic
|
||||
for (let i = 0; i < zip.length; i++) {
|
||||
const e = zip[i]
|
||||
if (e.entryName == "META-INF/mods.toml") { //Forge,Neoforge
|
||||
const modid = toml.parse(e.getData().toString('utf-8')).mods[0].modId
|
||||
const body = JSON.parse(await FastGot(`https://dearth.0771010.xyz/api/modid?modid=${modid}`))
|
||||
if (body.isClient) {
|
||||
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||
}
|
||||
} else if (e.entryName == "fabric.mod.json") { //Fabric
|
||||
const modid = JSON.parse(e.getData().toString('utf-8')).id
|
||||
const body = JSON.parse(await FastGot(`https://dearth.0771010.xyz/api/modid?modid=${modid}`))
|
||||
if (body.isClient) {
|
||||
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(errorr){
|
||||
for (let i = 0; i < zip.length; i++) {
|
||||
const e = zip[i]
|
||||
try {
|
||||
if (e.entryName == "META-INF/mods.toml") { //Forge,Neoforge
|
||||
const tr = toml.parse(e.getData().toString('utf-8'))
|
||||
const mcside = tr.dependencies[tr.mods[0].modId].find((mod: { modId: string; }) => mod.modId === "minecraft").side
|
||||
if (mcside == "CLIENT"){ //从Minecraft判断
|
||||
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||
}
|
||||
const forgeside = tr.dependencies[tr.mods[0].modId].find((mod: { modId: string; }) => mod.modId === "forge").side
|
||||
if (forgeside == "CLIENT") { //从Forge判断
|
||||
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||
}
|
||||
} else if (e.entryName == "fabric.mod.json") { //Fabric
|
||||
const fmj = JSON.parse(e.getData().toString('utf-8')).environment
|
||||
if (fmj == "client") {
|
||||
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||
}
|
||||
}
|
||||
} catch (erro) {//从Mixin判断 但是可能为不准确
|
||||
for (let i = 0; i < zip.length; i++) {
|
||||
const e = zip[i]
|
||||
try {
|
||||
if (!e.entryName.includes("/") && e.entryName.endsWith(".json") && !e.entryName.endsWith("refmap.json") && !e.entryName.endsWith("mod.json")) {
|
||||
LOGGER.info(e.entryName)
|
||||
const resx = JSON.parse(e.getData().toString('utf-8'))
|
||||
if (e.entryName.includes("common.mixins.json")) { //第一步从common mixins文件判断,判断失败后再使用modid.mixins.json进行判断
|
||||
if (resx.mixins == null || Object.keys(resx.mixins).length == 0 && Object.keys(resx.client).length !== 0) {
|
||||
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||
}
|
||||
} else {
|
||||
if (resx.mixins == null || Object.keys(resx.mixins).length == 0 && Object.keys(resx.client).length !== 0) {
|
||||
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err:any) {//避免有傻逼JSON写注释(虽然GSON可以这样 但是这样一点也不人道)
|
||||
if (err.errno !== -4058) {
|
||||
LOGGER.error(`大天才JSON写注释了估计,模组路径:${modpath},过滤失败`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function FastGot(url: string) {
|
||||
let e = []
|
||||
e.push([url])
|
||||
const fastgot = await pMap(e, async (e: any[]) => {
|
||||
try {
|
||||
if (e[0] !== null) { //防止URL为空
|
||||
//if(isChinaIpAddress((await got.get("https://4.ipw.cn/")).body)){
|
||||
return (await got.get(e[0], { headers: { "User-Agent": "DeEarth" } })).body
|
||||
//}else{
|
||||
//return (await got.get(`https://mod.mcimirror.top/modrinth/${new URL(e[0]).pathname}`, { headers: { "User-Agent": "DeEarth" } })).body //MCIM源
|
||||
//}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error.message !== "Response code 404 (Not Found)") {
|
||||
LOGGER.error({ err: error })
|
||||
} else {
|
||||
throw new Error(error)
|
||||
}
|
||||
}
|
||||
}, {
|
||||
concurrency: 48
|
||||
})
|
||||
if (fastgot[0] !== undefined) {
|
||||
return fastgot[0]
|
||||
}else{
|
||||
return "null"
|
||||
}
|
||||
}
|
||||
|
||||
const multibar = new MultiBar({
|
||||
format: ' {bar} | {filename} | {value}/{total}',
|
||||
noTTYOutput: true,
|
||||
notTTYSchedule: 10*1000,
|
||||
})
|
||||
|
||||
function isChinaIpAddress(ipAddress: string) {
|
||||
const chinaRegex = /^((?:(?:1(?:0|1|2[0-7]|[3-9][0-9])|2(?:[0-4][0-9]|5[0-5])|[3-9][0-9]{2})\.){3}(?:(?:1(?:0|1|2[0-7]|[3-9][0-9])|2(?:[0-4][0-9]|5[0-5])|[3-9][0-9]{2})))$/;
|
||||
return chinaRegex.test(ipAddress);
|
||||
}
|
||||
44
src/utils/logger.ts
Normal file
44
src/utils/logger.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import chalk from "chalk";
|
||||
export const LOGGER = {
|
||||
info(text: string) {
|
||||
info(text);
|
||||
},
|
||||
warn(text: string) {
|
||||
warn(text);
|
||||
},
|
||||
error(text: string | object) {
|
||||
error(text);
|
||||
},
|
||||
};
|
||||
function info(text: string) {
|
||||
console.log(
|
||||
`[${chalk.blue(
|
||||
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
|
||||
)}](${process.pid})[${chalk.green("INFO")}]:${chalk.cyan(text)}`
|
||||
);
|
||||
}
|
||||
|
||||
function warn(text: string) {
|
||||
console.log(
|
||||
`[${chalk.blue(
|
||||
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
|
||||
)}](${process.pid})[${chalk.yellowBright("WARN")}]:${chalk.yellowBright(
|
||||
text
|
||||
)}`
|
||||
);
|
||||
}
|
||||
function error(error: object | string) {
|
||||
if (typeof error === "object") {
|
||||
console.log(
|
||||
`[${chalk.blue(
|
||||
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
|
||||
)}](${process.pid})[${chalk.red("ERROR")}:${JSON.stringify(error)}`
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`[${chalk.blue(
|
||||
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
|
||||
)}](${process.pid})[${chalk.red("ERROR")}:${error}`
|
||||
);
|
||||
}
|
||||
}
|
||||
139
src/utils/utils.ts
Normal file
139
src/utils/utils.ts
Normal file
@@ -0,0 +1,139 @@
|
||||
import pMap from "p-map";
|
||||
import pRetry from "p-retry";
|
||||
import fse from "fs-extra"
|
||||
import yauzl from "yauzl";
|
||||
import got from "got";
|
||||
import env from "dotenv"
|
||||
import { MultiBar } from "cli-progress";
|
||||
import {URL, fileURLToPath } from "node:url";
|
||||
import { LOGGER } from "./logger.js";
|
||||
|
||||
export async function readzipentry(zipfile: yauzl.ZipFile, entry: yauzl.Entry):Promise<string|Buffer> {
|
||||
const data: Buffer<ArrayBufferLike>[] = [];
|
||||
return await new Promise((reslove, reject) => {
|
||||
zipfile.openReadStream(entry, (err, e) => {
|
||||
e.on("data", (chunk: Buffer) => {
|
||||
data.push(chunk);
|
||||
}).on("end", () => {
|
||||
reslove(data.toString());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function fastdownload(data:[string,string]){
|
||||
const multibar = new MultiBar({
|
||||
format: ' {bar} | {filename} | {value}/{total}',
|
||||
noTTYOutput: true,
|
||||
notTTYSchedule: 10*1000,
|
||||
})
|
||||
const totalBar = multibar.create(data.length, 0, {filename: '总文件数'})
|
||||
return await pMap(data,async(e)=>{
|
||||
const size:number = await (async()=>{const head = (await got.head(e[0])).headers['content-length'];if(head){return Number(head)}else{return 0}})()
|
||||
const bar = multibar.create(size, 0, {filename: e[1]})
|
||||
try{
|
||||
await pRetry(async()=>{
|
||||
if(!fse.existsSync(e[1])){
|
||||
await got.get(e[0],{
|
||||
responseType:"buffer",
|
||||
}).on('downloadProgress',(progress)=>{
|
||||
bar.update(progress.transferred)
|
||||
}).then((res)=>{
|
||||
fse.outputFileSync(e[1],res.rawBody)
|
||||
})
|
||||
}
|
||||
},{retries:3})
|
||||
}catch(e){
|
||||
LOGGER.error({err:e})
|
||||
}finally{
|
||||
bar.stop()
|
||||
totalBar.increment()
|
||||
multibar.remove(bar)
|
||||
}
|
||||
},{concurrency:16})
|
||||
}
|
||||
|
||||
export async function mr_fastdownload(data:[string,string,string]){
|
||||
const multibar = new MultiBar({
|
||||
format: ' {bar} | {filename} | {value}/{total}',
|
||||
noTTYOutput: true,
|
||||
notTTYSchedule: 10*1000,
|
||||
});
|
||||
const totalBar = multibar.create(data.length, 0, { filename: '总文件数' });
|
||||
return await pMap(data, async (e) => {
|
||||
const bar = multibar.create(Number(e[2]), 0, { filename: e[1] });
|
||||
try {
|
||||
await pRetry(async () => {
|
||||
if (!fse.existsSync(e[1])) {
|
||||
await got.get(e[0], {
|
||||
responseType: "buffer",
|
||||
}).on('downloadProgress', (progress) => {
|
||||
bar.update(progress.transferred);
|
||||
}).then((res) => {
|
||||
fse.outputFileSync(e[1], res.rawBody);
|
||||
});
|
||||
}
|
||||
}, { retries: 3 });
|
||||
}
|
||||
catch (e) {
|
||||
LOGGER.error({ err: e });
|
||||
}
|
||||
finally {
|
||||
bar.stop();
|
||||
totalBar.increment();
|
||||
multibar.remove(bar);
|
||||
}
|
||||
}, { concurrency: 16 });
|
||||
}
|
||||
|
||||
export async function xfastdownload(
|
||||
url: string,
|
||||
path: string,
|
||||
concurrency: number = 1
|
||||
) {
|
||||
let e = [];
|
||||
e.push([url, path]);
|
||||
await pMap(
|
||||
e,
|
||||
async (e) => {
|
||||
try {
|
||||
return await pRetry(
|
||||
async () => {
|
||||
if (
|
||||
url !== null &&
|
||||
url !== "" &&
|
||||
path !== null &&
|
||||
!fse.existsSync(e[1])
|
||||
) {
|
||||
const res = (await got.get(e[0])).rawBody; //下载文件
|
||||
await fse.outputFile(e[1], res); //保存文件
|
||||
}
|
||||
},
|
||||
{
|
||||
retries: 2,
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
LOGGER.error({ err: error });
|
||||
}
|
||||
},
|
||||
{
|
||||
concurrency: concurrency,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const usemirror = (()=>{
|
||||
env.config()
|
||||
const mirror = process.env.MIRROR
|
||||
if(mirror){
|
||||
return false
|
||||
}else{
|
||||
return true
|
||||
}
|
||||
})()
|
||||
|
||||
export const isDevelopment = (()=>{
|
||||
env.config()
|
||||
return process.env.DEVELOPMENT
|
||||
})()
|
||||
Reference in New Issue
Block a user