Skip to content

Commit

Permalink
chore: switch to pnpm (#3245)
Browse files Browse the repository at this point in the history
Second attempt at #3187

### What's new?

The big workaround before was to make sure that all bundled dependencies and their dependencies were symlinked to node_modules. This was great and made it work locally and via file:tgz installs (when all packages are installed directly). However, the final tarballs were not actually correct. 
For each bundled dep, if it had any bundled deps of its own, those were missing. npm normally includes these, but apparently if the bundled dep is a symlink then it doesn't do it 😢 .

So, the [main change](https://github.com/winglang/wing/blob/mark/pnpm-take-2/tools/bump-pack/src/pack.ts) here is that the packaging process creates a completely separate copy of the package. In that copy, we convert the necessary symlinks into copies. Then we package. These packages look almost identical to the ones we publish now.

I think the only way I could possibly test this with enough accuracy is to set up verdaccio, but I'm more confident that this iteration should work. Not sure I want to block this further by taking the time to go back to verdaccio.

Misc:
- Updated nx to latest with a patch to make sure our workflow of using `--` still works. I created a PR upstream in nx to maybe fix the issue. I did this update for two reasons:
  - We are very out of date on nx
  - Theres an old nx bug on linux causing it to watch/search node_modules. This hurts perf and caused nx to try to discover nx projects in node_modules. The update fixed this.
  • Loading branch information
MarkMcCulloh authored Jul 5, 2023
1 parent 38adc5b commit 8042879
Show file tree
Hide file tree
Showing 303 changed files with 31,334 additions and 167,351 deletions.
6 changes: 4 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "Wing Development",
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"postCreateCommand": "npm install -g [email protected]",
"updateContentCommand": "npm install",
"updateContentCommand": "pnpm install",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "18.16.0"
Expand All @@ -11,6 +10,9 @@
"ghcr.io/devcontainers/features/terraform:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/devcontainers-contrib/features/pnpm:2": {
"version": "8.6.5"
}
},
"hostRequirements": {
"cpus": 4,
Expand Down
78 changes: 41 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:
env:
RUST_VERSION: "1.67.1"
NODE_VERSION: "18.16.0"
NPM_VERSION: "8.19.3"
PNPM_VERSION: "8.6.3"

jobs:
build:
Expand All @@ -41,14 +41,17 @@ jobs:
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
node-version: ${{ env.NODE_VERSION }}

- name: Setup NPM
run: npm install -g npm@${{ env.NPM_VERSION }}

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -62,21 +65,21 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Install Dependencies
uses: bahmutov/npm-install@v1
run: pnpm install --frozen-lockfile

- name: Changelog Generation
id: changelog
env:
GENERATE_VERSION: ${{ github.event_name != 'push' || github.repository != 'winglang/wing' }}
run: npm run changelog
run: pnpm changelog

- name: Build
run: npm run build:ci
run: pnpm build:ci
env:
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}

- name: Package
run: npm run package:ci
run: pnpm package:ci

- name: Upload Wing CLI
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -180,14 +183,17 @@ jobs:
with:
fetch-depth: 1

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
node-version: ${{ env.NODE_VERSION }}

- name: Setup NPM
run: npm install -g npm@${{ env.NPM_VERSION }}

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -201,14 +207,14 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Install Dependencies
uses: bahmutov/npm-install@v1
run: pnpm install --frozen-lockfile

- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: apps/wing-console/console/app

- name: Test
run: npm run test:ci
run: pnpm test:ci

- uses: actions/upload-artifact@v3
if: always()
Expand Down Expand Up @@ -254,26 +260,23 @@ jobs:
- name: Download Build Artifacts
uses: actions/download-artifact@v2

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
node-version: ${{ env.NODE_VERSION }}

- name: Setup NPM
run: npm install -g npm@${{ env.NPM_VERSION }}

- name: Install Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: |
tools/hangar
examples/tests/valid
examples/tests/invalid
install-command: npm ci
run: pnpm install --ignore-scripts --frozen-lockfile --filter hangar --filter examples-valid --filter examples-invalid

- name: Run E2E Benchmarks
working-directory: tools/hangar
run: npm run bench
run: pnpm bench

- name: Upload Report JSON
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -323,25 +326,25 @@ jobs:
with:
path: target

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
node-version: ${{ matrix.node }}

- name: Install Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: |
tools/hangar
examples/tests/valid
examples/tests/invalid
install-command: npm ci
run: pnpm install --ignore-scripts --frozen-lockfile --filter hangar --filter examples-valid --filter examples-invalid

- name: Run E2E Tests
working-directory: tools/hangar
run: |
npm run test:generate
npm run test -- --shard=${{ matrix.shard }} --update=${{ matrix.runner == 'ubuntu' && matrix.node == '18' }}
pnpm test:generate
pnpm run test --shard=${{ matrix.shard }} --update=${{ matrix.runner == 'ubuntu' && matrix.node == '18' }}
- name: Create mutation if needed
# we only care about the diff in our standard dev env
Expand Down Expand Up @@ -415,6 +418,7 @@ jobs:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: "https://marketplace.visualstudio.com"
extensionFile: "vscode-wing/vscode-wing.vsix"
dependencies: false

- name: Login to NPM registry
run: npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_PUBLISH_TOKEN }}
Expand All @@ -437,15 +441,15 @@ jobs:
working-directory: wingcompiler
run: npm publish *.tgz --access public

- name: Check published Wing Console Design System version
id: wingconsoledesignsystem-version
run: echo "version=$(npm view @wingconsole/design-system version)" >> $GITHUB_OUTPUT

- name: Publish Wing Console Design System
if: ${{ steps.wingconsoledesignsystem-version.outputs.version != needs.build.outputs.version }}
working-directory: wingconsoledesignsystem
run: npm publish *.tgz --access public

- name: Check published Wing Console Design System version
id: wingconsoledesignsystem-version
run: echo "version=$(npm view @wingconsole/design-system version)" >> $GITHUB_OUTPUT

- name: Check published Wing Console UI version
id: wingconsoleui-version
run: echo "version=$(npm view @wingconsole/ui version)" >> $GITHUB_OUTPUT
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.DS_Store
node_modules/
.pnpm-store/
.env
*.tfstate
*.tfstate.*
.history
*.vsix

# WASI SDK (insalled by "npm install")
# WASI SDK (insalled by "pnpm install")
.cargo/wasi-sdk-*/

# Generated wing output
Expand Down
4 changes: 0 additions & 4 deletions .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .nxignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
**/package.json
package.json
package.json
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
"version": "0.2.0",
"configurations": [
{
"command": "npx nx wing -- compile -t tf-aws ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- compile -t tf-aws ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing compile tf-aws",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npx nx wing -- compile -t tf-azure ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- compile -t tf-azure ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing compile tf-azure",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npx nx wing -- compile -t sim ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- compile -t sim ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing compile sim",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npx nx wing -- test ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- test ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing test sim",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npx nx wing -- test -t tf-aws ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- test -t tf-aws ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing test tf-aws",
"request": "launch",
"type": "node-terminal"
Expand Down
2 changes: 1 addition & 1 deletion apps/jsii-docgen/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions apps/jsii-docgen/.npmrc

This file was deleted.

20 changes: 15 additions & 5 deletions apps/jsii-docgen/.projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apps/jsii-docgen/.projen/files.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8042879

Please sign in to comment.