Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce monorepo to manage packages using pnpm #880

Merged
merged 27 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
59081ee
Reorganize folder structure and install pnpm
gwbaik9717 Aug 4, 2024
fde46b7
Update package.json files
gwbaik9717 Aug 5, 2024
b1d263c
Update TypeScript and Vite version
gwbaik9717 Aug 8, 2024
1091704
Update tsconfig.json and vite.config.ts in examples
gwbaik9717 Aug 10, 2024
daec8c5
Allow only pnpm scripts with only-allow
gwbaik9717 Aug 10, 2024
97df479
Update tsconfig and package.json in 'package' folder
gwbaik9717 Aug 10, 2024
01129bc
Resolve MODUL NOT FOUND error in nextjs-scheduler
gwbaik9717 Aug 10, 2024
d73a922
Resolve nextjs-scheduler build fail issue
gwbaik9717 Aug 11, 2024
b753af0
Resolve issue of peer dependcies of plugin-react and tldraw
gwbaik9717 Aug 11, 2024
89fdbc8
Resolve type error in react-tldraw
gwbaik9717 Aug 11, 2024
884e53d
Resolve peer dependency issues in vuejs-kanba
gwbaik9717 Aug 11, 2024
95cc381
Remove unnecessary package-lock.json
gwbaik9717 Aug 12, 2024
162d529
Update .yml files to use pnpm
gwbaik9717 Aug 12, 2024
d2b8bc4
Resolve build fail issues of vailla-quill and vanilla-codemirror6
gwbaik9717 Aug 13, 2024
fcf1366
Change yml files
gwbaik9717 Aug 13, 2024
3d49d41
Update README.md, CONTRIBUTING.MD
gwbaik9717 Aug 13, 2024
f57f0e3
Merge remote-tracking branch 'origin/main' into monorepo-pnpm
gwbaik9717 Aug 13, 2024
d2b4912
Add package-lock.json to .gitignore
gwbaik9717 Aug 15, 2024
5aeacd6
Relocate README.md to root directory
gwbaik9717 Aug 15, 2024
a4cc9b7
Modify script for create-yorkie-app
gwbaik9717 Aug 15, 2024
5d5ff4c
Resolve type issues in devtools
gwbaik9717 Aug 15, 2024
ebd7a14
Resolve buid fail issues of Devtools
gwbaik9717 Aug 15, 2024
a289c05
Unify error throwing methods in Devtools
gwbaik9717 Aug 15, 2024
fc7c524
Update import statement for assert in helper.ts
hackerwins Aug 16, 2024
8a342ac
Add examples folder to the build process
hackerwins Aug 16, 2024
5651538
Update .gitignore and .npmrc files
hackerwins Aug 16, 2024
9167b0e
Update build:ghpages script to fix path issue
hackerwins Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,34 @@ jobs:
node-version: [18.x]
steps:
- uses: actions/checkout@v2

- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache: 'pnpm'

- name: Cache Node Moudles
- name: Cache pnpm store
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-pnpm-


- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
run: pnpm install

