From 21c2fda6f01551a936d5971dc35045620d35c765 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 1 Mar 2024 23:37:15 +0200 Subject: [PATCH] chore: actions workflow with linter --- .eslintrc | 6 +-- .github/actions/node-cache/action.yml | 27 +++++++++++ .github/workflows/release.yml | 65 +++++++++++++++++++-------- README.md | 3 ++ main.ts | 1 + package.json | 4 +- versions.json | 6 +-- 7 files changed, 84 insertions(+), 28 deletions(-) create mode 100644 .github/actions/node-cache/action.yml diff --git a/.eslintrc b/.eslintrc index 0807290..1a60afc 100644 --- a/.eslintrc +++ b/.eslintrc @@ -14,10 +14,10 @@ "sourceType": "module" }, "rules": { - "no-unused-vars": "off", + "no-unused-vars": "warn", "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], "@typescript-eslint/ban-ts-comment": "off", - "no-prototype-builtins": "off", - "@typescript-eslint/no-empty-function": "off" + "no-prototype-builtins": "warn", + "@typescript-eslint/no-empty-function": "warn" } } \ No newline at end of file diff --git a/.github/actions/node-cache/action.yml b/.github/actions/node-cache/action.yml new file mode 100644 index 0000000..0f4a857 --- /dev/null +++ b/.github/actions/node-cache/action.yml @@ -0,0 +1,27 @@ +name: 'Node setup and cache' +description: 'Setup Node.js packages and restore cache' + +inputs: + node-version: + description: 'Node version to use, default to 20' + required: true + default: '20' +outputs: + cache-hit: + description: 'Forward actions/cache cache-hit output' + value: ${{ steps.node-cache.outputs.cache-hit }} + +runs: + using: 'composite' + steps: + - name: ⚙️ Setup node.js ${{ inputs.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + + - name: 📦 Cache node modules + id: node-cache + uses: actions/cache@v4 + with: + path: node_modules + key: node-modules-${{ inputs.node-version }}-${{ hashFiles('package-lock.json') }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e1c60b..911ad66 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,34 +1,61 @@ -name: Release Obsidian plugin - -on: - push: - tags: - - "*" +name: Release Obsidian Plugin +on: [push] +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + jobs: - build: + node-setup: runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/node-cache + id: cache-node-modules + with: + node-version: '20' + - run: npm i + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run-lint: + name: ✅ Linter + needs: node-setup + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - - name: Use Node.js - uses: actions/setup-node@v3 + - uses: ./.github/actions/node-cache + id: cache-node-modules with: - node-version: "18.x" + node-version: '20' - - name: Build plugin - run: | - npm install - npm run build + - name: ✅ Run code style linter + id: linter + run: npm run lint + + release-plugin: + name: 📦 Release Obsidian Plugin + needs: run-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/node-cache + id: cache-node-modules + with: + node-version: '20' + + - name: 📗 Build plugin + id: build_plugin + if: steps.cache-node-modules.outcome == 'success' + run: npm run build - - name: Create release + - name: 📦 Create release + if: steps.build_plugin.outcome == 'success' && contains(github.ref, 'refs/tags/') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - tag="${GITHUB_REF#refs/tags/}" + tag='${GITHUB_REF#refs/tags/}' - gh release create "$tag" \ - --title="$tag" \ + gh release create '$tag' \ + --title='$tag' \ --draft \ main.js manifest.json styles.css \ No newline at end of file diff --git a/README.md b/README.md index cbad3dc..5622d01 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ Import all your Apple Books highlights to Obsidian. +![GitHub Downloads](https://img.shields.io/github/downloads/bandantonio/obsidian-apple-books-highlights-plugin/total?style=for-the-badge&logo=github&color=573e7a) + + ## Overview This plugin aims to be a **fast**, **customizable**, **reliable**, and **up-to-date** solution to import your Apple Books highlights to Obsidian: diff --git a/main.ts b/main.ts index 8703342..280a3f4 100644 --- a/main.ts +++ b/main.ts @@ -50,6 +50,7 @@ export default class IBookHighlightsPlugin extends Plugin { }); } + // @ts-ignore onunload() { } async loadSettings() { diff --git a/package.json b/package.json index 2738848..6096fc1 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "node esbuild.config.mjs", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", + "lint": "eslint . --ext .ts", "version": "node version-bump.mjs" }, "keywords": [ @@ -31,6 +32,7 @@ "@typescript-eslint/parser": "5.29.0", "builtin-modules": "3.3.0", "esbuild": "0.17.3", + "eslint": "^8.57.0", "obsidian": "latest", "tslib": "2.4.0", "typescript": "4.7.4" @@ -39,4 +41,4 @@ "handlebars": "^4.7.8", "sqlite3": "^5.1.7-rc.0" } -} \ No newline at end of file +} diff --git a/versions.json b/versions.json index 4c14266..26382a1 100644 --- a/versions.json +++ b/versions.json @@ -1,7 +1,3 @@ { - "1.0.0": "0.15.0", - "1.0.1": "0.15.0", - "1.0.2": "0.15.0", - "1.1.0": "0.15.0", - "1.1.1": "0.15.0" + "1.0.0": "0.15.0" }