From b410325b242fb97864211143ed244af9fa8c909d Mon Sep 17 00:00:00 2001 From: CEbbinghaus Date: Fri, 20 Dec 2024 17:30:37 +1100 Subject: [PATCH] Fixed CI not being run on CI and cleaned up build scripts --- package.json | 2 +- util/build.mjs | 5 +++-- util/versioning.mjs | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index e54f26a..871f790 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "author": "Christopher-Robin ", "license": "GPL-2.0", "scripts": { - "prebuild": "exec node --no-warnings=ExperimentalWarning util/versioning.mjs update package.json lib/package.json", + "prebuild": "(node --no-warnings=ExperimentalWarning util/ci.mjs) && (node --no-warnings=ExperimentalWarning util/versioning.mjs update package.json lib/package.json)", "build": "shx rm -rf dist && rollup -c", "bundle": "shx rm -rf dist && rollup -c", "watch": "rollup -c -w", diff --git a/util/build.mjs b/util/build.mjs index ac8f71c..1ccaef9 100644 --- a/util/build.mjs +++ b/util/build.mjs @@ -7,6 +7,7 @@ import { Logger } from './log.mjs'; import { exit } from 'process'; import plugin from "../plugin.json" with { type: "json" }; +import { IsCI, SetEnvironment } from './ci.mjs'; const { name: PluginName } = plugin; if (process.argv.includes('-h') || process.argv.includes('--help')) { @@ -96,9 +97,9 @@ async function importJson(file) { return (await import(file, { with: { type: "json" } })).default; } -if (env["CI"]) { +if (IsCI()) { Logger.Log("Running CI related setup"); - runCommand("git config --global --add safe.directory /plugin"); + SetEnvironment(); } if (!quiet) Logger.Log(`Building plugin ${PluginName}@${Version}`); diff --git a/util/versioning.mjs b/util/versioning.mjs index 7a9fb67..756805b 100644 --- a/util/versioning.mjs +++ b/util/versioning.mjs @@ -1,6 +1,7 @@ import { readFileSync, writeFileSync, utimesSync, statSync } from "fs"; import { dirname, resolve } from "path"; import { fileURLToPath } from "url"; +import { Logger } from "./log.mjs"; export const Version = ReadPackageVersion(); function ReadPackageVersion() { @@ -52,15 +53,15 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { switch (process.argv[2]) { case "reset": - console.log(`Resetting ${files.join(", ")}`); + Logger.Info(`Resetting ${files.join(", ")}`); ResetVersion(...files); break; case "update": - console.log(`Updating ${files.join(", ")} to version ${Version}`); + Logger.Info(`Updating ${files.join(", ")} to version ${Version}`); UpdateVersion(...files); break; default: - console.log("Invalid argument provided. Must be one of 'reset' | 'update'"); + Logger.Info("Invalid argument provided. Must be one of 'reset' | 'update'"); process.exit(1); } } \ No newline at end of file