Skip to content

Commit

Permalink
chore(deps|ci): better workflow and bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomeowww committed Nov 25, 2024
1 parent 1ce3f6a commit 7bc3733
Show file tree
Hide file tree
Showing 11 changed files with 1,298 additions and 735 deletions.
44 changes: 40 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Lint
permissions:
pull-requests: write
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -30,7 +30,6 @@ jobs:
uses: pnpm/action-setup@v4
with:
run_install: false
version: '9.5.0'

- name: Obtain pnpm store directory
shell: bash
Expand All @@ -51,11 +50,49 @@ jobs:
- name: Lint
run: pnpm run lint

typecheck:
name: Type Check
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js 22.x
uses: actions/setup-node@v3
with:
node-version: 22.x

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Obtain pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Obtain pnpm store cache
uses: actions/cache@v4
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 --frozen-lockfile

- name: Type Check
run: pnpm run typecheck

build-test:
name: Build Test
permissions:
pull-requests: write
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -69,7 +106,6 @@ jobs:
uses: pnpm/action-setup@v4
with:
run_install: false
version: '9.5.0'

- name: Obtain pnpm store directory
shell: bash
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
uses: pnpm/action-setup@v4
with:
run_install: false
version: '9.5.0'

- name: Obtain pnpm store directory
shell: bash
Expand All @@ -52,9 +51,6 @@ jobs:
id: version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Copy manifest
run: cp manifest.json dist/manifest.json

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
# Don't include the compiled main.js file in the repo.
# They should be uploaded to GitHub releases instead.
main.js
manifest.json

# Exclude sourcemaps
*.map
Expand Down
22 changes: 14 additions & 8 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { exec } from 'node:child_process'
import { promisify } from 'node:util'
import { env } from 'node:process'
import { copyFile, rm } from 'node:fs/promises'
import { join } from 'node:path'

import { defineBuildConfig } from 'unbuild'
import { cwd } from 'node:process'
import builtins from 'builtin-modules'
import { defineBuildConfig } from 'unbuild'

const execAsync = promisify(exec)
import { generateObsidianPluginManifest } from './scripts/manifest'
import { toErrorable } from './scripts/utils'

export default defineBuildConfig({
outDir: './dist',
Expand Down Expand Up @@ -36,7 +37,7 @@ export default defineBuildConfig({
output: {
dir: './dist',
format: 'cjs',
sourcemap: env.NODE_ENV === 'development' ? 'inline' : false,
sourcemap: 'inline',
entryFileNames: 'main.js',
},
// required for unocss, ofetch, etc.
Expand All @@ -46,9 +47,14 @@ export default defineBuildConfig({
inlineDependencies: true,
},
hooks: {
'build:before': async () => {
await toErrorable(async () => await rm(join(cwd(), 'main.js')))
await toErrorable(async () => await rm(join(cwd(), 'manifest.json')))
},
'build:done': async () => {
await execAsync('rm -rf ./main.js')
await execAsync('cp ./dist/main.js ./main.js')
await generateObsidianPluginManifest()
await copyFile(join(cwd(), 'dist', 'main.js'), join(cwd(), 'main.js'))
await copyFile(join(cwd(), 'dist', 'manifest.json'), join(cwd(), 'manifest.json'))
},
},
})
4 changes: 4 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ dictionaries: []
words:
- antfu
- codemirror
- collab
- Errorable
- lezer
- nolebase
- Nólëbase
- ofetch
- unocss
- vueuse
ignoreWords: []
import: []
10 changes: 0 additions & 10 deletions manifest.json

This file was deleted.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "obsidian-plugin-template",
"type": "module",
"version": "0.1.0",
"packageManager": "pnpm@9.5.0",
"packageManager": "pnpm@9.14.2",
"description": "Obsidian Template Plugin",
"author": {
"name": "Nólëbase",
Expand All @@ -21,18 +21,19 @@
"dist"
],
"scripts": {
"build:dev": "NODE_EMV=development unbuild",
"build": "unbuild",
"lint": "eslint --cache ."
"lint": "eslint --cache .",
"lint:fix": "eslint --cache --fix .",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@antfu/eslint-config": "^2.21.0",
"@codemirror/view": "^6.28.4",
"@types/node": "^20.14.10",
"@antfu/eslint-config": "^3.9.2",
"@codemirror/view": "^6.35.0",
"@types/node": "^22.9.3",
"builtin-modules": "^3.3.0",
"eslint": "^8.57.0",
"obsidian": "^1.5.7",
"typescript": "^5.5.3",
"eslint": "^9.15.0",
"obsidian": "^1.7.2",
"typescript": "^5.7.2",
"unbuild": "^2.0.0"
}
}
Loading

0 comments on commit 7bc3733

Please sign in to comment.