Skip to content

Commit

Permalink
Add useDocument document (#1)
Browse files Browse the repository at this point in the history
* install firebase

* install use-async-effect

* add useDocument hook

* install vitest

* configure and add sample test for vitest

* install @testing-library/react

* install jsdom

* run and exit vitest

* set environment to jsdom

* add sample component test

* install firebase-tools

* install concurrently

* ignore log files

* add firebase:emulators script

* add firebase config

* add sample test for hook test

* add test action

* change name for checkout step

* add step to start firebase emulator

* fix firebase emulator step order

* add lint:check script

* add lint checking job

* rename test workflow to check

* add formatter:check script

* add job for formatter:check script

* set options optional

* hide dist dir

* add initial test for useDocument hook

* install happy-dom

* use happy-dom

* add test for useDocument hook > should initially have no snapshot

* test useDocument hook > should initially have no error

* add firebase:emulators:download script

* rename firebase:emulators script to firebase:emulators:run

* add download firebase emulators step to test job

* add explanation as to why to use happy-dom instead of jsdom

* set loading state to false when complete

* test later useDocument hook

* install sleep-sleep

* use sleep-sleep

* add closures for onError and onCompletion

* include metadata changes on listen

* test for later listen useDocument hook

* hide and ignore coverage dir

* install v8 coverage

* add coverage to test job in check workflow

* add badge for coverage

* run check workflow on push to main

* add check workflow badge

* add publish workflow
  • Loading branch information
erayerdin authored Jan 21, 2024
1 parent 1a7a512 commit a2cecc7
Show file tree
Hide file tree
Showing 14 changed files with 11,523 additions and 2,534 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Check"
on:
pull_request:
push:
branches: main

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Install dependencies"
run: npm i
- name: "Download Firebase Emulators"
run: npm run firebase:emulators:download
- name: "Run Firebase Emulators"
run: npm run firebase:emulators:run &
- name: "Wait for Firebase Emulators"
run: sleep 10
- name: "Test"
run: npm run test
- name: "Analyze Coverage"
run: npm run test:coverage
- name: "Upload Coverage"
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
lint:
runs-on: ubuntu-22.04
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Install dependencies"
run: npm i
- name: "Check Linting"
run: npm run lint:check
formatter:
runs-on: ubuntu-22.04
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Install dependencies"
run: npm i
- name: "Check Formatting"
run: npm run formatter:check
24 changes: 24 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Setup Node"
uses: actions/setup-node@v3
with:
node-version: "18.16.0"
registry-url: "https://registry.npmjs.org"
- name: "Switch to Node CI Environment"
run: npm ci
- name: "Build Project"
run: rm -rfv dist && npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ node_modules
dist

#storybook build directory
storybook-static
storybook-static

**/*.log
coverage/
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"**/Thumbs.db": true,
"node_modules": true,
"package-lock.json": true,
"dist": true,
"coverage": true,
},
"explorerExclude.backup": {},
"licenser.license": "MIT",
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Fireact

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/erayerdin/fireact/check?branch=main&style=flat-square&logo=github&logoColor=white&label=check)
![Codecov](https://img.shields.io/codecov/c/github/erayerdin/fireact?token=Nw2dQOJfbC&style=flat-square&logo=codecov&logoColor=white)

A Firebase hooks library for React.
Loading

0 comments on commit a2cecc7

Please sign in to comment.