Skip to content

Commit

Permalink
chore: setup ci/cd and apply prettier suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
aitorres committed Dec 28, 2024
1 parent ffac6a2 commit 0e41657
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run tests and checks

on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest

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

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '22'

- name: Install dependencies
run: npm install

- name: Run tests and checks
run: npm run precommit
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"format": "prettier --write .",
"lint": "prettier --check . && eslint ."
"lint": "prettier --check . && eslint .",
"precommit": "npm run check && npm run lint && npm run format"
},
"devDependencies": {
"@sveltejs/adapter-static": "^3.0.6",
Expand Down
3 changes: 2 additions & 1 deletion src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<meta charset="utf-8" />
<link
rel="icon"
href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🎲</text></svg>"/>
href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🎲</text></svg>"
/>
<link rel="stylesheet" href="%sveltekit.assets%/global.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
Expand Down
8 changes: 4 additions & 4 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type Spell = {
duration: string;
range: string;
desc: string[];
}
};

// Weapon stub containing the basic information for the dropdown
export type WeaponStub = { index: string; name: string };
Expand All @@ -26,21 +26,21 @@ export type WeaponProperty = {
index: string;
name: string;
url: string;
}
};

// Weapon damage contains the full information for a weapon damage reference
export type WeaponDamage = {
damage_dice: string;
damage_type: { name: string };
}
};

// Weapon contains the full information for a weapon reference
export type Weapon = {
name: string;
damage: WeaponDamage;
weapon_range: string;
properties: WeaponProperty[];
}
};

/*
* Fetch all spells from the D&D 5e API
Expand Down
8 changes: 6 additions & 2 deletions src/routes/spells/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@
autoTable(doc, {
head: [['Spell', 'Level', 'Duration', 'Range', 'Description']],
body: await Promise.all(selectedSpells.map((spell) => getFullSpell(spell.index))).then((results) => results.filter((result) => result !== null))
body: await Promise.all(selectedSpells.map((spell) => getFullSpell(spell.index))).then(
(results) => results.filter((result) => result !== null)
)
});
doc.save('selected_spells.pdf');
}
// Get the full information of a spell
async function getFullSpell(index: string): Promise<[string, number, string, string, string] | null> {
async function getFullSpell(
index: string
): Promise<[string, number, string, string, string] | null> {
var spell: Spell;
try {
Expand Down

0 comments on commit 0e41657

Please sign in to comment.