From 4c3da91534d97f8a93cdbb6aede05b0fe28fc2d2 Mon Sep 17 00:00:00 2001 From: Souma Date: Sat, 16 May 2026 16:14:40 +0900 Subject: [PATCH 1/2] fix(git-notion): Specify Deno command explicity Avoid failing to execute the TypeScript file directly. --- .pre-commit-hooks.yaml | 4 +- .../main.ts => upload-git-commit-notion.ts} | 10 +- .../hooks/upload-git-commit-notion/deno.json | 11 -- .../hooks/upload-git-commit-notion/deno.lock | 124 ------------------ 4 files changed, 8 insertions(+), 141 deletions(-) rename pre-commit/hooks/{upload-git-commit-notion/main.ts => upload-git-commit-notion.ts} (82%) delete mode 100644 pre-commit/hooks/upload-git-commit-notion/deno.json delete mode 100644 pre-commit/hooks/upload-git-commit-notion/deno.lock diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index d25a28a8..9b175b28 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,8 +1,10 @@ - id: upload-git-commit-notion name: Upload Git Commits to Notion description: Upload not pushed Git commits data to Notion database - entry: pre-commit/hooks/upload-git-commit-notion/main.ts + entry: upload-git-commit-notion language: deno + additional_dependencies: + - ./pre-commit/hooks/upload-git-commit-notion.ts:upload-git-commit-notion always_run: true verbose: true pass_filenames: false diff --git a/pre-commit/hooks/upload-git-commit-notion/main.ts b/pre-commit/hooks/upload-git-commit-notion.ts similarity index 82% rename from pre-commit/hooks/upload-git-commit-notion/main.ts rename to pre-commit/hooks/upload-git-commit-notion.ts index d2b494d8..98fb3eb4 100644 --- a/pre-commit/hooks/upload-git-commit-notion/main.ts +++ b/pre-commit/hooks/upload-git-commit-notion.ts @@ -1,9 +1,9 @@ -#!/usr/bin/env -S deno run -P +#!/usr/bin/env -S deno run -EN='api.notion.com' --allow-run='git,op' -import { git } from "@roka/git"; -import gitUrlParse from "git-url-parse"; -import { item } from "@1password/op-js"; -import { Client } from "@notionhq/client"; +import { git } from "jsr:@roka/git@0.4.0"; +import gitUrlParse from "npm:git-url-parse@16.1.0"; +import { item } from "npm:@1password/op-js@0.1.13"; +import { Client } from "npm:@notionhq/client@5.21.0"; const range = { from: Deno.env.get("PRE_COMMIT_FROM_REF"), diff --git a/pre-commit/hooks/upload-git-commit-notion/deno.json b/pre-commit/hooks/upload-git-commit-notion/deno.json deleted file mode 100644 index 16c560b7..00000000 --- a/pre-commit/hooks/upload-git-commit-notion/deno.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "permissions": { - "default": { "net": ["api.notion.com"], "env": true, "run": ["git", "op"] } - }, - "imports": { - "@roka/git": "jsr:@roka/git@0.4.0", - "git-url-parse": "npm:git-url-parse@16.1.0", - "@1password/op-js": "npm:@1password/op-js@0.1.13", - "@notionhq/client": "npm:@notionhq/client@5.20.0" - } -} diff --git a/pre-commit/hooks/upload-git-commit-notion/deno.lock b/pre-commit/hooks/upload-git-commit-notion/deno.lock deleted file mode 100644 index 846afcfa..00000000 --- a/pre-commit/hooks/upload-git-commit-notion/deno.lock +++ /dev/null @@ -1,124 +0,0 @@ -{ - "version": "5", - "specifiers": { - "jsr:@roka/git@0.4.0": "0.4.0", - "jsr:@roka/maybe@0.1": "0.1.0", - "jsr:@std/assert@^1.0.19": "1.0.19", - "jsr:@std/collections@^1.1.6": "1.1.7", - "jsr:@std/internal@^1.0.12": "1.0.13", - "jsr:@std/path@^1.1.4": "1.1.4", - "jsr:@std/semver@^1.0.8": "1.0.8", - "npm:@1password/op-js@0.1.13": "0.1.13", - "npm:@notionhq/client@5.20.0": "5.20.0", - "npm:git-url-parse@16.1.0": "16.1.0" - }, - "jsr": { - "@roka/git@0.4.0": { - "integrity": "c4883f613dc0ec3410c1db7260f5f212c91acef2fe2a923dd629c5e2c1f9a35e", - "dependencies": [ - "jsr:@roka/maybe", - "jsr:@std/assert", - "jsr:@std/collections", - "jsr:@std/path", - "jsr:@std/semver" - ] - }, - "@roka/maybe@0.1.0": { - "integrity": "115238934c82411cab34042dc8549e53fa96b3206fb962b6cadf2f2b90cdef90", - "dependencies": [ - "jsr:@std/assert" - ] - }, - "@std/assert@1.0.19": { - "integrity": "eaada96ee120cb980bc47e040f82814d786fe8162ecc53c91d8df60b8755991e", - "dependencies": [ - "jsr:@std/internal" - ] - }, - "@std/collections@1.1.7": { - "integrity": "56f659d011218a69740b12829cf5ea2c9b70bbed0af02597e27dc1eb5e69e208" - }, - "@std/internal@1.0.13": { - "integrity": "2f9546691d4ac2d32859c82dff284aaeac980ddeca38430d07941e7e288725c0" - }, - "@std/path@1.1.4": { - "integrity": "1d2d43f39efb1b42f0b1882a25486647cb851481862dc7313390b2bb044314b5", - "dependencies": [ - "jsr:@std/internal" - ] - }, - "@std/semver@1.0.8": { - "integrity": "dc830e8b8b6a380c895d53fbfd1258dc253704ca57bbe1629ac65fd7830179b7" - } - }, - "npm": { - "@1password/op-js@0.1.13": { - "integrity": "sha512-ZZBLxVqywFdvIbLv2xWw2N1ImSi183rRKf90vV19KRMReNyLwuD0dv6IrKrIdrJU33IuV3Gz85Z4K2a1PJTBDg==", - "dependencies": [ - "lookpath", - "semver" - ] - }, - "@notionhq/client@5.20.0": { - "integrity": "sha512-MS0DFSfHPLZ0wi+e9mOP16gCCYbWAkaiMuu/rVK9KxDlKac4oAgHReOfTglcd77g/nlg78snp+KB7fNWP75bEw==" - }, - "@types/parse-path@7.1.0": { - "integrity": "sha512-EULJ8LApcVEPbrfND0cRQqutIOdiIgJ1Mgrhpy755r14xMohPTEpkV/k28SJvuOs9bHRFW8x+KeDAEPiGQPB9Q==", - "dependencies": [ - "parse-path" - ], - "deprecated": true - }, - "git-up@8.1.1": { - "integrity": "sha512-FDenSF3fVqBYSaJoYy1KSc2wosx0gCvKP+c+PRBht7cAaiCeQlBtfBDX9vgnNOHmdePlSFITVcn4pFfcgNvx3g==", - "dependencies": [ - "is-ssh", - "parse-url" - ] - }, - "git-url-parse@16.1.0": { - "integrity": "sha512-cPLz4HuK86wClEW7iDdeAKcCVlWXmrLpb2L+G9goW0Z1dtpNS6BXXSOckUTlJT/LDQViE1QZKstNORzHsLnobw==", - "dependencies": [ - "git-up" - ] - }, - "is-ssh@1.4.1": { - "integrity": "sha512-JNeu1wQsHjyHgn9NcWTaXq6zWSR6hqE0++zhfZlkFBbScNkyvxCdeV8sRkSBaeLKxmbpR21brail63ACNxJ0Tg==", - "dependencies": [ - "protocols" - ] - }, - "lookpath@1.2.3": { - "integrity": "sha512-kthRVhf4kH4+HW3anM4UBHxsw/XFESf13euCEldhXr6GpBdmBoa7rDd7WO5G0Mhd4G5XtKTcEy8OR0iRZXpS3Q==", - "bin": true - }, - "parse-path@7.1.0": { - "integrity": "sha512-EuCycjZtfPcjWk7KTksnJ5xPMvWGA/6i4zrLYhRG0hGvC3GPU/jGUj3Cy+ZR0v30duV3e23R95T1lE2+lsndSw==", - "dependencies": [ - "protocols" - ] - }, - "parse-url@9.2.0": { - "integrity": "sha512-bCgsFI+GeGWPAvAiUv63ZorMeif3/U0zaXABGJbOWt5OH2KCaPHF6S+0ok4aqM9RuIPGyZdx9tR9l13PsW4AYQ==", - "dependencies": [ - "@types/parse-path", - "parse-path" - ] - }, - "protocols@2.0.2": { - "integrity": "sha512-hHVTzba3wboROl0/aWRRG9dMytgH6ow//STBZh43l/wQgmMhYhOFi0EHWAPtoCz9IAUymsyP0TSBHkhgMEGNnQ==" - }, - "semver@7.8.0": { - "integrity": "sha512-AcM7dV/5ul4EekoQ29Agm5vri8JNqRyj39o0qpX6vDF2GZrtutZl5RwgD1XnZjiTAfncsJhMI48QQH3sN87YNA==", - "bin": true - } - }, - "workspace": { - "dependencies": [ - "jsr:@roka/git@0.4.0", - "npm:@1password/op-js@0.1.13", - "npm:@notionhq/client@5.20.0", - "npm:git-url-parse@16.1.0" - ] - } -} From a9c094229c1a488bd3af4a8579377d518d45850a Mon Sep 17 00:00:00 2001 From: Souma Date: Sat, 16 May 2026 16:48:03 +0900 Subject: [PATCH 2/2] ci(ci): Apply changes for the new Deno project structure The root project is the hooks directory. --- .github/renovate.json | 2 +- .github/workflows/ci.yml | 55 ++++++++++------------------------------ 2 files changed, 14 insertions(+), 43 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index b8c5e6b4..40a83739 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,6 +1,6 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["github>5ouma/utils"], + "extends": ["github>5ouma/utils", "github>Omochice/renovate-config:deno"], "pre-commit": { "enabled": true }, "renovate-config-presets": { "managerFilePatterns": ["/(^|/).?(renovate(?:rc)?|default)(?:\\.json5?)?$/"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e81fd6db..14226e85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,22 +5,23 @@ on: branches: - main paths: - - pre-commit/hooks/**/* + - pre-commit/hooks/* - .github/workflows/ci.yml pull_request: paths: - - pre-commit/hooks/**/* + - pre-commit/hooks/* - .github/workflows/ci.yml permissions: {} jobs: detect: - name: ๐Ÿ”„ Detect Deno Projects + name: ๐Ÿ”„ Detect Changed Projects runs-on: Ubuntu-Slim timeout-minutes: 1 outputs: - projects: ${{ steps.get-directories.outputs.result }} + hooks: ${{ steps.filter.outputs.hooks }} + ci: ${{ steps.filter.outputs.ci }} steps: - name: ๐Ÿšš Check out repository @@ -33,43 +34,19 @@ jobs: uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1 with: filters: | - hook: - - added|modified: ["pre-commit/hooks/**/*"] + hooks: + - added|modified: ["pre-commit/hooks/*"] ci: [".github/workflows/ci.yml"] - list-files: json - - - name: ๐Ÿ“ Get directories - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - id: get-directories - with: - script: | - const path = require("path"); - - if (JSON.parse(process.env.ci)) { - const globber = await glob.create("pre-commit/hooks/*/deno.json"); - const files = await globber.glob(); - return files.map(file => path.relative(process.env.GITHUB_WORKSPACE, path.dirname(file))); - } - - const files = JSON.parse(process.env.files); - const dirs = files.map(file => file.match(/^(pre-commit\/hooks\/[^/]+)/)[1]); - return Array.from(new Set(dirs)); - env: - files: ${{ steps.filter.outputs.hook_files }} - ci: ${{ steps.filter.outputs.ci }} lint-check: name: ๐Ÿงน Lint Check needs: detect + if: ${{ needs.detect.outputs.hooks || needs.detect.outputs.ci }} runs-on: Ubuntu-Slim defaults: run: - working-directory: ${{ matrix.project }} + working-directory: pre-commit/hooks timeout-minutes: 1 - strategy: - fail-fast: false - matrix: - project: ${{ fromJson(needs.detect.outputs.projects) }} steps: - name: ๐Ÿšš Check out repository @@ -93,14 +70,11 @@ jobs: format-check: name: ๐Ÿ“ Format Check needs: detect + if: ${{ needs.detect.outputs.hooks || needs.detect.outputs.ci }} runs-on: Ubuntu-Slim defaults: run: - working-directory: ${{ matrix.project }} - strategy: - fail-fast: false - matrix: - project: ${{ fromJson(needs.detect.outputs.projects) }} + working-directory: pre-commit/hooks timeout-minutes: 1 steps: @@ -118,14 +92,11 @@ jobs: type-check: name: ๐Ÿ” Type Check needs: detect + if: ${{ needs.detect.outputs.hooks || needs.detect.outputs.ci }} runs-on: Ubuntu-Slim defaults: run: - working-directory: ${{ matrix.project }} - strategy: - fail-fast: false - matrix: - project: ${{ fromJson(needs.detect.outputs.projects) }} + working-directory: pre-commit/hooks timeout-minutes: 1 steps: