feat(mc-mods): init new script
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
e1d77d8e05
commit
e3855ffb5e
8 changed files with 1769 additions and 0 deletions
3
apps/mc-mods/.envrc
Normal file
3
apps/mc-mods/.envrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
use flake $FLAKE#node
|
||||
(cd ../config; npm ci)
|
||||
npm ci
|
18
apps/mc-mods/default.nix
Normal file
18
apps/mc-mods/default.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
buildApp,
|
||||
nodejs_latest,
|
||||
...
|
||||
}:
|
||||
buildApp {
|
||||
src = ./.;
|
||||
npmDepsHash = "sha256-L4GX01M8/Q+9Kv+F2sYuhBVJrGv9V4fz4GyXQ/7IQn8=";
|
||||
|
||||
runtimeInputs = [
|
||||
nodejs_latest
|
||||
];
|
||||
|
||||
meta.description = ''
|
||||
Checks if a list of mods have a version available for a specific Minecraft
|
||||
version and a specific loader.
|
||||
'';
|
||||
}
|
3
apps/mc-mods/eslint.config.ts
Normal file
3
apps/mc-mods/eslint.config.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import eslintConf from 'eslint-conf';
|
||||
|
||||
export default eslintConf;
|
1653
apps/mc-mods/package-lock.json
generated
Normal file
1653
apps/mc-mods/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
18
apps/mc-mods/package.json
Normal file
18
apps/mc-mods/package.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "mc-mods",
|
||||
"version": "0.0.0",
|
||||
"bin": "out/bin/app.cjs",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "node_ver=$(node -v); esbuild src/app.ts --bundle --platform=node --target=\"node${node_ver:1:2}\" --outfile=out/bin/app.cjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint-conf": "file:../config",
|
||||
"@types/node": "22.13.4",
|
||||
"esbuild": "0.25.0",
|
||||
"eslint": "9.20.1",
|
||||
"jiti": "2.4.2",
|
||||
"pkg-types": "1.3.1",
|
||||
"typescript": "5.7.3"
|
||||
}
|
||||
}
|
63
apps/mc-mods/src/app.ts
Normal file
63
apps/mc-mods/src/app.ts
Normal file
|
@ -0,0 +1,63 @@
|
|||
interface Hashes {
|
||||
sha1: string
|
||||
sha512: string
|
||||
}
|
||||
interface File {
|
||||
hashes: Hashes
|
||||
url: string
|
||||
filename: string
|
||||
primary: boolean
|
||||
size: number
|
||||
file_type: string
|
||||
}
|
||||
interface Dependency {
|
||||
version_id: string
|
||||
project_id: string
|
||||
file_name: string
|
||||
dependency_type: string
|
||||
}
|
||||
interface ModVersion {
|
||||
game_versions: string[]
|
||||
loaders: string[]
|
||||
id: string
|
||||
project_id: string
|
||||
author_id: string
|
||||
featured: boolean
|
||||
name: string
|
||||
version_number: string
|
||||
changelog: string
|
||||
changelog_url: string
|
||||
date_published: string
|
||||
downloads: number
|
||||
version_type: string
|
||||
status: string
|
||||
files: File[]
|
||||
dependencies: Dependency[]
|
||||
}
|
||||
|
||||
const loader = 'fabric';
|
||||
const game_version = '1.21.4';
|
||||
|
||||
const getVersions = async(slug: string): Promise<ModVersion[]> => {
|
||||
const res = await fetch(`https://api.modrinth.com/v2/project/${slug}/version`);
|
||||
|
||||
if (res.ok) {
|
||||
return await res.json() as ModVersion[];
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
// TODO: prefer version_type 'release'
|
||||
// TODO: only get latest version based on date_published
|
||||
const checkModCompat = async(slug: string) => {
|
||||
const versions = await getVersions(slug);
|
||||
|
||||
const matching = versions.filter((ver) =>
|
||||
ver.game_versions.includes(game_version) &&
|
||||
ver.loaders.includes(loader));
|
||||
|
||||
console.log(matching);
|
||||
};
|
||||
|
||||
checkModCompat('lithium');
|
10
apps/mc-mods/tsconfig.json
Normal file
10
apps/mc-mods/tsconfig.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "../config/tsconfig.base.json",
|
||||
"includes": [
|
||||
"*.ts",
|
||||
"**/*.ts",
|
||||
"*.js",
|
||||
"**/*.js"
|
||||
]
|
||||
}
|
|
@ -11,6 +11,7 @@ in
|
|||
listToAttrs (map (x: nameValuePair x (callPackage ./${x})) [
|
||||
"extract-subs"
|
||||
"gen-docs"
|
||||
"mc-mods"
|
||||
"pin-inputs"
|
||||
"update-sources"
|
||||
])
|
||||
|
|
Loading…
Add table
Reference in a new issue