Skip to content

Commit

Permalink
feat(*): rewrite entire lib from scratch
Browse files Browse the repository at this point in the history
The lib has been entirely rewritten in order to have the source code in TypeScript and leveraging
the "tsdx" package for bundling, testing and linting.

BREAKING CHANGE: As part of the rewrite, the global exports are gone. Please use CommonJS or ESM
style imports as specified in the README.

fixes #55 closes #57
  • Loading branch information
favna committed Oct 21, 2020
1 parent 5bd29b2 commit 9f93221
Show file tree
Hide file tree
Showing 53 changed files with 17,978 additions and 4,994 deletions.
15 changes: 15 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"projectName": "react-if",
"projectOwner": "romac",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"commitConvention": "angular",
"contributors": [
],
"contributorsPerLine": 7
}
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

16 changes: 13 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# http://editorconfig.org
root = true

[*]
Expand All @@ -9,6 +8,17 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
[*.{js,ts,mjs}]
indent_size = 2
indent_style = space
block_comment_start = /*
block_comment = *
block_comment_end = */

[*.{yml,yaml}]
indent_size = 2
indent_style = space

[*.{md,rmd,mkd,mkdn,mdwn,mdown,markdown,litcoffee}]
tab_width = 2
trim_trailing_whitespace = false
37 changes: 0 additions & 37 deletions .eslintrc

This file was deleted.

11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
extends: ['@favware/eslint-config-react-app', 'plugin:prettier/recommended'],
overrides: [
{
files: ['./tsdx.config.js'],
rules: {
'@typescript-eslint/no-var-requires': 0
}
}
]
};
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/src/ @romac @favna
40 changes: 40 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing

To contribute to this repository, feel free to create a new fork of the repository and
submit a pull request. We highly suggest [ESLint] to be installed
in your text editor or IDE of your choice to ensure builds from GitHub Actions do not fail.

1. Fork, clone, and select the **main** branch.
2. Create a new branch in your fork.
3. Make your changes.
4. Ensure your linting and tests pass by running `yarn test && yarn lint`
5. Commit your changes, and push them.
6. Submit a Pull Request [here]!

## Commands

TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.

The recommended workflow is to run TSDX in one terminal:

```bash
npm start # or yarn start
```

This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.

Then run the example inside another:

```bash
cd example
npm i # or yarn to install dependencies
npm start # or yarn start
```

The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases).

To do a one-off build, use `npm run build` or `yarn build`.

To run tests, use `npm test` or `yarn test`.

[here]: https://github.com/romac/react-if/pulls
68 changes: 68 additions & 0 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Continuous Delivery

on:
push:
branches:
- master

jobs:
Docgen:
name: Docgen
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Restore CI Cache
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-14-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn --ignore-scripts --frozen-lockfile
- name: Build documentation
run: yarn docs
- name: Publish Docs
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo -e "\n# Initialize some useful variables"
REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
BRANCH_OR_TAG=`awk -F/ '{print $2}' <<< $GITHUB_REF`
CURRENT_BRANCH=`awk -F/ '{print $NF}' <<< $GITHUB_REF`
if [ "$BRANCH_OR_TAG" == "heads" ]; then
SOURCE_TYPE="branch"
else
SOURCE_TYPE="tag"
fi
echo -e "\n# Checkout the repo in the target branch"
TARGET_BRANCH="gh-pages"
git clone $REPO out -b $TARGET_BRANCH
echo -e "\n# Remove any old files in the out folder"
rm -rfv out/assets/*
rm -rfv out/interfaces/*
rm -rfv out/*.html
echo -e "\n# Move the generated docs to the newly-checked-out repo, to be committed and pushed"
rsync -vaI .all-contributorsrc out/
rsync -vaI LICENSE.md out/
rsync -vaI README.md out/
rsync -vaI docs/ out/
echo -e "\n# Commit and push"
cd out
git add --all .
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_EMAIL}"
git commit -m "docs: api docs build for ${GITHUB_SHA}" || true
git push origin $TARGET_BRANCH
env:
GITHUB_ACTOR: Favware-bot
GITHUB_EMAIL: [email protected]
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71 changes: 71 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Continuous Integration

on:
push:
branches:
- master
pull_request:

jobs:
Linting:
name: Linting
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Restore CI Cache
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-14-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn --ignore-scripts --frozen-lockfile
- name: Run ESLint
uses: yarn lint

Testing:
name: Unit Tests
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Restore CI Cache
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-14-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Run tests
run: yarn test --ci --coverage --maxWorkers=2

Building:
name: Compile source code
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Restore CI Cache
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-14-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn --ignore-scripts --frozen-lockfile
- name: Build Code
run: yarn build
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI
on: [push]
jobs:
build:
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['10.x', '12.x', '14.x']
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

- name: Lint
run: yarn lint

- name: Test
run: yarn test --ci --coverage --maxWorkers=2

- name: Build
run: yarn build
12 changes: 12 additions & 0 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: size
on: [pull_request]
jobs:
size:
runs-on: ubuntu-latest
env:
CI_JOB_NUMBER: 1
steps:
- uses: actions/checkout@v1
- uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
node_modules/
*.log
.DS_Store
node_modules
.cache
dist
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "http://json.schemastore.org/prettierrc",
"endOfLine": "lf",
"printWidth": 140,
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false,
"arrowParens": "avoid"
}
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

24 changes: 24 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The MIT License (MIT)

Copyright © `2014` `Romain Ruetschi`

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.
Loading

0 comments on commit 9f93221

Please sign in to comment.