Skip to content

Commit

Permalink
fix: migrating to pnpm workspaces (#1876)
Browse files Browse the repository at this point in the history
Migrate lerna to pnpm workspaces
  • Loading branch information
rebelchris authored Jun 19, 2023
1 parent e747d28 commit 20e79fd
Show file tree
Hide file tree
Showing 77 changed files with 14,317 additions and 118,170 deletions.
35 changes: 9 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
version: 2.1

commands:
create_concatenated_package_lock:
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.
parameters:
filename:
type: string
steps:
- run:
name: Combine package-lock.json files to single file
command: lerna la -a | awk -F packages '{printf "\"packages%s/package-lock.json\" ", $2}' | xargs cat > << parameters.filename >>

jobs:
build:
docker:
- image: cimg/node:18.16.0
steps:
- checkout
- run:
name: Install lerna
command: npm i --prefix=$HOME/.local -g lerna@6
- create_concatenated_package_lock:
filename: combined-package-lock.txt
name: Install pnpm
command: npm i --prefix=$HOME/.local -g pnpm
- restore_cache:
keys:
- deps-v5-{{ .Branch }}-{{ checksum "combined-package-lock.txt" }}
- deps-v5-{{ .Branch }}
- deps-v5-
- run:
name: Install dependencies
command: lerna bootstrap
command: pnpm install
- save_cache:
key: deps-v5-{{ .Branch }}-{{ checksum "combined-package-lock.txt" }}
key: deps-v5-{{ .Branch }}
paths:
- ./node_modules
- ./packages/eslint-config/node_modules
Expand All @@ -50,20 +36,17 @@ jobs:
steps:
- checkout
- run:
name: Install lerna
command: npm i --prefix=$HOME/.local -g lerna@6
- create_concatenated_package_lock:
filename: combined-package-lock.txt
name: Install pnpm
command: npm i --prefix=$HOME/.local -g pnpm
- restore_cache:
keys:
- deps-v5-{{ .Branch }}-{{ checksum "combined-package-lock.txt" }}
- deps-v5-{{ .Branch }}
- deps-v5-
- run:
name: Install dependencies
command: lerna bootstrap
command: pnpm install
- save_cache:
key: deps-v5-{{ .Branch }}-{{ checksum "combined-package-lock.txt" }}
key: deps-v5-{{ .Branch }}
paths:
- ./node_modules
- ./packages/eslint-config/node_modules
Expand All @@ -74,7 +57,7 @@ jobs:
- ./packages/extension/node_modules
- run:
name: Test
command: lerna run test:ci
command: pnpm run -r test:ci
environment:
JEST_JUNIT_OUTPUT_DIR: ../../test-results
- store_test_results:
Expand Down
4 changes: 2 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ tasks:
nvm install
nvm use
init: |
npm i -g lerna@6
lerna bootstrap
npm i -g pnpm
pnpm install
command: |
cd packages/webapp
npm run dev
19 changes: 19 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function switchToPreact(pkg, dep) {
if (pkg.dependencies[dep]) {
pkg.dependencies[dep] = 'npm:@preact/compat@17.0.2';
}
}

function readPackage(pkg) {
if (pkg.dependencies) {
switchToPreact(pkg, 'react');
switchToPreact(pkg, 'react-dom');
}
return pkg
}

module.exports = {
hooks: {
readPackage
}
}
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ RUN mkdir -p /opt/app
WORKDIR /opt/app

COPY package*.json .
COPY lerna.json .

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

Expand All @@ -23,8 +22,8 @@ RUN \
apk --no-cache add \
libc6-compat

RUN npm i -g lerna
RUN lerna bootstrap
RUN npm i -g pnpm
RUN pnpm install

COPY packages ./packages

Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ The decision was made to allow faster iterations and to keep features parity in

## Technology

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

## Projects

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

After cloning the project, please make sure to run the following commands to bootstrap the project:
```
npm i -g lerna
lerna bootstrap
npm i -g pnpm
pnpm install
```

## Firefox Review

* Install node v18.16.0 and npm v9.5.1
* Install `lerna` as a global package `npm i -g lerna`
* Bootstrap project `lerna bootstrap`
* Install `pnpm` as a global package `npm i -g pnpm`
* Bootstrap project `pnpm install`
* Change working directory to extension project `cd packages/extension`
* Build Firefox version `npm run build:firefox`
* Firefox build should be located at `dist`
7 changes: 0 additions & 7 deletions lerna.json

This file was deleted.

25 changes: 0 additions & 25 deletions package-lock.json

This file was deleted.

Loading

0 comments on commit 20e79fd

Please sign in to comment.