Skip to content

Commit

Permalink
Switch from yarn to pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
bhollis committed Oct 4, 2023
1 parent 49d86f2 commit c38edab
Show file tree
Hide file tree
Showing 21 changed files with 13,004 additions and 11,605 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache: pnpm

- name: Install SSH key
uses: benoitchantre/[email protected]
Expand All @@ -46,10 +46,10 @@ jobs:
echo "VERSION=${{ steps.package-version.outputs.current-version }}.$(($RUN_NUM+1000000))" >> $GITHUB_ENV
- name: Install
run: yarn install --frozen-lockfile --prefer-offline
run: pnpm install --frozen-lockfile --prefer-offline

- name: Build
run: yarn build:beta
run: pnpm build:beta
env:
NODE_OPTIONS: "--max_old_space_size=8192"
WEB_API_KEY: ${{ secrets.WEB_API_KEY }}
Expand All @@ -66,7 +66,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check Syntax
run: yarn syntax
run: pnpm syntax

- name: Rsync to Server
run: ./build/rsync-deploy.sh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache: pnpm

- name: Install SSH key
uses: benoitchantre/[email protected]
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
version: ${{ env.VERSION }}

- name: Install
run: yarn install --frozen-lockfile --prefer-offline
run: pnpm install --frozen-lockfile --prefer-offline

- name: Build and deploy
run: ./build/deploy-prod.sh
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/i18n-bot-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache: pnpm

- name: Install
run: yarn install --frozen-lockfile --prefer-offline
run: pnpm install --frozen-lockfile --prefer-offline

- name: Download updated i18n files
uses: crowdin/[email protected]
Expand All @@ -46,7 +46,7 @@ jobs:
done
- name: build browsercheck utils
run: yarn bcu
run: pnpm bcu

- name: porcelain check
uses: dorny/paths-filter@v2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/i18n-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache: pnpm

- name: Install
run: yarn install --frozen-lockfile --prefer-offline
run: pnpm install --frozen-lockfile --prefer-offline

- name: yarn i18n
run: yarn i18n
- name: pnpm i18n
run: pnpm i18n

- name: Commit files
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache: pnpm

- name: Install
run: yarn install --frozen-lockfile --prefer-offline
run: pnpm install --frozen-lockfile --prefer-offline

- name: get-npm-version
id: package-version
Expand All @@ -39,7 +39,7 @@ jobs:
echo "VERSION=${{ steps.package-version.outputs.current-version }}.${{ github.run_number }}" >> $GITHUB_ENV
- name: Build beta
run: yarn build:beta
run: pnpm build:beta
env:
NODE_OPTIONS: "--max_old_space_size=8192"
PR_BUILD: true
Expand All @@ -51,7 +51,7 @@ jobs:
filters: |
build-pipeline:
- package.json
- yarn.lock
- pnpm.lock
- config/webpack.ts
- babel.config.js
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/pr-test-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache: pnpm

- name: Install
run: yarn install --frozen-lockfile --prefer-offline
run: pnpm install --frozen-lockfile --prefer-offline

- name: Jest Test
run: yarn jest
run: pnpm jest

- uses: actions/upload-artifact@v3 # upload test results
if: success() || failure() # run this step even if previous step failed
Expand All @@ -43,7 +43,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache: pnpm

- name: Cache ESLint
uses: actions/cache@v3
Expand All @@ -57,21 +57,21 @@ jobs:
${{ runner.os }}-${{ env.cache-name }}-
- name: Install
run: yarn install --frozen-lockfile --prefer-offline
run: pnpm install --frozen-lockfile --prefer-offline

- name: Prettier
run: yarn lint:prettier
run: pnpm lint:prettier

- name: StyleLint
run: yarn lint:stylelint
run: pnpm lint:stylelint

- name: ESLint (Forked)
if: github.event.pull_request.head.repo.full_name != github.repository
run: yarn lintcached
run: pnpm lintcached

- name: Save ESLint Report JSON (Non-Forked)
if: github.event.pull_request.head.repo.full_name == github.repository
run: yarn lint-report:cached
run: pnpm lint-report:cached
continue-on-error: true

