Skip to content

Commit 4a606b2

Browse files
committed
feat: support workspace.packages notation
1 parent 06e627a commit 4a606b2

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 <dave@shax.com",
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
@@ -2105,7 +2105,7 @@ debug@^3.1.0:
21052105
dependencies:
21062106
ms "^2.1.1"
21072107

2108-
debuglog@*, debuglog@^1.0.1:
2108+
debuglog@^1.0.1:
21092109
version "1.0.1"
21102110
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
21112111
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@@ -3389,7 +3389,7 @@ import-local@^3.0.2:
33893389
pkg-dir "^4.2.0"
33903390
resolve-cwd "^3.0.0"
33913391

3392-
imurmurhash@*, imurmurhash@^0.1.4:
3392+
imurmurhash@^0.1.4:
33933393
version "0.1.4"
33943394
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
33953395
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
@@ -4575,11 +4575,6 @@ lockfile@^1.0.4:
45754575
dependencies:
45764576
signal-exit "^3.0.2"
45774577

4578-
lodash._baseindexof@*:
4579-
version "3.1.0"
4580-
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
4581-
integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
4582-
45834578
lodash._baseuniq@~4.6.0:
45844579
version "4.6.0"
45854580
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
@@ -4588,33 +4583,11 @@ lodash._baseuniq@~4.6.0:
45884583
lodash._createset "~4.0.0"
45894584
lodash._root "~3.0.0"
45904585

4591-
lodash._bindcallback@*:
4592-
version "3.0.1"
4593-
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
4594-
integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
4595-
4596-
lodash._cacheindexof@*:
4597-
version "3.0.2"
4598-
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
4599-
integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
4600-
4601-
lodash._createcache@*:
4602-
version "3.1.2"
4603-
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
4604-
integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
4605-
dependencies:
4606-
lodash._getnative "^3.0.0"
4607-
46084586
lodash._createset@~4.0.0:
46094587
version "4.0.3"
46104588
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
46114589
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=
46124590

4613-
lodash._getnative@*, lodash._getnative@^3.0.0:
4614-
version "3.9.1"
4615-
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
4616-
integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
4617-
46184591
lodash._reinterpolate@^3.0.0:
46194592
version "3.0.0"
46204593
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
@@ -4655,11 +4628,6 @@ lodash.isstring@^4.0.1:
46554628
resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451"
46564629
integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=
46574630

4658-
lodash.restparam@*:
4659-
version "3.6.1"
4660-
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
4661-
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
4662-
46634631
lodash.sortby@^4.7.0:
46644632
version "4.7.0"
46654633
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"

0 commit comments

Comments
 (0)