Refactor QB CI System (#555)

This reverts it back to the old way of building the JSON files and the lang at build time, instead of storing the built JSON and lang files.

Requested by @NotMyWing

[INTERNAL]
[IGNORE]
checks = { compareNot = "1.7-alpha-1" }
[IGNORE]
This commit is contained in:
Integer Limit 2023-12-04 22:57:11 +11:00 committed by GitHub
parent 7ee9e496d3
commit 1bee7c1776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 95829 additions and 143081 deletions

View File

@ -1,62 +0,0 @@
# This workflow updates the main json files, and the en_us.lang, after a Quest Book change.
name: Update Quest Book Jsons and Lang
on:
workflow_dispatch:
push:
branches:
- main
- test_buildscript*
paths:
- "overrides/config/betterquesting/saved_quests/NormalQuestsDev.json" # Normal QB Developer Json
- "overrides/config/betterquesting/saved_quests/ExpertQuestsDev.json" # Expert QB Developer Json
jobs:
updateQB:
if: "${{ github.repository_owner == 'Nomi-CEu' }}"
name: Update Quest Book Jsons and Lang (${{ inputs.tag }})
runs-on: ubuntu-latest
steps:
- name: Checkout Ref
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.tag }}
ssh-key: ${{ secrets.SSH_KEY }}
- name: Restore Cached Files
uses: actions/cache@v3
id: cache
with:
path: |
~/.npm
./.cache
./tools/node_modules
key: ${{ runner.os }}-bunny-${{ hashFiles('**/.cache', '**/package-lock.json', '**/manifest.json') }}
restore-keys: ${{ runner.os }}-bunny-
- name: Setup NodeJS v16
uses: actions/setup-node@v3
with:
node-version: "16"
check-latest: true
- name: Setup NPM Packages
working-directory: ./tools
run: npm ci
- name: Transform QB
working-directory: ./tools
run: npx gulp transformQB
- name: Commit and push QB Changes
uses: "stefanzweifel/git-auto-commit-action@v4"
id: "commit"
with:
commit_message: "Update Quest Book Jsons and Lang\n\n[SKIP]"
commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
- name: Throw Error if No Changes were Detected
if: steps.commit.outputs.changes_detected == 'false'
run: echo "No QB Changes Detected. This may be intended, or an error."

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,9 +5,6 @@ import * as gulp from "gulp";
import pruneCacheTask from "./tasks/misc/pruneCache";
export const pruneCache = pruneCacheTask;
import * as quest from "./tasks/github/quest";
export const transformQB = quest.transformQuestBook;
import * as transformFiles from "./tasks/misc/transformFiles";
export const updateFilesIssue = transformFiles.updateFilesIssue;
export const updateFilesRandomPatches = transformFiles.updateFilesRandomPatches;

View File

@ -132,6 +132,7 @@ import { createBuildChangelog } from "../changelog/createChangelog";
import mustache from "mustache";
import log from "fancy-log";
import { updateFilesBuild } from "../misc/transformFiles";
import { transformQuestBook } from "./quest";
export default gulp.series(
sharedCleanUp,
@ -141,4 +142,5 @@ export default gulp.series(
fetchOrMakeChangelog,
fetchExternalDependencies,
transformVersion,
transformQuestBook,
);

View File

@ -1,11 +1,10 @@
import fs from "fs";
import upath from "upath";
import { overridesFolder, configFolder, configOverridesFolder } from "../../globals";
import buildConfig from "../../buildConfig";
import { overridesFolder, configFolder, configOverridesFolder, sharedDestDirectory } from "../../globals";
import { Quest, QuestBook, QuestLines as QuestLine } from "../../types/bqQuestBook";
const sharedQBDefaults = upath.join(buildConfig.buildSourceDirectory, configFolder, "betterquesting");
const sharedConfigOverrides = upath.join(buildConfig.buildSourceDirectory, configOverridesFolder);
const sharedQBDefaults = upath.join(sharedDestDirectory, configFolder, "betterquesting");
const sharedConfigOverrides = upath.join(sharedDestDirectory, configOverridesFolder);
const langFileLocation = "resources/questbook/lang";
@ -30,7 +29,7 @@ function transformKeyPairs(
// Push lang file lines.
lines.push(
`#${namespace} ${storeKey} of mode ${mode}`,
`# ${namespace} ${storeKey} of mode ${mode}`,
`${titleKey}=${escapeString(properties["name:8"])}`,
`${descKey}=${escapeString(properties["desc:8"])}`,
"",
@ -103,12 +102,12 @@ function stripUselessMetadata(object: unknown) {
*/
export async function transformQuestBook(): Promise<void> {
// Source Quest Book File Locations
const questPathNormalDev = upath.join(sharedQBDefaults, "saved_quests", "NormalQuestsDev.json");
const questPathExpertDev = upath.join(sharedQBDefaults, "saved_quests", "ExpertQuestsDev.json");
const questPathNormalSource = upath.join(sharedQBDefaults, "DefaultQuests.json");
const questPathExpertSource = upath.join(sharedQBDefaults, "saved_quests", "ExpertQuests.json");
// Quest Book Objects
const questBookNormal: QuestBook = JSON.parse((await fs.promises.readFile(questPathNormalDev)).toString());
const questBookExpert: QuestBook = JSON.parse((await fs.promises.readFile(questPathExpertDev)).toString());
const questBookNormal: QuestBook = JSON.parse((await fs.promises.readFile(questPathNormalSource)).toString());
const questBookExpert: QuestBook = JSON.parse((await fs.promises.readFile(questPathExpertSource)).toString());
// Quest Book Paths
const questPathNormalDefault = upath.join(sharedQBDefaults, "DefaultQuests.json");
@ -118,13 +117,13 @@ export async function transformQuestBook(): Promise<void> {
const questPathExpertOverride = upath.join(sharedConfigOverrides, "expert", "betterquesting", "DefaultQuests.json");
// Quest Lang Location
const questLangLocation = upath.join(buildConfig.buildSourceDirectory, overridesFolder, langFileLocation);
const questLangLocation = upath.join(sharedDestDirectory, overridesFolder, langFileLocation);
// Traverse through the quest book and rewrite titles/descriptions.
// Extract title/desc pairs into a lang file.
const lines: string[] = [];
lines.push("Normal Quest Lang Entries:", "");
lines.push("# Normal Quest Lang Entries:", "");
// Normal Mode Quest lines.
transformKeyPairs(questBookNormal["questLines:9"], "normal", "line", lines);
@ -132,7 +131,7 @@ export async function transformQuestBook(): Promise<void> {
// Normal Mode Quests themselves.
transformKeyPairs(questBookNormal["questDatabase:9"], "normal", "db", lines);
lines.push("Expert Quest Lang Entries:", "");
lines.push("# Expert Quest Lang Entries:", "");
// Expert Mode Quest lines.
transformKeyPairs(questBookExpert["questLines:9"], "expert", "line", lines);