Skip to content

Commit 3df3ba4

Browse files
feat: configure standard tooling and CI
- Configure `mise.toml` with standard tasks and wildcard dependencies. - Add lint and format scripts to `package.json`. - Create `.github/workflows/autorelease.yml` with single job workflow. - Implement centralized error reporting in `src/lib/utils/error.ts`. - Update `src/lib/services/themeLoader.ts` to use `reportError`. Co-authored-by: lucasew <15693688+lucasew@users.noreply.github.com>
1 parent f38c346 commit 3df3ba4

6 files changed

Lines changed: 97 additions & 7 deletions

File tree

.github/workflows/autorelease.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- 'v*'
10+
pull_request:
11+
branches:
12+
- main
13+
- master
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- uses: jdx/mise-action@v2
29+
with:
30+
experimental: true
31+
32+
- name: Install dependencies
33+
run: mise run install
34+
35+
- name: Codegen
36+
run: mise run codegen
37+
38+
- name: Check for changes and create PR
39+
uses: peter-evans/create-pull-request@v6
40+
with:
41+
token: ${{ secrets.GITHUB_TOKEN }}
42+
commit-message: 'chore: update generated code'
43+
title: 'chore: update generated code'
44+
body: 'This PR updates the generated code.'
45+
branch: 'codegen-update'
46+
base: 'main'
47+
delete-branch: true
48+
49+
- name: CI
50+
run: mise run ci
51+
52+
- name: Release
53+
if: startsWith(github.ref, 'refs/tags/')
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: gh release create ${{ github.ref_name }} --generate-notes
57+
58+
- name: Artifacts
59+
if: startsWith(github.ref, 'refs/tags/')
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
tar -czf build.tar.gz build || echo "No build directory"
64+
gh release upload ${{ github.ref_name }} build.tar.gz || true

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mise.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ bun = "1.3.8"
33

44
[tasks]
55
install = "bun install"
6-
codegen = "npm run paraglide:compile"
7-
"lint:eslint" = "eslint ."
8-
"lint:prettier" = "prettier --check ."
6+
codegen = "bun run paraglide:compile"
7+
"lint:eslint" = "bun run lint:eslint"
8+
"lint:prettier" = "bun run lint:prettier"
99
"lint:check" = "bun run check"
10-
lint = { depends = ["lint:eslint", "lint:prettier", "lint:check"] }
10+
lint = { depends = ["lint:*"] }
11+
"fmt:prettier" = "bun run fmt:prettier"
12+
fmt = { depends = ["fmt:*"] }
1113
build = "bun run build"
1214
test = "echo 'No tests found'"
13-
ci = { depends = ["lint", "build"] }
15+
ci = { depends = ["lint", "test", "build"] }

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"build": "vite build",
1111
"preview": "vite preview",
1212
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
13-
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
13+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
14+
"lint:eslint": "eslint .",
15+
"lint:prettier": "prettier --check .",
16+
"fmt:prettier": "prettier --write ."
1417
},
1518
"devDependencies": {
1619
"@eslint/js": "^9.39.2",

src/lib/services/themeLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Theme } from '$lib/Model';
33
import { normalizeColor, normalizeColorKeys } from '$lib/utils/theme';
44
import { sanitize } from '$lib/utils/security';
55
import { parseSimpleYaml } from '$lib/utils/yaml';
6+
import { reportError } from '$lib/utils/error';
67

78
let themeCounter = 0;
89

@@ -104,7 +105,7 @@ async function processFile(file: File) {
104105
const structure = parseSimpleYaml(content);
105106
handleOneStructure(structure, filename);
106107
} catch (yamlError) {
107-
console.error(`Failed to parse file ${filename}:`, yamlError);
108+
reportError(`Failed to parse file ${filename}:`, yamlError);
108109
}
109110
}
110111

src/lib/utils/error.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Reports an error to the centralized error tracking system.
3+
* Currently logs to console, but can be extended to use Sentry or other services.
4+
*
5+
* @param message - A descriptive message for the error.
6+
* @param error - The error object or unknown error value.
7+
* @param context - Optional additional context to include with the error report.
8+
*/
9+
export function reportError(
10+
message: string,
11+
error?: unknown,
12+
context?: Record<string, unknown>
13+
): void {
14+
if (error) {
15+
console.error(message, error, context);
16+
} else {
17+
console.error(message, context);
18+
}
19+
}

0 commit comments

Comments
 (0)