diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f0a8e92 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI + +on: + workflow_dispatch: + push: + branches: + - main + + pull_request: + branches: + - main + +jobs: + test: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + fail-fast: false + + steps: + - id: checkout + name: Checkout + uses: actions/checkout@v3 + - id: setup-bun + name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - id: install-deps + name: Install dependencies + run: | + bun install + - id: test + name: Run test + run: | + bun test \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 9fcc998..0000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: Publish to npm - -on: - workflow_dispatch: - release: - types: [created] - -jobs: - publish: - runs-on: ubuntu-latest - - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Install Bun - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - - name: Install dependencies - run: bun install - - - name: Build with Bun - run: | - bun run build - - - name: Set up npm auth - run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc - - - name: Debug .npmrc content - run: cat ~/.npmrc - - - name: Publish to npm - run: bun publish --access public - env: - npm_config_userconfig: ~/.npmrc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a0f7509 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v3 + with: + node-version: 16.x + + - run: npx changelogithub + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/build.ts b/build.ts new file mode 100644 index 0000000..2aa8d0d --- /dev/null +++ b/build.ts @@ -0,0 +1,26 @@ +import type { BuildConfig } from 'bun' +import dts from 'bun-plugin-dts' + +const defaultBuildConfig: BuildConfig = { + entrypoints: ['./src/index.ts'], + outdir: './dist', + external: [ + 'hono', + 'pug', + 'path', + ] +} + +await Promise.all([ + Bun.build({ + ...defaultBuildConfig, + plugins: [dts()], + format: 'esm', + naming: "[dir]/[name].js", + }), + Bun.build({ + ...defaultBuildConfig, + format: 'cjs', + naming: "[dir]/[name].cjs", + }) +]) \ No newline at end of file diff --git a/package.json b/package.json index 28d14cc..1dff839 100644 --- a/package.json +++ b/package.json @@ -1,43 +1,48 @@ { "name": "hono-pug-renderer", - "module": "src/index.ts", - "main": "dist/index.js", - "types": "dist/index.d.ts", "type": "module", "version": "0.0.2", + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "description": "Pug renderer middleware for Hono", + "exports": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": "./dist/index.cjs" + }, "scripts": { - "build": "bun build --target=node ./src/index.ts --outfile=./dist/index.js && bun run build:declaration", - "build:declaration": "tsc --emitDeclarationOnly --project tsconfig.types.json", - "postbuild": "rimraf tsconfig.types.tsbuildinfo" - }, - "devDependencies": { - "@types/bun": "latest", - "@types/pug": "^2.0.10", - "prettier": "^3.5.3", - "rimraf": "^6.0.1" - }, - "peerDependencies": { - "typescript": "^5.8.3" - }, - "dependencies": { - "hono": "^4.7.8", - "pug": "^3.0.3" - }, - "repository": { - "type": "git", - "url": "https://github.com/LucasVbr/hono-pug-renderer.git" + "build": "bun run build.ts", + "prepublishOnly": "bun run build" }, + "files": [ + "dist" + ], "keywords": [ "hono", "pug", "renderer", "middleware" ], - "author": "LucasVbr", "license": "MIT", - "files": [ - "dist/*.js", - "dist/*.d.ts" - ] -} + "homepage": "https://github.com/LucasVbr/hono-pug-renderer#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/LucasVbr/hono-pug-renderer.git" + }, + "bugs": "https://github.com/LucasVbr/hono-pug-renderer/issues", + "author": "Lucàs Vabre ", + "dependencies": { + "hono": "^4.7.8", + "pug": "^3.0.3" + }, + "devDependencies": { + "@types/bun": "latest", + "@types/pug": "^2.0.10", + "prettier": "^3.5.3", + "bun-plugin-dts": "latest" + }, + "peerDependencies": { + "typescript": "^5.8.3" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index eee7c22..71fd327 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,31 +1,16 @@ { "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src", - "baseUrl": "./", - "paths": { - "@/*": ["src/*"] - }, - "lib": ["ESNext"], + "target": "es2020", "module": "esnext", - "target": "esnext", - "moduleResolution": "bundler", - "moduleDetection": "force", - "allowImportingTsExtensions": true, - "noEmit": true, - "composite": true, "strict": true, - "downlevelIteration": true, + "esModuleInterop": true, + "moduleResolution": "node", "skipLibCheck": true, - "jsx": "react-jsx", - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, + "noUnusedLocals": true, + "noImplicitAny": true, "allowJs": true, - "types": [ - "bun-types" - ] - }, - "include": [ - "src/**/*.ts" - ] -} + "noEmit": true, + "outDir": "dist", + "resolveJsonModule": true + } +} \ No newline at end of file diff --git a/tsconfig.types.json b/tsconfig.types.json deleted file mode 100644 index a6a3f21..0000000 --- a/tsconfig.types.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": false, - "emitDeclarationOnly": true, - "declaration": true, - "outDir": "./dist", - "rootDir": "./src", - }, - "include": [ - "src/**/*.ts" - ] -}