Skip to content

Commit

Permalink
Switches from npm to pnpm (microsoft#79)
Browse files Browse the repository at this point in the history
For faster node package installs - pnpm has a global cache and increased
parallelism, similar to uv
  • Loading branch information
markwaddle authored Oct 2, 2024
1 parent 4c42025 commit 60cac79
Show file tree
Hide file tree
Showing 10 changed files with 12,425 additions and 20,769 deletions.
49 changes: 35 additions & 14 deletions .github/workflows/workbench-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,31 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Node.js version
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: 20
cache: 'pnpm'
cache-dependency-path: workbench-app/pnpm-lock.yaml

- name: pnpm install
working-directory: ./workbench-app
run: pnpm install

- name: npm install, build, and test
- name: pnpm build
env:
NODE_OPTIONS: "--max_old_space_size=8192"
VITE_SEMANTIC_WORKBENCH_AUTHORITY: ${{ secrets.VITE_SEMANTIC_WORKBENCH_AUTHORITY }}
VITE_SEMANTIC_WORKBENCH_CLIENT_ID: ${{ secrets.VITE_SEMANTIC_WORKBENCH_CLIENT_ID }}
VITE_SEMANTIC_WORKBENCH_SERVICE_URL: ${{ secrets.VITE_SEMANTIC_WORKBENCH_SERVICE_URL }}
working-directory: ./workbench-app
run: |
npm install
npm run build --if-present
npm run test --if-present
run: pnpm run build

build-main:
runs-on: ubuntu-latest
Expand All @@ -49,22 +61,31 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Node.js version
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: 20
cache: 'pnpm'
cache-dependency-path: workbench-app/pnpm-lock.yaml

- name: pnpm install
working-directory: ./workbench-app
run: pnpm install

- name: npm install, build, and test
- name: pnpm build
env:
NODE_OPTIONS: "--max_old_space_size=8192"
VITE_SEMANTIC_WORKBENCH_AUTHORITY: ${{ secrets.VITE_SEMANTIC_WORKBENCH_AUTHORITY }}
VITE_SEMANTIC_WORKBENCH_CLIENT_ID: ${{ secrets.VITE_SEMANTIC_WORKBENCH_CLIENT_ID }}
VITE_SEMANTIC_WORKBENCH_SERVICE_URL: ${{ secrets.VITE_SEMANTIC_WORKBENCH_SERVICE_URL }}
working-directory: ./workbench-app
run: |
npm install
npm run build --if-present
npm run test --if-present
run: pnpm run build

- name: Zip artifact for deployment
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
Expand Down
1 change: 1 addition & 0 deletions docs/SETUP_DEV_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Once you have nvm installed:
```
nvm install 20 lts
nvm use 20
npm install -g pnpm
```

### Build the frontend
Expand Down
4 changes: 2 additions & 2 deletions tools/run-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ fi

echo "Starting the Semantic Workbench app, open https://localhost:4000 in your browser when ready"

npm install
npm start
pnpm install
pnpm start
9 changes: 4 additions & 5 deletions workbench-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ repo_root = $(shell git rev-parse --show-toplevel)
.PHONY: clean
clean:
$(rm) node_modules || $(true_expression)
npm cache clean --force

.PHONY: install
install:
npm install
pnpm install

.PHONY: test
test:
npm run type-check
pnpm run type-check

.PHONY: format
format:
npm run format
pnpm run format

.PHONY: lint
lint:
npm run lint
pnpm run lint

include $(repo_root)/tools/makefiles/shell.mk
10 changes: 5 additions & 5 deletions workbench-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Semantic Workbench app is a React/Typescript app integrated with the [Semantic Workbench](../service/README.md) backend service.

Follow the [setup guide](../../../docs/SETUP_DEV_ENVIRONMENT.md) to configure your dev environment.
Follow the [setup guide](../docs/SETUP_DEV_ENVIRONMENT.md) to configure your dev environment.

## Running Workbench App from VS Code

Expand All @@ -13,7 +13,7 @@ To run and/or debug in VS Code, View->Run, "app: semantic-workbench-app"
In the [app directory](./)

```sh
npm start
pnpm start
```

Note: you might be prompted for admin credentials, for the SSL certificates used by the app.
Expand All @@ -22,9 +22,9 @@ Note: you might be prompted for admin credentials, for the SSL certificates used

### Scripts

- `npm start` - start dev server and open browser
- `npm build` - build for production
- `npm preview` - locally preview production build
- `pnpm start` - start dev server and open browser
- `pnpm build` - build for production
- `pnpm preview` - locally preview production build

### More info

Expand Down
Loading

0 comments on commit 60cac79

Please sign in to comment.