This PR updates Nomi-Labs to 0.7.0, allowing for associate updates to GT, GCYM, GrS and Architecture Craft, as well as the removal of Random Patches, Just Enough Dimensions, and Difficulty Lock. Although GT 2.8.10 also fixed Extreme RAM Usage in Alfheim 1.3, (See PR https://github.com/GregTechCEu/GregTech/pull/2475) this PR **does not** update Alfheim to 1.3. This is because Alfheim 1.3, although not consuming large amounts of memory, still consumes more memory than 1.1.1, and causes fps spikes. Also, because Nomi-Labs now implements a native and better difficulty lock, of which works on dedicated servers, `server.properties` overrides, as well as previously changed parts in README and Pack Mode Switchers (in https://github.com/Nomi-CEu/Nomi-CEu/pull/292), have been removed. This PR also fixes an issue with corrupted images and jar files in built packs. /* Github Stuff */ [FIXUP] [[fixes]] sha = "bd58b9072f45d647734ae66168cbd27bf9b2f220" newTitle = "Update GT and Related Mods for 1.7" newBody = ''' [EXPAND] [[messages]] messageTitle = "Update GT to 2.8+, add Nomi Labs" messageBody = """ [BREAKING] [DETAILS] details = [ \"**Please DO NOT revert any saves that have been loaded in this release to 1.6.1b, 1.6.1a, or prior!**\", \"**Lots of Recipes have been moved to the Assembly Line, and now require Assembly Line Research.**\", \"Adds Assembly Line Research\", \"Adds ME Hatches and Buses, for combining Multiblocks with AE Networks\", \"Adds Filtered Output Hatches\", \"Adds EU Multiblock Power Storage\", \"Adds Multiblock Transformer and Laser Power Transfer\", \"Adds Long Distance Pipes\", \"Creating Waypoints in the Prospector\", \"Fixing many Bugs\", \"And many more!\" ] [DETAILS] [PRIORITY] priority = 100 [PRIORITY] """ [[messages]] messageTitle = "Multiblock Changes" messageBody = """ [BREAKING] [DETAILS] details = [ \"Multiblocks accept a new **maximum** of 2 Energy Hatches.\", \"All Custom Multiblocks, such as Naquadah Reactors and Multiverse Projectors, now have **minimum casing requirements** and a **maintenance hatch**.\", \"Some Custom Multiblocks now have Distinct Mode\", \"All Custom Multiblocks now have custom Front Overlays\", \"Reworked & Improved Multiblock UIs\" ] [DETAILS] [PRIORITY] priority = 50 [PRIORITY] """ [EXPAND] ''' [FIXUP] [EXPAND] [[messages]] messageTitle = "Upgrade AE2 Stuff to AE2 Stuff Unofficial" messageBody = ''' [BREAKING] [DETAILS] details = [ "Pattern Encoders have been Removed!", "Any existing Pattern Encoders, whether items, in patterns or placed, have been remapped to AE2 Interfaces.", "All Usages in Recipes have also been changed to AE2 Interfaces!", ] [DETAILS] [PRIORITY] priority=25 [PRIORITY] ''' [[messages]] messageTitle = "Update GT to 2.8.10" messageBody = ''' [BREAKING] [DETAILS] details = [ "Allows GregTech Data Sticks to Copy ME Hatch Settings", "Adds an 'Stocking' Version of ME Hatches and Buses", "Support for Displaying Power Substation on Central Monitor", ] [DETAILS] [PRIORITY] priority=20 [PRIORITY] [IGNORE] checks = { compareBefore = "1.7-alpha-4" } # Only apply this if the commit being compared against is 1.7-alpha-4 or newer [IGNORE] ''' [[messages]] messageTitle = "Update Nomi Labs to 0.7.0" messageBody = ''' [BREAKING] [DETAILS] details = [ "Improvement of DME Simulation Chamber (now increases Tiers and Data Counts of Models)", "Custom Implementation of Difficulty Lock, now works on Dedicated Servers", "Replacement of the Void Dimension, fixing issues with Difficulty Changing", "Replacement of Custom Window Titles and Logos, Allowing the Removal of Random Patches", "Improvements to FTB Utils and Effortless Building", "Allows Setting of Default Keybinds for New Players", ] [DETAILS] [PRIORITY] priority=15 [PRIORITY] [IGNORE] checks = { compareBefore = "1.7-alpha-4" } # Only apply this if the commit being compared against is 1.7-alpha-4 or newer [IGNORE] ''' [EXPAND] [MOD INFO] [[infos]] projectID = 254317 info = "Replaced by Nomi Labs" [[infos]] projectID = 285612 info = "Replaced by Nomi Labs" [[infos]] projectID = 390886 info = "Replaced by Nomi Labs" [[infos]] projectID = 538092 info = "Replaced by Betterer P2P" [MOD INFO]
269 lines
8.0 KiB
TypeScript
269 lines
8.0 KiB
TypeScript
import fs from "fs";
|
|
import upath from "upath";
|
|
import { configFolder, rootDirectory, templatesFolder } from "#globals";
|
|
import mustache from "mustache";
|
|
import gulp from "gulp";
|
|
import dedent from "dedent-js";
|
|
import { isEnvVariableSet } from "#utils/util.ts";
|
|
import { BuildData } from "#types/transformFiles.ts";
|
|
import { logWarn } from "#utils/log.ts";
|
|
import sortKeysRecursive from "sort-keys-recursive";
|
|
|
|
// This updates all the files, for a release.
|
|
|
|
// If it is not a release or build, and thus no changes to versions need to be made.
|
|
// This occurs when the files are to be updated from the templates outside of a release or a build.
|
|
let updateFiles: boolean;
|
|
let updateFileVersion: string;
|
|
let updateFileTransformedVersion: string;
|
|
|
|
let buildData: BuildData;
|
|
|
|
async function updateFilesSetup(): Promise<void> {
|
|
updateFiles = false;
|
|
// See if current run is to update files
|
|
if (isEnvVariableSet("UPDATE_FILES")) {
|
|
try {
|
|
updateFiles = JSON.parse(
|
|
(process.env.UPDATE_FILES ?? "false").toLowerCase(),
|
|
);
|
|
} catch (err) {
|
|
throw new Error("Update Files Env Variable set to Invalid Value.");
|
|
}
|
|
}
|
|
buildData = new BuildData();
|
|
|
|
const versionsFilePath: string = upath.join(templatesFolder, "versions.txt");
|
|
updateFileVersion = "";
|
|
|
|
if (!buildData.isVersionBuild() && !updateFiles) return;
|
|
|
|
// Versions.txt handling
|
|
if (!fs.existsSync(versionsFilePath)) {
|
|
if (updateFiles) {
|
|
if (!buildData.isVersionBuild())
|
|
throw new Error(
|
|
"In order to update files, needs versions.txt to exist and have values, or the version to be set via the GITHUB_TAG environmental variable.",
|
|
);
|
|
updateFileVersion = buildData.rawVersion;
|
|
updateFileTransformedVersion = buildData.transformedVersion;
|
|
return;
|
|
}
|
|
logWarn(
|
|
"Version.txt does not exist. Creating empty file. This may be an error.",
|
|
);
|
|
|
|
// Create Versions.txt
|
|
fs.closeSync(fs.openSync(versionsFilePath, "w"));
|
|
} else {
|
|
const versionList = await fs.promises.readFile(versionsFilePath, "utf8");
|
|
|
|
if (updateFiles) {
|
|
if (!versionList) {
|
|
if (!buildData.isVersionBuild())
|
|
throw new Error(
|
|
"In order to update files, needs versions.txt to exist and have values, or the version to be set via the GITHUB_TAG environmental variable.",
|
|
);
|
|
updateFileVersion = buildData.rawVersion;
|
|
updateFileTransformedVersion = buildData.transformedVersion;
|
|
return;
|
|
}
|
|
updateFileVersion = versionList.split("\n")[0].replace("-", "").trim();
|
|
updateFileTransformedVersion = `v${updateFileVersion}`;
|
|
return;
|
|
}
|
|
|
|
// Duplicate Key
|
|
if (versionList.includes(`${buildData.rawVersion}\n`)) {
|
|
throw new Error("Version already exists in version.txt. Exiting...");
|
|
}
|
|
}
|
|
}
|
|
|
|
export async function updateFilesBuildSetup() {
|
|
updateFiles = true;
|
|
buildData = new BuildData();
|
|
updateFileVersion = buildData.rawVersion;
|
|
updateFileTransformedVersion = buildData.transformedVersion;
|
|
}
|
|
|
|
/**
|
|
* @param readPath The filepath to read from. (Template)
|
|
* @param writePath The filepath to write to.
|
|
* @param replacementObject A record, of type string to type unknown, containing the keys, and replacement for those keys
|
|
* @param addWarning whether to add warning not to edit file
|
|
* <p>
|
|
* <p>
|
|
* A warning not to edit the file will also be added to the start of the file.
|
|
*/
|
|
async function modifyFile(
|
|
readPath: string,
|
|
writePath: string,
|
|
replacementObject: Record<string, unknown>,
|
|
addWarning = true,
|
|
) {
|
|
// Read the file content
|
|
const data: string = await fs.promises.readFile(readPath, "utf8");
|
|
|
|
// Moustache Render
|
|
let modifiedData: string = mustache.render(data, replacementObject);
|
|
|
|
// Add warning to not edit file
|
|
if (addWarning)
|
|
modifiedData = dedent`# FOR DEVELOPMENT, DO NOT EDIT THIS FILE! EDIT THE TEMPlATES INSTEAD!
|
|
# See https://github.com/Nomi-CEu/Nomi-CEu/wiki/Part-1:-Contributing-Information#section-5-template-information!
|
|
${modifiedData}`;
|
|
|
|
// Write the modified content back to the file
|
|
return fs.promises.writeFile(writePath, modifiedData, "utf8");
|
|
}
|
|
|
|
/* Functions NOT Used in Build Process */
|
|
async function updateIssueTemplates(): Promise<void> {
|
|
// Filenames
|
|
const fileNames: string[] = ["001-bug-report.yml", "002-feature-request.yml"];
|
|
|
|
const versionsFilePath: string = upath.join(templatesFolder, "versions.txt");
|
|
|
|
let versionList: string = await fs.promises.readFile(
|
|
versionsFilePath,
|
|
"utf8",
|
|
);
|
|
|
|
if (!updateFiles) {
|
|
if (!buildData.isVersionBuild())
|
|
throw new Error(
|
|
"In order to update Issue Templates, the version must be set via the GITHUB_TAG environmental variable.",
|
|
);
|
|
// Add new version to list, with indent
|
|
versionList = ` - ${buildData.rawVersion}\n${versionList}`;
|
|
|
|
// Write updated Version List
|
|
await fs.promises.writeFile(versionsFilePath, versionList);
|
|
}
|
|
|
|
// Replacement Object
|
|
const replacementObject: Record<string, unknown> = {
|
|
versions: versionList,
|
|
};
|
|
|
|
const issueTemplatesFolder: string = upath.join(
|
|
rootDirectory,
|
|
".github",
|
|
"ISSUE_TEMPLATE",
|
|
);
|
|
|
|
// Write to issue templates
|
|
for (const fileName of fileNames) {
|
|
const readPath = upath.join(templatesFolder, fileName);
|
|
const writePath = upath.join(issueTemplatesFolder, fileName);
|
|
await modifyFile(readPath, writePath, replacementObject);
|
|
}
|
|
}
|
|
|
|
async function updateMainMenuConfig(): Promise<void> {
|
|
// Filename & paths
|
|
const fileName = "mainmenu.json";
|
|
const readPath: string = upath.join(templatesFolder, fileName);
|
|
const writePath: string = upath.join(
|
|
rootDirectory,
|
|
configFolder,
|
|
"CustomMainMenu",
|
|
fileName,
|
|
);
|
|
|
|
if (!updateFiles && !buildData.isVersionBuild())
|
|
throw new Error(
|
|
"The main menu should only be updated if the version is set via the GITHUB_TAG environmental variable.",
|
|
);
|
|
|
|
// Replacement object
|
|
const replacementObject: Record<string, unknown> = {
|
|
version: updateFiles ? updateFileVersion : buildData.rawVersion,
|
|
};
|
|
|
|
// Read file
|
|
const data: string = await fs.promises.readFile(readPath, "utf8");
|
|
|
|
// Moustache Render
|
|
let modifiedData = JSON.parse(mustache.render(data, replacementObject));
|
|
|
|
// Add warning to not edit file
|
|
modifiedData["_comment"] =
|
|
"FOR DEVELOPMENT, DO NOT EDIT THIS FILE! EDIT THE TEMPlATES INSTEAD! See https://github.com/Nomi-CEu/Nomi-CEu/wiki/Part-1:-Contributing-Information#section-5-template-information!";
|
|
|
|
// Sort keys so that comment appears first
|
|
modifiedData = sortKeysRecursive(modifiedData);
|
|
|
|
return await fs.promises.writeFile(
|
|
writePath,
|
|
JSON.stringify(modifiedData, null, 2),
|
|
"utf8",
|
|
);
|
|
}
|
|
|
|
/* Functions USED in Build Process */
|
|
export async function updateLabsVersion(rootDir: string): Promise<void> {
|
|
const fileName = "nomilabs-version.cfg";
|
|
const readPath: string = upath.join(templatesFolder, fileName);
|
|
const writePath = upath.join(rootDir, configFolder, fileName);
|
|
|
|
const replacementObject: Record<string, unknown> = {
|
|
version: updateFiles
|
|
? updateFileTransformedVersion
|
|
: buildData.transformedVersion,
|
|
};
|
|
|
|
return modifyFile(readPath, writePath, replacementObject);
|
|
}
|
|
|
|
export async function updateServerProperties(rootDir: string): Promise<void> {
|
|
const fileName = "server.properties";
|
|
const readPath: string = upath.join(templatesFolder, fileName);
|
|
const writePath: string = upath.join(rootDir, fileName);
|
|
|
|
const replacementObject: Record<string, unknown> = {
|
|
versionTitle: updateFiles
|
|
? updateFileTransformedVersion
|
|
: buildData.transformedVersion,
|
|
};
|
|
|
|
return modifyFile(readPath, writePath, replacementObject);
|
|
}
|
|
|
|
// Main Closures
|
|
const updateFilesLabsVersion = async () => {
|
|
await updateLabsVersion(rootDirectory);
|
|
};
|
|
|
|
const updateFilesServerProperties = async () => {
|
|
await updateServerProperties(upath.join(rootDirectory, "serverfiles"));
|
|
};
|
|
|
|
export const updateFilesIssue = gulp.series(
|
|
updateFilesSetup,
|
|
updateIssueTemplates,
|
|
);
|
|
export const updateFilesVersion = gulp.series(
|
|
updateFilesSetup,
|
|
updateFilesLabsVersion,
|
|
);
|
|
export const updateFilesServer = gulp.series(
|
|
updateFilesSetup,
|
|
updateFilesServerProperties,
|
|
);
|
|
export const updateFilesMainMenu = gulp.series(
|
|
updateFilesSetup,
|
|
updateMainMenuConfig,
|
|
);
|
|
|
|
export const updateAll = gulp.series(
|
|
updateFilesSetup,
|
|
gulp.parallel(
|
|
updateIssueTemplates,
|
|
updateFilesLabsVersion,
|
|
updateFilesServerProperties,
|
|
updateMainMenuConfig,
|
|
),
|
|
);
|