Skip to content

Commit ad3b86a

Browse files
Introduce monorepo to manage packages using pnpm (#880)
Workspace: ``` examples/ - nextjs-scheduler - profile-stack - react-tldraw - react-todomvc - simultaneous-cursors - vanilla-codemirror6 - vanilla-quill - vuejs-kanban packages/ - create-yorkie-app - devtools - sdk <-- previous yorkie-js-sdk package ``` Command: ``` `sdk` - [x] pnpm sdk build - [x] pnpm sdk build:proto - [x] pnpm sdk build:docs - [x] pnpm sdk build:ghpages - [x] pnpm sdk dev - [x] pnpm sdk test - [x] pnpm sdk test:watch - [x] pnpm sdk test:bench - [x] pnpm sdk test:ci - [x] pnpm sdk test:yorkie.dev - [x] pnpm sdk lint - [x] pnpm sdk prepare `devtools` - [x] pnpm devtools dev - [x] pnpm devtools build - [x] pnpm devtools test `create-yorkie-app` - [x] pnpm create-yorkie-app start - [x] pnpm create-yorkie-app build - [x] pnpm create-yorkie-app build:copy-assets ``` --------- Co-authored-by: Youngteac Hong <susukang98@gmail.com>
1 parent 267878f commit ad3b86a

File tree

211 files changed

+14678
-22504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+14678
-22504
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,34 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v2
2020

21+
- uses: pnpm/action-setup@v2
22+
with:
23+
version: 8
24+
2125
- name: Use Node.js ${{ matrix.node-version }}
2226
uses: actions/setup-node@v4
2327
with:
2428
node-version: ${{ matrix.node-version }}
25-
cache: 'npm'
29+
cache: 'pnpm'
2630

27-
- name: Cache Node Moudles
31+
- name: Cache pnpm store
2832
id: cache
2933
uses: actions/cache@v3
3034
with:
31-
path: '**/node_modules'
32-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
35+
path: ~/.pnpm-store
36+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
3337
restore-keys: |
34-
${{ runner.os }}-node-
38+
${{ runner.os }}-pnpm-
3539
3640
- name: Install Dependencies
3741
if: steps.cache.outputs.cache-hit != 'true'
38-
run: npm install
42+
run: pnpm install
3943

40-
- run: npm run lint
41-
- run: npm run build
42-
- run: npm run build:examples
44+
- run: pnpm sdk lint
45+
- run: pnpm sdk build
46+
- run: pnpm build:examples
4347
- run: docker compose -f docker/docker-compose-ci.yml up --build -d
44-
- run: npm run test:ci
48+
- run: pnpm sdk test:ci
4549

4650
- name: Upload coverage to Codecov
4751
uses: codecov/codecov-action@v1
@@ -51,4 +55,4 @@ jobs:
5155
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5256

5357
- name: Run benchmark
54-
run: npm run test:bench
58+
run: pnpm sdk test:bench

.github/workflows/create-yorkie-app-publish.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ on:
55
branches:
66
- main
77
paths:
8-
- tools/create-yorkie-app/**
8+
- packages/create-yorkie-app/**
99
- examples/**
10+
1011
jobs:
1112
build:
1213
runs-on: ubuntu-latest
@@ -17,21 +18,25 @@ jobs:
1718
- name: Checkout 🛎️
1819
uses: actions/checkout@v2
1920

21+
- uses: pnpm/action-setup@v2
22+
with:
23+
version: 8
24+
2025
- name: Setup Node 🔧
2126
uses: actions/setup-node@v2
2227
with:
2328
node-version: '18'
24-
cache: 'npm'
29+
cache: 'pnpm'
2530
registry-url: 'https://registry.npmjs.org'
2631

2732
- name: Install and Build 🔧
2833
run: |
29-
cd tools/create-yorkie-app
30-
npm install
31-
npm run build
34+
cd packages/create-yorkie-app
35+
pnpm install
36+
pnpm build
3237
3338
- name: Publish 🚀
34-
run: cd tools/create-yorkie-app && npm publish --provenance
39+
run: cd packages/create-yorkie-app && pnpm publish --provenance
3540
continue-on-error: true
3641
env:
3742
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/devtools-publish.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,32 @@ on:
55
branches:
66
- 'main'
77
paths:
8-
- tools/devtools/**
8+
- packages/devtools/**
99
jobs:
1010
build-and-deploy:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout 🛎️
1414
uses: actions/checkout@v2.3.1
1515

16+
- uses: pnpm/action-setup@v2
17+
with:
18+
version: 8
19+
1620
- name: Setup Node 🔧
1721
uses: actions/setup-node@v2
1822
with:
1923
node-version: '18'
20-
cache: 'npm'
24+
cache: 'pnpm'
2125

2226
- name: Install and Build 🔧
2327
run: |
24-
cd tools/devtools
25-
npm install
26-
npm run build
28+
cd packages/devtools
29+
pnpm install
30+
pnpm build
2731
2832
- name: Deploy 🚀
2933
uses: PlasmoHQ/bpp@v3
3034
with:
3135
keys: ${{ secrets.BPP_KEYS }}
32-
chrome-file: 'tools/devtools/dist/chrome-mv3-prod.zip'
36+
chrome-file: 'packages/devtools/dist/chrome-mv3-prod.zip'

.github/workflows/github-page-publish.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,40 @@ jobs:
1212
- name: Checkout 🛎️
1313
uses: actions/checkout@v2.3.1
1414

15+
- uses: pnpm/action-setup@v2
16+
with:
17+
version: 8
18+
1519
- name: Setup Node 🔧
1620
uses: actions/setup-node@v2
1721
with:
1822
node-version: '18'
19-
cache: 'npm'
20-
cache-dependency-path: package-lock.json
23+
cache: 'pnpm'
24+
cache-dependency-path: pnpm-lock.yaml
2125

22-
- name: Cache Node Moudles
26+
- name: Cache pnpm store
2327
id: cache
2428
uses: actions/cache@v3
2529
with:
26-
path: '**/node_modules'
27-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
30+
path: ~/.pnpm-store
31+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
2832
restore-keys: |
29-
${{ runner.os }}-node-
33+
${{ runner.os }}-pnpm-
3034
3135
- name: Install Dependencies
3236
if: steps.cache.outputs.cache-hit != 'true'
33-
run: npm install
37+
run: pnpm install
3438

3539
- name: Build 🔧
3640
run: |
37-
npm run build
38-
npm run build:docs
39-
npm run build:examples
40-
npm run build:ghpages
41+
pnpm sdk build
42+
pnpm sdk build:docs
43+
pnpm build:examples
44+
pnpm sdk build:ghpages
4145
4246
- name: Deploy 🚀
4347
uses: peaceiris/actions-gh-pages@v3
4448
with:
4549
github_token: ${{ secrets.GITHUB_TOKEN }}
46-
publish_dir: ./ghpages
50+
publish_dir: ./packages/sdk/ghpages
4751
enable_jekyll: false

.github/workflows/npm-publish.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,33 @@ jobs:
1111
steps:
1212
- name: Checkout 🛎️
1313
uses: actions/checkout@v2
14+
15+
- uses: pnpm/action-setup@v2
16+
with:
17+
version: 8
18+
1419
- name: Setup Node 🔧
1520
uses: actions/setup-node@v2
1621
with:
1722
node-version: '18'
18-
cache: 'npm'
19-
cache-dependency-path: package-lock.json
23+
cache: 'pnpm'
24+
cache-dependency-path: pnpm-lock.yaml
2025
registry-url: 'https://registry.npmjs.org'
2126

22-
- name: Cache Node Moudles
27+
- name: Cache pnpm store
2328
id: cache
2429
uses: actions/cache@v3
2530
with:
26-
path: '**/node_modules'
27-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
31+
path: ~/.pnpm-store
32+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
2833
restore-keys: |
29-
${{ runner.os }}-node-
34+
${{ runner.os }}-pnpm-
3035
3136
- name: Install Dependencies
3237
if: steps.cache.outputs.cache-hit != 'true'
33-
run: npm install
38+
run: pnpm install
3439

35-
- run: npm run build
36-
- run: npm publish --provenance
40+
- run: pnpm sdk build
41+
- run: pnpm publish --provenance
3742
env:
3843
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,6 @@ lib/
142142

143143
# profile output
144144
*.cpuprofile
145+
146+
# npm
147+
**/package-lock.json

.npmrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
engine-strict=true
1+
engine-strict=true
2+
@buf:registry=https://buf.build/gen/npm/v1

CONTRIBUTING.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@ Thanks for contributing!
3636

3737
### Building yorkie-js-sdk
3838

39-
For building yorkie-js-sdk, You'll first need Node.js installed(Node.js version 18+ and npm version 7.10+ are required).
39+
For building yorkie-js-sdk, You'll first need Node.js installed(Node.js version 18+ and pnpm version 9.6+ are required).
4040

4141
- [Node.js](https://nodejs.org/en) (version 18+)
42-
- [npm](https://www.npmjs.com/) (version 7.10+)
42+
- [pnpm](https://pnpm.io/) (version 9.6+)
4343

4444
```bash
4545
# install packages
46-
$ npm install
46+
47+
# In the root directory of the repository.
48+
$ pnpm sdk install
4749

4850
# build
49-
$ npm run build
51+
52+
# In the root directory of the repository.
53+
$ pnpm sdk build
5054
```
5155

5256
To generate proto messages, we use protoc-gen-connect-es, which is a code generator plugin for Protocol Buffer compilers, like buf and protoc. It generates both clients and server definitions from Protocol Buffer schema.
@@ -55,7 +59,9 @@ For more details, see [@connectrpc/protoc-gen-connect-es](https://github.com/con
5559

5660
```bash
5761
# generate proto messages and the service client stub classes
58-
$ npm run build:proto
62+
63+
# In the root directory of the repository.
64+
$ pnpm sdk build:proto
5965
```
6066

6167
> Primary "source of truth" location of protobuf message is
@@ -72,7 +78,8 @@ $ docker compose -f docker/docker-compose.yml up --build -d
7278
Start the test in another terminal session.
7379

7480
```bash
75-
$ npm run test
81+
# In the root directory of the repository.
82+
$ pnpm sdk test
7683
```
7784

7885
To get the latest server locally, run the command below then restart containers again:
@@ -108,7 +115,8 @@ To run only specific suites or tests, use `.only` and execute the following comm
108115
Refer to [Test Filtering](https://vitest.dev/guide/filtering#selecting-suites-and-tests-to-run) in `vitest` for more details:
109116

110117
```bash
111-
$ npm run test {test file path} # e.g. npm run test integration/tree_test.ts
118+
# In the root directory of the repository.
119+
$ pnpm sdk test {test file path} # e.g. pnpm sdk test integration/tree_test.ts
112120
```
113121

114122
### Starting co-editing example with CodeMirror
@@ -122,7 +130,8 @@ $ docker compose -f docker/docker-compose.yml up --build -d
122130
Start the webpack-dev-server in another terminal session.
123131

124132
```bash
125-
$ npm run dev
133+
# In the root directory of the repository.
134+
$ pnpm sdk dev
126135
```
127136

128137
Open the co-editing example page served by webpack-dev-server in your browser.

examples/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,24 @@ $ docker compose -f docker/docker-compose.yml up --build -d
1414
The examples have own local dependencies. So you should install dependencies before running examples.
1515

1616
```bash
17-
# In the directory of the example.
18-
$ npm install
17+
# In the root directory of the repository.
18+
$ pnpm install
1919
```
2020

2121
Then you can run the examples.
2222

2323
```bash
24-
# In the directory of the example.
25-
$ npm run dev
24+
# In the root directory of the repository.
25+
$ pnpm <EXAMPLE-NAME> dev
26+
27+
# Or in the directory of the example.
28+
$ pnpm dev
2629
```
2730

2831
Open the browser and go to the URL that is printed in the terminal.
2932

3033
## Releasing an example to https://yorkie.dev
3134

32-
To release an example, the example should export static files to `./dist` directory when running `npm run build`.
35+
To release an example, the example should export static files to `./dist` directory when running `pnpm <EXAMPLE-NAME> build` in the root directory of the repository or `pnpm build` in the directory of the example.
36+
3337
After the example is merged to the `main` branch, it is automatically deployed to https://yorkie.dev/yorkie-js-sdk/examples/{EXAMPLE-NAME}.

examples/nextjs-scheduler/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
extends: ['next', 'plugin:prettier/recommended'],
23
rules: {
34
'prettier/prettier': [
45
'error',

examples/nextjs-scheduler/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ $ docker compose -f docker/docker-compose.yml up --build -d
1919
Then install dependencies and run the demo.
2020

2121
```bash
22-
$ npm install
22+
# In the root directory of the repository.
23+
$ pnpm install
2324
```
2425

2526
Now you can run the demo.
2627

2728
```bash
28-
$ npm run dev
29+
# In the root directory of the repository.
30+
$ pnpm nextjs-scheduler dev
31+
32+
# Or in the directory of the example.
33+
$ pnpm dev
2934
```

0 commit comments

Comments
 (0)