Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: chore: add lerna, eslint, prettier, commitlint, size limit, etc #2

Merged
merged 10 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@rambler-tech/commitlint-config/shared"]
}
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
62 changes: 0 additions & 62 deletions .eslintrc

This file was deleted.

10 changes: 10 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": [
"@rambler-tech/eslint-config/semi",
"@rambler-tech/eslint-config/ts"
],
"rules": {
"max-params": "off",
"new-cap": "off"
}
}
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release

on:
push:
branches:
- master
tags-ignore:
- v*

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version: '18.x'
- run: yarn
- run: |
git config --global user.email $BOT_EMAIL
git config --global user.name rambler-ui-bot
env:
BOT_EMAIL: ${{ secrets.BOT_EMAIL }}
- run: |
echo "@rambler-tech:registry=https://registry.npmjs.org/" > .npmrc
echo "registry=https://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn build
- run: yarn release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Test

on:
push:
branches:
- master
tags-ignore:
- v*

pull_request:
types:
- opened
- synchronize

jobs:
# test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Use Node.js
# uses: actions/setup-node@v3
# with:
# cache: yarn
# node-version: '18.x'
# - run: yarn
# - run: yarn test

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version: '18.x'
- run: yarn
- run: yarn lint
- run: yarn typecheck

size:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version: '18.x'
- run: yarn
- run: yarn sizecheck

commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version: '18.x'
- run: yarn
- uses: wagoid/commitlint-github-action@v3
env:
NODE_PATH: ${{ github.workspace }}/node_modules
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
.DS_Store
node_modules
npm-debug.log
yarn-error.log
lerna-debug.log
coverage
.nyc_output
.vscode
.idea
dist
build
spec.*
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
5 changes: 5 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"*.{js,ts,tsx}": ["prettier --write", "eslint --fix"],
"*.md": ["prettier --write"],
"!(packages/*/tsconfig).json": ["prettier --write"]
}
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@rambler-tech/prettier-config/semi"
10 changes: 10 additions & 0 deletions .size-limit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"path": "packages/core-v1/dist/index.js",
"limit": "3.8 KB"
},
{
"path": "packages/react-v1/dist/index.js",
"limit": "3.5 KB"
}
]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Rambler Internet Holdings LLC

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.
12 changes: 12 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('jest').Config} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
moduleDirectories: ['packages', 'node_modules'],
collectCoverage: true,
coverageReporters: ['text'],
moduleNameMapper: {
uuid: require.resolve('uuid'),
},
// setupFilesAfterEnv: ['./jest.setup.js']
};
18 changes: 18 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "independent",
"npmClient": "yarn",
"packages": ["packages/*"],
"command": {
"version": {
"allowBranch": "master",
"conventionalCommits": true,
"createRelease": "github",
"message": "chore(release): publish",
"ignoreChanges": ["**/*.md"]
},
"publish": {
"yes": true,
"verifyAccess": false
}
}
}
55 changes: 40 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
{
"name": "reflexio",
"private": true,
"description": "Business flow manager, more than just state manager",
"scripts": {},
"workspaces": [
"packages/*"
"keywords": [
"reflexio"
],
"author": "Konstantin Astapov",
"license": "MIT",
"readme": "README.md",
"scripts": {
"build": "lerna exec -- tsc",
"test": "jest",
"test:watch": "jest --watch",
"lint": "eslint '**/*.{js,ts,tsx}'",
"format": "prettier --write '**/*.{js,ts,tsx}' && eslint '**/*.{js,ts,tsx}' --fix",
"typecheck": "tsc --noEmit",
"sizecheck": "lerna exec -- tsc && size-limit",
"release": "lerna version && lerna publish from-package",
"prepare": "[ -n \"$CI\" ] && exit 0 || husky install"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/reflexio/reflexio.git"
"url": "git+https://github.com/rambler-digital-solutions/reflexio.git"
},
"keywords": [
"reflexio"
],
"author": "Konstantin Astapov",
"license": "MIT",
"private": true,
"devDependencies": {
"@reflexio/reflexio-on-redux": "*",
"@commitlint/cli": "^19.2.1",
"@rambler-tech/commitlint-config": "^0.1.1",
"@rambler-tech/eslint-config": "^0.13.0",
"@rambler-tech/prettier-config": "^0.1.0",
"@rambler-tech/ts-config": "^0.1.1",
"@size-limit/preset-small-lib": "^11.1.2",
"@types/jest": "^29.5.12",
"eslint": "^8.57.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lerna": "^8.1.2",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"redux": "^4.2.1",
"uuid": "^8.3.2"
}
"react-redux": "^9.1.0",
"redux": "^4",
"size-limit": "^11.1.2",
"ts-jest": "^29.1.2",
"typescript": "^5.4.3"
},
"workspaces": [
"packages/*"
]
}
15 changes: 15 additions & 0 deletions packages/core-v1/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable import/no-unused-modules */
export {Slice} from './lib/Slice';
export {Bite} from './lib/Bite';
export {Script} from './lib/Script';
export {useSystem, type System} from './lib/System';
export {configureRoot} from './lib/configureRoot';
export {getTriggerAndStatus, getActionType} from './lib/utils';
export type {
UpdateOnType,
DispatcherType,
BiteStatusWrap,
ScriptOptsType,
InitArgsType,
WatchArgsType,
} from './lib/types';
11 changes: 11 additions & 0 deletions packages/core-v1/lib/Bite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type {MakeBiteProcessorType, MakeBiteReducerType} from './types';

type BiteType = <ITriggers, IState, K extends keyof ITriggers, IRootTrigger>(
reducer: MakeBiteReducerType<ITriggers, IRootTrigger, IState, K>,
processor: MakeBiteProcessorType<ITriggers, IRootTrigger, K>,
) => {
reducer: MakeBiteReducerType<ITriggers, IRootTrigger, IState, K>;
processor: MakeBiteProcessorType<ITriggers, IRootTrigger, K>;
};

export const Bite: BiteType = (reducer, processor) => ({reducer, processor});
Loading
Loading