Skip to content

Commit

Permalink
feat: Switch from npm to pnpm (n8n-io#4429)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy authored Nov 9, 2022
1 parent db163b7 commit 7367773
Show file tree
Hide file tree
Showing 33 changed files with 22,666 additions and 72,016 deletions.
10 changes: 7 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
**/*.md
**/.env
.cache
assets
node_modules
packages/node-dev
packages/*/node_modules
packages/*/dist
packages/*/.turbo
packages/**/node_modules
packages/**/dist
packages/**/.turbo
.git
.github
*.tsbuildinfo
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ A clear and concise description of what you expected to happen.

**Environment (please complete the following information):**

- OS: [e.g. Ubuntu Linux 18.04]
- n8n Version [e.g. 0.119.0]
- Node.js Version [e.g. 14.16.0]
- OS: [e.g. Ubuntu Linux 22.04]
- n8n Version [e.g. 0.200.1]
- Node.js Version [e.g. 16.17.0]
- Database system [e.g. SQLite; n8n uses SQLite as default otherwise changed]
- Operation mode [e.g. own; operation modes are `own`, `main` and `queue`. Default is `own`]

Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/ci-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,27 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/[email protected]

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache: 'pnpm'

- name: Install npm and dependencies
run: npm install -g npm@latest && npm install
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: npm run build --if-present
run: pnpm build

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

- name: Test E2E
run:
npm run test:e2e:ci:smoke
run: |
pnpm cypress:install
pnpm test:e2e:ci:smoke
- name: Lint
run: npm run lint
run: pnpm lint
16 changes: 9 additions & 7 deletions .github/workflows/ci-postgres-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,32 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/[email protected]

- uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
cache: 'pnpm'

- name: Install npm and dependencies
run: npm install -g npm@latest && npm install
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Start MySQL & Postgres
uses: isbang/[email protected]
with:
compose-file: ./.github/docker-compose.yml

- name: Build Core & Workflow
run: npm run -w packages/workflow -w packages/core build
run: pnpm --filter n8n-workflow --filter=n8n-core build

- name: Test MySQL
working-directory: packages/cli
run: npm run test:mysql
run: pnpm test:mysql

- name: Test Postgres
working-directory: packages/cli
run: npm run test:postgres
run: pnpm test:postgres

- name: Test Postgres (alternate schema)
working-directory: packages/cli
run: npm run test:postgres:alt-schema
run: pnpm test:postgres:alt-schema
19 changes: 11 additions & 8 deletions .github/workflows/ci-pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,32 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/[email protected]

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache: 'pnpm'

- name: Install npm and dependencies
run: npm install -g npm@latest && npm install
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: npm run build --if-present
run: pnpm build

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

- name: Test E2E
run:
npm run test:e2e:ci:smoke
run: |
pnpm cypress:install
pnpm test:e2e:ci:smoke
- name: Fetch base branch for `git diff`
run: git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}

- name: Run ESLint on changes only
env:
ESLINT_PLUGIN_DIFF_COMMIT: ${{ github.event.pull_request.base.ref }}
run: npm run lint
run: pnpm lint
13 changes: 7 additions & 6 deletions .github/workflows/test-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ jobs:
repository: n8n-io/test-workflows
path: test-workflows

- uses: pnpm/[email protected]

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'n8n/package-lock.json'
cache: 'pnpm'
cache-dependency-path: 'n8n/pnpm-lock.yaml'

- name: Install dependencies
run: |
Expand All @@ -41,12 +43,11 @@ jobs:
DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y graphicsmagick
shell: bash

- name: npm install and build
- name: pnpm install and build
working-directory: n8n
run: |
npm install -g npm@latest
npm install
npm run build --if-present
pnpm install
pnpm build
shell: bash

