Skip to content

Commit

Permalink
chore: initialize project
Browse files Browse the repository at this point in the history
  • Loading branch information
ertgl committed Jan 27, 2025
1 parent 5ead9c4 commit 3339bbd
Show file tree
Hide file tree
Showing 138 changed files with 26,752 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.5/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
37 changes: 37 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
root = true
tab_width = 4
trim_trailing_whitespace = true

[*.{cjs,js,mjs}]
indent_size = 2
indent_style = space

[*.{cjs,js,mjs}x]
indent_size = 2
indent_style = space

[*.{cts,mts,ts}]
indent_size = 2
indent_style = space

[*.{cts,mts,ts}x]
indent_size = 2
indent_style = space

[*.json]
indent_size = 2
indent_style = space

[*.md]
indent_size = 2
indent_style = space

[*.{yaml,yml}]
indent_size = 2
indent_style = space
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
dist/ linguist-generated
120 changes: 120 additions & 0 deletions .github/actions/ci-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Setup CI
description: Setup CI environment

inputs:
build-cache-key:
description: 'Cache key for the build'
required: false
default: ''
cache-build:
description: 'Should cache the build'
required: false
default: 'true'
cache-node-modules:
description: 'Should cache node_modules'
required: false
default: 'true'
node-modules-cache-key:
description: 'Cache key for node_modules'
required: false
default: ''
restore-build-cache:
description: 'Should restore the build cache'
required: false
default: 'true'
restore-node-modules-cache:
description: 'Should restore the node_modules cache'
required: false
default: 'true'

outputs:
final-build-cache-key:
description: 'The final build cache key'
value: ${{ steps.determine-build-cache-key.outputs.final-build-cache-key }}
final-node-modules-cache-key:
description: 'The final node_modules cache key'
value: ${{ steps.determine-node-modules-cache-key.outputs.final-node-modules-cache-key }}

runs:
using: composite
steps:
- name: Determine build cache key
id: determine-build-cache-key
shell: bash
env:
FINAL_BUILD_CACHE_KEY: ${{ inputs.build-cache-key || format('build-cache-{0}-{1}', runner.os, hashFiles('yarn.lock', 'dist/**/*')) }}
run: echo "final-build-cache-key=$(echo "$FINAL_BUILD_CACHE_KEY")" >> $GITHUB_OUTPUT

- name: Determine node_modules cache key
id: determine-node-modules-cache-key
shell: bash
env:
FINAL_NODE_MODULES_CACHE_KEY: ${{ inputs.node-modules-cache-key || format('node-modules-cache-{0}-{1}', runner.os, hashFiles('yarn.lock', 'e2e/yarn.lock')) }}
run: echo "final-node-modules-cache-key=$(echo "$FINAL_NODE_MODULES_CACHE_KEY")" >> $GITHUB_OUTPUT

- name: Setup ASTNode.js LTS
uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: 'https://registry.npmjs.org'

- name: Enable Corepack
shell: bash
run: corepack enable

- name: Restore build cache
id: restore-build-cache
if: ${{ inputs.restore-build-cache == 'true' }}
uses: actions/cache/restore@v4
with:
path: dist
key: ${{ steps.determine-build-cache-key.outputs.final-build-cache-key }}

- name: Restore node_modules cache
id: restore-node-modules-cache
if: ${{ inputs.restore-node-modules-cache == 'true' }}
uses: actions/cache/restore@v4
with:
path: |
node_modules
e2e/node_modules
key: ${{ steps.determine-node-modules-cache-key.outputs.final-node-modules-cache-key }}

