Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregg Setzer committed Jul 12, 2024
1 parent d6bb8fa commit 6a232b4
Show file tree
Hide file tree
Showing 22 changed files with 12,816 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
23 changes: 23 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
rules: {},
settings: {
react: {
version: 'detect',
},
},
ignorePatterns: ["dist/"],
};
113 changes: 113 additions & 0 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# This is a basic GitHub Action workflow file. It's going to be triggered
# when code is merged into the main branch.

name: Build, Test and Publish

# This specifies the events that will trigger the workflow.
on:
push:
branches:
- main
pull_request:
branches:
- main

# A workflow consists of one or more jobs that run in parallel.
jobs:
build-and-test:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@greggsetzer'

- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: npm install

- name: Build project
run: |
npm run lint
npm run build
- name: Run unit tests
run: npm test

- name: Save build output
uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist

# Job #2 - bump the NPM Package.json version # and publish to GitHub Packages.
bump-version-and-publish:
runs-on: ubuntu-latest
needs: build-and-test

permissions:
contents: write
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download build output
uses: actions/download-artifact@v4
with:
name: dist
path: ./dist

- name: Specify the node version
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Configure Git Credentials
run: |
git config user.email "${{ github.actor }}@users.noreply.github.com"
git config user.name "${{ github.actor}}"
- name: Install dependencies
run: npm install

- name: Ensure a clean working directory
run: |
git add .
git commit -m "Clean working directory" || echo "No changes to commit"
- name: Pull the latest
run:
git pull

- name: Bump version
run: npm version patch
env:
CI: true

- name: Commit version bump
run: |
git add package.json package-lock.json
git commit -m "Bump version" || echo "No changes to commit"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}"

- name: Add global .npmrc file
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- name: Publish to GitHub packages
run:
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.DS_Store
.idea
coverage
dist
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@greggsetzer:registry=https://npm.pkg.github.com/
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"proseWrap": "preserve",
"endOfLine": "lf"
}
25 changes: 25 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
roots: ['<rootDir>/src', '<rootDir>/tests'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
setupFilesAfterEnv: ['<rootDir>/setupTests.ts'],
collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'src/**/*.{ts,tsx}', // Collect coverage from all TypeScript files in the src directory
'!src/**/*.d.ts', // Exclude type definition files
'!src/**/index.ts', // Exclude index files if needed
'!src/**/*.stories.tsx', // Exclude storybook files if any
'!src/**/__tests__/**', // Exclude test files
'!src/**/tests/**', // Exclude test-related directories
],
testEnvironment: 'jsdom',
};

export default config;
Loading

0 comments on commit 6a232b4

Please sign in to comment.