Skip to content

Commit

Permalink
[Tech] Move to pnpm (#3192)
Browse files Browse the repository at this point in the history
* "yarn" -> "pnpm"

* Add missing types packages & resolve issue with `copySync`

`copySync` never accepted a `recursive` parameter. Not sure how that didn't
cause an error before

* Import from `react-router-dom` instead of `react-router`

* Specify Electron version correctly

* Move over lock files

* Fix up packaged builds

Electron-Builder and pnpm are not the best of friends, but this should make them
 work together while not sacrificing too many pnpm speedups

* Use standalone version of pnpm on Windows to fix electron-builder issues

* Install pnpm in AppVeyor manifest

* Install dependencies with pnpm, run the signing with npm

This should give us the best of both worlds, with working lockfile for packages
but also a working electron-builder
  • Loading branch information
CommandMC authored Apr 10, 2024
1 parent eb4b8a8 commit 76e63a9
Show file tree
Hide file tree
Showing 26 changed files with 10,279 additions and 9,562 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn.lock linguist-generated=true
pnpm-lock.yaml linguist-generated=true
8 changes: 6 additions & 2 deletions .github/actions/install-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ runs:
- uses: actions/setup-node@v3
with:
node-version: '20'
- uses: pnpm/action-setup@v3
with:
version: 8
standalone: ${{ runner.os == 'Windows' }}
- name: Install node-gyp
run: npm install --global node-gyp
run: pnpm add --global node-gyp
shell: bash
- name: Install modules
run: npm install --legacy-peer-deps
run: pnpm install
shell: bash
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
8 changes: 4 additions & 4 deletions .github/workflows/build-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-deps
- name: Build Windows Portable version
run: yarn dist:win portable
run: pnpm dist:win portable
if: runner.os == 'Windows'
- name: Build macOS x64 & arm64 versions
run: yarn dist:mac --x64 --arm64 --publish=never
run: pnpm dist:mac --x64 --arm64 --publish=never
env:
GITHUB_TOKEN: ${{ secrets.workflowToken }}
GH_TOKEN: ${{ secrets.workflowToken }}
Expand All @@ -35,12 +35,12 @@ jobs:
- name: Build and publish Snap version
run: |
sudo apt-get install --no-install-recommends -y snapcraft
yarn dist:linux Snap --publish=always
pnpm dist:linux Snap --publish=always
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.snapcraftIdEdge }}
if: runner.os == 'Linux' && inputs.publish-snap
- name: Build AppImage version
run: yarn dist:linux AppImage --publish=never
run: pnpm dist:linux AppImage --publish=never
if: runner.os == 'Linux'
- name: Upload built version
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-deps
- name: Check Typescript syntax
run: yarn codecheck
run: pnpm codecheck
2 changes: 1 addition & 1 deletion .github/workflows/draft-release-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- run: sudo apt-get install --no-install-recommends -y libarchive-tools libopenjp2-tools rpm snapcraft
- uses: actions/checkout@v3
- uses: ./.github/actions/install-deps
- run: npm run release:linux
- run: pnpm release:linux
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-release-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
with:
python-version: '3.10'
- run: python3 -m pip install castlabs-evs
- run: npm run release:mac
- run: pnpm release:mac
2 changes: 1 addition & 1 deletion .github/workflows/draft-release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
python-version: '3.10'
- run: python3 -m pip install castlabs-evs
- run: npm run release:win
- run: pnpm release:win
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/flatpak-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install modules.
run: npm i --legacy-peer-deps
- uses: ./.github/actions/install-deps
- name: Build artifacts.
run: npm run dist:linux appimage --publish=never
run: pnpm dist:linux appimage --publish=never
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
- name: Prepare Flatpak
run: npm run flatpak:prepare
run: pnpm flatpak:prepare
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-deps
- name: Lint code.
run: yarn lint
run: pnpm lint
- name: Prettier code.
run: yarn prettier
run: pnpm prettier
- name: Find dead code
run: yarn find-deadcode
run: pnpm find-deadcode
2 changes: 1 addition & 1 deletion .github/workflows/release_flathub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Checkout flathub repository.
run: git clone https://github.com/flathub/com.heroicgameslauncher.hgl.git
- name: Update flathub release
run: export RELEASE_VERSION=${{ github.ref_name }} && yarn release:updateFlathub:ci
run: export RELEASE_VERSION=${{ github.ref_name }} && pnpm release:updateFlathub:ci
- name: Branch flathub repo
run: git checkout -b "${{ github.ref_name }}"
working-directory: ./com.heroicgameslauncher.hgl
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
uses: actions/checkout@v3
- uses: ./.github/actions/install-deps
- name: Test CI
run: yarn test:ci
run: pnpm test:ci
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout repository.
uses: actions/checkout@v3
- uses: ./.github/actions/install-deps
- name: Test E2E
run: yarn test:e2e
run: pnpm test:e2e
2 changes: 1 addition & 1 deletion .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
yarn
pnpm i
2 changes: 1 addition & 1 deletion .husky/post-merge
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
yarn
pnpm i
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
#yarn lint-fix
#pnpm lint-fix
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
yarn codecheck && yarn lint && yarn prettier && yarn i18n --fail-on-update
pnpm codecheck && pnpm lint && pnpm prettier && pnpm i18n --fail-on-update
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-linker=hoisted
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ sign/
.github/workflows/build-base.yml
signatures/version1/cla.json
playwright-report
pnpm-lock.yaml
20 changes: 10 additions & 10 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
{
"type": "shell",
"label": "Run tests",
"command": "yarn test",
"detail": "yarn test",
"command": "pnpm test",
"detail": "pnpm test",
"group": "test"
},
{
"type": "shell",
"label": "Build for Linux",
"command": "yarn dist:linux",
"detail": "yarn dist:linux",
"command": "pnpm dist:linux",
"detail": "pnpm dist:linux",
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -21,22 +21,22 @@
{
"type": "shell",
"label": "Build for Windows",
"command": "yarn dist:win",
"detail": "yarn dist:win",
"command": "pnpm dist:win",
"detail": "pnpm dist:win",
"group": "build"
},
{
"type": "shell",
"label": "Build for MacOS",
"command": "yarn dist:mac",
"detail": "yarn dist:mac",
"command": "pnpm dist:mac",
"detail": "pnpm dist:mac",
"group": "build"
},
{
"type": "shell",
"label": "Check code for errors",
"command": "yarn codecheck",
"detail": "yarn codecheck",
"command": "pnpm codecheck",
"detail": "pnpm codecheck",
"group": "test"
}
]
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,17 @@ Otherwise, download the file ending in .dmg from the [latest release](https://gi

This part will walk you through setting up a development environment so you can build Heroic binaries yourself or make changes to the code.

1. Make sure Git, NodeJS, and Yarn are installed
1. Make sure Git, NodeJS, and PNPM are installed
**NOTE**: On Windows, due to an issue with electron-builder, you'll need the standalone version of pnpm (`@pnpm/exe`)
to build packages
2. Clone the repo and enter the cloned folder, for example with these commands:

```bash
git clone https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher.git --recurse-submodules
cd HeroicGamesLauncher
```

3. Make sure all dependencies are installed by running `yarn`
3. Make sure all dependencies are installed by running `pnpm install`

### Building Heroic Binaries

Expand All @@ -224,18 +226,18 @@ Run the appropriate command for your OS:
- Build for Linux:

```bash
yarn dist:linux # Optionally specify a package to create (eg: deb, pacman, tar.xz, rpm, AppImage); default: AppImage
pnpm dist:linux # Optionally specify a package to create (eg: deb, pacman, tar.xz, rpm, AppImage); default: AppImage
```

- Build for Windows:

```bash
yarn dist:win
pnpm dist:win
```

- Build for Mac:
```bash
yarn dist:mac
pnpm dist:mac
```

### Building with VS Code
Expand All @@ -246,9 +248,9 @@ To do that, open up the command palette (Ctrl + P), type in "task" and press Spa
### Quickly testing/debugging Heroic on your own system

If you want to quickly test a change, or you're implementing features that require a lot of restarts, you can use Vite's development server to speed up the process:
Go to the "Run and Debug" tab of VSCode and start the "Launch Heroic (HMR & HR)" task (alternatively, if you're not using VSCode or just prefer the terminal, run `yarn start`). Heroic will start up after a short while, and once you make any change to the code, it'll reload/restart.
Go to the "Run and Debug" tab of VSCode and start the "Launch Heroic (HMR & HR)" task (alternatively, if you're not using VSCode or just prefer the terminal, run `pnpm start`). Heroic will start up after a short while, and once you make any change to the code, it'll reload/restart.

Note: If you do not need the React developer tools while testing changes, you can skip their install by setting the `HEROIC_NO_REACT_DEVTOOLS` environment variable before running `yarn start` (for example with `HEROIC_NO_REACT_DEVTOOLS=1 yarn start`).
Note: If you do not need the React developer tools while testing changes, you can skip their install by setting the `HEROIC_NO_REACT_DEVTOOLS` environment variable before running `pnpm start` (for example with `HEROIC_NO_REACT_DEVTOOLS=1 pnpm start`).

## Sponsors

Expand Down
6 changes: 4 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ init:

install:
- pip install castlabs-evs
- yarn install --force
- corepack enable
- corepack prepare pnpm@latest-8 --activate
- pnpm install

environment:
GH_TOKEN:
secure: kZMGyhBmfPsJKEryrd+I7gTEudm8tW0jSrKKhtT/3fbqKQzndTWp47C1Eetx5kFs

build_script:
- yarn sign:win
- npm run sign:win
- 7z.exe a -tzip dist\HeroicWin.zip dist\*x64.exe dist\*.blockmap dist\*.yml

test: off
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"dist:linux": "vite build && electron-builder --linux",
"dist:mac": "export CSC_IDENTITY_AUTO_DISCOVERY=false && vite build && electron-builder --mac",
"dist:win": "vite build && electron-builder --win",
"dist:flatpak": "yarn dist:linux appimage && yarn flatpak:prepare && yarn flatpak:build",
"dist:flatpak": "pnpm dist:linux appimage && pnpm flatpak:prepare && pnpm flatpak:build",
"lint": "eslint --cache --ext .tsx,ts .",
"lint-fix": "eslint --fix --ext .tsx,ts ./src",
"flatpak:build": "cd flatpak-build && flatpak-builder build com.heroicgameslauncher.hgl.yml --install --force-clean --user",
Expand Down Expand Up @@ -109,6 +109,8 @@
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "14.0.0",
"@testing-library/user-event": "14.1.1",
"@types/fs-extra": "^11.0.4",
"@types/graceful-fs": "^4.1.9",
"@types/i18next-fs-backend": "1.1.4",
"@types/ini": "1.3.31",
"@types/jest": "29.4.0",
Expand All @@ -119,12 +121,13 @@
"@types/react-dom": "18.2.14",
"@types/react-router-dom": "5.3.3",
"@types/sanitize-html": "2.9.0",
"@types/semver": "^7.5.8",
"@types/tmp": "0.2.3",
"@typescript-eslint/eslint-plugin": "5.47.1",
"@typescript-eslint/parser": "5.47.1",
"@vitejs/plugin-react-swc": "3.2.0",
"cross-env": "7.0.3",
"electron": "castlabs/electron-releases#29.1.3+wvcus",
"electron": "github:castlabs/electron-releases#v29.1.3+wvcus",
"electron-builder": "24.13.3",
"electron-devtools-installer": "3.2.0",
"eslint": "8.36.0",
Expand Down
Loading

0 comments on commit 76e63a9

Please sign in to comment.