- name: Import credentials
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ _START_PACKAGE
!.vscode/settings.default.json
.idea
nodelinter.config.json
packages/*/package-lock.json
packages/*/.turbo
**/package-lock.json
packages/**/.turbo
*.tsbuildinfo
cypress/videos/*
cypress/screenshots/*
Expand Down
8 changes: 7 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
legacy-peer-deps=true
auto-install-peers = true
strict-peer-dependencies = false
prefer-workspace-packages = true
link-workspace-packages = deep
hoist = true
shamefully-hoist = true
loglevel = warn
2 changes: 1 addition & 1 deletion .vscode/settings.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"search.exclude": {
"node_modules": true,
"dist": true,
"package-lock.json": true
"pnpm-lock.yaml": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"workspace-default-settings.runOnActivation": true
Expand Down
62 changes: 38 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@ Great that you are here and you want to contribute to n8n

## Contents

- [Code of Conduct](#code-of-conduct)
- [Directory Structure](#directory-structure)
- [Development Setup](#development-setup)
- [Development Cycle](#development-cycle)
- [Create Custom Nodes](#create-custom-nodes)
- [Create a new node to contribute to n8n](#create-a-new-node-to-contribute-to-n8n)
- [Checklist before submitting a new node](#checklist-before-submitting-a-new-node)
- [Extend Documentation](#extend-documentation)
- [Contributor License Agreement](#contributor-license-agreement)
- [Contributing to n8n](#contributing-to-n8n)
- [Contents](#contents)
- [Code of conduct](#code-of-conduct)
- [Directory structure](#directory-structure)
- [Development setup](#development-setup)
- [Requirements](#requirements)
- [Node.js](#nodejs)
- [Build tools](#build-tools)
- [pnpm workspaces](#pnpm-workspaces)
- [Actual n8n setup](#actual-n8n-setup)
- [Start](#start)
- [Development cycle](#development-cycle)
- [Test suite](#test-suite)
- [Create custom nodes](#create-custom-nodes)
- [Create a new node to contribute to n8n](#create-a-new-node-to-contribute-to-n8n)
- [Checklist before submitting a new node](#checklist-before-submitting-a-new-node)
- [Extend documentation](#extend-documentation)
- [Contributor License Agreement](#contributor-license-agreement)

## Code of conduct

Expand Down Expand Up @@ -51,7 +60,13 @@ dependencies are installed and the packages get linked correctly. Here a short g

#### Node.js

We suggest using [Node.js](https://nodejs.org/en/) version 16 for development purposes.
We suggest using [Node.js](https://nodejs.org/en/) version 16.9 or newer for development purposes.

After that we recommend enabling [Node.js corepack](https://nodejs.org/docs/latest-v16.x/api/corepack.html) with `corepack enable`, and [pnpm](https://pnpm.io/) with `corepack prepare pnpm --activate`.

**IMPORTANT**: If you have installed Node.js via homebrew, you'll need to run `brew install corepack`, since homebrew explicitly removes `npm` and `corepack` from [the `node` formula](https://github.com/Homebrew/homebrew-core/blob/master/Formula/node.rb#L66).

**IMPORTANT**: If you are on windows, you'd need to run `corepack enable` and `corepack prepare pnpm --activate` in a terminal as an administrator.

#### Build tools

Expand All @@ -72,15 +87,14 @@ yum install gcc gcc-c++ make
Windows:

```
npm install -g windows-build-tools
npm add -g windows-build-tools
```

#### npm workspaces
#### pnpm workspaces

n8n is split up in different modules which are all in a single mono repository.
To facilitate the module management, [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) are
used. This automatically sets up file-links between modules which depend on each
other.
To facilitate the module management, [pnpm workspaces](https://pnpm.io/workspaces) are used.
This automatically sets up file-links between modules which depend on each other.

### Actual n8n setup

Expand Down Expand Up @@ -112,20 +126,20 @@ checked out and set up:
5. Install all dependencies of all modules and link them together:

```
npm install
pnpm install
```

6. Build all the code:
```
npm run build
pnpm build
```

### Start

To start n8n execute:

```
npm run start
pnpm start
```

To start n8n with tunnel:
Expand All @@ -136,24 +150,24 @@ To start n8n with tunnel:

## Development cycle

While iterating on n8n modules code, you can run `npm run dev`. It will then
While iterating on n8n modules code, you can run `pnpm dev`. It will then
automatically build your code, restart the backend and refresh the frontend
(editor-ui) on every change you make.

1. Start n8n in development mode:
```
npm run dev
pnpm dev
```
1. Hack, hack, hack
1. Check if everything still runs in production mode
```
npm run build
npm run start
pnpm build
pnpm start
```
1. Create tests
1. Run all [tests](#test-suite)
```
npm run test
pnpm test
```
1. Commit code and [create a pull request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)

Expand All @@ -162,7 +176,7 @@ automatically build your code, restart the backend and refresh the frontend
The tests can be started via:

```
npm run test
pnpm test
```

If that gets executed in one of the package folders it will only run the tests
Expand Down
21 changes: 8 additions & 13 deletions docker/images/n8n-custom/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,20 @@ ARG NODE_VERSION=16
# 1. Create an image to build n8n
FROM n8nio/base:${NODE_VERSION} as builder

RUN npm install -g run-script-os [email protected]

COPY turbo.json package.json package-lock.json tsconfig.json ./
COPY turbo.json package.json .npmrc pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./
COPY packages ./packages
COPY patches ./patches

RUN corepack enable && corepack prepare --activate
RUN chown -R node:node .
RUN npm config set legacy-peer-deps true

USER node

RUN \
npm install && \
npm run build && \
# TODO: removing dev dependecies is deleting `bn.js`, which breaks the Snowflake node
npm prune --omit=dev && \
npm i --omit=dev bn.js && \
find . -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" -o -name "tsconfig.json" | xargs rm &&\
rm -rf node_modules/.cache packages/*/node_modules/.cache packages/*/.turbo .config .npm /tmp/*
RUN pnpm install --frozen-lockfile
RUN pnpm build
RUN rm -rf node_modules
RUN NODE_ENV=production pnpm install --prod --no-optional
RUN find . -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" -o -name "tsconfig.json" -o -name "*.tsbuildinfo" | xargs rm
RUN rm -rf patches .npmrc *.yaml node_modules/.cache packages/**/node_modules/.cache packages/**/.turbo .config .cache .local .node /tmp/*


# 2. Start with a new clean image with just the code that is needed to run n8n
Expand Down
Loading

0 comments on commit 7367773

Please sign in to comment.