Skip to content

Commit 3690000

Browse files
committed
Update docs for corepack and pnpm
1 parent a11146d commit 3690000

File tree

5 files changed

+43
-34
lines changed

5 files changed

+43
-34
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It's not uncommon that people discover incorrect implementations of certain test
66

77
We welcome contributions of all sorts and sizes, from reporting issues to submitting patches, as well as joining the current [discussions 💬][issue-discussion].
88

9-
> [!WARNING]
9+
> [!WARNING]
1010
> This guide is slightly outdated and doesn't hold the V3 changes yet.
1111
1212
---
@@ -168,7 +168,7 @@ You may improve these files by making the required changes and opening a new Pul
168168
## Tools
169169

170170
You'll need LTS or higher Node.js to contribute to the _code_ in this repository.
171-
Run `npm install` in the root to be able to run the scripts as listed below.
171+
Run `corepack pnpm install` in the root to be able to run the scripts as listed below.
172172
We use the following dependencies:
173173

174174
- `shelljs` to provide shell interface to scripts
@@ -177,9 +177,9 @@ We use the following dependencies:
177177
- `babel` to transpile everything so it works _regardless of your version of Node.js_.
178178

179179
We also use `prettier` to format the files.
180-
**Prettier is installed when using `npm install`**.
181-
You may use `npx babel-node scripts/format` to run prettier.
182-
If you want to auto-format using your editor, install via `npm install` and it will Just Work™.
180+
**Prettier is installed when using `corepack pnpm install`**.
181+
You may use `corepack pnpm node scripts/format.mjs` to run prettier.
182+
If you want to auto-format using your editor, install via `corepack pnpm install` and it will Just Work™.
183183

184184
### Fetch configlet
185185

@@ -210,7 +210,7 @@ It then interactively gives the maintainer the option to include or exclude test
210210

211211
We have various `scripts` to aid with maintaining and contributing to this repository.
212212

213-
> [!IMPORTANT]
213+
> [!IMPORTANT]
214214
> If you encounter the following error:
215215
>
216216
> ```text
@@ -243,7 +243,7 @@ We have various `scripts` to aid with maintaining and contributing to this repos
243243
```
244244
245245
Use this action to format all the files using the correct version of prettier.
246-
If you want your editor to do this automatically, install the project development dependencies (`npm i`), which includes `prettier`.
246+
If you want your editor to do this automatically, install the project development dependencies (`corepack pnpm install`), which includes `prettier`.
247247
The correct version will be extracted when running `.github/workflows/verify-code-formatting.yml`.
248248

249249
#### `lint`

config/exercise-readme-insert.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@ Please `cd` into exercise directory before running all below commands.
1414
Install assignment dependencies:
1515

1616
```bash
17-
$ npm install
17+
$ corepack pnpm install
18+
```
19+
20+
If `corepack` complains about not being enabled, you can do so by running:
21+
22+
```bash
23+
corepack enable pnpm
1824
```
1925

2026
## Making the test suite pass
2127

2228
Execute the tests with:
2329

2430
```bash
25-
$ npm test
31+
$ corepack pnpm test
2632
```
2733

2834
In the test suites all tests but the first have been skipped.

docs/INSTALLATION.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ The version should match the one on the website.
7070
>
7171
> Close any open terminals and open a new one.
7272
73+
## Enabling corepack
74+
75+
In order to use a versioned package manager compatible with this track, `corepack` needs to be enabled once:
76+
77+
```shell
78+
corepack enable pnpm
79+
```
80+
7381
## Assignment Requirements
7482
7583
Please follow [these instructions][cli-walkthrough] to download the Exercism CLI for your OS.
@@ -84,26 +92,23 @@ Each assignment then needs some tools to run the tests.
8492
They can be installed running this command within each assignment directory:
8593
8694
```shell
87-
npm install
95+
corepack pnpm install
8896
```
8997
90-
> [!IMPORTANT] > _**Help**_: `'<package>' is missing / cannot be found`
91-
>
92-
> If you see this after _upgrading_ your exercise, welcome to npm 7.
93-
> Delete `node_modules` and `package-lock.json` and re-run the command to resolve this.
94-
95-
If you're concerned about disk space and are okay installing another tool, take a look at [pnpm](https://pnpm.io/), which ensure only one copy of each package-version is ever installed on disk.
96-
In this case, run `pnpm install` instead of `npm install`, and everything should work as expected.
98+
As this track has switched to pnpm, you should not be concerned about disk space.
99+
Take a look at [pnpm](https://pnpm.io/), which ensures only one copy of each package-version is ever installed on disk.
97100
98-
> **But what is npm and why does this work?**
101+
> **But what is corepack and why does this work?**
99102
>
100103
> You don't need this information to complete the JavaScript track, but if you're eager to understand what just happened, the following paragraphs are for you:
101104
>
102-
> This works because `npm` is a package manager that comes bundled with Node.js, which has been installed per the steps above.
103-
> The `npm` command looks for a `package.json` file, which is present in _each_ assignment folder.
104-
> This file lists the `"dependencies"` above, which are then downloaded by `npm` and placed into the `node_modules` folder.
105+
> This works because `corepack` is a tool that comes bundled with Node.js, which has been installed per the steps above.
106+
> It can install the package manager `pnpm`. It configures the system
107+
> The `corepack` command looks for a `package.json` file, which is present in _each_ assignment folder.
108+
> It then checks `packageManager` which matches `pnpm`, so it may continue. If necessary it will upgrade `pnpm` first.
109+
> This file also lists the `"dependencies"` above, which are then downloaded by `pnpm` and placed into a local cache.
105110
>
106-
> The scripts in the `package.json` use the binaries from the local `node_modules` folder, and it's these scripts that are used to run the tests, as listed in the `exercise` description.
111+
> The scripts in the `package.json` use the binaries from the local cache, and it's these scripts that are used to run the tests, as listed in the `exercise` description.
107112
108113
[web-nodejs]: https://nodejs.org/
109114
[web-nodejs-download]: https://nodejs.org/en/download/

docs/TESTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
Execute the tests with:
44

55
```shell
6-
npm run test
6+
corepack pnpm test
77
```
88

99
Be sure your code follows best practices and coding styles, as other users do, with ESLint, a tool to perform static analysis on your code.
1010
Sometimes, tools like this save you some time detecting typos or silly mistakes in your JavaScript code:
1111

1212
```shell
13-
npm run lint
13+
corepack pnpm lint
1414
```
1515

1616
You can also run Jest in "watch" mode, which will re-run your tests automatically when you save changes to the code or test module:
1717

1818
```shell
19-
npm run watch
19+
corepack pnpm watch
2020
```
2121

2222
## Understanding Skip Tests

exercises/shared/.docs/tests.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ Go through the setup [instructions for JavaScript][docs-exercism-javascript] to
99
Install assignment dependencies:
1010

1111
```shell
12-
# Using npm
13-
npm install
12+
corepack pnpm install
13+
```
14+
15+
If `corepack` complains about not being enabled, you can do so by running:
1416

15-
# Alternatively using yarn
16-
yarn
17+
```bash
18+
corepack enable pnpm
1719
```
1820

1921
## Making the test suite pass
@@ -22,11 +24,7 @@ All exercises come with a test suite to help you validate your solution before s
2224
You can execute these tests by opening a command prompt in the exercise's directory, and then running:
2325

2426
```bash
25-
# Using npm
26-
npm test
27-
28-
# Alternatively using yarn
29-
yarn test
27+
corepack pnpm test
3028
```
3129

3230
In some test suites all tests but the first have been skipped.

0 commit comments

Comments
 (0)