Skip to content

Commit

Permalink
Merge branch 'master' into zombiePirate2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nwjgit authored Sep 16, 2024
2 parents 9e8961a + f211cad commit 7996de7
Show file tree
Hide file tree
Showing 55 changed files with 5,583 additions and 665 deletions.
77 changes: 40 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
name: Unit Tests

on:
push:
branches:
- master
pull_request:
push:
branches:
- master
pull_request:

jobs:
test:
name: Tests
runs-on: ubuntu-latest

steps:
- name: Checkout Project
uses: actions/checkout@v4

- run: corepack enable
- run: corepack install

- name: Install NodeJS
uses: actions/setup-node@v4
with:
cache: yarn
node-version: 20

- name: Restore CI Cache
uses: actions/cache@v4
with:
path: node_modules
key: NODE-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install Dependencies
run: yarn --immutable

- name: Fix package.json
run: npx biome check --write package.json

- name: Test
run: |
yarn test
npm i -g dpdm && dpdm --exit-code circular:1 --progress=false --warning=false --tree=false ./dist/index.js
test:
name: Tests
runs-on: ubuntu-latest

steps:
- name: Checkout Project
uses: actions/checkout@v4

- run: corepack enable
- run: corepack install

- name: Install NodeJS
uses: actions/setup-node@v4
with:
cache: yarn
node-version: 20

- name: Restore CI Cache
uses: actions/cache@v4
with:
path: node_modules
key: NODE-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install Dependencies
run: yarn --immutable

- name: Fix package.json
run: npx biome check --write package.json

- name: Build
run: tsc -p src

- name: Test
run: |
yarn test
npm i -g dpdm && dpdm --exit-code circular:1 --progress=false --warning=false --tree=false ./dist/index.js
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oldschooljs",
"version": "2.5.11",
"version": "2.6.0",
"description": "Allows you to interact with the OSRS Hiscores, Wiki, Items, & more.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -10,17 +10,15 @@
"url": "git+https://github.com/oldschoolgg/oldschooljs.git"
},
"scripts": {
"test": "tsc -p src && concurrently \"yarn test:lint\" \"yarn test:unit\" \"tsc -p test\"",
"test": "tsc --noEmit -p src && concurrently \"yarn test:lint\" \"yarn test:unit\" \"tsc --noEmit -p test\"",
"test:unit": "vitest run --coverage",
"build": "tsc -p src && tsx scripts/minifyDist.ts",
"dev": "tsc --watch -p .",
"updateitems": "tsx scripts/prepare",
"prepare:monsters": "yarn build && tsx scripts/prepareMonsters.ts",
"prepare": "tsx scripts/prepare",
"dev": "yarn prepare && yarn lint && yarn build && yarn test",
"lint": "biome check --write --diagnostic-level=error",
"test:lint": "biome check --diagnostic-level=error"
},
"dependencies": {
"deepmerge": "4.3.1",
"e": "^0.2.33",
"node-fetch": "2.6.7"
},
Expand All @@ -31,6 +29,7 @@
"@vitest/coverage-v8": "^1.6.0",
"concurrently": "^8.2.2",
"deep-object-diff": "^1.1.9",
"deepmerge": "4.3.1",
"tsx": "^4.16.2",
"typescript": "^5.5.3",
"vitest": "^1.6.0"
Expand Down
28 changes: 22 additions & 6 deletions scripts/enum.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { writeFileSync } from "node:fs";

import { Items } from "../src";
import { Items, Monsters } from "../src";
import { USELESS_ITEMS } from "../src/structures/Items";
import { moidLink } from "./prepareItems";

