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

chore(project): migrate to pnpm #1442

Merged
merged 9 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
8 changes: 4 additions & 4 deletions .eslint.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const eslintCommon = {
base: {
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
project: ["./tsconfig.json"],
ecmaVersion: 2018,
sourceType: "module",
},
Expand All @@ -12,7 +12,7 @@ const eslintCommon = {
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended",
"plugin:eslint-comments/recommended"
"plugin:eslint-comments/recommended",
],
plugins: ["@netless", "prettier", "@typescript-eslint", "eslint-comments"],
rules: {
Expand Down Expand Up @@ -239,8 +239,8 @@ const eslintCommon = {
ignore: [],
},
],
'react/jsx-sort-props': [
'error',
"react/jsx-sort-props": [
"error",
{
callbacksLast: true,
shorthandFirst: true,
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@ jobs:
flat-web:
- 'web/flat-web/**/*.(ts|tsx)'

- name: Install NodeJS
uses: actions/setup-node@v2
- name: Install PNPM
uses: pnpm/action-setup@v2.0.1
with:
node-version: "16"
version: latest
run_install: true

- name: Install changed package dependencies and build packages
run: |-
if node ./scripts/ci/install-changed-package-dependencies.js; then
# failure automatically retries 3 times
yarn run bootstrap || yarn run bootstrap || yarn run bootstrap
pnpm bootstrap || pnpm bootstrap || pnpm bootstrap
fi
env:
components: ${{ steps.filter.outputs.components }}
Expand All @@ -69,15 +70,15 @@ jobs:
flatWeb: ${{ steps.filter.outputs.flat-web }}

- name: Build renderer
run: yarn workspace renderer-app build
run: pnpm --filter renderer-app build
if: steps.filter.outputs.renderer == 'true'

- name: Build main
run: yarn workspace flat build
run: pnpm --filter flat build
if: steps.filter.outputs.main == 'true'

- name: Build flat-web
run: yarn workspace flat-web build
run: pnpm --filter flat-web build
if: steps.filter.outputs.flat-web == 'true'

- name: Check i18n
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-spell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version: "16"

- name: Install cspell
run: yarn global add cspell
run: npm i -g cspell

- name: Check cspell
run: yarn run check-spelling
run: npm run check-spelling
21 changes: 11 additions & 10 deletions .github/workflows/deploy-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install NodeJS
uses: actions/setup-node@v2
- name: Install PNPM
uses: pnpm/action-setup@v2.0.1
with:
node-version: "16"
version: latest
run_install: true

- uses: actions/cache@v2
id: yarn-cache
id: pnpm-cache
with:
key: yarn-storybook-v1-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
key: pnpm-storybook-v1-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
path: |
./node_modules
./packages/**/node_modules
Expand All @@ -31,19 +32,19 @@ jobs:
run: |-
if node ./scripts/ci/install-changed-package-dependencies.js; then
# failure automatically retries 3 times
yarn run bootstrap || yarn run bootstrap || yarn run bootstrap
pnpm bootstrap || pnpm bootstrap || pnpm bootstrap
fi
env:
components: true
if: steps.yarn-cache.outputs.cache-hit != 'true'
if: steps.pnpm-cache.outputs.cache-hit != 'true'

- name: Build Types
# it must be added here, otherwise when the cache matches, there will be flat-types not found
run: yarn workspace flat-types build
if: steps.yarn-cache.outputs.cache-hit == 'true'
run: pnpm --filter flat-types build
if: steps.pnpm-cache.outputs.cache-hit == 'true'

- name: Build Storybook
run: yarn workspace flat-components build
run: pnpm --filter flat-components build

- name: Deploy Storybook
uses: peaceiris/actions-gh-pages@v3
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/deploy-web-dev-cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install PNPM
uses: pnpm/action-setup@v2.0.1
with:
version: latest
run_install: true

- name: Install dependencies
run: |
node ./scripts/ci/remove-workspace-packages.js web
node ./scripts/ci/remove-package-scripts-hooks.js
# failure automatically retries 3 times
yarn run bootstrap || yarn run bootstrap || yarn run bootstrap
pnpm bootstrap || pnpm bootstrap || pnpm bootstrap

- name: Build flat web development
run: yarn workspace flat-web build:cn -m development
run: pnpm --filter flat-web build:cn -m development

- name: Log in to Docker Hub
uses: docker/login-action@v1
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/deploy-web-dev-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install PNPM
uses: pnpm/action-setup@v2.0.1
with:
version: latest
run_install: true

- name: Install dependencies
run: |
node ./scripts/ci/remove-workspace-packages.js web
node ./scripts/ci/remove-package-scripts-hooks.js
# failure automatically retries 3 times
yarn run bootstrap || yarn run bootstrap || yarn run bootstrap
pnpm bootstrap || pnpm bootstrap || pnpm bootstrap

- name: Build flat web development
run: yarn workspace flat-web build:us -m development
run: pnpm --filter flat-web build:us -m development

- name: Log in to Docker Hub
uses: docker/login-action@v1
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/deploy-web-prod-cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install PNPM
uses: pnpm/action-setup@v2.0.1
with:
version: latest
run_install: true

- name: Install dependencies
run: |
node ./scripts/ci/remove-workspace-packages.js web
node ./scripts/ci/remove-package-scripts-hooks.js
# failure automatically retries 3 times
yarn run bootstrap || yarn run bootstrap || yarn run bootstrap
pnpm bootstrap || pnpm bootstrap || pnpm bootstrap

- name: Build flat web production
run: yarn workspace flat-web build:cn -m production
run: pnpm --filter flat-web build:cn -m production

- name: Log in to Docker Hub
uses: docker/login-action@v1
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/deploy-web-prod-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install PNPM
uses: pnpm/action-setup@v2.0.1
with:
version: latest
run_install: true

- name: Install dependencies
run: |
node ./scripts/ci/remove-workspace-packages.js web
node ./scripts/ci/remove-package-scripts-hooks.js
# failure automatically retries 3 times
yarn run bootstrap || yarn run bootstrap || yarn run bootstrap
pnpm bootstrap || pnpm bootstrap || pnpm bootstrap

- name: Build flat web production
run: yarn workspace flat-web build:us -m production
run: pnpm --filter flat-web build:us -m production

- name: Log in to Docker Hub
uses: docker/login-action@v1
Expand Down
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn run check-spelling
yarn run lint
pnpm check-spelling
pnpm lint
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
"directory": "packages/flat-types",
"changeProcessCWD": true
}
]
],
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ We're always looking for more opinions on discussions in the issue tracker. It's
* For ambitious tasks, you should try to get your work in front of the community for feedback as soon as possible. Open a pull request as soon as you have done the minimum needed to demonstrate your idea. At this early stage, don't worry about making things perfect, or 100% complete. Add a [WIP] prefix to the title, and describe what you still need to do. This lets reviewers know not to nit-pick small details or point out improvements you already know you need to make.
* New features should be accompanied by tests and documentation.
* Don't include unrelated changes.
* Lint and test before submitting the pull request by running `$ yarn run lint`.
* Lint and test before submitting the pull request by running `$ pnpm lint`.
* Use a clear and descriptive title for the pull request and commits.
* Write a convincing description of why we should land your pull request. It's your job to convince us. Answer "why" it's needed and provide use-cases.
* You might be asked to do changes to your pull request. There's never a need to open another pull request. Just update the existing one.
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,30 @@ You can build and run the Flat client without a server. This repository includes
Run the following commands at the root of the repository to build and run Flat Electron client.

```shell
yarn run bootstrap
yarn run start
pnpm bootstrap
pnpm start
```

You can use one of the following methods to package your executable:

- Run `yarn ship` at project root to package based on current system.
- Alternatively, run `yarn ship:mac` or `yarn ship:win` at project root to package for a specified system.
- Run `pnpm ship` at project root to package based on current system.
- Alternatively, run `pnpm ship:mac` or `pnpm ship:win` at project root to package for a specified system.

### Build and run Flat Web client

Run the following command at the root of the repository to build and run Flat web client.

```shell
yarn workspace flat-web start
pnpm --filter flat-web start
```

Alternatively, run the following command:

```shell
cd ./web/flat-web/ && yarn run start
cd ./web/flat-web/ && pnpm start
```

UI and business logic are separated in Flat. You can view and develop Flat components UI via Storybook. You can either visit the ([Online address][flat-storybook]) or run `yarn run storybook` at the root of the repository to run Storybook locally.
UI and business logic are separated in Flat. You can view and develop Flat components UI via Storybook. You can either visit the ([Online address][flat-storybook]) or run `pnpm storybook` at the root of the repository to run Storybook locally.

## References

Expand Down
2 changes: 2 additions & 0 deletions cspell.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ module.exports = {
"micromessenger",
"bokeh",
"lintstagedrc",
"pnpm",

// CNCF
"nindent",
Expand Down Expand Up @@ -162,6 +163,7 @@ module.exports = {
"desktop/main-app/static/**",
"cspell.config.js",
"yarn.lock",
"pnpm-lock.yaml",
hyrious marked this conversation as resolved.
Show resolved Hide resolved
"CHANGELOG.md",
],
};
3 changes: 2 additions & 1 deletion desktop/main-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { base } = require("../../.eslint.common.js")
const { base } = require("../../.eslint.common.js");

module.exports = {
...base,
root: true,
};
34 changes: 8 additions & 26 deletions desktop/main-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,34 @@
},
"scripts": {
"start": "cross-env NODE_ENV=development webpack --config webpack/webpack.dev.js",
"start:cn": "cross-env FLAT_REGION=China yarn start",
"start:us": "cross-env FLAT_REGION=America yarn start",
"start:cn": "cross-env FLAT_REGION=China pnpm start",
"start:us": "cross-env FLAT_REGION=America pnpm start",
"build": "cross-env NODE_ENV=production webpack --config webpack/webpack.prod.js",
"build:cn": "cross-env FLAT_REGION=China yarn build",
"build:us": "cross-env FLAT_REGION=America yarn build",
"build:cn": "cross-env FLAT_REGION=China pnpm build",
"build:us": "cross-env FLAT_REGION=America pnpm build",
"build:debug": "cross-env FLAT_DEBUG=debug webpack --config webpack/webpack.debug.js",
"pack:win": "node ./scripts/pack win",
"pack:mac": "node ./scripts/pack mac",
"ship": "yarn build && node ./scripts/pack auto",
"ship:win": "yarn build && yarn pack:win",
"ship:mac": "yarn build && yarn pack:mac",
"postinstall": "yarn _download:agora-addon",
"ship": "pnpm build && node ./scripts/pack auto",
"ship:win": "pnpm build && pnpm pack:win",
"ship:mac": "pnpm build && pnpm pack:mac",
"postinstall": "pnpm _download:agora-addon",
"lint": "lint-staged",
"_download:agora-addon": "node scripts/download-agora-addon/cli.js",
"_launch:electron": "node --trace-uncaught ./scripts/launch/electron.js"
},
"devDependencies": {
"@netless/eslint-plugin": "1.1.4",
"@types/fs-extra": "^9.0.13",
"@types/node": "^17.0.21",
"@types/webpack-env": "^1.16.3",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"cross-env": "^7.0.3",
"dotenv-flow": "^3.2.0",
"dotenv-flow-webpack": "^1.1.0",
"electron": "12.0.15",
"electron-builder": "^22.14.13",
"electron-devtools-vendor": "^1.0.5",
"electron-notarize": "^1.1.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-webpack-plugin": "^3.1.1",
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^7.2.1",
"js-yaml": "^4.1.0",
"lint-staged": "^12.3.5",
"move-cli": "^2.0.0",
"nodemon": "^2.0.15",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"ts-loader": "^9.2.8",
"typescript": "^4.6.2",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2",
"webpack-merge": "^5.8.0",
"webpack-node-externals": "^3.0.0"
Expand Down
5 changes: 4 additions & 1 deletion desktop/main-app/scripts/download-agora-addon/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ module.exports.downloadAddon = platform => {
encoding: "utf-8",
});

fs.moveSync(path.join(mainPath, "build"), path.join(agoraElectronSdkPath, "build"), {});
const downloaded = path.join(mainPath, "build");
if (fs.existsSync(downloaded)) {
fs.moveSync(downloaded, path.join(agoraElectronSdkPath, "build"), {});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ const path = require("path");
const fs = require("fs-extra");
const { agoraElectronSdkPath } = require("../constant");
const download = require(path.join(agoraElectronSdkPath, "scripts", "download"));
const nativeExtPath = path.join(agoraElectronSdkPath, "build", "Release", "agora_node_ext.node");

if (fs.existsSync(nativeExtPath) && !("FORCE_REBUILD_AGORA_NODE_EXT" in process.env)) {
// Don't download again.
process.exit(0);
}

const electronVersion =
require("../../../../scripts/init-agora-configure/agora-electron-options").electron_version;
Expand Down
Loading