diff --git a/.eslintrc.json b/.eslintrc.json index fc8634c..29e3129 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,6 +17,7 @@ ], "ignorePatterns": [ "coverage/*", + "generated/*", "out/*" ], "overrides": [ diff --git a/.github/workflows/generate-types.yml b/.github/workflows/generate-types.yml new file mode 100644 index 0000000..44ace1f --- /dev/null +++ b/.github/workflows/generate-types.yml @@ -0,0 +1,40 @@ +name: Generate Types + +on: + push: + branches: + - main + paths: + - '**.js' + - '**.ts' + - '**.json' + pull_request: + branches: + - main + +concurrency: + group: generate-types-${{ github.ref }} + cancel-in-progress: true + +jobs: + generate-types: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Install Dependencies + run: bun install + - name: Run + run: bun run generate-types + - name: Push + continue-on-error: true + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add -A ./generated + git commit -m "Update generated types" + git push diff --git a/package.json b/package.json index 12ddf07..be2ad56 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "name": "lighthouse-crawler", "main": "./src/index.js", "bin": "./src/bin.js", + "types": "./generated/index.d.ts", "scripts": { "eslint": "eslint --no-eslintrc -c .eslintrc.json .", "lint": "npm run eslint && npm run tsc && npm run stylelint", diff --git a/tsconfig.d.json b/tsconfig.d.json new file mode 100644 index 0000000..d6bbbdc --- /dev/null +++ b/tsconfig.d.json @@ -0,0 +1,18 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "generated", + "declarationMap": true, + "removeComments": true + }, + "exclude": [ + "**/*.config.js", + "**/*.test.js", + "coverage/*", + "generated/*", + "out/*" + ] +} diff --git a/tsconfig.json b/tsconfig.json index 4031f4a..7663303 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ ], "exclude": [ "coverage/*", + "generated/*", "out/*" ] }