Skip to content

Commit cd0ee38

Browse files
authored
feat: support workspace.packages notation (#23)
feat: support workspace.packages notation
2 parents 01aa116 + 18d86f6 commit cd0ee38

File tree

9 files changed

+75
-38
lines changed

9 files changed

+75
-38
lines changed

lib/getWorkspacesYarn.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ function getWorkspacesYarn(cwd) {
1212
// Load package.json
1313
const manifest = getManifest(`${cwd}/package.json`);
1414

15-
// Only continue if manifest.workspaces is an array of strings.
16-
if (!checker("string[]+")(manifest.workspaces))
17-
throw new TypeError("package.json: workspaces: Must be non-empty array of string");
15+
let packages = manifest.workspaces;
16+
if (packages && packages.packages) {
17+
packages = packages.packages;
18+
}
19+
20+
// Only continue if manifest.workspaces or manifest.workspaces.packages is an array of strings.
21+
if (!checker("string[]+")(packages)) {
22+
throw new TypeError("package.json: workspaces or workspaces.packages: Must be non-empty array of string");
23+
}
1824

1925
// Turn workspaces into list of package.json files.
2026
const workspaces = glob.sync(
21-
manifest.workspaces.map((p) => p.replace(/\/?$/, "/package.json")),
27+
packages.map((p) => p.replace(/\/?$/, "/package.json")),
2228
{
2329
cwd: cwd,
2430
realpath: true,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "msr-test-yarn",
3+
"author": "Dave Houlbrooke <[email protected]",
4+
"version": "0.0.0-semantically-released",
5+
"private": true,
6+
"license": "0BSD",
7+
"engines": {
8+
"node": ">=8.3"
9+
},
10+
"workspaces": {
11+
"packages": ["packages/*"]
12+
},
13+
"release": {
14+
"plugins": [
15+
"@semantic-release/commit-analyzer",
16+
"@semantic-release/release-notes-generator"
17+
],
18+
"noCi": true
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "msr-test-a",
3+
"version": "0.0.0",
4+
"peerDependencies": {
5+
"msr-test-c": "*",
6+
"left-pad": "latest"
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "msr-test-b",
3+
"version": "0.0.0",
4+
"dependencies": {
5+
"msr-test-a": "*"
6+
},
7+
"devDependencies": {
8+
"msr-test-c": "*",
9+
"left-pad": "latest"
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"tagFormat": "multi-semantic-release-test-c@v${version}"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "msr-test-c",
3+
"version": "0.0.0",
4+
"devDependencies": {
5+
"msr-test-b": "*",
6+
"msr-test-d": "*"
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "msr-test-d",
3+
"version": "0.0.0"
4+
}

test/lib/getWorkspacesYarn.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,13 @@ describe("getWorkspacesYarn()", () => {
2727
expect(() => getWorkspacesYarn(resolved)).toThrow(Error);
2828
expect(() => getWorkspacesYarn(resolved)).toThrow("contain one or more workspaces");
2929
});
30+
test("Works correctly with workspaces.packages", () => {
31+
const resolved = resolve(`${__dirname}/../fixtures/yarnWorkspacesPackages`);
32+
expect(getWorkspacesYarn(resolved)).toEqual([
33+
`${resolved}/packages/a/package.json`,
34+
`${resolved}/packages/b/package.json`,
35+
`${resolved}/packages/c/package.json`,
36+
`${resolved}/packages/d/package.json`,
37+
]);
38+
});
3039
});

yarn.lock

+2-34
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ debug@^3.1.0:
20592059
dependencies:
20602060
ms "^2.1.1"
20612061

2062-
debuglog@*, debuglog@^1.0.1:
2062+
debuglog@^1.0.1:
20632063
version "1.0.1"
20642064
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
20652065
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@@ -3338,7 +3338,7 @@ import-local@^3.0.2:
33383338
pkg-dir "^4.2.0"
33393339
resolve-cwd "^3.0.0"
33403340

3341-
imurmurhash@*, imurmurhash@^0.1.4:
3341+
imurmurhash@^0.1.4:
33423342
version "0.1.4"
33433343
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
33443344
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
@@ -4519,11 +4519,6 @@ lockfile@^1.0.4:
45194519
dependencies:
45204520
signal-exit "^3.0.2"
45214521

4522-
lodash._baseindexof@*:
4523-
version "3.1.0"
4524-
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
4525-
integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
4526-
45274522
lodash._baseuniq@~4.6.0:
45284523
version "4.6.0"
45294524
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
@@ -4532,33 +4527,11 @@ lodash._baseuniq@~4.6.0:
45324527
lodash._createset "~4.0.0"
45334528
lodash._root "~3.0.0"
45344529

4535-
lodash._bindcallback@*:
4536-
version "3.0.1"
4537-
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
4538-
integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
4539-
4540-
lodash._cacheindexof@*:
4541-
version "3.0.2"
4542-
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
4543-
integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
4544-
4545-
lodash._createcache@*:
4546-
version "3.1.2"
4547-
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
4548-
integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
4549-
dependencies:
4550-
lodash._getnative "^3.0.0"
4551-
45524530
lodash._createset@~4.0.0:
45534531
version "4.0.3"
45544532
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
45554533
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=
45564534

4557-
lodash._getnative@*, lodash._getnative@^3.0.0:
4558-
version "3.9.1"
4559-
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
4560-
integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
4561-
45624535
lodash._reinterpolate@^3.0.0:
45634536
version "3.0.0"
45644537
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
@@ -4599,11 +4572,6 @@ lodash.isstring@^4.0.1:
45994572
resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451"
46004573
integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=
46014574

4602-
lodash.restparam@*:
4603-
version "3.6.1"
4604-
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
4605-
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
4606-
46074575
lodash.sortby@^4.7.0:
46084576
version "4.7.0"
46094577
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"

0 commit comments

Comments
 (0)