From aff0d5ffbee455a4e53ba2d3bd07f610757d49f7 Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 24 Sep 2024 19:21:44 +0200 Subject: [PATCH 01/19] Updated release workflow --- .gitlab-ci.yml | 130 +++++++++------------- gulpfile.js | 286 +++++++++++++++++++++++++++++++++++++++++++++---- package.json | 3 +- 3 files changed, 321 insertions(+), 98 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c2ec346..2092403 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,24 @@ +image: ubuntu:latest + + stages: - - compile + - build - release -# Compile Job (runs on every commit) -compile: - stage: compile - image: ubuntu:latest +variables: + MANIFEST: "system.json" + ZIPFILE: "kidsonbrooms.zip" + PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}" + MANIFEST_RELEASE_URL: "${PACKAGE_REGISTRY_URL}/${MANIFEST}" + ZIPFILE_RELEASE_URL: "${PACKAGE_REGISTRY_URL}/${ZIPFILE}" + MANIFEST_PERMALINK_URL: "https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/permalink/latest/downloads/${MANIFEST}" + ZIPFILE_PERMALINK_URL: "https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/${CI_COMMIT_TAG}/downloads/${ZIPFILE}" + dry_run: true + + +# Build job +build: + stage: build before_script: # Install Node.js v21.x manually - apt-get update && apt-get install -y curl @@ -17,94 +30,57 @@ compile: - gulp --version # Verify Gulp is installed script: - npm install - - gulp compile - only: - - branches + - gulp build artifacts: paths: - kidsonbrooms.zip - expire_in: never + - system.json + - packs/ + only: + - branches -# Release Job (manually triggered with version) +# Release job release: stage: release - image: ubuntu:latest + rules: + - if: $CI_COMMIT_TAG before_script: - # Install necessary tools - - apt-get update && apt-get install -y curl jq git # Install Node.js v21.x manually + - apt-get update && apt-get install -y curl - curl -fsSL https://deb.nodesource.com/setup_21.x | bash - - apt-get install -y nodejs - node -v # Verify the correct Node.js version # Install Gulp globally - npm install --global gulp-cli - gulp --version # Verify Gulp is installed - - git fetch --all - - git switch master - - git branch --set-upstream-to=origin/master master script: - # Check if VERSION is provided - - | - if [ -z "$VERSION" ]; then - echo "Error: VERSION variable is required." - exit 1 - fi - - # Install dependencies and run Gulp release task - npm install - gulp release + only: + - tags - - grep '"download":' system.json - - git config --global user.name "GitLab CI" - - git config --global user.email "ci@gitlab.com" - - git add kidsonbrooms.zip - - git commit -m "Update .zip with new version" - - git push "https://$CI_COMMITTER_USER_AND_TOKEN@gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git" HEAD:master +# Create GitLab release +create-release: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + variables: + dry_run: "false" + needs: + - job: release + rules: + - if: $CI_COMMIT_TAG + script: + - echo "Creating GitLab release for $CI_COMMIT_TAG" + release: + name: "$CI_COMMIT_TAG" + tag_name: "$CI_COMMIT_TAG" + description: "Release $CI_COMMIT_TAG of $CI_PROJECT_NAME." + assets: + links: + - name: "$MANIFEST" + url: "${MANIFEST_RELEASE_URL}" + filepath: "/${MANIFEST}" + - name: "$ZIPFILE" + url: "${ZIPFILE_PERMALINK_URL}" + filepath: "/${ZIPFILE}" - # Create a release on GitLab - - | - export RELEASE_RESPONSE=$(curl --request POST \ - --header "PRIVATE-TOKEN: ${GITLAB_PAT}" \ - --header "Content-Type: application/json" \ - --data '{ - "name": "Release v'$VERSION'", - "tag_name": "v'$VERSION'", - "description": "Release v'$VERSION'", - "ref": "master", - "assets": { - "links": [ - { - "name": "Download kidsonbrooms.zip", - "url": "https://gitlab.com/wintermyst/kidsonbrooms/-/raw/master/kidsonbrooms.zip?inline=false" - } - ] - } - }' "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/releases") - # Publish the release to the Foundry API - - | - curl -X POST https://api.foundryvtt.com/_api/packages/release_version/ \ - -H "Authorization: $FOUNDRY_API_KEY" \ - -H "Content-Type: application/json" \ - -d "{ - \"id\": \"kidsonbrooms\", - \"release\": { - \"version\": \"$VERSION\", - \"manifest\": \"https://gitlab.com/wintermyst/kidsonbrooms/-/raw/master/system.json\", - \"notes\": \"https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/v$VERSION\", - \"compatibility\": { - \"minimum\": \"12\", - \"verified\": \"12.331\", - \"maximum\": \"\" - } - } - }" - only: - - master - when: manual - allow_failure: false - dependencies: - - compile - artifacts: - paths: - - kidsonbrooms.zip - expire_in: never diff --git a/gulpfile.js b/gulpfile.js index a31780f..302e1a8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,42 @@ const prefix = require('gulp-autoprefixer'); const sourcemaps = require('gulp-sourcemaps'); const sass = require('gulp-sass')(require('sass')); const zip = require('gulp-zip'); +const fs = require('fs'); +const fetch = require('node-fetch'); +const replace = require('gulp-replace'); +const FormData = require('form-data'); + +/* ----------------------------------------- */ +/* Export Tasks +/* ----------------------------------------- */ + +exports.default = gulp.series( + compileScss, + watchUpdates +); + +exports.build = gulp.series( + compileScss, + checkVersion, + ensureOutputDirExists, + packageCompendiums, + updateSystemJson, + zipRelease +); + +exports.compile = gulp.series( + compileScss, + ensureOutputDirExists, + packageCompendiums, +); + +exports.css = css; + +exports.release = gulp.series( + exports.build, + uploadToPackageRegistry, + publishToFoundry +); /* ----------------------------------------- */ /* Compile Sass @@ -40,21 +76,6 @@ function watchUpdates() { gulp.watch(SYSTEM_SCSS, css); } -/* ----------------------------------------- */ -/* Export Tasks -/* ----------------------------------------- */ - -exports.default = gulp.series( - compileScss, - watchUpdates -); -exports.build = gulp.series( - compileScss -); -exports.compile = gulp.series( - compileScss -); -exports.css = css; /* ----------------------------------------- */ /* Zip Release @@ -71,12 +92,239 @@ function zipRelease() { '!./package.json', '!./scss/**/*', '!./.github/**/*', + '!./.gitlab-ci.yml', + '!./README.md', + '!./compendiums/**/*', + '!./*.zip' ], { base: '.' }) .pipe(zip('kidsonbrooms.zip')) .pipe(gulp.dest('.')); } -exports.release = gulp.series( - compileScss, - zipRelease -); +/* ----------------------------------------- */ +/* Version Check +/* ----------------------------------------- */ + + +function checkVersion(done) { + const moduleManifest = JSON.parse(fs.readFileSync('module.json')); + const manifestVersion = moduleManifest.version; + const gitTag = process.env.CI_COMMIT_TAG; + + if (gitTag && manifestVersion !== gitTag) { + console.error(`Version mismatch between tag (${gitTag}) and manifest (${manifestVersion})!`); + process.exit(1); + } else { + console.log(`Version check passed: ${manifestVersion}`); + done(); + } +} + +/* ----------------------------------------- */ +/* Bundle Compendium +/* ----------------------------------------- */ + +const { exec } = require('child_process'); + +function packageCompendiums(done) { + const packsDir = './compendiums'; // Adjust to your compendium source directory + const outputDir = './packs'; + const moduleId = 'kidsonbrooms'; // Replace with your actual module ID + + // Read all subdirectories in the packsDir + fs.readdir(packsDir, (err, files) => { + if (err) { + console.error(`Error reading directory ${packsDir}: ${err}`); + process.exit(1); + } + + // Filter out files to get only directories + const folders = files.filter(file => fs.statSync(path.join(packsDir, file)).isDirectory()); + + if (folders.length === 0) { + console.log(`No compendium folders found in ${packsDir}`); + done(); + return; + } + + let completed = 0; + folders.forEach(folder => { + const packName = folder; // Use the folder name as the pack name + const inputPath = path.join(packsDir, folder); + const command = `npx fvtt package pack --type System --id ${moduleId} -n "${packName}" --in "${inputPath}" --out "${outputDir}" --yaml`; + + exec(command, (err, stdout, stderr) => { + if (err) { + console.error(`Error packaging compendium ${packName}:\n${stderr}`); + process.exit(1); + } else { + console.log(`Compendium ${packName} packaged successfully.`); + console.log(stdout); + completed++; + // When all compendiums have been processed, call done() + if (completed === folders.length) { + done(); + } + } + }); + }); + }); +} + +/* ----------------------------------------- */ +/* Ensure Output Directory Exists +/* ----------------------------------------- */ + +function ensureOutputDirExists() { + const outputDir = './packs'; + if (!fs.existsSync(outputDir)) { + fs.mkdirSync(outputDir); + } + return Promise.resolve(); +} + +/* ----------------------------------------- */ +/* Upload to Package Registry +/* ----------------------------------------- */ + + +async function uploadToPackageRegistry(done) { + const manifestFile = 'system.json'; + const zipFile = process.env.ZIPFILE || 'kidsonbrooms.zip'; + const packageRegistryUrl = process.env.PACKAGE_REGISTRY_URL; + const ciJobToken = process.env.CI_JOB_TOKEN; + + if (!packageRegistryUrl || !ciJobToken) { + console.error('PACKAGE_REGISTRY_URL or CI_JOB_TOKEN is not defined.'); + process.exit(1); + } + + try { + // Upload manifest file + const manifestUploadUrl = `${packageRegistryUrl}/${manifestFile}`; + console.log(`Uploading ${manifestFile} to ${manifestUploadUrl}`); + + let response = await fetch(manifestUploadUrl, { + method: 'PUT', + headers: { + 'JOB-TOKEN': ciJobToken, + 'Content-Type': 'application/octet-stream', + }, + body: fs.createReadStream(manifestFile), + }); + + if (response.ok) { + console.log(`Uploaded ${manifestFile} successfully.`); + } else { + console.error(`Failed to upload ${manifestFile}: ${response.statusText}`); + process.exit(1); + } + + // Upload zip file + const zipUploadUrl = `${packageRegistryUrl}/${zipFile}`; + console.log(`Uploading ${zipFile} to ${zipUploadUrl}`); + + response = await fetch(zipUploadUrl, { + method: 'PUT', + headers: { + 'JOB-TOKEN': ciJobToken, + 'Content-Type': 'application/octet-stream', + }, + body: fs.createReadStream(zipFile), + }); + + if (response.ok) { + console.log(`Uploaded ${zipFile} successfully.`); + } else { + console.error(`Failed to upload ${zipFile}: ${response.statusText}`); + process.exit(1); + } + + done(); + } catch (error) { + console.error(`Error uploading files: ${error.message}`); + process.exit(1); + } +} + +/* ----------------------------------------- */ +/* Publish to FoundryVTT +/* ----------------------------------------- */ + +function publishToFoundry(done) { + const moduleManifestPath = 'system.json'; + const moduleManifest = JSON.parse(fs.readFileSync(moduleManifestPath)); + + const id = moduleManifest.name; + const version = moduleManifest.version; + const compMin = moduleManifest.compatibility.minimum; + const compVer = moduleManifest.compatibility.verified; + const compMax = moduleManifest.compatibility.maximum; + const manifest = process.env.MANIFEST_RELEASE_URL || `https://gitlab.com/${process.env.CI_PROJECT_NAMESPACE}/${process.env.CI_PROJECT_NAME}/-/releases/${process.env.CI_COMMIT_TAG}/downloads/${moduleManifestPath}`; + const notes = `https://gitlab.com/${process.env.CI_PROJECT_NAMESPACE}/${process.env.CI_PROJECT_NAME}/-/tags/${process.env.CI_COMMIT_TAG}`; + + const dryRun = process.env.dry_run === 'true'; + const authToken = process.env.auth_token; + + if (!authToken) { + console.error('Foundry VTT API authentication token (auth_token) is not defined.'); + process.exit(1); + } + + // Construct the payload + const payload = { + id: id, + release: { + version: version, + manifest: manifest, + notes: notes, + compatibility: { + minimum: compMin, + verified: compVer, + maximum: compMax, + }, + }, + }; + + if (dryRun) { + payload['dry-run'] = true; + } + + // Send the POST request to Foundry VTT API + const response = fetch('https://api.foundryvtt.com/_api/packages/release', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: authToken, + }, + body: JSON.stringify(payload), + }); + + const responseData = response.json(); + + if (responseData.status === 'success') { + console.log('Successfully published to Foundry VTT:'); + console.log(JSON.stringify(responseData, null, 2)); + done(); + } else { + console.error('Failed to publish to Foundry VTT:'); + console.error(JSON.stringify(responseData, null, 2)); + process.exit(1); + } +} + +/* ----------------------------------------- */ +/* Update systen.json with Download URL +/* ----------------------------------------- */ + +function updateSystemJson(done) { + const ManifestPath = 'system.json'; + const Manifest = JSON.parse(fs.readFileSync(ManifestPath)); + const zipUrl = process.env.ZIPFILE_PERMALINK_URL || 'https://gitlab.com/wintermyst/kidsonbrooms/-/raw/master/kidsonbrooms.zip?inline=false'; + + Manifest.download = zipUrl; + + fs.writeFileSync(ManifestPath, JSON.stringify(Manifest, null, 2)); + console.log(`Updated module.json with download URL: ${zipUrl}`); + done(); +} diff --git a/package.json b/package.json index 811ae5d..45bf26c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kids-on-brooms", - "version": "2.0.0", + "version": "1.1.0", "description": "CSS compiler for the Kids On Brooms system", "scripts": { "build": "gulp build", @@ -20,7 +20,6 @@ "gulp-sass": "^5", "gulp-sourcemaps": "^2.6.5", "gulp-zip": "^5.0.1", - "kids-on-brooms": "file:" }, "devDependencies": { "sass": "^1.79.1" From 90f4d79e4805b53f762d25e609d330f08365a341 Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 24 Sep 2024 19:22:58 +0200 Subject: [PATCH 02/19] Fix error --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2092403..cd02c08 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,8 +56,6 @@ release: script: - npm install - gulp release - only: - - tags # Create GitLab release create-release: From 6fe30953ccd9c522ad9ad808e7b58ca365e3c9ee Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 24 Sep 2024 19:23:45 +0200 Subject: [PATCH 03/19] a --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cd02c08..1ad4239 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,6 +44,8 @@ release: stage: release rules: - if: $CI_COMMIT_TAG + variables: + dry_run: "false" before_script: # Install Node.js v21.x manually - apt-get update && apt-get install -y curl @@ -61,8 +63,6 @@ release: create-release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest - variables: - dry_run: "false" needs: - job: release rules: From 2294addb8adaf5866b57eb7c89bf1c792ce3c200 Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 24 Sep 2024 19:25:17 +0200 Subject: [PATCH 04/19] fix typo --- gulpfile.js | 4 ++-- package.json | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 302e1a8..95b6175 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -264,10 +264,10 @@ function publishToFoundry(done) { const notes = `https://gitlab.com/${process.env.CI_PROJECT_NAMESPACE}/${process.env.CI_PROJECT_NAME}/-/tags/${process.env.CI_COMMIT_TAG}`; const dryRun = process.env.dry_run === 'true'; - const authToken = process.env.auth_token; + const authToken = process.env.FOUNDRY_API_KEY; if (!authToken) { - console.error('Foundry VTT API authentication token (auth_token) is not defined.'); + console.error('Foundry VTT API authentication token (FOUNDRY_API_KEY) is not defined.'); process.exit(1); } diff --git a/package.json b/package.json index 45bf26c..082625a 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "gulp-sass": "^5", "gulp-sourcemaps": "^2.6.5", "gulp-zip": "^5.0.1", + "kids-on-brooms": "file:" }, "devDependencies": { "sass": "^1.79.1" From 36a506b338301e01941e27c3d8368fd4f3fb656c Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 24 Sep 2024 19:29:36 +0200 Subject: [PATCH 05/19] update depencies --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 082625a..cf17427 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,15 @@ "license": "MIT", "private": true, "dependencies": { + "form-data": "^4.0.0", "gulp": "^5", "gulp-autoprefixer": "^8", + "gulp-replace": "^1.1.4", "gulp-sass": "^5", "gulp-sourcemaps": "^2.6.5", "gulp-zip": "^5.0.1", - "kids-on-brooms": "file:" + "kids-on-brooms": "file:", + "node-fetch": "^3.3.2" }, "devDependencies": { "sass": "^1.79.1" From de8b7ec38a712e54859597c5341809a821d104b8 Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 24 Sep 2024 19:31:35 +0200 Subject: [PATCH 06/19] a --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 95b6175..7c2f328 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,7 +4,7 @@ const sourcemaps = require('gulp-sourcemaps'); const sass = require('gulp-sass')(require('sass')); const zip = require('gulp-zip'); const fs = require('fs'); -const fetch = require('node-fetch'); +const fetch = import('node-fetch'); const replace = require('gulp-replace'); const FormData = require('form-data'); From f81fcb61116bae48bcfd357f21aa50e7509b8adc Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 24 Sep 2024 19:34:17 +0200 Subject: [PATCH 07/19] b --- gulpfile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 7c2f328..bd29b7a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -66,7 +66,6 @@ function compileScss() { })) .pipe(gulp.dest("./css")) } -const css = gulp.series(compileScss); /* ----------------------------------------- */ /* Watch Updates From e928c253eb2ba10154fe33b6869655ba3bf2e7c9 Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 24 Sep 2024 19:35:44 +0200 Subject: [PATCH 08/19] c --- gulpfile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index bd29b7a..f1e6489 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,7 +32,6 @@ exports.compile = gulp.series( packageCompendiums, ); -exports.css = css; exports.release = gulp.series( exports.build, From cc49017b3f33d164a3168973f6ed1cfa6f319a8f Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 24 Sep 2024 19:37:22 +0200 Subject: [PATCH 09/19] d --- gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f1e6489..acbaa69 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -105,8 +105,8 @@ function zipRelease() { function checkVersion(done) { - const moduleManifest = JSON.parse(fs.readFileSync('module.json')); - const manifestVersion = moduleManifest.version; + const Manifest = JSON.parse(fs.readFileSync('system.json')); + const manifestVersion = Manifest.version; const gitTag = process.env.CI_COMMIT_TAG; if (gitTag && manifestVersion !== gitTag) { From 1ec482a98f5dd3ffa602c543f381cb8b58f14490 Mon Sep 17 00:00:00 2001 From: WinterMyst <22961076-wintermyst@users.noreply.gitlab.com> Date: Thu, 26 Sep 2024 00:35:05 +0000 Subject: [PATCH 10/19] chore: fix name --- module/helpers/templates.mjs | 8 ++++---- module/kidsonbrooms.mjs | 22 +++++++++++----------- package.json | 4 ++-- readme.md | 2 +- system.json | 2 +- templates/actor/actor-character-sheet.html | 6 +++--- templates/actor/actor-npc-sheet.html | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/module/helpers/templates.mjs b/module/helpers/templates.mjs index 63debb1..a96cd05 100644 --- a/module/helpers/templates.mjs +++ b/module/helpers/templates.mjs @@ -7,9 +7,9 @@ return loadTemplates([ // Actor partials. - "systems/kids-on-brooms/templates/actor/parts/actor-features.html", - "systems/kids-on-brooms/templates/actor/parts/actor-adversity.html", - "systems/kids-on-brooms/templates/actor/parts/actor-stats.html", - "systems/kids-on-brooms/templates/actor/parts/actor-npc-stats.html", + "systems/kidsonbrooms/templates/actor/parts/actor-features.html", + "systems/kidsonbrooms/templates/actor/parts/actor-adversity.html", + "systems/kidsonbrooms/templates/actor/parts/actor-stats.html", + "systems/kidsonbrooms/templates/actor/parts/actor-npc-stats.html", ]); }; diff --git a/module/kidsonbrooms.mjs b/module/kidsonbrooms.mjs index eb69120..31165ad 100644 --- a/module/kidsonbrooms.mjs +++ b/module/kidsonbrooms.mjs @@ -47,7 +47,7 @@ Hooks.once('init', async function() { // Register sheet application classes Actors.unregisterSheet("core", ActorSheet); - Actors.registerSheet("kids-on-brooms", KidsOnBroomsActorSheet, { makeDefault: true }); + Actors.registerSheet("kidsonbrooms", KidsOnBroomsActorSheet, { makeDefault: true }); //If there is a new chat message that is a roll we add the adversity token controls Hooks.on("renderChatMessage", (message, html, messageData) => { @@ -67,7 +67,7 @@ Hooks.once('init', async function() { } // Check if the token has already been claimed -- Contigency if the button somehow activates again - if (message.getFlag("kids-on-brooms", "tokenClaimed")) { + if (message.getFlag("kidsonbrooms", "tokenClaimed")) { ui.notifications.warn("This adversity token has already been claimed."); return; } @@ -85,10 +85,10 @@ Hooks.once('init', async function() { // Update the message content tokenControls.update({ content: updatedContent }); // Set the flag on the chat message to indicate that the token has been claimed - tokenControls.setFlag("kids-on-brooms", "tokenClaimed", true); + tokenControls.setFlag("kidsonbrooms", "tokenClaimed", true); } else { // Emit a socket request to update the message to show that the token has been claimed - game.socket.emit('system.kids-on-brooms', { + game.socket.emit('system.kidsonbrooms', { action: "takeToken", messageID: message.id, actorID: actor.id, @@ -118,7 +118,7 @@ Hooks.once('init', async function() { * if a player wants to claim a token we will update the message since they do not have the permissions */ Hooks.once('ready', function() { - game.socket.on('system.kids-on-brooms', async (data) => { + game.socket.on('system.kidsonbrooms', async (data) => { console.log("Socket data received:", data); if (data.action === "spendTokens") { @@ -190,7 +190,7 @@ Hooks.once('ready', function() { // Update the message content tokenControls.update({ content: updatedContent }); // Set the flag on the chat message to indicate that the token has been claimed - tokenControls.setFlag("kids-on-brooms", "tokenClaimed", true); + tokenControls.setFlag("kidsonbrooms", "tokenClaimed", true); } }); }); @@ -277,7 +277,7 @@ async function _onSpendAdversityTokens(e, rollMessageId) { console.log(`Requesting to spend ${tokensToSpend} tokens for ${rollActor.name} by ${spendingPlayerActor.name} (cost: ${tokenCost})`); // Emit a socket request to spend tokens - game.socket.emit('system.kids-on-brooms', { + game.socket.emit('system.kidsonbrooms', { action: "spendTokens", rollActorId: rollActorId, spendingActorId: spendingPlayerActor.id, // Send the player's actor who is spending the tokens @@ -300,8 +300,8 @@ async function _updateRollMessage(rollMessageId, tokensToSpend, isPlayerOfActor) } // Retrieve current tokens spent from flags, or initialize to 0 if not found - let cumulativeTokensSpent = message.getFlag("kids-on-brooms", "tokensSpent") || 0; - let newTotal = message.getFlag("kids-on-brooms", "newRollTotal") || message.rolls[0].total; + let cumulativeTokensSpent = message.getFlag("kidsonbrooms", "tokensSpent") || 0; + let newTotal = message.getFlag("kidsonbrooms", "newRollTotal") || message.rolls[0].total; /*if(isPlayerOfActor) { @@ -312,10 +312,10 @@ async function _updateRollMessage(rollMessageId, tokensToSpend, isPlayerOfActor) }*/ cumulativeTokensSpent += tokensToSpend; newTotal += tokensToSpend; - await message.setFlag("kids-on-brooms", "newRollTotal", newTotal); + await message.setFlag("kidsonbrooms", "newRollTotal", newTotal); // Update the message's flags to store the cumulative tokens spent - await message.setFlag("kids-on-brooms", "tokensSpent", cumulativeTokensSpent); + await message.setFlag("kidsonbrooms", "tokensSpent", cumulativeTokensSpent); let newContent = ""; if(cumulativeTokensSpent === 1) { diff --git a/package.json b/package.json index cf17427..2b7f347 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "kids-on-brooms", + "name": "kidsonbrooms", "version": "1.1.0", "description": "CSS compiler for the Kids On Brooms system", "scripts": { @@ -22,7 +22,7 @@ "gulp-sass": "^5", "gulp-sourcemaps": "^2.6.5", "gulp-zip": "^5.0.1", - "kids-on-brooms": "file:", + "kidsonbrooms": "file:", "node-fetch": "^3.3.2" }, "devDependencies": { diff --git a/readme.md b/readme.md index e0141b6..8291a1a 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,3 @@ -The Kids On Brooms System Implemented in FoundryVTT, reupload from https://github.com/Singularity-Lathe-VTT/kids-on-brooms +The Kids On Brooms System Implemented in FoundryVTT To get support create a issue on this Repository \ No newline at end of file diff --git a/system.json b/system.json index 5311251..2b90c94 100644 --- a/system.json +++ b/system.json @@ -1,7 +1,7 @@ { "id": "kidsonbrooms", "title": "Kids on Brooms System", - "description": "The Kids on Brooms system for FoundryVTT! - Deprecated", + "description": "The Kids on Brooms system for FoundryVTT!", "version": "1.1.0", "compatibility": { "minimum": 12, diff --git a/templates/actor/actor-character-sheet.html b/templates/actor/actor-character-sheet.html index f549c89..120ff36 100644 --- a/templates/actor/actor-character-sheet.html +++ b/templates/actor/actor-character-sheet.html @@ -32,12 +32,12 @@
- {{> "systems/kids-on-brooms/templates/actor/parts/actor-features.html"}} - {{> "systems/kids-on-brooms/templates/actor/parts/actor-adversity.html"}} + {{> "systems/kidsonbrooms/templates/actor/parts/actor-features.html"}} + {{> "systems/kidsonbrooms/templates/actor/parts/actor-adversity.html"}}
diff --git a/templates/actor/actor-npc-sheet.html b/templates/actor/actor-npc-sheet.html index eb8c83c..4299a0a 100644 --- a/templates/actor/actor-npc-sheet.html +++ b/templates/actor/actor-npc-sheet.html @@ -28,7 +28,7 @@ {{!-- Owned Features Tab --}}
- {{> "systems/kids-on-brooms/templates/actor/parts/actor-npc-stats.html"}} + {{> "systems/kidsonbrooms/templates/actor/parts/actor-npc-stats.html"}}
From a514ad43675d5580c538d1f189d7a55eb94da335 Mon Sep 17 00:00:00 2001 From: WinterMyst <22961076-wintermyst@users.noreply.gitlab.com> Date: Thu, 26 Sep 2024 00:46:34 +0000 Subject: [PATCH 11/19] fix: no compendium folder --- gulpfile.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index acbaa69..d07a9a2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -129,18 +129,29 @@ function packageCompendiums(done) { const outputDir = './packs'; const moduleId = 'kidsonbrooms'; // Replace with your actual module ID + if() // Read all subdirectories in the packsDir + if (!fs.existsSync(packsDir)) { + console.log(`Compendium directory ${packsDir} does not exist. Skipping packaging.`); + done(); + return; + } + + // Read all files and directories in the packsDir fs.readdir(packsDir, (err, files) => { if (err) { console.error(`Error reading directory ${packsDir}: ${err}`); process.exit(1); } - // Filter out files to get only directories - const folders = files.filter(file => fs.statSync(path.join(packsDir, file)).isDirectory()); + // Filter to get only directories + const folders = files.filter(file => { + const fullPath = path.join(packsDir, file); + return fs.statSync(fullPath).isDirectory(); + }); if (folders.length === 0) { - console.log(`No compendium folders found in ${packsDir}`); + console.log(`No compendium folders found in ${packsDir}. Skipping packaging.`); done(); return; } From b9b014d59ff54f72a0b43a33d7dd40b5d7606544 Mon Sep 17 00:00:00 2001 From: WinterMyst <22961076-wintermyst@users.noreply.gitlab.com> Date: Thu, 26 Sep 2024 00:48:12 +0000 Subject: [PATCH 12/19] fix: typo --- gulpfile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index d07a9a2..9bc1b0d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -129,7 +129,6 @@ function packageCompendiums(done) { const outputDir = './packs'; const moduleId = 'kidsonbrooms'; // Replace with your actual module ID - if() // Read all subdirectories in the packsDir if (!fs.existsSync(packsDir)) { console.log(`Compendium directory ${packsDir} does not exist. Skipping packaging.`); From 0ad5baa34172a1d687e2501b97fabf6233f774c7 Mon Sep 17 00:00:00 2001 From: Joscha Maier Date: Thu, 26 Sep 2024 12:25:28 +0200 Subject: [PATCH 13/19] chore update version and readme --- package.json | 2 +- readme.md | 4 +++- system.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2b7f347..07f5083 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kidsonbrooms", - "version": "1.1.0", + "version": "1.1.2", "description": "CSS compiler for the Kids On Brooms system", "scripts": { "build": "gulp build", diff --git a/readme.md b/readme.md index 8291a1a..62948f4 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,5 @@ The Kids On Brooms System Implemented in FoundryVTT -To get support create a issue on this Repository \ No newline at end of file +To get support create a issue on this Repository or join my discord: + +https://discord.gg/4sTXjxs5Yv \ No newline at end of file diff --git a/system.json b/system.json index 2b90c94..6ca4175 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "id": "kidsonbrooms", "title": "Kids on Brooms System", "description": "The Kids on Brooms system for FoundryVTT!", - "version": "1.1.0", + "version": "1.1.3", "compatibility": { "minimum": 12, "verified": 12 From c112950a3ef095c6d8ffe45f463617adc7db0f26 Mon Sep 17 00:00:00 2001 From: Joscha Maier Date: Thu, 26 Sep 2024 12:28:17 +0200 Subject: [PATCH 14/19] fix: reupload template --- template.json | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 template.json diff --git a/template.json b/template.json new file mode 100644 index 0000000..10376e7 --- /dev/null +++ b/template.json @@ -0,0 +1,68 @@ +{ + "Actor": { + "types": ["character", "npc"], + "templates": { + "base": { + "stats": { + "fight": { + "value": "d4", + "stat": 0, + "magic": 0 + }, + "flight": { + "value": "d4", + "stat": 0, + "magic": 0 + }, + "brains": { + "value": "d4", + "stat": 0, + "magic": 0 + }, + "brawn": { + "value": "d4", + "stat": 0, + "magic": 0 + }, + "charm": { + "value": "d4", + "stat": 0, + "magic": 0 + }, + "grit": { + "value": "d4", + "stat": 0, + "magic": 0 + } + }, + "description": "" + } + }, + "character": { + "templates": ["base"], + "trope": "", + "age": "", + "pronouns": "", + "fear": "", + "motivation": "", + "grade":"", + "broom": { + "name": "", + "look": "", + "mechanicalbenifit": "" + }, + "wand": { + "wood": "", + "core": "" + }, + "animalfamiliar":"", + "schoolbag": "", + "adversityTokens": 0, + "tropequestions": "", + "strengths": "" + }, + "npc": { + "templates": ["base"] + } + } +} From 943e2c5185bf57a602fcb09166b81e8755054a0e Mon Sep 17 00:00:00 2001 From: Joscha Maier Date: Thu, 26 Sep 2024 12:31:51 +0200 Subject: [PATCH 15/19] fix: renamed links to sheets --- module/sheets/actor-sheet.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/sheets/actor-sheet.mjs b/module/sheets/actor-sheet.mjs index 021f9d9..87e7f42 100644 --- a/module/sheets/actor-sheet.mjs +++ b/module/sheets/actor-sheet.mjs @@ -8,7 +8,7 @@ export class KidsOnBroomsActorSheet extends ActorSheet { static get defaultOptions() { return foundry.utils.mergeObject(super.defaultOptions, { - classes: ["kids-on-brooms", "sheet", "actor"], + classes: ["kidsonbrooms", "sheet", "actor"], width: 800, height: 800, tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }] @@ -19,7 +19,7 @@ export class KidsOnBroomsActorSheet extends ActorSheet { get template() { console.log("template", this.actor) - return `systems/kids-on-brooms/templates/actor/actor-${this.actor.type}-sheet.html`; + return `systems/kidsonbrooms/templates/actor/actor-${this.actor.type}-sheet.html`; } /* -------------------------------------------- */ From d18c52ac54c543222addb7a3853f3d9b6c975367 Mon Sep 17 00:00:00 2001 From: WinterMyst Date: Thu, 26 Sep 2024 13:58:51 +0200 Subject: [PATCH 16/19] chore:update so future releases link to the correct manifest --- .gitlab-ci.yml | 2 +- gulpfile.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ad4239..d1a2db8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ variables: PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}" MANIFEST_RELEASE_URL: "${PACKAGE_REGISTRY_URL}/${MANIFEST}" ZIPFILE_RELEASE_URL: "${PACKAGE_REGISTRY_URL}/${ZIPFILE}" - MANIFEST_PERMALINK_URL: "https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/permalink/latest/downloads/${MANIFEST}" + MANIFEST_PERMALINK_URL: "https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/${CI_COMMIT_TAG}/downloads/${MANIFEST}" ZIPFILE_PERMALINK_URL: "https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/${CI_COMMIT_TAG}/downloads/${ZIPFILE}" dry_run: true diff --git a/gulpfile.js b/gulpfile.js index d219d8d..08fbb29 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -268,7 +268,7 @@ async function publishToFoundry(done) { const compMin = moduleManifest.compatibility.minimum; const compVer = moduleManifest.compatibility.verified; const compMax = moduleManifest.compatibility.maximum; - const manifest = process.env.MANIFEST_RELEASE_URL || `https://gitlab.com/${process.env.CI_PROJECT_NAMESPACE}/${process.env.CI_PROJECT_NAME}/-/releases/${process.env.CI_COMMIT_TAG}/downloads/${moduleManifestPath}`; + const manifest = process.env.MANIFEST_PERMALINK_URL || `https://gitlab.com/${process.env.CI_PROJECT_NAMESPACE}/${process.env.CI_PROJECT_NAME}/-/releases/${process.env.CI_COMMIT_TAG}/downloads/${moduleManifestPath}`; const notes = `https://gitlab.com/${process.env.CI_PROJECT_NAMESPACE}/${process.env.CI_PROJECT_NAME}/-/tags/${process.env.CI_COMMIT_TAG}`; const dryRun = process.env.dry_run === 'true'; From beb432291788379d10c622da19e09d7d0408de26 Mon Sep 17 00:00:00 2001 From: WinterMyst Date: Thu, 26 Sep 2024 14:00:01 +0200 Subject: [PATCH 17/19] chore: correct release note url --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 08fbb29..92f75ca 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -269,7 +269,7 @@ async function publishToFoundry(done) { const compVer = moduleManifest.compatibility.verified; const compMax = moduleManifest.compatibility.maximum; const manifest = process.env.MANIFEST_PERMALINK_URL || `https://gitlab.com/${process.env.CI_PROJECT_NAMESPACE}/${process.env.CI_PROJECT_NAME}/-/releases/${process.env.CI_COMMIT_TAG}/downloads/${moduleManifestPath}`; - const notes = `https://gitlab.com/${process.env.CI_PROJECT_NAMESPACE}/${process.env.CI_PROJECT_NAME}/-/tags/${process.env.CI_COMMIT_TAG}`; + const notes = `https://gitlab.com/${process.env.CI_PROJECT_NAMESPACE}/${process.env.CI_PROJECT_NAME}/-/releases/${process.env.CI_COMMIT_TAG}`; const dryRun = process.env.dry_run === 'true'; const authToken = process.env.FOUNDRY_API_KEY; From 2eac4210e654e5ff8d246ffe737a5487bc6ae3e3 Mon Sep 17 00:00:00 2001 From: Joscha Maier Date: Fri, 27 Sep 2024 23:11:01 +0200 Subject: [PATCH 18/19] fix: NPC sheet not being able to fetch roll data --- module/documents/actor.mjs | 8 +++++++- module/sheets/actor-sheet.mjs | 13 ++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index 491ac40..dfca7dc 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -7,7 +7,7 @@ export class KidsOnBroomsActor extends Actor { /** * Override getRollData() that's supplied to rolls. */ - getRollData() { + getRollDataPC() { let data = { ...this.system }; // Wand bonuses @@ -18,6 +18,12 @@ export class KidsOnBroomsActor extends Actor { return data; } + + getRollDataNPC() { + let data = { ...this.system}; + + return data; + } _getWandBonus(type) { const bonuses = { diff --git a/module/sheets/actor-sheet.mjs b/module/sheets/actor-sheet.mjs index 87e7f42..7de4c75 100644 --- a/module/sheets/actor-sheet.mjs +++ b/module/sheets/actor-sheet.mjs @@ -40,8 +40,6 @@ async getData() // Add roll data for TinyMCE editors. context.rollData = context.actor.getRollData(); - // Add roll data for TinyMCE editors. - context.rollData = context.actor.getRollData(); console.log(context); @@ -87,7 +85,16 @@ async getData() if (dataset.roll) { let label = dataset.label ? `${dataset.label}` : ''; // Get the roll data and include wand bonuses - let rollData = this.actor.getRollData(); + + let rollData; + if(this.actor.type == "character") { + rollData = this.actor.getRollDataPC(); + } else if (this.actor.type == "npc") { + rollData = this.actor.getRollDataNPC(); + } else { + console.log("ERROR: UNKNOWN AUTHOR TYPE"); + return; + } let totalBonus = 0; console.log(dataset.roll); // Apply wood bonus if it matches the stat being rolled for From c1a962e3b867ab669a08263f765a39715a8cc027 Mon Sep 17 00:00:00 2001 From: Joscha Maier Date: Fri, 27 Sep 2024 23:26:54 +0200 Subject: [PATCH 19/19] fix: magi die lucky break --- templates/actor/parts/actor-stats.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/actor/parts/actor-stats.html b/templates/actor/parts/actor-stats.html index 9541059..94f8032 100644 --- a/templates/actor/parts/actor-stats.html +++ b/templates/actor/parts/actor-stats.html @@ -25,7 +25,7 @@
Magic - +