Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b18dbe

Browse files
authored
feat: pnpm workspaces support (#3284)
1 parent 1d6a6f5 commit 1b18dbe

File tree

54 files changed

+1711
-354
lines changed

Some content is hidden

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

54 files changed

+1711
-354
lines changed

.github/actions/install-node-and-dependencies/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ runs:
3131
- name: Install dependencies
3232
run: npm ci
3333
shell: bash
34+
35+
- name: Install pnpm
36+
run: npm install -g pnpm
37+
shell: bash
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3+
"useNx": false,
4+
"useWorkspaces": true,
5+
"version": "1.0.0",
6+
"npmClient": "pnpm"
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "root",
3+
"private": true,
4+
"workspaces": [
5+
"packages/*"
6+
],
7+
"devDependencies": {
8+
"lerna": "^5.3.0"
9+
}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "package-1",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"fail": "exit 1",
6+
"my-script": "echo package-1"
7+
}
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "package-2",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"fail": "exit 1",
6+
"my-script": "echo package-2"
7+
},
8+
"dependencies": {
9+
"package-1": "^1.0.0"
10+
}
11+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages:
2+
- "packages/*"

commands/add/__tests__/add-command.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ describe("AddCommand", () => {
4444
await expect(command).rejects.toThrow(/Requested package has no version:/);
4545
});
4646

47+
it("should throw when using pnpm", async () => {
48+
const testDir = await initFixture("pnpm");
49+
const command = lernaAdd(testDir)("@test/package-1");
50+
51+
await expect(command).rejects.toThrow(
52+
"Add is not supported when using `pnpm` workspaces. Use `pnpm` directly to add dependencies to packages: https://pnpm.io/cli/add"
53+
);
54+
});
55+
4756
it("should reference remote dependencies", async () => {
4857
const testDir = await initFixture("basic");
4958

commands/add/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ class AddCommand extends Command {
3636
}
3737

3838
initialize() {
39+
if (this.options.npmClient === "pnpm") {
40+
throw new ValidationError(
41+
"EPNPMNOTSUPPORTED",
42+
"Add is not supported when using `pnpm` workspaces. Use `pnpm` directly to add dependencies to packages: https://pnpm.io/cli/add"
43+
);
44+
}
45+
3946
this.spec = npa(this.options.pkg);
4047
this.dirs = new Set(this.options.globs.map((fp) => path.resolve(this.project.rootPath, fp)));
4148
this.selfSatisfied = this.packageSatisfied();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3+
"useNx": true,
4+
"useWorkspaces": true,
5+
"version": "1.0.0",
6+
"npmClient": "pnpm"
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "root",
3+
"private": true,
4+
"workspaces": [
5+
"packages/*"
6+
],
7+
"devDependencies": {
8+
"lerna": "^5.3.0"
9+
}
10+
}

0 commit comments

Comments
 (0)