- run: npm run lint
- run: npm run build
- run: npm run build:examples
- run: pnpm sdk lint
- run: pnpm sdk build
- run: pnpm build:examples
- run: docker compose -f docker/docker-compose-ci.yml up --build -d
- run: npm run test:ci
- run: pnpm sdk test:ci

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Expand All @@ -51,4 +54,4 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Run benchmark
run: npm run test:bench
run: pnpm sdk test:bench
13 changes: 7 additions & 6 deletions .github/workflows/create-yorkie-app-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on:
branches:
- main
paths:
- tools/create-yorkie-app/**
- packages/create-yorkie-app/**
hackerwins marked this conversation as resolved.
Show resolved Hide resolved
- examples/**

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -21,17 +22,17 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'npm'
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'

- name: Install and Build 🔧
run: |
cd tools/create-yorkie-app
npm install
npm run build
cd packages/create-yorkie-app
pnpm install
pnpm build

- name: Publish 🚀
run: cd tools/create-yorkie-app && npm publish --provenance
run: cd packages/create-yorkie-app && pnpm publish --provenance
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
12 changes: 6 additions & 6 deletions .github/workflows/devtools-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- 'main'
paths:
- tools/devtools/**
- packages/devtools/**
jobs:
build-and-deploy:
runs-on: ubuntu-latest
Expand All @@ -17,16 +17,16 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'npm'
cache: 'pnpm'

- name: Install and Build 🔧
run: |
cd tools/devtools
npm install
npm run build
cd packages/devtools
pnpm install
pnpm build

- name: Deploy 🚀
uses: PlasmoHQ/bpp@v3
with:
keys: ${{ secrets.BPP_KEYS }}
chrome-file: 'tools/devtools/dist/chrome-mv3-prod.zip'
chrome-file: 'packages/devtools/dist/chrome-mv3-prod.zip'
22 changes: 11 additions & 11 deletions .github/workflows/github-page-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: package-lock.json
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

- name: Cache Node Moudles
- name: Cache pnpm store
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-pnpm-

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
run: pnpm install

- name: Build 🔧
run: |
npm run build
npm run build:docs
npm run build:examples
npm run build:ghpages
pnpm sdk build
pnpm sdk build:docs
pnpm build:examples
pnpm sdk build:ghpages

- name: Deploy 🚀
uses: peaceiris/actions-gh-pages@v3
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,31 @@ jobs:
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node 🔧
uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: package-lock.json
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
registry-url: 'https://registry.npmjs.org'

- name: Cache Node Moudles
- name: Cache pnpm store
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-pnpm-

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
run: pnpm install

- run: npm run build
- run: npm publish --provenance
- run: pnpm sdk build
- run: pnpm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,6 @@ lib/

# profile output
*.cpuprofile

# npm
**/package-lock.json
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
engine-strict=true
engine-strict=true
@buf:registry=https://buf.build/gen/npm/v1
25 changes: 17 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,21 @@ Thanks for contributing!

### Building yorkie-js-sdk

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

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

```bash
# install packages
$ npm install

# In the root directory of the repository.
$ pnpm sdk install

# build
$ npm run build

# In the root directory of the repository.
$ pnpm sdk build
```

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.
Expand All @@ -55,7 +59,9 @@ For more details, see [@connectrpc/protoc-gen-connect-es](https://github.com/con

```bash
# generate proto messages and the service client stub classes
$ npm run build:proto

# In the root directory of the repository.
$ pnpm sdk build:proto
```

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

```bash
$ npm run test
# In the root directory of the repository.
$ pnpm sdk test
```

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

```bash
$ npm run test {test file path} # e.g. npm run test integration/tree_test.ts
# In the root directory of the repository.
$ pnpm sdk test {test file path} # e.g. pnpm sdk test integration/tree_test.ts
```

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

```bash
$ npm run dev
# In the root directory of the repository.
$ pnpm sdk dev
```

Open the co-editing example page served by webpack-dev-server in your browser.
Expand Down
14 changes: 9 additions & 5 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ $ docker compose -f docker/docker-compose.yml up --build -d
The examples have own local dependencies. So you should install dependencies before running examples.

```bash
# In the directory of the example.
$ npm install
# In the root directory of the repository.
$ pnpm install
```

Then you can run the examples.

```bash
# In the directory of the example.
$ npm run dev
# In the root directory of the repository.
$ pnpm <EXAMPLE-NAME> dev

# Or in the directory of the example.
$ pnpm dev
```

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

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

To release an example, the example should export static files to `./dist` directory when running `npm run build`.
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.

After the example is merged to the `main` branch, it is automatically deployed to https://yorkie.dev/yorkie-js-sdk/examples/{EXAMPLE-NAME}.
1 change: 1 addition & 0 deletions examples/nextjs-scheduler/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
extends: ['next', 'plugin:prettier/recommended'],
rules: {
'prettier/prettier': [
'error',
Expand Down
9 changes: 7 additions & 2 deletions examples/nextjs-scheduler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ $ docker compose -f docker/docker-compose.yml up --build -d
Then install dependencies and run the demo.

```bash
$ npm install
# In the root directory of the repository.
$ pnpm install
```

Now you can run the demo.

```bash
$ npm run dev
# In the root directory of the repository.
$ pnpm nextjs-scheduler dev

# Or in the directory of the example.
$ pnpm dev
```
Loading