- name: Annotate ESLint Results
Expand Down
4 changes: 4 additions & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm install --frozen-lockfile --prefer-offline
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"gamunu.vscode-yarn",
"Jacano.vscode-pnpm",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker",
"dbaeumer.vscode-eslint",
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"jest.jestCommandLine": "yarn test",
"jest.jestCommandLine": "pnpm test",
"[javascript]": {
"editor.codeActionsOnSave": {
"source.organizeImports": false
Expand Down Expand Up @@ -62,7 +62,7 @@
"*.tsx": "${capture}.ts, ${capture}.test.ts",
"*.m.scss": "${capture}.m.scss.d.ts",
"tsconfig.json": "tsconfig.*.json",
"package.json": "package-lock.json, yarn.lock"
"package.json": "package-lock.json, pnpm-lock.yaml"
},
"eslint.lintTask.options": "src"
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"label": "start",
"type": "shell",
"command": "yarn",
"command": "pnpm",
"args": ["start"],
"isBackground": true,
"problemMatcher": ["$ts-checker-webpack", "$ts-checker-eslint-webpack"]
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json yarn.lock /usr/src/app/
RUN yarn install --frozen-lockfile --prefer-offline
COPY package.json pnpm-lock.yaml /usr/src/app/
RUN pnpm install --frozen-lockfile --prefer-offline

# Bundle app source
COPY . /usr/src/app
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = function (api) {
useBuiltIns: 'usage',
corejs,
shippedProposals: true,
// Set to true and run `yarn build:beta` to see what plugins and polyfills are being used
// Set to true and run `pnpm build:beta` to see what plugins and polyfills are being used
debug: false,
// corejs includes a bunch of polyfills for behavior we don't use or bugs we don't care about
exclude: [
Expand Down
4 changes: 2 additions & 2 deletions build/deploy-prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ git commit -m"$VERSION"
git tag "v$VERSION"

# build and check
yarn build:release
yarn syntax
pnpm build:release
pnpm syntax

# rsync the files onto the remote host using SSH keys
./build/rsync-deploy.sh
Expand Down
2 changes: 1 addition & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"jest.config.js",
"package.json",
"tsconfig.json",
"yarn.lock",
"pnpm-lock.yaml",
".gitignore",
"webpack-stats.json",
".stylelintrc"
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ services:
- '8080:8080'
working_dir: /usr/src/app
command: >
bash -c "yarn install &&
yarn start"
bash -c "pnpm install &&
pnpm start"
environment:
- NODE_ENV=dev
- DOCKER=true
restart: 'no'
volumes:
- .:/usr/src/app
- node_modules:/usr/src/app/node_modules
volumes:
volumes:
node_modules:

32 changes: 18 additions & 14 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Here are some tips to make sure your Pull Request (PR) can be merged smoothly:
1. If you want to add a feature or make some change to DIM, consider [filing an issue](https://github.com/DestinyItemManager/DIM/issues/new) describing your idea first. This will give the DIM community a chance to discuss the idea, offer suggestions and pointers, and make sure what you're thinking of fits with the style and direction of DIM. If you want a more free-form chat, [join our Discord](https://discordapp.com/invite/UK2GWC7).
1. Resist the temptation to change more than one thing in your PR. Keeping PRs focused on a single change makes them much easier to review and accept. If you want to change multiple things, or clean up/refactor the code, make a new branch and submit those changes as a separate PR.
1. All of our code is written in [TypeScript](https://typescriptlang.org) and uses React to build UI components.
1. Be sure to run `yarn fix` before submitting your PR - it'll catch most style problems and make things much easier to merge.
1. Be sure to run `pnpm fix` before submitting your PR - it'll catch most style problems and make things much easier to merge.
1. Don't forget to add a description of your change to [docs/CHANGELOG.md](CHANGELOG.md) so it'll be included in the release notes!

## Developer Quick start
Expand All @@ -20,18 +20,22 @@ Here are some tips to make sure your Pull Request (PR) can be merged smoothly:

**Note:** It's often easier to use a package manager like [Homebrew](https://brew.sh/) for Mac, or [Chocolatey](https://docs.chocolatey.org/en-us/choco/setup) for Windows, and install the prerequisites through them.

* Homebrew: `brew install git nodejs yarn visual-studio-code`
* Chocolatey: `choco install git nodejs-lts yarn vscode`
* Homebrew: `brew install git nodejs corepack visual-studio-code`
* Chocolatey: `choco install git nodejs-lts corepack vscode`

#### Manual Install

* Install [Git](https://git-scm.com/downloads)
* Install [NodeJS](https://nodejs.org/)
* Install [Yarn](https://yarnpkg.com/en/docs/install)
* Use Yarn 1.x as DIM is not compatible with later versions of Yarn. If you're used to NPM, see "[Migrating from NPM](https://yarnpkg.com/lang/en/docs/migrating-from-npm/)".
* It is highly recommended to use [VSCode](https://code.visualstudio.com/) to work on DIM. When you open DIM in VSCode, accept the recommended plugins it suggests (find them manually by searching "@recommended" in the Extensions window).
* On Windows, restart your system after installing everything.

### Enable Corepack

Corepack manages the version of pnpm, the package manager used by DIM. It comes with NodeJS and will automatically get the right version of pnpm for you.

* [`corepack enable`](https://github.com/nodejs/corepack#how-to-install)

### Clone the repo

To locally **run a copy** of DIM, you can simply clone the code repository:
Expand All @@ -56,12 +60,12 @@ More detailed information on these steps is [here](https://docs.github.com/en/ge

Once you have cloned the repository or a fork of the repository to your local machine, in the root directory:

* Run `yarn install`
* If `yarn` isn't installed, install it with `npm i -g yarn`.
* If you're using PowerShell on Windows, you may need to run `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted` to allow yarn to run.
* Windows-based developers will need to install `windows-build-tools` (run `yarn global add windows-build-tools` in your terminal) globally prior to running `yarn install`. Refer to issue #1439 for [details](https://github.com/DestinyItemManager/DIM/issues/1439).
* Linux-based developers will need to install `build-essential` (`sudo apt-get install -y build-essential`) prior to running `yarn install`.
* Run `yarn start`
* Run `pnpm install`
* If `pnpm` isn't installed, run `corepack enable` and try again, or [install it manually](https://pnpm.io/installation).
* If you're using PowerShell on Windows, you may need to run `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted` to allow pnpm to run.
* Windows-based developers will need to install `windows-build-tools` (run `pnpm install -g windows-build-tools` in your terminal) globally prior to running `pnpm install`. Refer to issue #1439 for [details](https://github.com/DestinyItemManager/DIM/issues/1439).
* Linux-based developers will need to install `build-essential` (`sudo apt-get install -y build-essential`) prior to running `pnpm install`.
* Run `pnpm start`

On Windows machines, this will also install SnoreToast to provide notifications for parts of the development process, like when a build completes.

Expand Down Expand Up @@ -90,17 +94,17 @@ if the app can't load them from local storage when it starts.

**Overview**

The `yarn start` step will create a hot-loading web server and a TLS cert/key pair. You will access your local development site by visiting https://localhost:8080.
The `pnpm start` step will create a hot-loading web server and a TLS cert/key pair. You will access your local development site by visiting https://localhost:8080.
You will likely get a security warning about the certificate not being trusted. This is because it's a self-signed cert generated dynamically for your environment
and is not signed by a recognized authority. Dismiss/advance past this warning to view your local DIM application.

**Check code Style**

* `yarn fix` will tell you if you're following the DIM code style (and automatically fix what it can).
* `pnpm fix` will tell you if you're following the DIM code style (and automatically fix what it can).
Check out the [docs]() folder for more tips.

**Translation**

* We use [i18next](https://github.com/i18next/i18next) for all our translated strings, so if you want to translate something that's currently English-only, take a look at that. Usually it's as simple as replacing some text with `<span>{t('KEY')}</span>` and then defining KEY in the `config\i18n.json` file.

* `yarn i18n` will add, sort, and prune `src/locale/en.json`. You should never manually edit `src/locale/en.json`. Some keys are obfuscated by code and will need to be added as comments into the code such as `// t('LoadoutBuilder.ObfuscatedKey1')`. If you have any questions, ping @delphiactual via GitHub, Slack, or Discord.
* `pnpm i18n` will add, sort, and prune `src/locale/en.json`. You should never manually edit `src/locale/en.json`. Some keys are obfuscated by code and will need to be added as comments into the code such as `// t('LoadoutBuilder.ObfuscatedKey1')`. If you have any questions, ping @delphiactual via GitHub, Slack, or Discord.
6 changes: 3 additions & 3 deletions docs/Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Install Dependencies, and start webpack, with Docker

Run the following commands from the DIM cloned directory on your machine:

* `docker-compose up` to build the dist and start yarn watcher
* It will take a while for the dist files to build on the first startup while yarn installs dependencies
* `docker-compose up` to build the dist and start pnpm watcher
* It will take a while for the dist files to build on the first startup while pnpm installs dependencies
* `ctrl+c` to stop
* `docker-compose up -d` to start in detached mode
* `docker-compose stop` to stop detached mode
Expand Down Expand Up @@ -57,7 +57,7 @@ This will install the `nano` editor. Another option is `vim`.

## Node modules

If you need to install new node dependencies, you should run those commands from inside the container. Once inside, use `yarn add NameOfTheDependency` as normal.
If you need to install new node dependencies, you should run those commands from inside the container. Once inside, use `pnpm add NameOfTheDependency` as normal.

## Container terminates unexpectedly

Expand Down
Loading

0 comments on commit c38edab

Please sign in to comment.