-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workspaces): add support for npm, pnpm, bolt (#52)
- Loading branch information
Showing
47 changed files
with
645 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const getManifest = require("./getManifest"); | ||
const glob = require("./glob"); | ||
const path = require("path"); | ||
const { getPackagesSync } = require("@manypkg/get-packages"); | ||
|
||
/** | ||
* Return array of package.json for workspace packages. | ||
* | ||
* @param {string} cwd The current working directory where a package.json file can be found. | ||
* @param {string[]|null} ignorePackages (Optional) Packages to be ignored passed via cli. | ||
* @returns {string[]} An array of package.json files corresponding to the workspaces setting in package.json | ||
*/ | ||
function getPackagePaths(cwd, ignorePackages = null) { | ||
let workspace; | ||
// Ignore exceptions as we will rely on `getManifest` validation | ||
try { | ||
workspace = getPackagesSync(cwd); | ||
} catch (e) { | ||
/**/ | ||
} | ||
workspace = workspace || { | ||
tool: "root", | ||
root: { dir: cwd }, | ||
}; | ||
workspace.root.packageJson = getManifest(path.join(workspace.root.dir, "package.json")); | ||
|
||
if (workspace.tool === "root") { | ||
workspace.packages = []; | ||
} | ||
|
||
// remove cwd from results | ||
const packages = workspace.packages.map((p) => path.relative(cwd, p.dir)); | ||
|
||
// If packages to be ignored come from CLI, we need to combine them with the ones from manifest workspaces | ||
if (Array.isArray(ignorePackages)) packages.push(...ignorePackages.map((p) => `!${p}`)); | ||
|
||
// Turn workspaces into list of package.json files. | ||
const workspacePackages = glob( | ||
packages.map((p) => p.replace(/\/?$/, "/package.json")), | ||
{ | ||
cwd: cwd, | ||
absolute: true, | ||
gitignore: true, | ||
} | ||
); | ||
|
||
// Must have at least one workspace-package. | ||
if (!workspacePackages.length) | ||
throw new TypeError("package.json: Project must contain one or more workspace-packages"); | ||
|
||
// Return. | ||
return workspacePackages; | ||
} | ||
|
||
// Exports. | ||
module.exports = getPackagePaths; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "msr-test-bolt", | ||
"author": "Dave Houlbrooke <dave@shax.com>", | ||
"version": "0.0.0-semantically-released", | ||
"private": true, | ||
"license": "0BSD", | ||
"engines": { | ||
"node": ">=8.3" | ||
}, | ||
"bolt": { | ||
"workspaces": [ | ||
"packages/*" | ||
] | ||
}, | ||
"release": { | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator" | ||
], | ||
"noCi": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "msr-test-a", | ||
"version": "0.0.0", | ||
"peerDependencies": { | ||
"msr-test-c": "*", | ||
"left-pad": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "msr-test-b", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"msr-test-a": "*" | ||
}, | ||
"devDependencies": { | ||
"msr-test-c": "*", | ||
"left-pad": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"tagFormat": "multi-semantic-release-test-c@v${version}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "msr-test-c", | ||
"version": "0.0.0", | ||
"devDependencies": { | ||
"msr-test-b": "*", | ||
"msr-test-d": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "msr-test-d", | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "msr-test-bolt", | ||
"author": "Dave Houlbrooke <dave@shax.com", | ||
"version": "0.0.0-semantically-released", | ||
"private": true, | ||
"license": "0BSD", | ||
"engines": { | ||
"node": ">=8.3" | ||
}, | ||
"bolt": { | ||
"workspaces": [ | ||
"packages/*", | ||
"!packages/d/**" | ||
] | ||
}, | ||
"release": { | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator" | ||
], | ||
"noCi": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "msr-test-a", | ||
"version": "0.0.0", | ||
"peerDependencies": { | ||
"msr-test-c": "*", | ||
"left-pad": "latest" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/fixtures/boltWorkspacesIgnore/packages/b/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
{ | ||
"name": "msr-test-b", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"msr-test-a": "*" | ||
}, | ||
"devDependencies": { | ||
"msr-test-c": "*", | ||
"left-pad": "latest" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/boltWorkspacesIgnore/packages/c/.releaserc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"tagFormat": "multi-semantic-release-test-c@v${version}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "msr-test-c", | ||
"version": "0.0.0", | ||
"devDependencies": { | ||
"msr-test-b": "*", | ||
"msr-test-d": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "msr-test-d", | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "msr-test-bolt", | ||
"author": "Dave Houlbrooke <dave@shax.com>", | ||
"version": "0.0.0-semantically-released", | ||
"private": true, | ||
"license": "0BSD", | ||
"engines": { | ||
"node": ">=8.3" | ||
}, | ||
"bolt": { | ||
}, | ||
"release": { | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator" | ||
], | ||
"noCi": true | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test/fixtures/boltWorkspacesUndefined/packages/a/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "msr-test-a", | ||
"version": "0.0.0", | ||
"peerDependencies": { | ||
"msr-test-c": "*", | ||
"left-pad": "latest" | ||
} | ||
} |
Oops, something went wrong.