Skip to content

Commit

Permalink
Switch from 'npm' to 'pnpm'
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Hatvan <markus_hatvan@aon.at>
Co-authored-by: Nathanaël Houn <contact@nathanaelhoun.fr>
Vijay Aravamudhan <vraravam@users.noreply.github.com>
Co-authored-by: André Oliveira <oliveira.andrerodrigues95@gmail.com>
  • Loading branch information
4 people authored and vraravam committed Nov 24, 2022
1 parent 99e7a59 commit c523310
Show file tree
Hide file tree
Showing 23 changed files with 15,380 additions and 48,849 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Expand Up @@ -13,8 +13,7 @@
**/*.tsbuildinfo
**/build
**/node_modules
**/npm-debug.log*
**/.pnpm-debug.log
**/.pnpm-debug.log*
**/server*.log
**/yarn-error.log
Dockerfile
Expand Down
1 change: 0 additions & 1 deletion .eslintignore
Expand Up @@ -19,7 +19,6 @@ node_modules
.DS_Store

.idea
npm-debug.log.*
.pnpm-debug.log*
*.css.d.ts
*.sass.d.ts
Expand Down
6 changes: 4 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -25,10 +25,12 @@

#### Checklist
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

- [ ] My pull request is properly named
- [ ] The changes respect the code style of the project (`npm run prepare-code`)
- [ ] `npm test` passes
- [ ] The changes respect the code style of the project (`pnpm prepare-code`)
- [ ] `pnpm test` passes
- [ ] I tested/previewed my changes locally

#### Release Notes

