Skip to content

Commit 20e79fd

Browse files
authored
fix: migrating to pnpm workspaces (#1876)
Migrate lerna to pnpm workspaces
1 parent e747d28 commit 20e79fd

File tree

77 files changed

+14317
-118170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+14317
-118170
lines changed

.circleci/config.yml

+9-26
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
11
version: 2.1
22

3-
commands:
4-
create_concatenated_package_lock:
5-
description: Concatenate all package-lock.json files recognized by lerna.js into single file. File is used as checksum source for part of caching key.
6-
parameters:
7-
filename:
8-
type: string
9-
steps:
10-
- run:
11-
name: Combine package-lock.json files to single file
12-
command: lerna la -a | awk -F packages '{printf "\"packages%s/package-lock.json\" ", $2}' | xargs cat > << parameters.filename >>
13-
143
jobs:
154
build:
165
docker:
176
- image: cimg/node:18.16.0
187
steps:
198
- checkout
209
- run:
21-
name: Install lerna
22-
command: npm i --prefix=$HOME/.local -g lerna@6
23-
- create_concatenated_package_lock:
24-
filename: combined-package-lock.txt
10+
name: Install pnpm
11+
command: npm i --prefix=$HOME/.local -g pnpm
2512
- restore_cache:
2613
keys:
27-
- deps-v5-{{ .Branch }}-{{ checksum "combined-package-lock.txt" }}
2814
- deps-v5-{{ .Branch }}
2915
- deps-v5-
3016
- run:
3117
name: Install dependencies
32-
command: lerna bootstrap
18+
command: pnpm install
3319
- save_cache:
34-
key: deps-v5-{{ .Branch }}-{{ checksum "combined-package-lock.txt" }}
20+
key: deps-v5-{{ .Branch }}
3521
paths:
3622
- ./node_modules
3723
- ./packages/eslint-config/node_modules
@@ -50,20 +36,17 @@ jobs:
5036
steps:
5137
- checkout
5238
- run:
53-
name: Install lerna
54-
command: npm i --prefix=$HOME/.local -g lerna@6
55-
- create_concatenated_package_lock:
56-
filename: combined-package-lock.txt
39+
name: Install pnpm
40+
command: npm i --prefix=$HOME/.local -g pnpm
5741
- restore_cache:
5842
keys:
59-
- deps-v5-{{ .Branch }}-{{ checksum "combined-package-lock.txt" }}
6043
- deps-v5-{{ .Branch }}
6144
- deps-v5-
6245
- run:
6346
name: Install dependencies
64-
command: lerna bootstrap
47+
command: pnpm install
6548
- save_cache:
66-
key: deps-v5-{{ .Branch }}-{{ checksum "combined-package-lock.txt" }}
49+
key: deps-v5-{{ .Branch }}
6750
paths:
6851
- ./node_modules
6952
- ./packages/eslint-config/node_modules
@@ -74,7 +57,7 @@ jobs:
7457
- ./packages/extension/node_modules
7558
- run:
7659
name: Test
77-
command: lerna run test:ci
60+
command: pnpm run -r test:ci
7861
environment:
7962
JEST_JUNIT_OUTPUT_DIR: ../../test-results
8063
- store_test_results:

.gitpod.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ tasks:
3838
nvm install
3939
nvm use
4040
init: |
41-
npm i -g lerna@6
42-
lerna bootstrap
41+
npm i -g pnpm
42+
pnpm install
4343
command: |
4444
cd packages/webapp
4545
npm run dev

.pnpmfile.cjs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function switchToPreact(pkg, dep) {
2+
if (pkg.dependencies[dep]) {
3+
pkg.dependencies[dep] = 'npm:@preact/[email protected]';
4+
}
5+
}
6+
7+
function readPackage(pkg) {
8+
if (pkg.dependencies) {
9+
switchToPreact(pkg, 'react');
10+
switchToPreact(pkg, 'react-dom');
11+
}
12+
return pkg
13+
}
14+
15+
module.exports = {
16+
hooks: {
17+
readPackage
18+
}
19+
}

Dockerfile

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ RUN mkdir -p /opt/app
55
WORKDIR /opt/app
66

77
COPY package*.json .
8-
COPY lerna.json .
98

109
COPY packages/eslint-config/package*.json ./packages/eslint-config/
1110

@@ -23,8 +22,8 @@ RUN \
2322
apk --no-cache add \
2423
libc6-compat
2524

26-
RUN npm i -g lerna
27-
RUN lerna bootstrap
25+
RUN npm i -g pnpm
26+
RUN pnpm install
2827

2928
COPY packages ./packages
3029

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ The decision was made to allow faster iterations and to keep features parity in
2626

2727
## Technology
2828

29-
* NPM for managing dependencies.
3029
* Node v18.16.0 (a `.nvmrc` is presented for [nvm](https://github.com/nvm-sh/nvm) users).
31-
* [lerna](https://github.com/lerna/lerna) for managing the monorepo.
30+
* [pnpm](https://pnpm.io/workspaces) for managing the monorepo and dependencies.
3231

3332
## Projects
3433

@@ -70,15 +69,15 @@ https://github.com/dailydotdev/.github/blob/master/CONTRIBUTING.md
7069

7170
After cloning the project, please make sure to run the following commands to bootstrap the project:
7271
```
73-
npm i -g lerna
74-
lerna bootstrap
72+
npm i -g pnpm
73+
pnpm install
7574
```
7675

7776
## Firefox Review
7877

7978
* Install node v18.16.0 and npm v9.5.1
80-
* Install `lerna` as a global package `npm i -g lerna`
81-
* Bootstrap project `lerna bootstrap`
79+
* Install `pnpm` as a global package `npm i -g pnpm`
80+
* Bootstrap project `pnpm install`
8281
* Change working directory to extension project `cd packages/extension`
8382
* Build Firefox version `npm run build:firefox`
8483
* Firefox build should be located at `dist`

lerna.json

-7
This file was deleted.

package-lock.json

-25
This file was deleted.

0 commit comments

Comments
 (0)