Skip to content

Commit

Permalink
feat: initial branch code commit (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
shtaif authored Dec 16, 2024
1 parent 5abf72b commit d57b1d3
Show file tree
Hide file tree
Showing 28 changed files with 4,197 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/actions/ci-common-setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Common Setup for CI

description: Reusable common setup for project's CI jobs

inputs:
node-version:
description: Specific Node.js version to override the common one that's gonna be selected by default
required: false
default: v22.5.0

runs:
using: composite
steps:
- uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}

- name: Get Node.js version
id: node_version
run: |
echo "::set-output name=version::$(node -v)"
shell: bash

- name: Install pnpm
run: npm install -g pnpm@^9
shell: bash

- name: Restore possibly cached dependencies
id: cache-node-modules
uses: actions/cache@v3
with:
path: ./node_modules
key: node-modules-${{ runner.os }}-${{ steps.node_version.outputs.version }}-${{ hashFiles('./pnpm-lock.yaml') }}

- name: Install dependencies if weren't cached
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
shell: bash
18 changes: 18 additions & 0 deletions .github/workflows/ci-build-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI - build check

on:
pull_request:
branches: [master]

jobs:
ts_build_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: ./.github/actions/ci-common-setup

- name: TypeScript test build
run: pnpm run build-check
18 changes: 18 additions & 0 deletions .github/workflows/ci-eslint-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI - ESLint check

on:
pull_request:
branches: [master]

jobs:
lint_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: ./.github/actions/ci-common-setup

- name: Lint check
run: pnpm exec eslint --cache
18 changes: 18 additions & 0 deletions .github/workflows/ci-prettier-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI - Prettier check

on:
pull_request:
branches: [master]

jobs:
prettier_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: ./.github/actions/ci-common-setup

- name: Prettier check
run: pnpm exec prettier --check "./{src,spec}/**/*.{ts,tsx,js,mjs,jsx}"
18 changes: 18 additions & 0 deletions .github/workflows/ci-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI - tests

on:
pull_request:
branches: [master]

jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: ./.github/actions/ci-common-setup

- name: Run tests
run: pnpm run test
42 changes: 42 additions & 0 deletions .github/workflows/release-new-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release new version

on:
workflow_dispatch:
inputs:
dry_run:
type: boolean
default: false
description: Perform as a dry run

jobs:
release_new_version:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.SEMANTIC_RELEASE_ACTION_PAT }} # Without providing any token here as well as if passing the built-in `secrets.GITHUB_TOKEN` - the semantic release action would end up unauthorized to push changes to master since it is set with branch protection, more reference for this issue on: https://github.com/semantic-release/semantic-release/issues/2636#issuecomment-1574476011

- uses: ./.github/actions/ci-common-setup
with:
node-version: v18

# The following action version, value of `semantic_version` and the versions of all the plugins specifically set here are a work around found for now to deal with the constant crush described here: https://github.com/cycjimmy/semantic-release-action/issues/159 (was hard to just go with the Node v14 suggestion said there since we use pnpm which outright doesn't support Node v14)
- name: Semantic Release
id: semantic_release
uses: cycjimmy/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
semantic_version: 19.0.5
dry_run: ${{ inputs.dry_run }}
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
conventional-changelog-conventionalcommits@^7.0.2
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

.env
_node_compile_cache
5 changes: 5 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trailingComma: es5
singleQuote: true
printWidth: 100
semi: true
arrowParens: avoid
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Dor Shtaif

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.
58 changes: 58 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// @ts-check

import globals from 'globals';
import eslintJs from '@eslint/js';
import eslintTs from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';

/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} */
const eslintConfigPrettierTypeForced = (() => {
/** @type {any} */
const eslintConfigPrettierAsAny = eslintConfigPrettier;
return eslintConfigPrettierAsAny;
})();

/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
eslintJs.configs.recommended,
...eslintTs.configs.recommended,
eslintConfigPrettierTypeForced,
{
files: ['**/*.{ts,ts,tsx,js,mjs,jsx}'],
plugins: {},
languageOptions: {
globals: { ...globals.browser },
parser: eslintTs.parser,
ecmaVersion: 5,
sourceType: 'script',
},
/** @type {Partial<import("eslint/rules").ESLintRules>} */
rules: {
['no-shadow']: 'off',
['comma-dangle']: 'off',
['radix']: 'off',
['no-use-before-define']: 'off',
['no-constant-condition']: 'off',
['no-unused-vars']: 'off',
['no-unused-expressions']: 'off',
['no-await-in-loop']: 'off',
['no-empty']: 'off',
['no-continue']: 'off',
['require-yield']: 'off',
['@typescript-eslint/require-yield']: 'off',
['@typescript-eslint/no-explicit-any']: 'off',
['@typescript-eslint/no-non-null-assertion']: 'off',
['@typescript-eslint/no-empty-function']: 'off',
['@typescript-eslint/no-unused-expressions']: 'warn',
['@typescript-eslint/no-unused-vars']: [
'warn',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
},
],
},
},
];
53 changes: 53 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "react-async-iterators",
"version": "0.0.1",
"author": "Dor Shtaif <[email protected]>",
"description": "The magic of JavaScript async iterators in React ⛓️ 🧬 🔃",
"type": "module",
"homepage": "https://github.com/shtaif/react-async-iterators",
"bugs": "https://github.com/shtaif/react-async-iterators/issues",
"repository": "github:shtaif/react-async-iterators",
"sideEffects": false,
"keywords": [],
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"default": "./dist/esm/index.js"
}
},
"files": [
"dist"
],
"scripts": {
"test": "vitest --run --config ./spec/vitest.config.ts",
"test:dev": "vitest --watch --config ./spec/vitest.config.ts",
"build": "rm -rf ./dist && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node ./scripts/set-module-type-in-dist-builds.mjs",
"build-check": "tsc --noEmit -p ./tsconfig.json",
"prepublishOnly": "npm run build"
},
"peerDependencies": {
"react": ">=17"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@types/node": "^22.10.2",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react-swc": "^3.6.0",
"@vitest/ui": "^2.1.8",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"globals": "^15.13.0",
"jsdom": "^25.0.1",
"prettier": "^3.4.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.0",
"vitest": "~2.1.8"
}
}
Loading

0 comments on commit d57b1d3

Please sign in to comment.