export function safeItemName(itemName: string) {
let key = itemName;
key = key.replace("3rd", "third");
key = key.replace(/[^\w\s]|_/g, "");
key = key.replace(/\s+/g, "_");
key = key.toUpperCase();
return key;
}
const exitingKeys = new Set<string>();
const duplicates = new Set<number>();
let str = "export enum EItem {";
Expand Down Expand Up @@ -32,11 +40,8 @@ outer: for (const item of Items.values()) {
if (USELESS_ITEMS.includes(item.id)) {
continue;
}
let key = item.wiki_name ?? item.name;
key = key.replace("3rd", "third");
key = key.replace(/[^\w\s]|_/g, "");
key = key.replace(/\s+/g, "_");
key = key.toUpperCase();
const key = safeItemName(item.wiki_name ?? item.name);

if (exitingKeys.has(key)) {
duplicates.add(item.id);
continue;
Expand All @@ -48,3 +53,14 @@ str += "\n}";
str += "\n";
writeFileSync("./src/EItem.ts", str);
console.log(`Duplicates: ${moidLink(Array.from(duplicates))}`);

// EMonster
let monsterEnumStr = "export enum EMonster {";
for (const monster of Monsters.values()) {
let key = monster.name;
key = key.replaceAll(" ", "_");
key = key.replace(/[^a-zA-Z0-9_]/g, "").toUpperCase();
monsterEnumStr += `\n\t${key} = ${monster.id},`;
}
monsterEnumStr += "\n}";
writeFileSync("./src/EMonster.ts", monsterEnumStr);
3 changes: 3 additions & 0 deletions scripts/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import prepareItems from "./prepareItems";
import "./enum";
import { prepareMonsters } from "./prepareMonsters";

prepareItems();
prepareMonsters();
4 changes: 1 addition & 3 deletions scripts/prepareMonsters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default interface RawMonsterData {
magic_damage: number;
}

async function prepareMonsters(): Promise<void> {
export async function prepareMonsters(): Promise<void> {
const allMonsters: { [key: string]: RawMonsterData } = await fetch(
"https://raw.githubusercontent.com/0xNeffarion/osrsreboxed-db/master/docs/monsters-complete.json",
).then((res): Promise<any> => res.json());
Expand Down Expand Up @@ -124,5 +124,3 @@ async function prepareMonsters(): Promise<void> {
writeFileSync("./src/data/monsters_data.json", JSON.stringify(monsterMap, null, 4));
console.log("Prepared Monsters. Check any new monsters quickly to see that the data looks okay.");
}

prepareMonsters();
110 changes: 110 additions & 0 deletions src/EItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5767,8 +5767,12 @@ export enum EItem {
FLOWER_CROWN_GENDERQUEER = 27151,
FLOWER_CROWN_LESBIAN = 27153,
FLOWER_CROWN_GAY = 27155,
GUTHIX_CHAPS_LAST_MAN_STANDING = 27180,
ZAMORAK_CHAPS_LAST_MAN_STANDING = 27181,
SARADOMIN_CHAPS_LAST_MAN_STANDING = 27182,
LIGHT_BALLISTA_LAST_MAN_STANDING = 27188,
VERACS_FLAIL_LAST_MAN_STANDING = 27189,
ANCESTRAL_ROBE_BOTTOM_LAST_MAN_STANDING = 27194,
MENAPHITE_REMEDY_4_DOSE = 27202,
MENAPHITE_REMEDY_3_DOSE = 27205,
MENAPHITE_REMEDY_2_DOSE = 27208,
Expand Down Expand Up @@ -6281,4 +6285,110 @@ export enum EItem {
TELEPORT_ANCHORING_SCROLL = 29455,
ADAMANT_SEEDS = 29458,
CURSED_AMULET_OF_MAGIC = 29486,
RAINBOW_CAPE_PRIDE = 29489,
RAINBOW_CAPE_BISEXUAL = 29491,
RAINBOW_CAPE_ASEXUAL = 29493,
RAINBOW_CAPE_TRANSGENDER = 29495,
RAINBOW_CAPE_PANSEXUAL = 29497,
RAINBOW_CAPE_NONBINARY = 29499,
RAINBOW_CAPE_GENDERQUEER = 29501,
RAINBOW_CAPE_LESBIAN = 29503,
RAINBOW_CAPE_GAY = 29505,
RAINBOW_CROWN_SHIRT_PRIDE = 29507,
RAINBOW_CROWN_SHIRT_BISEXUAL = 29509,
RAINBOW_CROWN_SHIRT_ASEXUAL = 29510,
RAINBOW_CROWN_SHIRT_TRANSGENDER = 29511,
RAINBOW_CROWN_SHIRT_PANSEXUAL = 29512,
RAINBOW_CROWN_SHIRT_NONBINARY = 29513,
RAINBOW_CROWN_SHIRT_GENDERQUEER = 29514,
RAINBOW_CROWN_SHIRT_LESBIAN = 29515,
RAINBOW_CROWN_SHIRT_GAY = 29516,
ELITE_BLACK_FULL_HELM = 29560,
ELITE_BLACK_PLATEBODY = 29562,
ELITE_BLACK_PLATELEGS = 29564,
DARK_SQUALL_HOOD = 29566,
DARK_SQUALL_ROBE_TOP = 29568,
DARK_SQUALL_ROBE_BOTTOM = 29570,
BURNING_CLAW = 29574,
BONE_CLAWS = 29577,
TORMENTED_SYNAPSE = 29580,
EMBERLIGHT = 29589,
SCORCHING_BOW = 29591,
PURGING_STAFF = 29594,
CORRUPTED_DARK_BOW = 29599,
CORRUPTED_VOLATILE_NIGHTMARE_STAFF = 29602,
ARMADYL_GODSWORD_DEADMAN = 29605,
VOIDWAKER_DEADMAN = 29607,
VOLATILE_NIGHTMARE_STAFF_DEADMAN = 29609,
DARK_BOW_DEADMAN = 29611,
IMBUED_ZAMORAK_CAPE_DEADMAN = 29613,
IMBUED_GUTHIX_CAPE_DEADMAN = 29615,
IMBUED_SARADOMIN_CAPE_DEADMAN = 29617,
ARMAGEDDON_RUG = 29619,
ARMAGEDDON_TELEPORT_SCROLL = 29622,
ARMAGEDDON_WEAPON_SCROLL = 29625,
ARMAGEDDON_CAPE_FABRIC = 29628,
BLIGHTED_OVERLOAD_4_DOSE = 29631,
BLIGHTED_OVERLOAD_3_DOSE = 29634,
BLIGHTED_OVERLOAD_2_DOSE = 29637,
BLIGHTED_OVERLOAD_1_DOSE = 29640,
CHITIN = 29643,
GUTHIXIAN_TEMPLE_TELEPORT = 29684,
DNI23_TORSO_LIGHTBUTTONS = 29686,
DNI23_TORSO_DARKBUTTONS_DARK_BUTTONS = 29688,
DNI23_TORSO_DARKBUTTONS_JACKET = 29690,
DNI23_TORSO_SHIRT = 29692,
DNI23_TORSO_STITCHING = 29694,
DNI23_TORSO_TWOTONED = 29696,
DNI23_TORSO_PRINCELY = 29698,
DNI23_TORSO_RIPPEDWESKIT_RIPPED_WESKIT = 29700,
DNI23_TORSO_RIPPEDWESKIT_TORN_WESKIT = 29702,
DNI23_TORSO_CROPTOPS = 29704,
DNI23_TORSO_POLONECK = 29706,
DNI23_TORSO_SIMPLE = 29708,
DNI23_TORSO_FRILLY = 29710,
DNI23_TORSO_CORSETRY = 29712,
DNI23_TORSO_BODICE = 29714,
DNI23_ARMS_THIN = 29716,
DNI23_ARMS_SHOULDERPADS = 29718,
DNI23_ARMS_THICKSTRIPE = 29720,
DNI23_ARMS_LOOSESLEEVES = 29722,
DNI23_ARMS_PRINCELY = 29724,
DNI23_ARMS_TATTYLONG = 29726,
DNI23_ARMS_RIPPED = 29728,
DNI23_ARMS_BARE = 29730,
DNI23_ARMS_FRILLY = 29732,
DNI23_ARMS_TATTYSHORT = 29734,
DNI23_ARMS_BARESHOULDERS = 29736,
DNI23_LEGS_SHORTS = 29738,
DNI23_LEGS_BEACH = 29740,
DNI23_LEGS_PRINCELY = 29742,
DNI23_LEGS_LEGGINGS = 29744,
DNI23_LEGS_SIDESTRIPES = 29746,
DNI23_LEGS_RIPPED = 29748,
DNI23_LEGS_PATCHED = 29750,
DNI23_LEGS_SKIRT = 29752,
DNI23_LEGS_LONGSKIRT = 29754,
DNI23_LEGS_LONGNARROWSKIRT = 29756,
DNI23_LEGS_SHORTSKIRT = 29758,
DNI23_LEGS_LAYERED = 29760,
DNI23_LEGS_SASHDOTS = 29762,
DNI23_LEGS_BIGHEM = 29764,
DNI23_LEGS_SASHTROUSERS = 29766,
DNI23_LEGS_PATTERNED = 29768,
DNI23_LEGS_TORNSKIRT = 29770,
DNI23_LEGS_PATCHEDSKIRT = 29772,
AMYS_SAW_OFFHAND = 29774,
IMCANDO_HAMMER_OFFHAND = 29775,
BRUMA_TORCH_OFFHAND = 29777,
SPIDER_CAVE_TELEPORT = 29782,
ARAXYTE_VENOM_SACK = 29784,
NOXIOUS_HALBERD = 29796,
AMULET_OF_RANCOUR = 29801,
AMULET_OF_RANCOUR_S = 29804,
ARANEA_BOOTS = 29806,
ARAXYTE_SLAYER_HELMET = 29816,
ARAXYTE_SLAYER_HELMET_I_NIGHTMARE_ZONE = 29818,
ARAXYTE_SLAYER_HELMET_I_SOUL_WARS = 29820,
ARAXYTE_SLAYER_HELMET_I_EMIRS_ARENA = 29822,
}
Loading

0 comments on commit 7996de7

Please sign in to comment.