Skip to content

Commit

Permalink
Add support for generating cache diff pages (#3)
Browse files Browse the repository at this point in the history
* Add support for detecting file-level changes between two caches

* diff items

* Compile resulting cache changes into one resulting object

* start of index name mapping

* Basic support for struct differences

* Add support for including added and removed files in resulting diffs

* Set up supported PerFileLoadable columns for builder

* Add build output for added diffs

* Add changed diff building

* Fix various styling bugs

* Add support for structs, enums, params, and dbrows

* changesets

* Comments
  • Loading branch information
allenkinzalow authored Feb 14, 2024
1 parent 9c01393 commit daf6d1f
Show file tree
Hide file tree
Showing 29 changed files with 1,292 additions and 233 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-rings-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osrs-wiki/cache-mediawiki": minor
---

Add support for loading different cache versions
5 changes: 5 additions & 0 deletions .changeset/light-dolls-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osrs-wiki/cache-mediawiki": minor
---

Add support for writing cache differences to a wiki page.
5 changes: 5 additions & 0 deletions .changeset/many-jars-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osrs-wiki/cache-mediawiki": minor
---

Add support for detecting cache differences in indices, archives, and files
12 changes: 10 additions & 2 deletions .github/workflows/workflow-dispatch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run News Scraper
name: Run Cache Tasks

on:
workflow_dispatch:
Expand All @@ -11,6 +11,14 @@ on:
description: "Infobox type (optional)"
required: false

oldCache:
description: "Old cache date (optional)"
required: false

newCache:
description: "New cache date (optional)"
required: false

jobs:
scrapeNews:
runs-on: ubuntu-latest
Expand All @@ -30,7 +38,7 @@ jobs:
run: yarn build

- name: Run task
run: yarn start:node -t ${{ github.event.inputs.task }} -infobox ${{ github.event.inputs.infobox }}
run: yarn start:node -t ${{ github.event.inputs.task }} --infobox ${{ github.event.inputs.infobox }} --oldCache ${{ github.event.inputs.oldCache }} --newCache ${{ github.event.inputs.newCache }}

- name: Upload Output
uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"homepage": "https://github.com/osrs-wiki/cache-mediawiki#readme",
"dependencies": {
"@osrs-wiki/mediawiki-builder": "^1.1.2",
"@osrs-wiki/mediawiki-builder": "^1.2.0",
"dotenv": "^16.4.1",
"fflate": "^0.8.1",
"tsconfig-paths": "^4.2.0",
Expand Down Expand Up @@ -55,7 +55,7 @@
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"ts-patch": "^2.1.0",
"typescript": "^4.6.3"
"typescript": "^5.3.2"
},
"lint-staged": {
"src/**/*.{js,ts}": [
Expand Down
14 changes: 10 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ import config from "@config";
import { parseArgs } from "node:util";

import generateCluePages from "./scripts/clues";
import differences from "./scripts/difference/difference";
import differencesCache from "./scripts/differences/differences";
import infoboxGenerator from "./scripts/infoboxGenernator";

console.log(`Running ${config.environment}`);

const {
values: { task, infobox },
values: { oldCache, newCache, task, infobox },
} = parseArgs({
options: {
oldCache: {
type: "string",
},
newCache: {
type: "string",
},
task: {
type: "string",
short: "t",
Expand All @@ -21,8 +27,8 @@ const {
},
});

if (task === "differences") {
differences();
if (task === "differences" || (task === "diffs" && oldCache)) {
differencesCache(oldCache, newCache);
} else if (task === "infobox" && infobox) {
infoboxGenerator(infobox);
} else if (task === "clues") {
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/clues/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export const getCacheProvider = async () => {
});
};

export const getCacheProviderGithub = async () => {
export const getCacheProviderGithub = async (version = "master") => {
return new FlatCacheProvider({
async getFile(name) {
const req = await fetch(
`https://raw.githubusercontent.com/abextm/osrs-cache/master/${name}`
`https://raw.githubusercontent.com/abextm/osrs-cache/${version}/${name}`
);
if (!req.ok) {
return;
Expand Down
170 changes: 0 additions & 170 deletions src/scripts/difference/difference.ts

This file was deleted.

39 changes: 0 additions & 39 deletions src/scripts/difference/difference.utils.ts

This file was deleted.

Loading

0 comments on commit daf6d1f

Please sign in to comment.