Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a since prop to project defs #59

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This workflow will do a clean install of node dependencies, build the source
# code across multiple Node.js versions, and lint the project.

name: Build & Lint

on:
Expand All @@ -9,18 +8,21 @@ on:
pull_request:
branches: [main]

env:
# Default version of Node.js for jobs
node-version: "18"

jobs:
lint:
name: Code formatting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
- run: yarn install --frozen-lockfile
node-version: latest
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Check code formatting
run: yarn run lint
14 changes: 9 additions & 5 deletions .github/workflows/deploy_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ name: Deploy KoLmafia script

on:
push:
branches: [main]
branches: [main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
name: Build and Push
steps:
- name: git-checkout
uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
cache: yarn
node-version: latest

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build script
run: yarn workspace excavator-script run build

- name: Push
uses: s0/git-publish-subdir-action@develop
env:
Expand All @@ -27,4 +31,4 @@ jobs:
FOLDER: packages/excavator-script/dist # The directory where your assets are generated
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token
MESSAGE: "Build: ({sha}) {msg}" # The commit message
SKIP_EMPTY_COMMITS: true
SKIP_EMPTY_COMMITS: true
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"scripts": {
"build": "yarn workspace excavator-script run build",
"format": "yarn workspaces run format",
"lint": "yarn workspaces run lint"
"format": "yarn workspaces run format && yarn prettier --write .github",
"lint": "yarn workspaces run lint && yarn prettier --check .github"
}
}
4 changes: 3 additions & 1 deletion packages/excavator-script/src/excavator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getRevision } from "kolmafia";

import { projects } from "./projects";
import { Hooks } from "./type";
import { sendSpadingData } from "./utils/spading";
Expand All @@ -10,7 +12,7 @@ function tupleNotNull<A, B>(

function main(event: keyof Hooks, meta: string, page: string) {
projects
.filter(({ hooks }) => event in hooks)
.filter(({ hooks, since = 0 }) => event in hooks && since <= getRevision())
.map(({ name, hooks }) => [name, hooks[event]!(meta, page)] as const)
.filter(tupleNotNull)
.forEach(([name, data]) => {
Expand Down
5 changes: 2 additions & 3 deletions packages/excavator-script/src/projects/monsterParts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
dartPartsToSkills,
Effect,
Familiar,
getRevision,
haveEquipped,
isWearingOutfit,
Item,
Expand Down Expand Up @@ -175,8 +174,7 @@ function spadeMonsterParts(
encounter: string,
page: string,
): MonsterPartsData[] | null {
if (getRevision() < 27884 || MONSTER_DENYLIST.includes(lastMonster()))
return null;
if (MONSTER_DENYLIST.includes(lastMonster())) return null;

const monster = toNormalisedString(lastMonster());
const monsterParts = lastMonster().parts;
Expand Down Expand Up @@ -293,4 +291,5 @@ export const MONSTER_PARTS: ExcavatorProject = {
hooks: {
COMBAT_ROUND: spadeMonsterParts,
},
since: 27884, // Monster.prototype.parts added
};
1 change: 1 addition & 0 deletions packages/excavator-script/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export type Hooks = {
export type ExcavatorProject = {
name: string;
hooks: Partial<Hooks>;
since?: number;
};