Skip to content

Commit 775917a

Browse files
sean-zlaitechniqken-zlai
authored
Replace npm with pnpm (#136)
## Summary [`pnpm`](https://pnpm.io/) vs `npm` - Pros - Integrated (interactive) version manager - `pnpm up-deps` / (aliased `pnpm update -r -i --latest`) - `npm outdated` / `npm update --save-dev --save` only adhere to `package.json` semver - Must manually modify versions for major versions (ex. Vite 5 => 6) - Can use [`npx npm-check-updates`](https://github.com/raineorshine/npm-check-updates) package to provide similar functionality - Efficient Disk space - Workspace support - npm added [support](https://docs.npmjs.com/cli/v8/using-npm/workspaces) but not aware of any major projects using it - Typically [faster installs](https://pnpm.io/benchmarks) than npm - Slightly better developer ergonomics (`pnpm dev` vs `npm run dev`) - [Used](https://pnpm.io/users) by many large projects/companies (Vite, Svelte, etc) - Cons - Additional install (`npm` included with Node.js) - Synk [support](https://docs.snyk.io/supported-languages-package-managers-and-frameworks/javascript/javascript-for-open-source?_gl=1*1gi9low*_gcl_au*MTA2ODIxOTcxNy4xNzM0Mzg4MTY2*_ga*MTEzMzg2NzM3NS4xNzM0MDIzMDg5*_ga_X9SH3KP7B4*MTczNDU0MzI4Mi40LjAuMTczNDU0MzI4Mi4wLjAuMA..#pnpm) is currently in [preview](https://app.snyk.io/org/varant-zlai/manage/beta-features) - package version overrides not currently applying with Synk (configuration, preview status of integration, ...). Likely because snyk is configured to scan `package-lock.json` (npm) and not `pnpm-lock.yaml` (pnpm). ([here](https://app.snyk.io/org/varant-zlai/project/f4bdc116-d05b-4937-96b5-b1f9a02872e5)) --- ![image](https://github.com/user-attachments/assets/3fff95c6-f100-4083-9463-042b27763d1f) ![image](https://github.com/user-attachments/assets/decb6b45-60d0-40b5-a37a-803dd6deb302) ## Checklist - [ ] Added Unit Tests - [x] Covered by existing CI - [ ] Integration tested - [ ] Documentation update <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Updated README files to reflect the use of `pnpm` as the recommended package manager, including installation instructions and best practices. - **New Features** - Transitioned scripts in the project to utilize `pnpm` for various tasks including development, building, and testing. - **Configuration** - Modified Playwright configuration and other build configurations to use `pnpm` for starting the web server and managing dependencies. - **Dependency Updates** - Updated Spark dependency version from `3.5.0` to `3.5.1` and Jackson version from `2.15.1` to `2.15.2`. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- av pr metadata This information is embedded by the av CLI when creating PRs to track the status of stacks when using Aviator. Please do not delete or edit this section of the PR. ``` {"parent":"main","parentHead":"","trunk":"main"} ``` --> --------- Co-authored-by: Sean Lynch <[email protected]> Co-authored-by: ken-zlai <[email protected]>
1 parent 2b7efd8 commit 775917a

File tree

7 files changed

+4012
-6078
lines changed

7 files changed

+4012
-6078
lines changed

build.sbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,14 @@ lazy val frontend = (project in file("frontend"))
240240
buildFrontend := {
241241
println("Installing frontend dependencies...")
242242
import scala.sys.process._
243-
val npmCiResult = Process("npm ci", file("frontend")).!
243+
val pnpmCiResult = Process("pnpm install --frozen-lockfile", file("frontend")).!
244244

245-
if (npmCiResult != 0) {
246-
sys.error("npm ci failed!")
245+
if (pnpmCiResult != 0) {
246+
sys.error("pnpm install failed!")
247247
}
248248

249249
println("Building frontend...")
250-
val buildResult = Process("npm run build", file("frontend")).!
250+
val buildResult = Process("pnpm run build", file("frontend")).!
251251

252252
if (buildResult == 0) {
253253
println("Copying frontend assets to /hub/public...")

docker-init/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $ docker compose -f docker-init/compose.yaml up
3333

3434
The **backend** is served at: http://localhost:9000
3535

36-
The **frontend** is served at: http://localhost:3000. This serves statically built code - no live dev server. `cd frontend; npm run dev` for a live dev server.
36+
The **frontend** is served at: http://localhost:3000. This serves statically built code - no live dev server. `cd frontend; pnpm run dev` for a live dev server.
3737

3838
You can also access the parquet anomaly data table. To do so, from another terminal run:
3939

frontend/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The frontend for Chronon.
77
### Prerequisites
88

99
- [Node.js](https://nodejs.org/en/) (LTS version recommended)
10-
- npm (comes with Node.js)
10+
- [pnpm](https://pnpm.io/installation) - fast and disk space efficient package manager
1111

1212
### Installation
1313

@@ -26,7 +26,7 @@ The frontend for Chronon.
2626

2727
3. Install dependencies:
2828
```bash
29-
npm install
29+
pnpm install
3030
```
3131

3232
### Development
@@ -53,7 +53,7 @@ Done uploading summaries! 🥳
5353
3. Then, start the development server:
5454

5555
```bash
56-
npm run dev
56+
pnpm dev
5757
```
5858

5959
This will start a local server. The app will automatically reload if you make changes to the code.
@@ -63,7 +63,7 @@ This will start a local server. The app will automatically reload if you make ch
6363
To create an optimized production build:
6464

6565
```bash
66-
npm run build
66+
pnpm build
6767
```
6868

6969
This will create an optimized version of your project in the `build` directory.
@@ -73,7 +73,7 @@ This will create an optimized version of your project in the `build` directory.
7373
To preview the production build locally:
7474

7575
```bash
76-
npm run preview
76+
pnpm preview
7777
```
7878

7979
### Running Tests
@@ -85,72 +85,72 @@ npm run preview
8585
To run both unit and integration tests together:
8686

8787
```bash
88-
npm run test
88+
pnpm test
8989
```
9090

9191
#### Unit Tests
9292

9393
To run unit tests using Vitest:
9494

9595
```bash
96-
npm run test:unit
96+
pnpm test:unit
9797
```
9898

9999
To run unit tests once:
100100

101101
```bash
102-
npm run test:unit:once
102+
pnpm test:unit:once
103103
```
104104

105105
#### Integration Tests
106106

107107
To run integration tests using Playwright:
108108

109109
```bash
110-
npm run test:integration
110+
pnpm test:integration
111111
```
112112

113113
To run integration tests once:
114114

115115
```bash
116-
npm run test:integration:once
116+
pnpm test:integration:once
117117
```
118118

119119
For the Playwright UI to explore test results:
120120

121121
```bash
122-
npm run test:integration:ui
122+
pnpm test:integration:ui
123123
```
124124

125125
### Linting and Formatting
126126

127127
To check code formatting and linting issues:
128128

129129
```bash
130-
npm run lint
130+
pnpm lint
131131
```
132132

133133
To format the codebase:
134134

135135
```bash
136-
npm run format
136+
pnpm format
137137
```
138138

139139
### Type Checking
140140

141141
To check the TypeScript types:
142142

143143
```bash
144-
npm run check
144+
pnpm check
145145
```
146146

147147
To continuously check types while developing:
148148

149149
```bash
150-
npm run check:watch
150+
pnpm check:watch
151151
```
152152

153153
## Best Practices
154154

155-
1. **Code Style**: This project uses Prettier and ESLint for code formatting and linting. Please run `npm run lint` and `npm run format` before committing changes.
155+
1. **Code Style**: This project uses Prettier and ESLint for code formatting and linting. Please run `pnpm lint` and `pnpm format` before committing changes.
156156
2. **Testing**: Ensure all changes are covered with unit and integration tests. Use Vitest for unit tests and Playwright for integration tests.

0 commit comments

Comments
 (0)