Skip to content

Commit

Permalink
feat: ✨ initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmannZ committed Nov 14, 2023
0 parents commit 68c3ccb
Show file tree
Hide file tree
Showing 24 changed files with 6,803 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .audit-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"moderate": true,
"allowlist": [],
"retry-count": 10,
"skip-dev": true
}
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/build
/node_modules
/coverage
/examples
!.eslintrc.js
50 changes: 50 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: [
'airbnb-base',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
env: {
node: true,
jest: true,
},
rules: {
'eol-last': ['error', 'always'],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'import/extensions': ['off'],
'import/order': ['off'],
'import/prefer-default-export': ['off'],
'simple-import-sort/imports': 'warn',
'simple-import-sort/exports': 'warn',
'@typescript-eslint/no-empty-interface': ['off'],
'@typescript-eslint/explicit-function-return-type': ['off'],
},
overrides: [
{
files: ['src/__mocks__/.*', '**/*.spec.ts', '**/*.spec.tsx'],
rules: {
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: true },
],
'@typescript-eslint/no-empty-function': ['off'],
'@typescript-eslint/no-non-null-assertion': ['off'],
},
},
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts', '.jsx', '.tsx'],
},
},
},
plugins: ['simple-import-sort'],
};
42 changes: 42 additions & 0 deletions .github/actions/back-merge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Back-merge

description: Back-merge main into development.

inputs:
gh_token:
description: The Github token to use for authentication.
required: true
git_user_email:
description: The email of the user to use for the git commit.
required: true
git_user_name:
description: The name of the user to use for the git commit.
required: true
main_branch:
description: The main branch to back-merge from.
required: false
default: "main"

runs:
using: "composite"

steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ inputs.gh_token }}

- name: Setup git config
shell: bash
run: |
git config --global user.email ${{ inputs.git_user_email }}
git config --global user.name ${{ inputs.git_user_name }}
- name: Merge main back to development
shell: bash
run: |
git fetch --unshallow
git checkout development
git pull
git merge --no-ff origin/${{ inputs.main_branch }} -m "Back-merge ${{ inputs.main_branch }} into development"
git push
61 changes: 61 additions & 0 deletions .github/actions/setup-pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Setup pnpm

description: Setup pnpm with caching and install dependencies.

inputs:
npm_token:
description: The npm token to use for authentication.
required: true
install_dependencies:
description: Whether to install dependencies.
required: false
default: "true"

runs:
using: "composite"

steps:
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false

- name: Set pnpm home
shell: bash
run: |
echo "PNPM_HOME=$HOME/.local/share/pnpm" >> $GITHUB_ENV
echo "$HOME/.local/share/pnpm" >> $GITHUB_PATH
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Authenticate for private NPM package
shell: bash
env:
NPM_TOKEN: ${{ inputs.npm_token }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- name: Install dependencies
shell: bash
if: ${{ inputs.install_dependencies == 'true' }}
run: |
pnpm install --frozen-lockfile
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Continuous Integration

on:
push:
# branches-ignore:
# - main
# - development

defaults:
run:
shell: bash

jobs:
audit:
name: Audit
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20]

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

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm
with:
npm_token: ${{ secrets.NPM_TOKEN }}

- name: Perform dependency audit
run: |
pnpm audit-ci --config .audit-ci.json
lint:
name: Lint
needs: audit
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20]

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

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm
with:
npm_token: ${{ secrets.NPM_TOKEN }}

- name: Execute lint
run: |
pnpm lint
coverage:
name: Coverage
needs: audit
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20]

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

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm
with:
npm_token: ${{ secrets.NPM_TOKEN }}

- name: Generate code coverage
run: |
pnpm test -- \
--ci \
--runInBand \
--coverage
- name: Upload code coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
push:
branches:
- main
- development

defaults:
run:
shell: bash

jobs:
release:
name: Tag Release and deploy to NPM
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18]

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

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm
with:
npm_token: ${{ secrets.NPM_TOKEN }}

- name: Build
run: |
pnpm build
- name: Create version and publish to NPM
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
pnpm semantic-release
- name: Merge main into development
if: ${{ github.ref_name == 'main' }}
uses: ./.github/actions/back-merge
with:
gh_token: ${{ secrets.GH_TOKEN }}
git_user_email: ${{ secrets.GIT_USER_EMAIL }}
git_user_name: ${{ secrets.GIT_USER_NAME }}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Webstorm
.idea

# Typescript
*.tsbuildinfo
34 changes: 34 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# testing
/coverage

# server
.audit-ci.json
.env.sample
.eslintignore
.eslintrc.js
.releaserc.yaml
codecov.yml
jest.config.js
prettier.config.js
tsconfig.json
/.github
/.vscode

# source
/src

# expamples
/examples

# misc
.DS_Store
.env
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Webstorm
.idea

# Typescript
tsconfig.tsbuildinfo
29 changes: 29 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
branches:
- main
- name: development
prerelease: alpha
channel: alpha

plugins:
- - "@semantic-release/commit-analyzer"
- preset: angular
releaseRules:
- scope: no-release
release: false
- type: build
release: patch
- type: chore
release: patch
- type: ci
release: false
- type: docs
release: false
- type: style
release: patch
- type: refactor
release: patch
- type: test
release: patch
- - "@semantic-release/release-notes-generator"
- - "@semantic-release/npm"
- - "@semantic-release/github"
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"cSpell.words": ["Zaraz"],
"typescript.tsdk": "node_modules/typescript/lib"
}
Loading

0 comments on commit 68c3ccb

Please sign in to comment.