Skip to content

Commit

Permalink
Merge pull request #18 from react18-tools/plugins
Browse files Browse the repository at this point in the history
Plugins
  • Loading branch information
mayank1513 committed Apr 29, 2024
2 parents 8d2f621 + 8cd72ec commit 4789eab
Show file tree
Hide file tree
Showing 28 changed files with 436 additions and 256 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
packages: write
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org
node-version: 20
Expand Down
26 changes: 11 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
working-directory: ./lib/r18gs

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
Expand All @@ -35,30 +35,26 @@ jobs:
# fail and not publish if any of the unit tests are failing
- name: Test
run: pnpm test
- name: Create release and publish to NPM
- name: publish to NPM
run: pnpm build && pnpm publish-package
# continue on error to publish scoped package name <- by default repo is setup for a non-scoped + scoped package name
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.event.repository.owner.login }}
REPO: ${{ github.event.repository.name }}

- name: Publish Scoped package to NPM
# continue on error - expecing npm to trow error if scoping is done twice
continue-on-error: true
run: cd dist && node ../scope.js && npm publish --provenance --access public && cd ..
- name: Create GitHub release
run: |
v=$(node.exe -p -e "require('./package.json').version")
gh release create $v --generate-notes --latest -F CHANGELOG.md --title "Release $v"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.event.repository.owner.login }}
REPO: ${{ github.event.repository.name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish package with long name for better SEO
- name: Publish canonical packages
continue-on-error: true
run: |
cd dist
sed -i -e "s/.*name.*/\t\"name\": \"@mayank1513\/r18gs\",/" package.json
npm publish --provenance --access public
sed -i -e "s/.*name.*/\t\"name\": \"react18-global-store\",/" package.json
npm publish --provenance --access public
sed -i -e "s/.*name.*/\t\"name\": \"react18-store\",/" package.json
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i -g pnpm && pnpm i
Expand All @@ -21,7 +21,7 @@ jobs:
run: pnpm test
- name: Upload coverage reports to Codecov
continue-on-error: true
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
directory: ./lib/r18gs
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
29 changes: 3 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Thus, I decided to create a bare minimum, ultra-light store that creates shared

✅ Works with all build systems/tools/frameworks for React18

✅ Works for both client side and server side components (be careful, separate states are created for server side and client side. Any changes done on client side will not affect the server components.)

✅ Doccumented with [Typedoc](https://react18-tools.github.io/react18-global-store) ([Docs](https://react18-tools.github.io/react18-global-store))

✅ Next.js, Vite and Remix examples
Expand Down Expand Up @@ -53,7 +51,7 @@ and make this state accessible to all client components.
const [state, setState] = useRGS<number>("counter", 1);
```

You can access the same state across all client side components using unique.
You can access the same state across all client side components using unique key.

> It is recommended to store your keys in separate file to avoid typos and unnecessary conflicts.
Expand Down Expand Up @@ -106,30 +104,9 @@ export default function Counter() {
}
```

## Contribute

### Build

To build all apps and packages, run the following command:

```
cd react18-global-store
pnpm build
```

### Develop

To develop all apps and packages, run the following command:

```
cd react18-global-store
pnpm dev
```

Also, please
## Contributing

1. check out discussion for providing any feedback or sugestions.
2. Report any issues or feature requests in issues tab
See [contributing.md](/contributing.md)

### 🤩 Don't forger to star [this repo](https://github.com/mayank1513/react18-global-store)!

Expand Down
81 changes: 48 additions & 33 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
# Contributing to fork-me
# Contributing to r18gs

## What's inside?

### Utilities

This Turborepo has some additional tools already setup for you:
## Contribute

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting

### Apps and Packages

This Turborepo includes the following packages/examples:

- `nextjs`: a [Next.js](https://nextjs.org/) app
- `vite`: a [Vite.js](https://vitest.dev) app
- `eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
- `tsconfig`: `tsconfig.json`s used throughout the monorepo

To increase the visibility we have moved core library to lib

- `fork-me`: a React component library shared by both `nextjs` and `vite` examples lives in `./lib/fork-me`

Each package/example is 100% [TypeScript](https://www.typescriptlang.org/).

## Automatic file generation

- just run `yarn turbo gen` and follow the propts to auto generate your new component with test file and dependency linking
- follow best practices automatically
Once you have cloned the repo. `cd` to the repo directory and use following commands.

### Build

To build all apps and packages, run the following command:

```bash
cd r18gs
pnpm build
```

Expand All @@ -44,7 +17,6 @@ pnpm build
To develop all apps and packages, run the following command:

```bash
cd r18gs
pnpm dev
```

Expand All @@ -53,7 +25,6 @@ pnpm dev
To run unit tests, run the following command:

```bash
cd r18gs
pnpm test
```

Expand All @@ -62,7 +33,6 @@ pnpm test
Before creating PR make sure lint is passing and also run formatter to properly format the code.

```bash
cd r18gs
pnpm lint
```

Expand All @@ -72,6 +42,49 @@ and
pnpm format
```

You can also contribute by

1. Sponsoring
2. Check out discussion for providing any feedback or sugestions.
3. Report any issues or feature requests in issues tab

## What's inside?

### Utilities

This Turborepo has some additional tools already setup for you:

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting

### Library, Examples and Packages

This Turborepo includes the following packages/examples:

#### React18 Global Store library

You will find the core library code inside lib/r18gs

#### Examples (/examples)

- `nextjs`: a [Next.js](https://nextjs.org/) app
- `vite`: a [Vite.js](https://vitest.dev) app
- `remix`: a [Remix](https://remix.run/) app

#### Packages (/packages)

- `eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
- `tsconfig`: `tsconfig.json`s used throughout the monorepo
- `shared-ui`: An internal UI package for shared UI code

Each package/example is 100% [TypeScript](https://www.typescriptlang.org/).

## Automatic file generation

- just run `yarn turbo gen` and follow the propts to auto generate your new component with test file and dependency linking
- follow best practices automatically

## Useful Links

Learn more about Turborepo and Next.js:
Expand All @@ -89,4 +102,6 @@ Learn more about Turborepo and Next.js:
<hr />

### 🤩 Don't forger to star [this repo](https://github.com/mayank1513/react18-global-store)!

<p align="center" style="text-align:center">with 💖 by <a href="https://mayank-chaudhari.vercel.app" target="_blank">Mayank Kumar Chaudhari</a></p>
9 changes: 9 additions & 0 deletions examples/nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# nextjs-example

## 0.0.11

### Patch Changes

- Updated dependencies [81b9d3f]
- Updated dependencies
- [email protected]
- [email protected]

## 0.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nextjs-example",
"version": "0.0.10",
"version": "0.0.11",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
10 changes: 10 additions & 0 deletions examples/remix/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# remix-example

## 0.0.11

### Patch Changes

- 81b9d3f: Make the library extensible with plugins
- Updated dependencies [81b9d3f]
- Updated dependencies
- [email protected]
- [email protected]

## 0.0.10

### Patch Changes
Expand Down
16 changes: 1 addition & 15 deletions examples/remix/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remix-example",
"version": "0.0.10",
"version": "0.0.11",
"private": true,
"sideEffects": false,
"type": "module",
Expand Down Expand Up @@ -33,19 +33,5 @@
},
"engines": {
"node": ">=18.0.0"
},
"pnpm": {
"packageExtensions": {
"@remix-run/dev": {
"peerDependencies": {
"react-dom": "18.2.0"
}
},
"@remix-run/serve": {
"peerDependencies": {
"react-dom": "18.2.0"
}
}
}
}
}
9 changes: 9 additions & 0 deletions examples/vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# vite-example

## 0.0.11

### Patch Changes

- Updated dependencies [81b9d3f]
- Updated dependencies
- [email protected]
- [email protected]

## 0.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vite-example",
"private": true,
"version": "0.0.10",
"version": "0.0.11",
"type": "module",
"scripts": {
"dev": "vite --port 3001",
Expand Down
10 changes: 10 additions & 0 deletions lib/r18gs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# r18gs

## 0.2.0

### Minor Changes

- 81b9d3f: Make the library extensible with plugins

### Patch Changes

- Add Persist and Sync plugin

## 0.1.4

### Patch Changes
Expand Down
Loading

0 comments on commit 4789eab

Please sign in to comment.