Add Minecraft 26.x support and version Java artifacts
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { existsSync } from "node:fs";
|
||||
import { mkdir, copyFile } from "node:fs/promises";
|
||||
import { mkdir, copyFile, readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
const windows = process.platform === "win32";
|
||||
const command = windows ? "gradlew.bat" : "sh";
|
||||
const targets = process.argv.slice(2);
|
||||
if (!targets.some((target) => !target.startsWith("-")))
|
||||
targets.unshift(":plugin:build", ":fabric:build");
|
||||
targets.unshift(
|
||||
":plugin:build",
|
||||
":fabric:build",
|
||||
":fabric261:build",
|
||||
":fabric262:build",
|
||||
);
|
||||
const version = (await readFile("minecraft/build.gradle", "utf8")).match(
|
||||
/version = '([^']+)'/,
|
||||
)?.[1];
|
||||
if (!version) throw new Error("Minecraft tools release version is missing");
|
||||
await new Promise((resolve, reject) => {
|
||||
const child = spawn(command, windows ? targets : ["./gradlew", ...targets], {
|
||||
cwd: "minecraft",
|
||||
@@ -18,15 +28,28 @@ await new Promise((resolve, reject) => {
|
||||
code === 0 ? resolve() : reject(new Error(`Gradle exited ${code}`)),
|
||||
);
|
||||
});
|
||||
for (const name of ["plugin", "fabric"]) {
|
||||
const directory = `public/tools/${name === "fabric" ? "mod" : "plugin"}`;
|
||||
const file = `minegeo-${name}-1.21.11.jar`,
|
||||
path = `minecraft/${name}/build/libs/${file}`;
|
||||
if (existsSync(path)) {
|
||||
for (const [name, kind, minecraftVersion] of [
|
||||
["plugin", "plugin", "1.21.11"],
|
||||
["fabric", "fabric", "1.21.11"],
|
||||
["fabric261", "fabric", "26.1"],
|
||||
["fabric262", "fabric", "26.2"],
|
||||
]) {
|
||||
const directory = `public/tools/${kind === "fabric" ? "mod" : "plugin"}`;
|
||||
const file = `minegeo-${kind}-${minecraftVersion}.jar`;
|
||||
const buildRoot = process.env.MINEGEO_JAVA_BUILD_ROOT
|
||||
? path.join(process.env.MINEGEO_JAVA_BUILD_ROOT, name)
|
||||
: `minecraft/${name}/build`;
|
||||
const artifact = path.join(buildRoot, "libs", file);
|
||||
if (existsSync(artifact)) {
|
||||
await mkdir(directory, { recursive: true });
|
||||
await copyFile(path, `${directory}/${file}`);
|
||||
await copyFile(artifact, `${directory}/${file}`);
|
||||
const releaseFile =
|
||||
kind === "plugin"
|
||||
? `minegeo-plugin-${version}.jar`
|
||||
: `minegeo-fabric-${minecraftVersion}-${version}.jar`;
|
||||
await copyFile(artifact, `${directory}/${releaseFile}`);
|
||||
console.log(
|
||||
`Updated ${directory}/${file}. Include this JAR in your next commit.`,
|
||||
`Updated ${directory}/${releaseFile} and its compatibility download.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user