<!-- Please add a one-line description for users of Ferdium to read in the release notes, or 'none' if no notes relevant to such users. Examples and help on special cases: https://github.com/electron/clerk/blob/master/README.md#examples -->
2 changes: 1 addition & 1 deletion .github/config.yml
Expand Up @@ -5,7 +5,7 @@ newPRWelcomeComment: |
Things that will help get your PR across the finish line:
- Follow the JavaScript [coding style](https://github.com/electron/electron/blob/master/docs/development/coding-style.md) as recommended by the Electron project.
- Run `npm run lint` locally to catch formatting errors earlier.
- Run `pnpm lint` locally to catch formatting errors earlier.
- Document any user-facing changes you've made by including screenshots and animated GIFs whenever possible.
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.
Expand Down
49 changes: 20 additions & 29 deletions .github/workflows/builds.yml
Expand Up @@ -51,15 +51,12 @@ jobs:
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }}
with:
node-version-file: ".nvmrc"
- name: Install npm
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }}
run: npm i -gf "npm@$(node -p 'require("./package.json").engines.npm')" && npm -v
- name: Install pnpm
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }}
run: npm i -gf "pnpm@$(node -p 'require("./recipes/package.json").engines.pnpm')" && pnpm -v
run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v
- name: Install node dependencies
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }}
run: npm i
run: pnpm i
- id: should_run
name: Check whether there are any commits since this run was last triggered and push them and/or set the output
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }}
Expand Down Expand Up @@ -90,8 +87,8 @@ jobs:
echo "GIT_DIRTY=$(git status -s | wc -l)" >> $GITHUB_ENV
echo "Run linter, reformatter, rebrander and tests"
npm run prepare-code
npm run test
pnpm prepare-code
pnpm test
echo "Commit dependency-updates and linter changes"
git commit -am "Update browserslist data updates and linter fixes [skip ci]" --no-verify || true
Expand All @@ -107,7 +104,7 @@ jobs:
# there were other changes coming from the 'develop' branch (or)
# this is a manual trigger with the key-phrase
git checkout develop
npm version -m "%s [skip ci]" prerelease --preid=nightly
pnpm version -m "%s [skip ci]" prerelease --preid=nightly
git commit --all --amend --no-edit --no-verify
git push origin develop --no-verify
Expand Down Expand Up @@ -173,22 +170,20 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install npm
run: npm i -gf "npm@$(node -p 'require("./package.json").engines.npm')" && npm -v
- name: Install pnpm
run: npm i -gf "pnpm@$(node -p 'require("./recipes/package.json").engines.pnpm')" && pnpm -v
run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v
- name: Install node dependencies
run: npm i
run: pnpm i
- name: Package recipes
run: pnpm i && pnpm lint && pnpm reformat-files && pnpm package
working-directory: ./recipes
- name: Run linter and tests
run: npm run lint && npm run test
run: pnpm lint && pnpm test
- name: Build Ferdium without publish for any branch not 'nightly' and not 'release'
if: ${{ env.GIT_BRANCH_NAME != 'nightly' && env.GIT_BRANCH_NAME != 'release' }}
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
run: npm run build -- --publish never
run: pnpm build --publish never
shell: bash
- name: "Build Ferdium with publish for '${{ env.GIT_BRANCH_NAME }}' branch"
if: ${{ env.GIT_BRANCH_NAME == 'nightly' || env.GIT_BRANCH_NAME == 'release' }}
Expand All @@ -199,7 +194,7 @@ jobs:
APPLEID_PASSWORD: ${{ secrets.APPLEID_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
run: npm run build -- --publish always
run: pnpm build --publish always
shell: bash

build_linux:
Expand Down Expand Up @@ -249,12 +244,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install npm
run: npm i -gf "npm@$(node -p 'require("./package.json").engines.npm')" && npm -v
- name: Install pnpm
run: npm i -gf "pnpm@$(node -p 'require("./recipes/package.json").engines.pnpm')" && pnpm -v
run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v
- name: Install node dependencies
run: npm i
run: pnpm i
- name: Figure out used package.json version
run: |
PACKAGE_VERSION="$(node -p 'require("./package.json").version')"
Expand All @@ -278,12 +271,12 @@ jobs:
run: pnpm i && pnpm lint && pnpm reformat-files && pnpm package
working-directory: ./recipes
- name: Run linter and tests
run: npm run lint && npm run test
run: pnpm lint && pnpm test
- name: Build Ferdium without publish for any branch not 'nightly' and not 'release'
if: ${{ env.GIT_BRANCH_NAME != 'nightly' && env.GIT_BRANCH_NAME != 'release' }}
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
run: npm run build -- --publish never
run: pnpm build --publish never
shell: bash
- name: "Build Ferdium with publish for '${{ env.GIT_BRANCH_NAME }}' branch"
if: ${{ env.GIT_BRANCH_NAME == 'nightly' || env.GIT_BRANCH_NAME == 'release' }}
Expand All @@ -294,7 +287,7 @@ jobs:
run: |
sudo snap install snapcraft --channel=5.x/stable --classic
echo "$SNAPCRAFT_LOGIN" | snapcraft login --with -
npm run build -- --publish always -c.snap.publish.repo=$SNAP_PUBLISH_REPO -c.snap.publish.channels=$SNAP_PUBLISH_CHANNEL
pnpm build --publish always -c.snap.publish.repo=$SNAP_PUBLISH_REPO -c.snap.publish.channels=$SNAP_PUBLISH_CHANNEL
snapcraft logout
shell: bash

Expand Down Expand Up @@ -347,14 +340,12 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install npm
run: npm i -gf "npm@$(node -p 'require(\"./package.json\").engines.npm')" && npm -v
- name: Install pnpm
run: npm i -gf "pnpm@$(node -p 'require(\"./recipes/package.json\").engines.pnpm')" && pnpm -v
run: npm i -gf "pnpm@$(node -p 'require(\"./package.json\").engines.pnpm')" && pnpm -v
- name: Install node dependencies
uses: nick-invision/retry@v2.4.0
with:
command: npm i
command: pnpm i
timeout_minutes: 15
max_attempts: 3
retry_on: error
Expand All @@ -363,13 +354,13 @@ jobs:
working-directory: ./recipes
shell: bash
- name: Run linter and tests
run: npm run lint && npm run test
run: pnpm lint && pnpm test
shell: bash
- name: Build Ferdium without publish for any branch not 'nightly' and not 'release'
if: ${{ env.GIT_BRANCH_NAME != 'nightly' && env.GIT_BRANCH_NAME != 'release' }}
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
run: npm run build -- --publish never
run: pnpm build --publish never
shell: bash
- name: "Build Ferdium with publish for '${{ env.GIT_BRANCH_NAME }}' branch"
if: ${{ env.GIT_BRANCH_NAME == 'nightly' || env.GIT_BRANCH_NAME == 'release' }}
Expand All @@ -378,5 +369,5 @@ jobs:
CSC_IDENTITY_AUTO_DISCOVERY: true
WIN_CSC_LINK: ${{ secrets.WIN_CSC_LINK }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
run: npm run build -- --publish always
run: pnpm build --publish always
shell: bash
2 changes: 1 addition & 1 deletion .husky/commit-msg
Expand Up @@ -2,7 +2,7 @@

FILE_NAME="$(dirname "$0")/_/husky.sh"

# Conditionally invoke so as to avoid running npm commands if this is a clean checkout (ie before installing node modules)
# Conditionally invoke so as to avoid running pnpm commands if this is a clean checkout (ie before installing node modules)
if [ -f $FILE_NAME ]; then
. $FILE_NAME

Expand Down
5 changes: 3 additions & 2 deletions .husky/pre-commit
Expand Up @@ -2,8 +2,9 @@

FILE_NAME="$(dirname "$0")/_/husky.sh"

# Conditionally invoke so as to avoid running npm commands if this is a clean checkout (ie before installing node modules)
# Conditionally invoke so as to avoid running pnpm commands if this is a clean checkout (ie before installing node modules)
if [ -f $FILE_NAME ]; then
. $FILE_NAME
npm run prepare-code
pnpm prepare-code
pnpm test
fi
3 changes: 1 addition & 2 deletions .npmrc
@@ -1,6 +1,5 @@
save-exact = true
engine-strict = true
unsafe-perm = true
frozen-lockfile = false
legacy-peer-deps = true
shamefully-hoist = true
frozen-lockfile = false
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Expand Up @@ -2,17 +2,17 @@
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"type": "pnpm",
"script": "dev",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"type": "pnpm",
"script": "lint",
"group": "test"
}
]
}
}
11 changes: 5 additions & 6 deletions CONTRIBUTING.md
Expand Up @@ -13,7 +13,7 @@
- [How can I contribute?](#how-can-i-contribute)
- [Setting up your development machine](#setting-up-your-development-machine)
- [Install system-level dependencies](#install-system-level-dependencies)
- [Node.js, npm, pnpm](#nodejs-npm-pnpm)
- [Node.js, pnpm](#nodejs-pnpm)
- [Git](#git)
- [On Debian/Ubuntu](#on-debianubuntu)
- [On Fedora](#on-fedora)
Expand Down Expand Up @@ -52,7 +52,7 @@ If so, engage in the already existing discussion.

_Note:_ This list can likely get outdated. If so, please refer to the specific version of the [electronuserland builder](https://hub.docker.com/r/electronuserland/builder) that we use in our [Dockerfile](./Dockerfile).

#### Node.js, npm, pnpm
#### Node.js, pnpm

Please make sure you are conforming to the `engines` requirements used by the developers/contributors as specified in the [`package.json`](./package.json#engines) and [`recipes/package.json`](./recipes/package.json#engine) files.

Expand All @@ -63,12 +63,11 @@ Currently, these are the combinations of system dependencies that work for MacOS
$ jq --null-input '[inputs.engines] | add' < ./package.json < ./recipes/package.json
{
"node": "16.18.0",
"npm": "8.19.2",
"pnpm": "7.17.0"
}
```

_Note:_ You can choose any version manager to manage multiple versions of `node` and `npm`. For eg, [nvm](https://github.com/nvm-sh/nvm) or [asdf](https://github.com/asdf-vm/asdf).
_Note:_ You can choose any version manager to manage multiple versions of `node` and `pnpm`. For eg, [nvm](https://github.com/nvm-sh/nvm) or [asdf](https://github.com/asdf-vm/asdf).

#### Git

Expand All @@ -90,7 +89,7 @@ dnf install libX11-devel libXext-devel libXScrnSaver-devel libxkbfile-devel rpm

Please make sure you have the following installed:

- Microsoft Visual Studio Build Tools (2019 or higher - with Windows 10 SDK selected).
- Microsoft Visual Studio Build Tools (2017, 2019 or 2022 - with Windows 10 SDK selected).

### Clone repository with submodule

Expand Down Expand Up @@ -147,7 +146,7 @@ mv /ferdium/latest-linux.yml /ferdium-out/latest-linux-$GIT_SHA.yml
Run this command on the terminal:

```bash
npm run debug
pnpm debug
```

Note: please prefer [`debug()`](https://github.com/visionmedia/debug) over `console.log()`.
Expand Down
8 changes: 3 additions & 5 deletions Dockerfile
Expand Up @@ -20,21 +20,19 @@ WORKDIR /usr/src/ferdium
COPY package*.json ./
COPY .npmrc ./

RUN npm i -gf "npm@$(node -p 'require("./package.json").engines.npm')" && npm -v
RUN npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v

RUN npm i
RUN pnpm i

COPY . .

WORKDIR /usr/src/ferdium/recipes

RUN npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v

RUN pnpm i && pnpm lint && pnpm reformat-files && pnpm package

WORKDIR /usr/src/ferdium

RUN npm run build --dir
RUN pnpm build --dir

# --------------------------------------------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions electron-builder-fix-env.js
@@ -0,0 +1,4 @@
// HACKTAG: Fix from https://github.com/electron-userland/electron-builder/issues/7256 to overcome issue from electron-builder for windows multi-arch builds
exports.default = async function (context) {
delete process.env.GYP_MSVS_VERSION;
};
4 changes: 4 additions & 0 deletions electron-builder.npmrc
@@ -0,0 +1,4 @@
# Workarounds for supporting pnpm in electron-builder
node-linker = hoisted
shamefully-hoist = true
legacy-peer-deps = true
2 changes: 2 additions & 0 deletions electron-builder.yml
Expand Up @@ -4,6 +4,8 @@ directories:

appId: "org.ferdium.ferdium-app"

beforePack: './electron-builder-fix-env.js'

publish:
provider: github

Expand Down
10 changes: 9 additions & 1 deletion gulpfile.babel.ts
Expand Up @@ -4,6 +4,7 @@ import babel from 'gulp-babel';
import dartSass from 'sass';
import gulpSass from 'gulp-sass';
import csso from 'gulp-csso';
import rename from 'gulp-rename';
import terser from 'gulp-terser';
import htmlMin from 'gulp-htmlmin';
import connect from 'gulp-connect';
Expand Down Expand Up @@ -101,6 +102,13 @@ function mvSrc() {
.pipe(gulp.dest(paths.dest));
}

function mvElectronNpmrc() {
return gulp
.src(['electron-builder.npmrc'])
.pipe(rename('.npmrc'))
.pipe(gulp.dest(paths.dest));
}

function mvPackageJson() {
return gulp.src(['./package.json']).pipe(gulp.dest(paths.dest));
}
Expand Down Expand Up @@ -219,7 +227,7 @@ function recipeInfo() {

export const build = gulp.series(
clean,
gulp.parallel(mvSrc, mvPackageJson, BuildInfo),
gulp.parallel(mvElectronNpmrc, mvSrc, mvPackageJson, BuildInfo),
gulp.parallel(
html,
processJavascript,
Expand Down

0 comments on commit c523310

Please sign in to comment.