From 23fe6d10f5f7d92502f20c3460995caed68ecf75 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 13 Jan 2026 17:07:15 -0700 Subject: [PATCH] Remove scripts in favour of submodule --- scripts/buildCompendia.mjs | 32 ------------- scripts/createForgejoRelease.mjs | 55 ---------------------- scripts/extractCompendia.mjs | 27 ----------- scripts/linkFoundry.mjs | 47 ------------------- scripts/macros/deleteInvalidActors.mjs | 4 -- scripts/macros/deleteInvalidItems.mjs | 4 -- scripts/prepareManifest.mjs | 45 ------------------ scripts/tagExists.mjs | 38 --------------- scripts/uploadToS3.mjs | 65 -------------------------- 9 files changed, 317 deletions(-) delete mode 100644 scripts/buildCompendia.mjs delete mode 100644 scripts/createForgejoRelease.mjs delete mode 100644 scripts/extractCompendia.mjs delete mode 100644 scripts/linkFoundry.mjs delete mode 100644 scripts/macros/deleteInvalidActors.mjs delete mode 100644 scripts/macros/deleteInvalidItems.mjs delete mode 100644 scripts/prepareManifest.mjs delete mode 100644 scripts/tagExists.mjs delete mode 100644 scripts/uploadToS3.mjs diff --git a/scripts/buildCompendia.mjs b/scripts/buildCompendia.mjs deleted file mode 100644 index a9f3152..0000000 --- a/scripts/buildCompendia.mjs +++ /dev/null @@ -1,32 +0,0 @@ -import { compilePack } from "@foundryvtt/foundryvtt-cli"; -import { existsSync } from "fs"; -import { join } from "path"; -import { readFile } from "fs/promises"; - -async function main() { - const system = JSON.parse(await readFile(`./system.json`, `utf-8`)); - - if (!system.packs || system.packs.length === 0) { - console.log(`No compendium packs defined`); - process.exit(0); - }; - - for (const compendium of system.packs) { - console.debug(`Packing ${compendium.label} (${compendium.name})`); - let src = join(process.cwd(), compendium.path, `_source`); - if (!existsSync(src)) { - console.warn(`${compendium.path} doesn't exist, skipping.`) - continue; - }; - await compilePack( - src, - join(process.cwd(), compendium.path), - { recursive: true }, - ); - console.debug(`Finished packing ${compendium.name}`); - }; - - console.log(`Finished packing compendia`) -}; - -main(); diff --git a/scripts/createForgejoRelease.mjs b/scripts/createForgejoRelease.mjs deleted file mode 100644 index c45ae47..0000000 --- a/scripts/createForgejoRelease.mjs +++ /dev/null @@ -1,55 +0,0 @@ -import axios from "axios"; - -const { - TAG, - FORGEJO_SERVER_URL: WEB_URL, - FORGEJO_API_URL: API, - FORGEJO_REPOSITORY: REPO, - FORGEJO_TOKEN: TOKEN, - CDN_URL, -} = process.env; - -async function addReleaseAsset(releaseID, name) { - return axios.post( - `${API}/repos/${REPO}/releases/${releaseID}/assets`, - { external_url: `${CDN_URL}/${REPO}/${TAG}/${name}`, }, - { - headers: { - Authorization: `token ${TOKEN}`, - "Content-Type": `multipart/form-data`, - }, - params: { name }, - } - ); -}; - -async function main() { - - // Initial Release Data - const release = await axios.post( - `${API}/repos/${REPO}/releases`, - { - name: TAG, - tag_name: TAG, - draft: true, - hide_archive_links: true, - target_commitish: `main`, - body: ``, - }, - { - headers: { Authorization: `token ${TOKEN}` }, - } - ); - - try { - await addReleaseAsset(release.data.id, `release.zip`); - await addReleaseAsset(release.data.id, `system.json`); - } catch (e) { - console.error(`Failed to add assets to the release`); - process.exit(1); - }; - - console.log(`Release created`); -}; - -main(); diff --git a/scripts/extractCompendia.mjs b/scripts/extractCompendia.mjs deleted file mode 100644 index 32935c9..0000000 --- a/scripts/extractCompendia.mjs +++ /dev/null @@ -1,27 +0,0 @@ -import { readFile } from "fs/promises"; -import { join } from "path"; -import { extractPack } from "@foundryvtt/foundryvtt-cli"; - -async function main() { - const system = JSON.parse(await readFile(`./system.json`, `utf-8`)); - - if (!system.packs || system.packs.length === 0) { - console.log(`No compendium packs defined`); - process.exit(0); - }; - - for (const compendium of system.packs) { - console.debug(`Unpacking ${compendium.label} (${compendium.name})`); - let src = join(process.cwd(), compendium.path, `_source`); - await extractPack( - join(process.cwd(), compendium.path), - src, - { recursive: true }, - ); - console.debug(`Finished packing ${compendium.name}`); - }; - - console.log(`Finished unpacking compendia`); -}; - -main(); diff --git a/scripts/linkFoundry.mjs b/scripts/linkFoundry.mjs deleted file mode 100644 index 1cbb71a..0000000 --- a/scripts/linkFoundry.mjs +++ /dev/null @@ -1,47 +0,0 @@ -import { existsSync } from "fs"; -import { symlink, unlink } from "fs/promises"; -import { join } from "path"; -import { config } from "dotenv"; - -config({ quiet: true }); - -const root = process.env.FOUNDRY_ROOT; - -// Early exit -if (!root) { - console.error(`Must provide a FOUNDRY_ROOT environment variable`); - process.exit(1); -}; - -// Assert Foundry exists -if (!existsSync(root)) { - console.error(`Foundry root not found.`); - process.exit(1); -}; - -// Removing existing symlink -if (existsSync(`foundry`)) { - console.log(`Attempting to unlink foundry instance`); - try { - await unlink(`foundry`); - } catch { - console.error(`Failed to unlink foundry folder.`); - process.exit(1); - }; -}; - -// Account for if the root is pointing at an Electron install -let targetRoot = root; -if (existsSync(join(root, `resources`, `app`))) { - console.log(`Switching to use the "${root}/resources/app" directory`); - targetRoot = join(root, `resources`, `app`); -}; - -// Create symlink -console.log(`Linking foundry source into folder`) -try { - await symlink(targetRoot, `foundry`); -} catch (e) { - console.error(e); - process.exit(1); -}; diff --git a/scripts/macros/deleteInvalidActors.mjs b/scripts/macros/deleteInvalidActors.mjs deleted file mode 100644 index c8f09e6..0000000 --- a/scripts/macros/deleteInvalidActors.mjs +++ /dev/null @@ -1,4 +0,0 @@ -const invalids = game.actors.invalidDocumentIds; -invalids.forEach(id => { - game.actors.getInvalid(id).delete(); -}); diff --git a/scripts/macros/deleteInvalidItems.mjs b/scripts/macros/deleteInvalidItems.mjs deleted file mode 100644 index 6fcbdc9..0000000 --- a/scripts/macros/deleteInvalidItems.mjs +++ /dev/null @@ -1,4 +0,0 @@ -const invalids = game.items.invalidDocumentIds; -invalids.forEach(id => { - game.items.getInvalid(id).delete(); -}); diff --git a/scripts/prepareManifest.mjs b/scripts/prepareManifest.mjs deleted file mode 100644 index 34f4236..0000000 --- a/scripts/prepareManifest.mjs +++ /dev/null @@ -1,45 +0,0 @@ -/* -The intent of this script is to do all of the modifications of the -manifest file that we need to do in order to release the system. -This can include removing dev-only fields/attributes that end -users will never, and should never, care about nor need. -*/ -import { readFile, writeFile } from "fs/promises"; - -const MANIFEST_PATH = `system.json`; - -const { - DOWNLOAD_URL, - LATEST_URL, -} = process.env; - -let manifest; -try { - manifest = JSON.parse(await readFile(MANIFEST_PATH, `utf-8`)); - console.log(`Manifest loaded from disk`); -} catch { - console.error(`Failed to parse manifest file.`); - process.exit(1); -}; - -console.log(`Updating download/manifest URLs`) -manifest.download = DOWNLOAD_URL; -manifest.manifest = LATEST_URL; - -// Filter out dev-only resources -if (manifest.esmodules) { - console.log(`Removing dev-only esmodules`); - manifest.esmodules = manifest.esmodules.filter( - filepath => !filepath.startsWith(`dev/`) - ); -}; - -// Remove dev flags -console.log(`Cleaning up flags`); -delete manifest.flags?.hotReload; -if (Object.keys(manifest.flags).length === 0) { - delete manifest.flags; -}; - -await writeFile(MANIFEST_PATH, JSON.stringify(manifest, undefined, `\t`)); -console.log(`Manifest written back to disk`); diff --git a/scripts/tagExists.mjs b/scripts/tagExists.mjs deleted file mode 100644 index 2ddcdbd..0000000 --- a/scripts/tagExists.mjs +++ /dev/null @@ -1,38 +0,0 @@ -import axios from "axios"; - -const { - TAG_NAME, - FORGEJO_API_URL: API_URL, - FORGEJO_REPOSITORY: REPO, - FORGEJO_TOKEN: TOKEN, -} = process.env; - - -async function main() { - - if (!TAG_NAME) { - console.log(`Tag name must not be blank`); - process.exit(1); - }; - - const requestURL = `${API_URL}/repos/${REPO}/tags/${TAG_NAME}`; - - const response = await axios.get( - requestURL, - { - headers: { Authorization: `token ${TOKEN}` }, - validateStatus: () => true, - }, - ); - - // We actually *want* an error when the tag exists, instead of when - // it doesn't - if (response.status === 200) { - console.log(`Tag with name "${TAG_NAME}" already exists`); - process.exit(1); - }; - - console.log(`Tag with name "${TAG_NAME}" not found, proceeding`); -}; - -main(); diff --git a/scripts/uploadToS3.mjs b/scripts/uploadToS3.mjs deleted file mode 100644 index dacd2e8..0000000 --- a/scripts/uploadToS3.mjs +++ /dev/null @@ -1,65 +0,0 @@ -import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'; -import { createReadStream } from "fs"; - -const requiredEnvVariables = [ - `TAG`, `FILE`, - `FORGEJO_REPOSITORY`, - `S3_BUCKET`, `S3_REGION`, `S3_KEY`, `S3_SECRET`, `S3_ENDPOINT`, -]; - -async function main() { - - // Assert all of the required env variables are present - const missing = []; - for (const envVar of requiredEnvVariables) { - if (!(envVar in process.env)) { - missing.push(envVar); - }; - }; - if (missing.length > 0) { - console.error(`Missing the following required environment variables: ${missing.join(`, `)}`); - process.exit(1); - }; - - const { - TAG, - S3_ENDPOINT, - S3_REGION, - S3_KEY, - S3_SECRET, - S3_BUCKET, - FILE, - FORGEJO_REPOSITORY: REPO, - } = process.env; - - const s3Client = new S3Client({ - endpoint: S3_ENDPOINT, - forcePathStyle: false, - region: S3_REGION, - credentials: { - accessKeyId: S3_KEY, - secretAccessKey: S3_SECRET - }, - }); - - const name = FILE.split(`/`).at(-1); - - const params = { - Bucket: S3_BUCKET, - Key: `${REPO}/${TAG}/${name}`, - Body: createReadStream(FILE), - ACL: "public-read", - METADATA: { - "x-repo-version": TAG, - }, - }; - - try { - const response = await s3Client.send(new PutObjectCommand(params)); - console.log("Upload successful"); - } catch (err) { - console.error("Upload to s3 failed"); - }; -}; - -main();