mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-11 09:11:50 +00:00
* Fix tsconfig scopes affecting html.js Since it's quite hard to use a DOM library type there, remove the type entirely. * Remove environment variables check Nothing is using them anymore. It can be added back if needed later. * Refactor Texture Packer downloading Refactor local-config.js tasks file into a generic "environment" category consisting of checking if Java is installed, downloading the runnable Texture Packer if it's not yet downloaded and copying the local configuration template; update README accordingly. * Prepare environment only at postinstall Remove environment.prepare task from default build pipelines, add a postinstall script that calls the task, using environment.js as the gulpfile to speed it up. * Remove "docs" tasks and types generation script Remove tasks from docs.js as they are unlikely to do anything meaningful nowadays. Also remove the buildTypes script as it doesn't work anymore. A better solution will be provided in the future. * Simplify some globs Use additional gulp.src options instead of specifying more or complex globs. * Extract built-temp location to a variable Add the src/js/built-temp directory as a new variable in config.js, replace all existing references to built-temp with this variable.
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
import { exec } from "child_process";
|
|
import fs from "fs/promises";
|
|
import gulp from "gulp";
|
|
import { promisify } from "util";
|
|
|
|
const texturePackerUrl =
|
|
"https://libgdx-nightlies.s3.amazonaws.com/libgdx-runnables/runnable-texturepacker.jar";
|
|
|
|
const configTemplatePath = "../src/js/core/config.local.template.js";
|
|
const configPath = "../src/js/core/config.local.js";
|
|
|
|
export async function checkJava() {
|
|
try {
|
|
const { stderr } = await promisify(exec)("java -version");
|
|
console.log(`Found Java:`, stderr);
|
|
} catch {
|
|
throw new Error("Java is required to build the texture atlas, but was not found");
|
|
}
|
|
}
|
|
|
|
export async function downloadTexturePacker() {
|
|
const destination = "./runnable-texturepacker.jar";
|
|
|
|
try {
|
|
// If the file exists already, we're done
|
|
await fs.access(destination);
|
|
return;
|
|
} catch {
|
|
// File does not exist, need to download
|
|
}
|
|
|
|
console.log(`Downloading ${destination}...`);
|
|
const response = await fetch(texturePackerUrl);
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to download Texture Packer: ${response.statusText}`);
|
|
}
|
|
|
|
await fs.writeFile(destination, response.body);
|
|
}
|
|
|
|
export async function createLocalConfig() {
|
|
try {
|
|
await fs.copyFile(configTemplatePath, configPath, fs.constants.COPYFILE_EXCL);
|
|
} catch {
|
|
// The file is already there
|
|
}
|
|
}
|
|
|
|
export const prepare = gulp.parallel(gulp.series(checkJava, downloadTexturePacker), createLocalConfig);
|