Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pnpm workspaces support #3284

Merged
merged 35 commits into from Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0333df7
feat(bootstrap): prevent bootstrapping when using pnpm
fahslaj Aug 4, 2022
c4cdcdc
chore(run): add tests for pnpm repo
fahslaj Aug 5, 2022
ded2d63
feat: enable parsing of workspace: dependency specs
fahslaj Aug 5, 2022
963de35
feat(version): update pnpm lockfile
fahslaj Aug 7, 2022
f932e63
chore(e2e): add lerna version test for pnpm
fahslaj Aug 8, 2022
bf285b3
feat(link): throw error when using link with pnpm workspace
fahslaj Aug 8, 2022
293c1b7
chore(e2e): update yarn and npm tests
fahslaj Aug 9, 2022
8c7c989
chore: minor PR style suggestions
fahslaj Aug 10, 2022
f1e0117
chore(e2e): add support for pnpm package manager
fahslaj Aug 10, 2022
e5601b2
feat: prevent usage of pnpm without workspaces
fahslaj Aug 10, 2022
1a02f26
feat(add): prevent usage with pnpm workspaces
fahslaj Aug 10, 2022
18ee9e8
feat: read packages config from pnpm-workspace.yaml
fahslaj Aug 11, 2022
4a973d8
chore: update unit test fixtures to have pnpm-workspace.yaml
fahslaj Aug 11, 2022
6809a67
chore(e2e): Update github action to include installing pnpm globally
fahslaj Aug 11, 2022
5544dfc
chore(e2e): commit changes for pnpm test
fahslaj Aug 11, 2022
22d822a
chore(docs): add doc for using pnpm with lerna
fahslaj Aug 11, 2022
05aca02
chore(e2e): remove useless registry argument from fixture
fahslaj Aug 11, 2022
5ca1b42
chore(docs): add recipes section with pnpm guide
fahslaj Aug 12, 2022
7ed1c1d
Merge branch 'main' into pnpm-support
JamesHenry Aug 14, 2022
d89992b
chore: fix merge conflict resolution typo
JamesHenry Aug 14, 2022
f80edbc
chore: error message format, async await in fixture, remove extra arg…
fahslaj Aug 15, 2022
9d77773
chore(add): update wording of pnpm error for consistency
fahslaj Aug 15, 2022
e24e606
chore(e2e): remove unused exports
fahslaj Aug 19, 2022
e28e1ba
chore(e2e): clarify test description message
fahslaj Aug 19, 2022
4b0c763
Merge branch 'main' into pnpm-support
fahslaj Aug 19, 2022
4eeb8b8
fix(version): ignore scripts on pnpm install to update lockfile
fahslaj Aug 19, 2022
711364c
chore(e2e): add test to cover pnpm lockfile update skipping install s…
fahslaj Aug 19, 2022
592efad
Merge branch 'main' into pnpm-support
fahslaj Aug 23, 2022
2b47157
fix(version): Update pnpm lockfile when on independent versions
fahslaj Aug 23, 2022
d67b578
Merge branch 'main' into pnpm-support
fahslaj Aug 23, 2022
fd2ead3
fix: add typescript dependency
fahslaj Aug 26, 2022
3b5b5aa
chore(e2e): Add test for lerna run with nx and pnpm
fahslaj Aug 26, 2022
00f511d
Merge branch 'main' into pnpm-support
fahslaj Aug 26, 2022
bfa4112
Merge branch 'main' into pnpm-support
fahslaj Aug 30, 2022
e5406d8
Merge branch 'main' into pnpm-support
fahslaj Aug 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/install-node-and-dependencies/action.yml
Expand Up @@ -31,3 +31,7 @@ runs:
- name: Install dependencies
run: npm ci
shell: bash

- name: Install pnpm
run: npm install -g pnpm
shell: bash
7 changes: 7 additions & 0 deletions commands/add/__tests__/__fixtures__/pnpm/lerna.json
@@ -0,0 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": false,
"useWorkspaces": true,
"version": "1.0.0",
"npmClient": "pnpm"
}
10 changes: 10 additions & 0 deletions commands/add/__tests__/__fixtures__/pnpm/package.json
@@ -0,0 +1,10 @@
{
"name": "root",
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"lerna": "^5.3.0"
}
}
@@ -0,0 +1,8 @@
{
"name": "package-1",
"version": "1.0.0",
"scripts": {
"fail": "exit 1",
"my-script": "echo package-1"
}
}
@@ -0,0 +1,11 @@
{
"name": "package-2",
"version": "1.0.0",
"scripts": {
"fail": "exit 1",
"my-script": "echo package-2"
},
"dependencies": {
"package-1": "^1.0.0"
}
}
2 changes: 2 additions & 0 deletions commands/add/__tests__/__fixtures__/pnpm/pnpm-workspace.yaml
@@ -0,0 +1,2 @@
packages:
- "packages/*"
9 changes: 9 additions & 0 deletions commands/add/__tests__/add-command.test.js
Expand Up @@ -44,6 +44,15 @@ describe("AddCommand", () => {
await expect(command).rejects.toThrow(/Requested package has no version:/);
});