- name: Install dependencies
id: install-dependencies
if: ${{ steps.restore-build-cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
yarn install --immutable
yarn e2e:yarn install --immutable
- name: Cache node_modules
id: cache-node-modules
if: ${{ inputs.cache-node-modules == 'true' && steps.restore-node-modules-cache.outputs.cache-hit != 'true' && steps.install-dependencies.conclusion == 'success' }}
uses: actions/cache/save@v4
with:
path: |
node_modules
e2e/node_modules
key: ${{ steps.determine-node-modules-cache-key.outputs.final-node-modules-cache-key }}

- name: Prepare
if: ${{ steps.restore-build-cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
yarn prepare
yarn e2e:prepare
- name: Build
id: build
if: steps.restore-build-cache.outputs.cache-hit != 'true'
shell: bash
run: yarn build

- name: Cache build
id: cache-build
if: ${{ inputs.cache-build == 'true' && steps.restore-build-cache.outputs.cache-hit != 'true' && steps.build.conclusion == 'success' }}
uses: actions/cache/save@v4
with:
path: dist
key: ${{ steps.determine-build-cache-key.outputs.final-build-cache-key }}
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
time: "10:00"
timezone: "Europe/Istanbul"
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

env:
CI: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/ci-setup

test:
if: ${{ needs.build.result == 'success' }}
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/ci-setup
- name: Test
run: yarn test

test-e2e:
if: ${{ needs.test.result == 'success' }}
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/ci-setup
- name: Test
run: yarn e2e:test

lint:
if: ${{ needs.build.result == 'success' }}
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/ci-setup
- name: Lint
run: yarn eslint:lint
119 changes: 119 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: npm

on:
workflow_dispatch:
inputs:
action:
description: "Action to perform"
required: true
type: choice
options:
- publish
repositoryName:
description: "Confirm repository name"
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.sha }}

defaults:
run:
shell: bash

env:
CI: true

jobs:
prerequisites:
runs-on: ubuntu-latest
outputs:
should-validate: ${{ steps.determine-prerequisites.outputs.should-validate }}
should-validate-repository-name: ${{ steps.determine-prerequisites.outputs.should-validate-repository-name }}
should-build: ${{ steps.determine-prerequisites.outputs.should-build }}
should-test: ${{ steps.determine-prerequisites.outputs.should-test }}
should-test-e2e: ${{ steps.determine-prerequisites.outputs.should-test-e2e }}
should-publish: ${{ steps.determine-prerequisites.outputs.should-publish }}
steps:
- name: Determine prerequisites
id: determine-prerequisites
env:
INPUT_ACTION: ${{ github.event.inputs.action }}
run: |
if [[ "$INPUT_ACTION" == "publish" ]];
then
echo "should-validate=true" >> "$GITHUB_OUTPUT"
echo "should-validate-repository-name=true" >> "$GITHUB_OUTPUT"
echo "should-build=true" >> "$GITHUB_OUTPUT"
echo "should-test=true" >> "$GITHUB_OUTPUT"
echo "should-test-e2e=true" >> "$GITHUB_OUTPUT"
echo "should-publish=true" >> "$GITHUB_OUTPUT"
fi
validation:
if: ${{ needs.prerequisites.outputs.should-validate == 'true' }}
runs-on: ubuntu-latest
needs: [prerequisites]
steps:
- name: Validate repository name
if: ${{ needs.prerequisites.outputs.should-validate-repository-name == 'true' }}
env:
INPUT_REPOSITORY_NAME: ${{ github.event.inputs.repositoryName }}
REPOSITORY_NAME: ${{ github.repository }}
run: |
if [[ "$INPUT_REPOSITORY_NAME" != "$REPOSITORY_NAME" ]];
then
echo "Repository name mismatch: "$INPUT_REPOSITORY_NAME" != "$REPOSITORY_NAME""
exit 1
fi
build:
if: ${{ needs.prerequisites.outputs.should-build == 'true' && needs.validation.result != 'failure' }}
runs-on: ubuntu-latest
needs: [prerequisites, validation]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/ci-setup

test:
if: ${{ needs.prerequisites.outputs.should-test == 'true' && needs.build.result == 'success' }}
runs-on: ubuntu-latest
needs: [prerequisites, build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/ci-setup
- name: Test
run: yarn test

test-e2e:
if: ${{ needs.prerequisites.outputs.should-test-e2e == 'true' && needs.test.result == 'success' }}
runs-on: ubuntu-latest
needs: [prerequisites, test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/ci-setup
- name: Test
run: yarn e2e:test

publish:
if: ${{ needs.prerequisites.outputs.should-publish == 'true' && needs.prerequisites.result == 'success' && needs.test.result == 'success' && needs.test-e2e.result == 'success' }}
runs-on: ubuntu-latest
needs: [prerequisites, test, test-e2e]
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/ci-setup
- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --provenance
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Distribution
dist/

# Environment-specific
.env
.env.*

# Husky artifacts
.husky/_/

# Log files
*.log

# Misc
.DS_Store

# Package manager artifacts
.yarn/
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# User-specific
/.local/
3 changes: 3 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

yarn commitlint:lint::edit "$1"
Loading

0 comments on commit 3339bbd

Please sign in to comment.