Compare commits
23 Commits
fc20a736c4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9afbc993ba | ||
|
|
f65dea29f5 | ||
|
|
9d77fa53c7 | ||
|
|
d8d8c4051a | ||
|
|
32f7473533 | ||
|
|
9f9cfc3e17 | ||
|
|
777d8e43aa | ||
|
|
5ddcaf9b45 | ||
|
|
40492b8bd0 | ||
|
|
bb860b2c4a | ||
|
|
9dcc4e6c83 | ||
|
|
cfa97c8715 | ||
|
|
0acd64ae86 | ||
|
|
2f518e4487 | ||
|
|
1e35fac53b | ||
|
|
63d318772a | ||
|
|
f2fa0c8bdf | ||
|
|
f0ead136fe | ||
|
|
ba8c21cd6c | ||
|
|
fa83d5095f | ||
|
|
38c0aeb516 | ||
|
|
ea56258dee | ||
|
|
839d208029 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -132,3 +132,7 @@ ndist
|
|||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
# test files
|
||||||
|
*.zip
|
||||||
|
*.mrpack
|
||||||
|
instance/
|
||||||
15
Untitled-2.js
Normal file
15
Untitled-2.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import got from 'got';
|
||||||
|
const res = await got.post('https://api.modrinth.com/v2/version_files', {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0',
|
||||||
|
},
|
||||||
|
json: {
|
||||||
|
hashes: [
|
||||||
|
"ea0f38408102e4d2efd53c2cc11b88b711996b48d8922f76ea6abf731219c5bd1efe39ddf9cce77c54d49a62ff10fb685c00d2e4c524ab99d20f6296677ab2c4",
|
||||||
|
"925a5c4899affa4098d997dfa4a4cb52c636d539e94bc489d1fa034218cb96819a70eb8b01647a39316a59fcfe223c1a8c05ed2e2ae5f4c1e75fa48f6af1c961"
|
||||||
|
],
|
||||||
|
algorithm: 'sha512',
|
||||||
|
}
|
||||||
|
}).json()
|
||||||
|
|
||||||
|
console.log(res)
|
||||||
404
package-lock.json
generated
404
package-lock.json
generated
@@ -9,16 +9,28 @@
|
|||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^5.4.1",
|
"adm-zip": "^0.5.16",
|
||||||
"cli-progress": "^3.12.0",
|
"cli-progress": "^3.12.0",
|
||||||
|
"dotenv": "^17.0.1",
|
||||||
"fs-extra": "^11.3.0",
|
"fs-extra": "^11.3.0",
|
||||||
"got": "^14.4.7",
|
"got": "^14.4.7",
|
||||||
"inquirer": "^12.6.3",
|
"inquirer": "^12.6.3",
|
||||||
"minizlib": "^3.0.2",
|
|
||||||
"p-map": "^7.0.3",
|
"p-map": "^7.0.3",
|
||||||
"p-retry": "^6.2.1"
|
"p-retry": "^6.2.1",
|
||||||
|
"picocolors": "^1.1.1",
|
||||||
|
"smol-toml": "^1.4.1",
|
||||||
|
"yauzl": "^3.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-commonjs": "^28.0.6",
|
||||||
|
"@rollup/plugin-json": "^6.1.0",
|
||||||
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||||
|
"@rollup/plugin-typescript": "^12.1.4",
|
||||||
|
"@types/adm-zip": "^0.5.7",
|
||||||
|
"@types/cli-progress": "^3.11.6",
|
||||||
|
"@types/fs-extra": "^11.0.4",
|
||||||
|
"@types/inquirer": "^9.0.8",
|
||||||
|
"@types/yauzl": "^2.10.3",
|
||||||
"nexe": "^5.0.0-beta.4",
|
"nexe": "^5.0.0-beta.4",
|
||||||
"rollup": "^4.44.1",
|
"rollup": "^4.44.1",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
@@ -445,6 +457,170 @@
|
|||||||
"node": ">= 8"
|
"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/plugin-typescript": {
|
||||||
|
"version": "12.1.4",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@rollup/plugin-typescript/-/plugin-typescript-12.1.4.tgz",
|
||||||
|
"integrity": "sha512-s5Hx+EtN60LMlDBvl5f04bEiFZmAepk27Q+mr85L/00zPDn1jtzlTV6FWn81MaIwqfWzKxmOJrBWHU6vtQyedQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@rollup/pluginutils": "^5.1.0",
|
||||||
|
"resolve": "^1.22.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"rollup": "^2.14.0||^3.0.0||^4.0.0",
|
||||||
|
"tslib": "*",
|
||||||
|
"typescript": ">=3.7.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"rollup": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"tslib": {
|
||||||
|
"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": {
|
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||||
"version": "4.44.1",
|
"version": "4.44.1",
|
||||||
"resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.44.1.tgz",
|
"resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.44.1.tgz",
|
||||||
@@ -755,6 +931,26 @@
|
|||||||
"node": ">=14.16"
|
"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": {
|
"node_modules/@types/emscripten": {
|
||||||
"version": "1.40.1",
|
"version": "1.40.1",
|
||||||
"resolved": "https://registry.npmmirror.com/@types/emscripten/-/emscripten-1.40.1.tgz",
|
"resolved": "https://registry.npmmirror.com/@types/emscripten/-/emscripten-1.40.1.tgz",
|
||||||
@@ -791,12 +987,34 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"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": {
|
"node_modules/@types/http-cache-semantics": {
|
||||||
"version": "4.0.4",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmmirror.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz",
|
"resolved": "https://registry.npmmirror.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz",
|
||||||
"integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==",
|
"integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/inquirer": {
|
||||||
|
"version": "9.0.8",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@types/inquirer/-/inquirer-9.0.8.tgz",
|
||||||
|
"integrity": "sha512-CgPD5kFGWsb8HJ5K7rfWlifao87m4ph8uioU7OTncJevmE/VLIqAAjfQtko578JZg7/f69K4FgqYym3gNr7DeA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/through": "*",
|
||||||
|
"rxjs": "^7.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/json-schema": {
|
"node_modules/@types/json-schema": {
|
||||||
"version": "7.0.15",
|
"version": "7.0.15",
|
||||||
"resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.15.tgz",
|
"resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.15.tgz",
|
||||||
@@ -804,6 +1022,16 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"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": {
|
"node_modules/@types/node": {
|
||||||
"version": "24.0.8",
|
"version": "24.0.8",
|
||||||
"resolved": "https://registry.npmmirror.com/@types/node/-/node-24.0.8.tgz",
|
"resolved": "https://registry.npmmirror.com/@types/node/-/node-24.0.8.tgz",
|
||||||
@@ -814,6 +1042,13 @@
|
|||||||
"undici-types": "~7.8.0"
|
"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": {
|
"node_modules/@types/retry": {
|
||||||
"version": "0.12.2",
|
"version": "0.12.2",
|
||||||
"resolved": "https://registry.npmmirror.com/@types/retry/-/retry-0.12.2.tgz",
|
"resolved": "https://registry.npmmirror.com/@types/retry/-/retry-0.12.2.tgz",
|
||||||
@@ -834,6 +1069,16 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/through": {
|
||||||
|
"version": "0.0.33",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@types/through/-/through-0.0.33.tgz",
|
||||||
|
"integrity": "sha512-HsJ+z3QuETzP3cswwtzt2vEIiHBk/dCcHGhbmG5X3ecnwFD/lPrMpliGXxSCg03L9AhrdwA4Oz/qfspkDW+xGQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/uglify-js": {
|
"node_modules/@types/uglify-js": {
|
||||||
"version": "3.17.5",
|
"version": "3.17.5",
|
||||||
"resolved": "https://registry.npmmirror.com/@types/uglify-js/-/uglify-js-3.17.5.tgz",
|
"resolved": "https://registry.npmmirror.com/@types/uglify-js/-/uglify-js-3.17.5.tgz",
|
||||||
@@ -881,6 +1126,16 @@
|
|||||||
"node": ">= 8"
|
"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": {
|
"node_modules/@webassemblyjs/ast": {
|
||||||
"version": "1.14.1",
|
"version": "1.14.1",
|
||||||
"resolved": "https://registry.npmmirror.com/@webassemblyjs/ast/-/ast-1.14.1.tgz",
|
"resolved": "https://registry.npmmirror.com/@webassemblyjs/ast/-/ast-1.14.1.tgz",
|
||||||
@@ -1147,6 +1402,15 @@
|
|||||||
"node": ">=0.4.0"
|
"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": {
|
"node_modules/ajv": {
|
||||||
"version": "8.17.1",
|
"version": "8.17.1",
|
||||||
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.17.1.tgz",
|
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.17.1.tgz",
|
||||||
@@ -1540,7 +1804,6 @@
|
|||||||
"version": "0.2.13",
|
"version": "0.2.13",
|
||||||
"resolved": "https://registry.npmmirror.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
|
"resolved": "https://registry.npmmirror.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
|
||||||
"integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
|
"integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "*"
|
"node": "*"
|
||||||
@@ -1674,18 +1937,6 @@
|
|||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/chalk": {
|
|
||||||
"version": "5.4.1",
|
|
||||||
"resolved": "https://registry.npmmirror.com/chalk/-/chalk-5.4.1.tgz",
|
|
||||||
"integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/chardet": {
|
"node_modules/chardet": {
|
||||||
"version": "0.7.0",
|
"version": "0.7.0",
|
||||||
"resolved": "https://registry.npmmirror.com/chardet/-/chardet-0.7.0.tgz",
|
"resolved": "https://registry.npmmirror.com/chardet/-/chardet-0.7.0.tgz",
|
||||||
@@ -1825,6 +2076,13 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"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": {
|
"node_modules/compress-commons": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmmirror.com/compress-commons/-/compress-commons-4.1.2.tgz",
|
"resolved": "https://registry.npmmirror.com/compress-commons/-/compress-commons-4.1.2.tgz",
|
||||||
@@ -2198,6 +2456,17 @@
|
|||||||
"node": ">=0.10.0"
|
"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": {
|
"node_modules/decompress/node_modules/make-dir": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-1.3.0.tgz",
|
"resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-1.3.0.tgz",
|
||||||
@@ -2231,6 +2500,16 @@
|
|||||||
"node": ">=0.10.0"
|
"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": {
|
"node_modules/defaults": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.npmmirror.com/defaults/-/defaults-1.0.4.tgz",
|
"resolved": "https://registry.npmmirror.com/defaults/-/defaults-1.0.4.tgz",
|
||||||
@@ -2284,6 +2563,18 @@
|
|||||||
"node": ">=8"
|
"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": {
|
"node_modules/download": {
|
||||||
"version": "8.0.0",
|
"version": "8.0.0",
|
||||||
"resolved": "https://registry.npmmirror.com/download/-/download-8.0.0.tgz",
|
"resolved": "https://registry.npmmirror.com/download/-/download-8.0.0.tgz",
|
||||||
@@ -2699,6 +2990,13 @@
|
|||||||
"node": ">=4.0"
|
"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": {
|
"node_modules/events": {
|
||||||
"version": "3.3.0",
|
"version": "3.3.0",
|
||||||
"resolved": "https://registry.npmmirror.com/events/-/events-3.3.0.tgz",
|
"resolved": "https://registry.npmmirror.com/events/-/events-3.3.0.tgz",
|
||||||
@@ -3510,6 +3808,13 @@
|
|||||||
"node": ">=0.10.0"
|
"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": {
|
"node_modules/is-natural-number": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmmirror.com/is-natural-number/-/is-natural-number-4.0.1.tgz",
|
"resolved": "https://registry.npmmirror.com/is-natural-number/-/is-natural-number-4.0.1.tgz",
|
||||||
@@ -3572,6 +3877,16 @@
|
|||||||
"node": ">=0.10.0"
|
"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": {
|
"node_modules/is-retry-allowed": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmmirror.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz",
|
"resolved": "https://registry.npmmirror.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz",
|
||||||
@@ -3891,6 +4206,16 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"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": {
|
"node_modules/make-dir": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-2.1.0.tgz",
|
"resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-2.1.0.tgz",
|
||||||
@@ -4034,27 +4359,6 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"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": {
|
"node_modules/mkdirp": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.npmmirror.com/mkdirp/-/mkdirp-1.0.4.tgz",
|
"resolved": "https://registry.npmmirror.com/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||||
@@ -4551,14 +4855,12 @@
|
|||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmmirror.com/pend/-/pend-1.2.0.tgz",
|
"resolved": "https://registry.npmmirror.com/pend/-/pend-1.2.0.tgz",
|
||||||
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==",
|
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/picocolors": {
|
"node_modules/picocolors": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz",
|
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz",
|
||||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
@@ -5167,6 +5469,18 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/smol-toml": {
|
||||||
|
"version": "1.4.1",
|
||||||
|
"resolved": "https://registry.npmmirror.com/smol-toml/-/smol-toml-1.4.1.tgz",
|
||||||
|
"integrity": "sha512-CxdwHXyYTONGHThDbq5XdwbFsuY4wlClRGejfE2NtwUtiHYsP1QtNsHb/hnj31jKYSchztJsaA8pSQoVzkfCFg==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/cyyynthia"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/sort-keys": {
|
"node_modules/sort-keys": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmmirror.com/sort-keys/-/sort-keys-1.1.2.tgz",
|
"resolved": "https://registry.npmmirror.com/sort-keys/-/sort-keys-1.1.2.tgz",
|
||||||
@@ -6104,14 +6418,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/yauzl": {
|
"node_modules/yauzl": {
|
||||||
"version": "2.10.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmmirror.com/yauzl/-/yauzl-2.10.0.tgz",
|
"resolved": "https://registry.npmmirror.com/yauzl/-/yauzl-3.2.0.tgz",
|
||||||
"integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==",
|
"integrity": "sha512-Ow9nuGZE+qp1u4JIPvg+uCiUr7xGQWdff7JQSk5VGYTAZMDe2q8lxJ10ygv10qmSj031Ty/6FNJpLO4o1Sgc+w==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"buffer-crc32": "~0.2.3",
|
"buffer-crc32": "~0.2.3",
|
||||||
"fd-slicer": "~1.1.0"
|
"pend": "~1.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/yoctocolors-cjs": {
|
"node_modules/yoctocolors-cjs": {
|
||||||
|
|||||||
26
package.json
26
package.json
@@ -8,23 +8,35 @@
|
|||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"tsbuild": "tsc",
|
"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",
|
"nexe": "nexe -i ./dist/bundle.js --ico Dex.ico --build -t x86-22.13.0 --output ./dist/DeEarthX.exe",
|
||||||
"upx": ".\\.dist_modules\\upx.exe .\\ndist\\main.exe",
|
"upx": ".\\dist_modules\\upx.exe .\\dist\\DeEarthX.exe",
|
||||||
"build": "npm run tsbuild&&npm run rollup&&npm run nexe&&npm run upx",
|
"build": "npm run rollup&&npm run nexe&&npm run upx",
|
||||||
"test": "tsc&&node dist/main.js"
|
"test": "tsc&&node dist/main.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^5.4.1",
|
"adm-zip": "^0.5.16",
|
||||||
"cli-progress": "^3.12.0",
|
"cli-progress": "^3.12.0",
|
||||||
|
"dotenv": "^17.0.1",
|
||||||
"fs-extra": "^11.3.0",
|
"fs-extra": "^11.3.0",
|
||||||
"got": "^14.4.7",
|
"got": "^14.4.7",
|
||||||
"inquirer": "^12.6.3",
|
"inquirer": "^12.6.3",
|
||||||
"minizlib": "^3.0.2",
|
|
||||||
"p-map": "^7.0.3",
|
"p-map": "^7.0.3",
|
||||||
"p-retry": "^6.2.1"
|
"p-retry": "^6.2.1",
|
||||||
|
"picocolors": "^1.1.1",
|
||||||
|
"smol-toml": "^1.4.1",
|
||||||
|
"yauzl": "^3.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-commonjs": "^28.0.6",
|
||||||
|
"@rollup/plugin-json": "^6.1.0",
|
||||||
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||||
|
"@rollup/plugin-typescript": "^12.1.4",
|
||||||
|
"@types/adm-zip": "^0.5.7",
|
||||||
|
"@types/cli-progress": "^3.11.6",
|
||||||
|
"@types/fs-extra": "^11.0.4",
|
||||||
|
"@types/inquirer": "^9.0.8",
|
||||||
|
"@types/yauzl": "^2.10.3",
|
||||||
"nexe": "^5.0.0-beta.4",
|
"nexe": "^5.0.0-beta.4",
|
||||||
"rollup": "^4.44.1",
|
"rollup": "^4.44.1",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
|
import typescript from '@rollup/plugin-typescript'
|
||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs'
|
||||||
|
import json from '@rollup/plugin-json';
|
||||||
/** @type {import('rollup').RollupOptions} */
|
/** @type {import('rollup').RollupOptions} */
|
||||||
// ---cut---
|
// ---cut---
|
||||||
export default {
|
export default {
|
||||||
input: 'dist/main.js',
|
input: 'src/main.ts',
|
||||||
output: {
|
output: {
|
||||||
file: 'bundle.js',
|
file: 'dist/bundle.js',
|
||||||
format: 'es'
|
format: 'esm'
|
||||||
}
|
},
|
||||||
|
plugins:[
|
||||||
|
typescript(),
|
||||||
|
resolve({preferBuiltins: true}),
|
||||||
|
commonjs(),
|
||||||
|
json()
|
||||||
|
]
|
||||||
};
|
};
|
||||||
167
src/main copy.ts
Normal file
167
src/main copy.ts
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
import inquirer from "inquirer";
|
||||||
|
import yauzl, { Entry, ZipFile } from "yauzl";
|
||||||
|
import process, { emit } from "node:process";
|
||||||
|
import fs from "node:fs";
|
||||||
|
import fse from "fs-extra";
|
||||||
|
import { exec } from "node:child_process";
|
||||||
|
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().replace("dist", ""), "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 (!fs.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 | undefined = undefined;
|
||||||
|
let entry_arr: Entry[] = [];
|
||||||
|
//unzip
|
||||||
|
const zipfile: ZipFile = await new Promise((resolve, reject) => {
|
||||||
|
yauzl.open(modpack_path, { lazyEntries: true }, (err, zipfile) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
resolve(zipfile);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
zipfile.readEntry(); //首次读取
|
||||||
|
zipfile.on("entry", (entry) => {
|
||||||
|
entry_arr.push(entry);
|
||||||
|
zipfile.readEntry();
|
||||||
|
});
|
||||||
|
await new Promise((resolve) => zipfile.on("end", async () => resolve));
|
||||||
|
for (let i = 0; i < entry_arr.length; i++) {
|
||||||
|
const entry = entry_arr[i];
|
||||||
|
const name: string = entry.fileName;
|
||||||
|
if (/\/$/.test(name)) {
|
||||||
|
continue;
|
||||||
|
} else if (name.includes("overrides/")) {
|
||||||
|
const zipfilex = join(
|
||||||
|
unzip_path,
|
||||||
|
zipname,
|
||||||
|
name.replace("overrides/", "")
|
||||||
|
);
|
||||||
|
if (!fs.existsSync(zipfilex)) {
|
||||||
|
zipfile.openReadStream(entry, (err, stream) => {
|
||||||
|
//读取overrides文件夹下的所有文件和文件夹
|
||||||
|
const dir = dirname(zipfilex);
|
||||||
|
fse.ensureDirSync(dir);
|
||||||
|
console.log(zipfilex);
|
||||||
|
stream.pipe(fse.createWriteStream(zipfilex));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (name.endsWith(".json") || name.includes("mcbbs.packmeta")) {
|
||||||
|
dud_files.push(name);
|
||||||
|
if (
|
||||||
|
name.includes("manifest.json") ||
|
||||||
|
name.includes("modrinth.index.json")
|
||||||
|
) {
|
||||||
|
pack_info = JSON.parse((await readzipentry(zipfile, entry)).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//zipfile.on("end", async () => {
|
||||||
|
//zip
|
||||||
|
//try {
|
||||||
|
const dirx = join(unzip_path, zipname);
|
||||||
|
const plat = platform(what_platform(dud_files));
|
||||||
|
if (typeof pack_info !== "object") throw new Error("未找到manifest.json");
|
||||||
|
const info = await plat.getinfo(pack_info);
|
||||||
|
await plat.downloadfile(pack_info, dirx);
|
||||||
|
await DeEarthMain(join(dirx, "mods"), join(unzip_path, "rubbish"));
|
||||||
|
await install(info.loader, info.minecraft, info.loader_version, dirx);
|
||||||
|
fs.writeFileSync(
|
||||||
|
join(dirx, "eula.txt"),
|
||||||
|
"#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).\n#This serverpack created by DeEarthX(QQ_Group:559349662)\neula=true"
|
||||||
|
);
|
||||||
|
LOGGER.info("DeEarthX已将服务端制作完成!");
|
||||||
|
zipfile.close();
|
||||||
|
//} catch (e) {
|
||||||
|
//LOGGER.error(e);
|
||||||
|
//}
|
||||||
|
//});
|
||||||
|
//});
|
||||||
|
//})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function install(
|
||||||
|
type: string,
|
||||||
|
minecraft: string,
|
||||||
|
loaderver: string,
|
||||||
|
path: string
|
||||||
|
) {
|
||||||
|
if (await checkJava()) {
|
||||||
|
LOGGER.error(
|
||||||
|
"未安装Java或系统环境变量不存在Java,已跳过自动安装模组加载器服务端!"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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 checkJava() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
exec("java -version", (err) => {
|
||||||
|
if (err) {
|
||||||
|
resolve(false);
|
||||||
|
} else {
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrnetDir() {
|
||||||
|
const url = new URL(".", import.meta.url);
|
||||||
|
return fileURLToPath(url);
|
||||||
|
}
|
||||||
155
src/main.ts
Normal file
155
src/main.ts
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
import inquirer from "inquirer";
|
||||||
|
import yauzl from "yauzl";
|
||||||
|
import process from "node:process";
|
||||||
|
import fs from "node:fs";
|
||||||
|
import fse from "fs-extra";
|
||||||
|
import { join, basename, dirname } from "node:path";
|
||||||
|
import { platform, what_platform } from "./platform/index.js";
|
||||||
|
import { type ForgeInfo, isDevelopment, isInstallJava, 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().replace("dist", ""), "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 (!fs.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) => {
|
||||||
|
|
||||||
|
const name: string = entry.fileName;
|
||||||
|
if (/\/$/.test(name)) {
|
||||||
|
} else if (name.includes("overrides/")) {
|
||||||
|
const zipfilex = join(
|
||||||
|
unzip_path,
|
||||||
|
zipname,
|
||||||
|
name.replace("overrides/", "")
|
||||||
|
);
|
||||||
|
if (!fs.existsSync(zipfilex)) {
|
||||||
|
zipfile.openReadStream(entry, (err, stream) => {
|
||||||
|
//读取overrides文件夹下的所有文件和文件夹
|
||||||
|
const dir = dirname(zipfilex);
|
||||||
|
fse.ensureDirSync(dir);
|
||||||
|
console.log(zipfilex);
|
||||||
|
stream.pipe(fse.createWriteStream(zipfilex));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (name.endsWith(".json")||name.endsWith("mcbbs.packmeta")) {
|
||||||
|
dud_files.push(name);
|
||||||
|
//console.log((await readzipentry(zipfile, entry)))
|
||||||
|
if(name.endsWith("modrinth.index.json")|| name.endsWith("manifest.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 DeEarthMain(join(dirx, "mods"), join(unzip_path, ".rubbish"));
|
||||||
|
await install(info.loader, info.minecraft, info.loader_version, dirx);
|
||||||
|
fs.writeFileSync(
|
||||||
|
join(dirx, "eula.txt"),
|
||||||
|
"#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).\n#This serverpack created by DeEarthX(QQ_Group:559349662)\neula=true"
|
||||||
|
);
|
||||||
|
await garcol(dirx,{minecraft_verison: info.minecraft, forge_verison: info.loader_version}).catch((e)=>{});
|
||||||
|
LOGGER.info("DeEarthX已将服务端制作完成!");
|
||||||
|
zipfile.close();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function install(
|
||||||
|
type: string,
|
||||||
|
minecraft: string,
|
||||||
|
loaderver: string,
|
||||||
|
path: string
|
||||||
|
) {
|
||||||
|
if (!(await isInstallJava)){
|
||||||
|
LOGGER.error("请先安装Java!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (type) {
|
||||||
|
case "fabric":
|
||||||
|
await fabric(minecraft, loaderver, path);
|
||||||
|
break;
|
||||||
|
case "fabric-loader":
|
||||||
|
await fabric(minecraft, loaderver, path);
|
||||||
|
const com = "java -jar fabric-server-launch.jar"
|
||||||
|
fs.writeFileSync(join(path,'run.bat'),com)
|
||||||
|
fs.writeFileSync(join(path,'run.sh'),com)
|
||||||
|
break;
|
||||||
|
case "forge":
|
||||||
|
await forge(minecraft, loaderver, path);
|
||||||
|
break;
|
||||||
|
case "neoforge":
|
||||||
|
await neoforge(minecraft, loaderver, path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function garcol(p:string,fi:ForgeInfo): Promise<void> {
|
||||||
|
return new Promise((resolve,reject)=>{
|
||||||
|
try{
|
||||||
|
LOGGER.info("正在删除垃圾文件......")
|
||||||
|
const x = [`Forge-${fi.minecraft_verison}-${fi.forge_verison}.jar`,`installer.log`,`installer.jar`,`fabric-installer-1.0.3.jar`,`options.txt`,`shaderpacks/`,`resourcepacks/`,'essential/']
|
||||||
|
for (let i=0;i<x.length;i++){
|
||||||
|
try{
|
||||||
|
fs.rmSync(join(p, x[i]),{recursive: true, force: true})
|
||||||
|
}catch(e){}
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
|
}catch(err){
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrnetDir() {
|
||||||
|
const url = new URL(".", import.meta.url);
|
||||||
|
return fileURLToPath(url);
|
||||||
|
}
|
||||||
20
src/ml_install/fabric.ts
Normal file
20
src/ml_install/fabric.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import cp from "child_process";
|
||||||
|
import fsExtra from "fs-extra";
|
||||||
|
import got from "got";
|
||||||
|
import { usemirror } from "../utils/utils.js";
|
||||||
|
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.3/fabric-installer-1.0.3.jar`
|
||||||
|
)
|
||||||
|
).rawBody;
|
||||||
|
fsExtra.outputFileSync(path+"/fabric-installer-1.0.3.jar", data);
|
||||||
|
cp.execSync(
|
||||||
|
`java -jar fabric-installer-1.0.3.jar server -mcver ${mcver} -loader ${fabricver}`,
|
||||||
|
{ cwd: path, stdio: "ignore" }
|
||||||
|
);
|
||||||
|
}
|
||||||
124
src/ml_install/forge.ts
Normal file
124
src/ml_install/forge.ts
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
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" },
|
||||||
|
});
|
||||||
|
|
||||||
|
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`,{ headers: { "User-Agent": "DeEarthX" } })
|
||||||
|
.json()) as mcinfoX; //获取Minecraft版本JSON
|
||||||
|
const forgepath = path;
|
||||||
|
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";
|
||||||
|
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" },
|
||||||
|
});
|
||||||
|
|
||||||
|
interface mcinfoX {
|
||||||
|
libraries: Array<any>;
|
||||||
|
downloads: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function install(
|
||||||
|
minecraft: string,
|
||||||
|
neoforge: string,
|
||||||
|
path: string
|
||||||
|
) {
|
||||||
|
const mcinfo = (await got
|
||||||
|
.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(
|
||||||
|
`https://bmclapi2.bangbang93.com/maven${new URL(t.url).pathname.replace("/releases","")}`,
|
||||||
|
`${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(
|
||||||
|
`https://bmclapi2.bangbang93.com/maven${new URL(t.url).pathname.replace("/releases","")}`,
|
||||||
|
`${path}/libraries/${t.path}`,
|
||||||
|
16
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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}`,
|
||||||
|
`${path}/libraries/${g.path}`,
|
||||||
|
16
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await xfastdownload(
|
||||||
|
`https://bmclapi2.bangbang93.com/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完成!");
|
||||||
|
}
|
||||||
73
src/platform/curseforge.ts
Normal file
73
src/platform/curseforge.ts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import got from "got";
|
||||||
|
import { join } from "node:path";
|
||||||
|
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",
|
||||||
|
"User-Agent": "DeEarthX",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.json()
|
||||||
|
.then((res: any) => {
|
||||||
|
res.data.forEach(
|
||||||
|
(e: { fileName: string; downloadUrl: null | string }) => {
|
||||||
|
if (e.fileName.endsWith(".zip") || e.downloadUrl == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const unpath = join(path + "/mods/", e.fileName);
|
||||||
|
if (usemirror) {
|
||||||
|
tmp.push([
|
||||||
|
"https://mod.mcimirror.top" + new URL(e.downloadUrl).pathname,
|
||||||
|
unpath,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
tmp.push([e.downloadUrl, unpath]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await fastdownload(tmp as unknown as [string, string]); //下载文件
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/platform/index.ts
Normal file
42
src/platform/index.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
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();
|
||||||
|
break;
|
||||||
|
case "mcbbs":
|
||||||
|
platform = new MCBBS();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/platform/mcbbs.ts
Normal file
20
src/platform/mcbbs.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
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 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(urls: [string, string]): Promise<void> {}
|
||||||
|
}
|
||||||
49
src/platform/modrinth.ts
Normal file
49
src/platform/modrinth.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import fs from "node:fs";
|
||||||
|
import { mr_fastdownload, usemirror } from "../utils/utils.js";
|
||||||
|
import { modpack_info, XPlatform } from "./index.js";
|
||||||
|
import { join } from "node:path";
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
const unpath = join(path,e.path)
|
||||||
|
if (usemirror){
|
||||||
|
tmp.push(["https://mod.mcimirror.top"+new URL(e.downloads[0]).pathname,unpath,String(e.fileSize)])
|
||||||
|
}else{
|
||||||
|
tmp.push([e.downloads[0],unpath,String(e.fileSize)])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await mr_fastdownload(tmp as unknown as [string, string, string])
|
||||||
|
}
|
||||||
|
}
|
||||||
199
src/utils/DeEarth.ts
Normal file
199
src/utils/DeEarth.ts
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
/* Power by.Tianpao
|
||||||
|
* 本工具可能会判断失误,但也能为您节省不少时间!
|
||||||
|
* DeEarth V2 From StarNet.X
|
||||||
|
* Writing in 07.10.2025(latest)
|
||||||
|
* ©2024-2025
|
||||||
|
*/
|
||||||
|
import AdmZip from "adm-zip";
|
||||||
|
import got from "got";
|
||||||
|
import fs from "fs";
|
||||||
|
import crypto from "crypto";
|
||||||
|
import toml from 'smol-toml'
|
||||||
|
import path from 'path';
|
||||||
|
import pMap from "p-map";
|
||||||
|
import { usemirror } from "./utils.js";
|
||||||
|
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) {
|
||||||
|
let mrurl = "https://api.modrinth.com"
|
||||||
|
if (usemirror){
|
||||||
|
mrurl = "https://mod.mcimirror.top/modrinth"
|
||||||
|
}
|
||||||
|
|
||||||
|
let pid:string|undefined = undefined
|
||||||
|
try {
|
||||||
|
const data = fs.readFileSync(modpath)
|
||||||
|
const hash = crypto.createHash('sha1').update(data).digest('hex')
|
||||||
|
const pjson = await got.get(`${mrurl}/v2/version_file/${hash}?algorithm=sha1`,{
|
||||||
|
headers:{
|
||||||
|
"User-Agent": "DeEarth"
|
||||||
|
}
|
||||||
|
}).json<{project_id:string}>()
|
||||||
|
pid = pjson.project_id
|
||||||
|
//console.log("哈希命中成功,正在查询Modrinth")
|
||||||
|
}catch(e){}
|
||||||
|
|
||||||
|
const zipinfo = ZipInfo(modpath)
|
||||||
|
let modid:string = ""
|
||||||
|
if(zipinfo){
|
||||||
|
if(zipinfo.modinfo.type === "forge"){
|
||||||
|
modid = zipinfo.modinfo.data.mods[0].modId
|
||||||
|
}else if(zipinfo.modinfo.type === "fabric"){
|
||||||
|
modid = zipinfo.modinfo.data.id
|
||||||
|
}
|
||||||
|
|
||||||
|
try { //Modrinth
|
||||||
|
let body:any
|
||||||
|
if (pid){
|
||||||
|
body = JSON.parse(await FastGot(`${mrurl}/v2/project/${pid}`))
|
||||||
|
}else{
|
||||||
|
body = JSON.parse(await FastGot(`${mrurl}/v2/project/${modid}`))
|
||||||
|
}
|
||||||
|
if(body.client_side == "required" && body.server_side !== "required"){
|
||||||
|
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||||
|
}
|
||||||
|
} catch (error) { //DeEarthPublic
|
||||||
|
try {
|
||||||
|
if (JSON.parse(await FastGot(`https://dearth.0771010.xyz/api/modid?modid=${modid}`)).isClient) {
|
||||||
|
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||||
|
}else{
|
||||||
|
throw new Error("DeEarthPublic Not Found This Mod")
|
||||||
|
}
|
||||||
|
} catch (error) { //mods.toml或fabric.mod.json判断
|
||||||
|
try{
|
||||||
|
if(zipinfo.modinfo.type === "forge"){
|
||||||
|
const mcside = zipinfo.modinfo.data.dependencies[modid].find((mod: { modId: string; }) => mod.modId === "minecraft").side //Minecraft
|
||||||
|
if (mcside == "CLIENT") {
|
||||||
|
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||||
|
}
|
||||||
|
const forgeside = zipinfo.modinfo.data.dependencies[modid].find((mod: { modId: string; }) => mod.modId === "forge").side //Forge
|
||||||
|
if (forgeside == "CLIENT") {
|
||||||
|
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||||
|
}
|
||||||
|
const neoside = zipinfo.modinfo.data.dependencies[modid].find((mod: { modId: string; }) => mod.modId === "neoforge").side //NeoForge
|
||||||
|
if (neoside == "CLIENT") {
|
||||||
|
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||||
|
}
|
||||||
|
}else if(zipinfo.modinfo.type === "fabric"){ //Fabric
|
||||||
|
const fmj = zipinfo.modinfo.data.environment
|
||||||
|
if (fmj == "client") {
|
||||||
|
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(error){
|
||||||
|
try{
|
||||||
|
for (let i = 0; i < zipinfo.mixins.length; i++) {
|
||||||
|
const e = zipinfo.mixins[i]
|
||||||
|
const info = JSON.parse(e.info)
|
||||||
|
if (isMixin(info)) {
|
||||||
|
fs.renameSync(modpath, `${movepath}/${path.basename(modpath)}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(error){
|
||||||
|
LOGGER.error(`大天才JSON写注释了估计,模组路径:${modpath},过滤失败`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ZipInfo(modpath: string) {
|
||||||
|
interface ZipInfo {
|
||||||
|
mixins: { filename: string, info: string }[]
|
||||||
|
modinfo: {type:string,data:any};
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
let zipinfo: ZipInfo = { mixins: [], modinfo: {type: "",data: {}} }
|
||||||
|
const zip = new AdmZip(modpath).getEntries();
|
||||||
|
for (let i = 0; i < zip.length; i++) {
|
||||||
|
const e = zip[i]
|
||||||
|
if (isMixinFile(e.entryName)) {
|
||||||
|
zipinfo.mixins.push({ filename: e.entryName, info: e.getData().toString('utf-8') })
|
||||||
|
} else if (isForge(e.entryName)) {
|
||||||
|
zipinfo.modinfo.type = "forge"
|
||||||
|
zipinfo.modinfo.data = toml.parse(e.getData().toString('utf-8'))
|
||||||
|
} else if (e.entryName.endsWith("fabric.mod.json")) {
|
||||||
|
zipinfo.modinfo.type = "fabric"
|
||||||
|
zipinfo.modinfo.data = JSON.parse(e.getData().toString('utf-8'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return zipinfo;
|
||||||
|
}catch(error){
|
||||||
|
LOGGER.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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": "DeEarthX" } })).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 isMixin(resx: { mixins: {} | null; client: {}; }) {
|
||||||
|
return resx.mixins == null || Object.keys(resx.mixins).length == 0 && Object.keys(resx.client).length !== 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function isForge(name: string): boolean {
|
||||||
|
return name.endsWith("mods.toml") || name.endsWith("neoforge.mod.toml")
|
||||||
|
}
|
||||||
|
|
||||||
|
function isMixinFile(name: string): boolean {
|
||||||
|
return !name.includes("/") && name.endsWith(".json") && !name.endsWith("refmap.json") && !name.endsWith("mod.json")
|
||||||
|
}
|
||||||
|
|
||||||
|
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 pc from "picocolors"
|
||||||
|
export const LOGGER = {
|
||||||
|
info(text: string) {
|
||||||
|
info(text);
|
||||||
|
},
|
||||||
|
warn(text: string) {
|
||||||
|
warn(text);
|
||||||
|
},
|
||||||
|
error(text: string | object | unknown) {
|
||||||
|
error(text);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
function info(text: string) {
|
||||||
|
console.log(
|
||||||
|
`[${pc.blue(
|
||||||
|
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
|
||||||
|
)}](${process.pid})[${pc.green("INFO")}]:${pc.cyan(text)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function warn(text: string) {
|
||||||
|
console.log(
|
||||||
|
`[${pc.blue(
|
||||||
|
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
|
||||||
|
)}](${process.pid})[${pc.yellowBright("WARN")}]:${pc.yellowBright(
|
||||||
|
text
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function error(error: object | string | unknown) {
|
||||||
|
if (typeof error === "object") {
|
||||||
|
console.log(
|
||||||
|
`[${pc.blue(
|
||||||
|
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
|
||||||
|
)}](${process.pid})[${pc.red("ERROR")}:${JSON.stringify(error)}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
`[${pc.blue(
|
||||||
|
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
|
||||||
|
)}](${process.pid})[${pc.red("ERROR")}:${error}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
203
src/utils/utils.ts
Normal file
203
src/utils/utils.ts
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
import pMap from "p-map";
|
||||||
|
import pRetry from "p-retry";
|
||||||
|
import fs from "node:fs";
|
||||||
|
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";
|
||||||
|
import { exec } from "node:child_process";
|
||||||
|
|
||||||
|
export interface ForgeInfo{
|
||||||
|
minecraft_verison: string,
|
||||||
|
forge_verison: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function readzipentry(
|
||||||
|
zipfile: yauzl.ZipFile,
|
||||||
|
entry: yauzl.Entry
|
||||||
|
): Promise<string> {
|
||||||
|
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", () => {
|
||||||
|
if (data.length !== 0 && typeof data !== "string") {
|
||||||
|
reslove(Buffer.concat(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] /*.replace("https://mod.mcimirror.top","https://edge.forgecdn.net")*/,
|
||||||
|
{ headers: { "user-agent": "DeEarthX" } }
|
||||||
|
)
|
||||||
|
).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 (!fs.existsSync(e[1])) {
|
||||||
|
await got
|
||||||
|
.get(e[0], {
|
||||||
|
responseType: "buffer",
|
||||||
|
headers: {
|
||||||
|
"user-agent": "DeEarthX",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.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",
|
||||||
|
headers: {
|
||||||
|
"user-agent": "DeEarthX",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.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 &&
|
||||||
|
!fs.existsSync(e[1])
|
||||||
|
) {
|
||||||
|
const res = (await got.get(e[0],{
|
||||||
|
headers: {
|
||||||
|
"user-agent": "DeEarthX"
|
||||||
|
}
|
||||||
|
})).rawBody; //下载文件
|
||||||
|
await fse.outputFile(e[1], res); //保存文件
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
retries: 2,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
LOGGER.error({ err: error });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
concurrency: concurrency,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const usemirror = (() => {
|
||||||
|
env.config({ debug: false });
|
||||||
|
const mirror = process.env.MIRROR;
|
||||||
|
if (mirror) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
export const isDevelopment = (() => {
|
||||||
|
env.config();
|
||||||
|
return process.env.DEVELOPMENT;
|
||||||
|
})();
|
||||||
|
|
||||||
|
export const isInstallJava:Promise<boolean> = (() => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
exec("java -version", (err) => {
|
||||||
|
if (err) {
|
||||||
|
resolve(false);
|
||||||
|
} else {
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user