it("should throw when using pnpm", async () => {
const testDir = await initFixture("pnpm");
const command = lernaAdd(testDir)("@test/package-1");

await expect(command).rejects.toThrow(
"The 'add' command is not supported when using `pnpm` workspaces. Use `pnpm` directly to add dependencies to packages: https://pnpm.io/cli/add."
JamesHenry marked this conversation as resolved.
Show resolved Hide resolved
);
});

it("should reference remote dependencies", async () => {
const testDir = await initFixture("basic");

Expand Down
7 changes: 7 additions & 0 deletions commands/add/index.js
Expand Up @@ -36,6 +36,13 @@ class AddCommand extends Command {
}

initialize() {
if (this.options.npmClient === "pnpm") {
throw new ValidationError(
"EPNPMNOTSUPPORTED",
"The 'add' command is not supported when using `pnpm` workspaces. Use `pnpm` directly to add dependencies to packages: https://pnpm.io/cli/add."
JamesHenry marked this conversation as resolved.
Show resolved Hide resolved
);
}

this.spec = npa(this.options.pkg);
this.dirs = new Set(this.options.globs.map((fp) => path.resolve(this.project.rootPath, fp)));
this.selfSatisfied = this.packageSatisfied();
Expand Down
7 changes: 7 additions & 0 deletions commands/bootstrap/__tests__/__fixtures__/pnpm/lerna.json
@@ -0,0 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": true,
"useWorkspaces": true,
"version": "1.0.0",
"npmClient": "pnpm"
}
10 changes: 10 additions & 0 deletions commands/bootstrap/__tests__/__fixtures__/pnpm/package.json
@@ -0,0 +1,10 @@
{
"name": "root",
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"lerna": "^5.3.0"
}
}
@@ -0,0 +1,2 @@
packages:
- "packages/*"
11 changes: 11 additions & 0 deletions commands/bootstrap/__tests__/bootstrap-command.test.js
Expand Up @@ -138,6 +138,17 @@ describe("BootstrapCommand", () => {
});
});

describe("with pnpm", () => {
it("should throw validation error", async () => {
const testDir = await initFixture("pnpm");
const command = lernaBootstrap(testDir)();

await expect(command).rejects.toThrow(
"Bootstrapping with pnpm is not supported. Use pnpm directly to manage dependencies (https://pnpm.io/cli/install)."
JamesHenry marked this conversation as resolved.
Show resolved Hide resolved
);
});
});

describe("with hoisting", () => {
it("should hoist", async () => {
const testDir = await initFixture("basic");
Expand Down
7 changes: 7 additions & 0 deletions commands/bootstrap/index.js
Expand Up @@ -38,6 +38,13 @@ class BootstrapCommand extends Command {
initialize() {
const { registry, npmClient = "npm", npmClientArgs = [], mutex, hoist, nohoist } = this.options;

if (npmClient === "pnpm") {
throw new ValidationError(
"EWORKSPACES",
"Bootstrapping with pnpm is not supported. Use pnpm directly to manage dependencies (https://pnpm.io/cli/install)."
JamesHenry marked this conversation as resolved.
Show resolved Hide resolved
);
}

if (npmClient === "yarn" && hoist) {
throw new ValidationError(
"EWORKSPACES",
Expand Down
7 changes: 7 additions & 0 deletions commands/link/__tests__/__fixtures__/pnpm/lerna.json
@@ -0,0 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": true,
"useWorkspaces": true,
"version": "1.0.0",
"npmClient": "pnpm"
}
10 changes: 10 additions & 0 deletions commands/link/__tests__/__fixtures__/pnpm/package.json
@@ -0,0 +1,10 @@
{
"name": "root",
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"lerna": "^5.3.0"
}
}
2 changes: 2 additions & 0 deletions commands/link/__tests__/__fixtures__/pnpm/pnpm-workspace.yaml
@@ -0,0 +1,2 @@
packages:
- "packages/*"