diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..96412cc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: Build + +on: + pull_request: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.2.2 + - uses: actions/setup-node@v4 + with: + node-version: '20.10.0' + - run: bun install --frozen-lockfile --ignore-scripts + - run: bun run build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..89688e7 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +name: Lint + +on: + pull_request: + push: + branches: + - main + +jobs: + format-and-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.2.2 + - uses: actions/setup-node@v4 + with: + node-version: '20.10.0' + - run: bun install --frozen-lockfile --ignore-scripts + - run: bun run format:check + - run: bun run lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2a8d6d4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Test + +on: + pull_request: + push: + branches: + - main + +jobs: + unit-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.1.13 + - uses: actions/setup-node@v4 + with: + node-version: '20.10.0' + - run: bun install --frozen-lockfile --ignore-scripts + - run: bun run test diff --git a/.gitignore b/.gitignore index 1cac559..0369a87 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ lerna-debug.log* node_modules dist +app-dist dist-ssr *.local diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8520f43 --- /dev/null +++ b/LICENSE @@ -0,0 +1,17 @@ +MIT License +Copyright (c) 2025 +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 5baa662..b90ae54 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,7 @@ This script will: 6. Ask you to select if this is a patch, minor, or major version change. This will adjust your package.json accordingly and create a tag commit. ✅ 7. Run another build so the package version update is included in the published code ✅ 8. Attempt to run `npm publish` to publish your package! 🚀 + +## License + +[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) diff --git a/lib/mock.test.ts b/lib/mock.test.ts new file mode 100644 index 0000000..267c6dd --- /dev/null +++ b/lib/mock.test.ts @@ -0,0 +1,5 @@ +describe('A mock test so your project has at least one test', () => { + it('is a mock test', () => { + expect('Hello, world!').toBe('Hello, world!'); + }); +}); diff --git a/package.json b/package.json index 1992414..1954a3d 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "@m4ttheweric/react-package-template", "private": false, "version": "0.0.1", + "license": "MIT", "type": "module", "main": "./dist/main.cjs", "module": "./dist/main.mjs", @@ -29,13 +30,15 @@ "scripts": { "dev": "vite", "build": "tsc -b ./tsconfig.lib.json && vite build", + "build:app": "tsc -b ./tsconfig.app.json && vite build --config vite.app.config.ts", "test": "vitest run", "lint": "eslint . --quiet", "format:write": "prettier --write \"**/*.{ts,tsx}\" --cache", "format:check": "prettier --check \"**/*.{ts,tsx}\" --cache", "preview": "vite preview", "type-check": "tsc --noEmit", - "release": "node --no-warnings publish.mjs" + "release": "node --no-warnings publish.mjs", + "pre-release": "bun run build && bun run type-check && bun run lint && bun run format:write" }, "peerDependencies": { "react": "^18.0.0", diff --git a/publish.mjs b/publish.mjs index 8814849..9f83938 100644 --- a/publish.mjs +++ b/publish.mjs @@ -32,8 +32,8 @@ const run = async () => { execute(`bun run format:write`); // if you have tests eventually, uncomment this to run them as part of the publish process - // log('Testing code...'); - // execute(`bun run test`); + log('Testing code...'); + execute(`bun run test`); log('Building code...'); execute(`bun run build`); diff --git a/tsconfig.app.json b/tsconfig.app.json index dc71ae6..6cbc8db 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -4,6 +4,7 @@ "target": "ESNext", "module": "ESNext", "useDefineForClassFields": true, + "types": ["vitest/globals"], "lib": ["ES2020", "DOM", "DOM.Iterable"], "skipLibCheck": true, "allowSyntheticDefaultImports": true, diff --git a/vite.app.config.ts b/vite.app.config.ts new file mode 100644 index 0000000..eb8f009 --- /dev/null +++ b/vite.app.config.ts @@ -0,0 +1,11 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; + +// this is the config for the app in ./src NOT your library +// you may want to build the app so you can deploy a demo/docs app to go along with your library +export default defineConfig({ + plugins: [react()], + build: { + outDir: 'app-dist', + }, +});