Skip to content

Commit

Permalink
Merge pull request #7 from gadingnst/feat/upgrade
Browse files Browse the repository at this point in the history
[RELEASE] Upgrade & Revamp
  • Loading branch information
Gading Nasution authored Oct 8, 2022
2 parents 1d577fa + 2f691e0 commit 55d4d98
Show file tree
Hide file tree
Showing 7 changed files with 5,999 additions and 4,840 deletions.
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2

updates:
# Fetch and update latest `npm` packages
- package-ecosystem: npm
directory: '/'
target-branch: 'main'
schedule:
interval: monthly
time: '00:00'
open-pull-requests-limit: 5
reviewers:
- gadingnst
assignees:
- gadingnst
commit-message:
prefix: fix
prefix-development: chore
include: scope
7 changes: 3 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
scope: "@gadingnst"
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm ci
- name: Build Package
run: npm run build
- name: Publishing Package
run: npm publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint
32 changes: 10 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ♻️ Store SWR
# ♻️ SWR Global State
Zero-setup & simple state management for React Components with SWR. So you can focus on your awesome React Project and not waste another afternoon on the setup & configuring your global state. 🌄

# Table of Contents
- [♻️ Store SWR](#️-store-swr)
- [♻️ SWR Global State](#️-swr-global-state)
- [Table of Contents](#table-of-contents)
- [Getting Started](#getting-started)
- [Install](#install)
Expand All @@ -18,23 +18,11 @@ Zero-setup & simple state management for React Components with SWR. So you can f

# Getting Started
## Install
- Create a new file named `.npmrc` in your project root directory.
- Add the following content to that file:
```
@gadingnst:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGE_TOKEN}
```

- You can generate `${GITHUB_PACKAGE_TOKEN}` in your profile settings here: https://github.com/settings/tokens
- Choose the token expiration according to what you want.
- In creating Github Token, check only `read:packages` permissions, Click `Generate Token` button.
- Then copy the token and replace it in the `${GITHUB_PACKAGE_TOKEN}`. Or you can just define it on your Environment Variables, see: https://stackoverflow.com/a/55578270/8112320
- After that, run following command.
```
npm install @gadingnst/store-swr
npm install swr-global-state
//or
yarn add @gadingnst/store-swr
yarn add swr-global-state
```

## Usage
Expand All @@ -53,7 +41,7 @@ export const APP_COUNT = {
```jsx
// file: components/SetCountComponent.js

import { useStore } from "@gadingnst/store-swr";
import { useStore } from "swr-global-state";
import { APP_COUNT } from "stores/app";

function SetCountComponent() {
Expand All @@ -77,7 +65,7 @@ export default SetCountComponent;
```jsx
// file: components/GetCountComponent.js

import { useStore } from "@gadingnst/store-swr";
import { useStore } from "swr-global-state";
import { APP_COUNT } from "stores/app";

function GetCountComponent() {
Expand All @@ -95,7 +83,7 @@ export default GetCountComponent;
### TypeScript
```ts
// file: stores/app.ts
import type { Store } from "@gadingnst/store-swr";
import type { Store } from "swr-global-state";

export const APP_COUNT: Store<number> = {
key: "@app/count",
Expand All @@ -112,7 +100,7 @@ Instead of creating store object in `stores/app.js` file, you can wrap it into c
```js
// file: stores/count.js

import useStore from "@gadingnst/store-swr";
import useStore from "swr-global-state";

const useCount = () => useStore({
key: "@app/count",
Expand Down Expand Up @@ -165,11 +153,11 @@ export default GetCountComponent;
```

# Demo
> You can see demo repository [here](https://github.com/gadingnst/store-swr-demo)
> You can see demo repository [here](https://github.com/gadingnst/swr-global-state-demo)
# Publishing
- Before pushing your changes to Github, make sure that `version` in `package.json` is changed to newest version. Then run `npm install` for synchronize it to `package-lock.json`
- After your changes have been merged on branch `main`, you can publish the packages by creating new Relase here: https://github.com/gadingnst/store-swr/releases/new
- After your changes have been merged on branch `main`, you can publish the packages by creating new Relase here: https://github.com/gadingnst/swr-global-state/releases/new
- Create new `tag`, make sure the `tag` name is same as the `version` in `package.json`.
- You can write Release title and notes here. Or you can use auto-generated release title and notes.
- Click `Publish Release` button, then wait the package to be published.
Loading

0 comments on commit 55d4d98

Please sign in to comment.