Skip to content

Commit

Permalink
Merge pull request #3 from riceball-tw/ci-typecheck
Browse files Browse the repository at this point in the history
ci: Typecheck
  • Loading branch information
riceball-tw authored Jan 10, 2025
2 parents 387fb5c + b481fc1 commit 09c1d70
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 42 deletions.
32 changes: 32 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Setup Node & pnpm, Restore node_modules'

runs:
using: composite
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
shell: bash
42 changes: 16 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,26 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Environment Setup
uses: ./.github/actions/setup

- name: Linter
run: pnpm run lint

typecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Environment Setup
uses: ./.github/actions/setup

- name: Typecheck
run: pnpm typecheck



# Since I haven't deploy any db, test is unable to run in CI right now, disable for now

# - name: Install Playwright Browsers
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"typecheck": "npx nuxi typecheck",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"unit-test": "vitest",
Expand Down Expand Up @@ -44,6 +45,7 @@
"@nuxt/test-utils": "^3.15.1",
"@nuxtjs/tailwindcss": "^6.12.2",
"@playwright/test": "^1.49.1",
"@types/bcryptjs": "^2.4.6",
"@types/jsonwebtoken": "^9.0.7",
"@vitest/ui": "2.1.8",
"@vue/test-utils": "^2.4.6",
Expand All @@ -52,6 +54,7 @@
"playwright-core": "^1.49.1",
"tsx": "^4.19.2",
"typescript": "^5.7.3",
"vitest": "^2.1.8"
"vitest": "^2.1.8",
"vue-tsc": "^2.2.0"
}
}
21 changes: 12 additions & 9 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@
return acc;
}, defaultNotes);
const sortedGroupedNotes = Object.fromEntries(
Object.entries(groupedNotes).map(([category, notes]: [string, Notes]) => [
category,
notes!.slice().sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime())
])
)
const sortedGroupedNotes = {
today: groupedNotes.today?.slice().sort((a, b) =>
new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
) ?? [],
yesterday: groupedNotes.yesterday?.slice().sort((a, b) =>
new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
) ?? [],
earlier: groupedNotes.earlier?.slice().sort((a, b) =>
new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
) ?? []
};
return sortedGroupedNotes;
})
Expand Down Expand Up @@ -145,7 +148,7 @@
$fetch(`/api/notes/${currentNoteId.value}`, {
method: 'DELETE'
})
notes.value = notes.value?.filter(note => note.id !== currentNoteId.value)
notes.value = notes.value!.filter(note => note.id !== currentNoteId.value)
currentNoteId.value = null
} catch (err) {
console.error(err)
Expand Down
Loading

0 comments on commit 09c1d70

Please sign in to comment.