Skip to content

Commit

Permalink
feat: add pnpm and bolt support
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jul 8, 2021
1 parent 7f933f9 commit 91465de
Show file tree
Hide file tree
Showing 47 changed files with 2,127 additions and 2,620 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ hacky [semantic-release](https://github.com/semantic-release/semantic-release) f
[![Maintainability](https://api.codeclimate.com/v1/badges/c6ee027803a794f1d67d/maintainability)](https://codeclimate.com/github/qiwi/multi-semantic-release/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/c6ee027803a794f1d67d/test_coverage)](https://codeclimate.com/github/qiwi/multi-semantic-release/test_coverage)

This fork of [dhoub/multi-semantic-release](https://github.com/dhoulb/multi-semantic-release) replaces [`setImmediate` loops](https://github.com/dhoulb/multi-semantic-release/blob/561a8e66133d422d88008c32c479d1148876aba4/lib/wait.js#L13)
This fork of [dhoub/multi-semantic-release](https://github.com/dhoulb/multi-semantic-release) replaces [`setImmediate` loops](https://github.com/dhoulb/multi-semantic-release/blob/561a8e66133d422d88008c32c479d1148876aba4/lib/wait.js#L13)
and [`execa.sync` hooks](https://github.com/dhoulb/multi-semantic-release/blob/561a8e66133d422d88008c32c479d1148876aba4/lib/execaHook.js#L5) with event-driven flow and finally makes possible to run the most release operations in parallel.
🎉 🎉 🎉

Expand Down Expand Up @@ -92,4 +92,4 @@ You can also combine the CLI ignore options with the `!` operator at each packag
We use this tool to release our JS platform code inhouse (GitHub Enterprise + JB TeamCity) and for our OSS (GitHub + Travis CI). Guaranteed working configurations available in projects.
* [qiwi/substrate](https://github.com/qiwi/substrate)
* [qiwi/json-rpc](https://github.com/qiwi/json-rpc)
* [qiwi/lint-config-qiwi](https://github.com/qiwi/lint-config-qiwi)
* [qiwi/lint-config-qiwi](https://github.com/qiwi/lint-config-qiwi)
8 changes: 4 additions & 4 deletions bin/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = (flags) => {
}

// Imports.
const getWorkspacesYarn = require("../lib/getWorkspacesYarn");
const getPackagePaths = require("../lib/getPackagePaths");
const multiSemanticRelease = require("../lib/multiSemanticRelease");
const multisemrelPkgJson = require("../package.json");
const semrelPkgJson = require("semantic-release/package.json");
Expand All @@ -18,9 +18,9 @@ module.exports = (flags) => {
console.log(`semantic-release version: ${semrelPkgJson.version}`);
console.log(`flags: ${JSON.stringify(flags, null, 2)}`);

// Get list of package.json paths according to Yarn workspaces.
const paths = getWorkspacesYarn(cwd, flags.ignorePackages);
console.log("yarn paths", paths);
// Get list of package.json paths according to workspaces.
const paths = getPackagePaths(cwd, flags.ignorePackages);
console.log("package paths", paths);

// Do multirelease (log out any errors).
multiSemanticRelease(paths, {}, { cwd }, flags).then(
Expand Down
56 changes: 56 additions & 0 deletions lib/getPackagePaths.js
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;
47 changes: 0 additions & 47 deletions lib/getWorkspacesYarn.js

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@
],
"modulePathIgnorePatterns": [
"<rootDir>/test/fixtures"
]
],
"testTimeout": 10000
},
"dependencies": {
"blork": "^9.3.0",
"@manypkg/get-packages": "^1.1.1",
"cosmiconfig": "^7.0.0",
"debug": "^4.3.1",
"detect-indent": "^6.0.0",
Expand Down
22 changes: 22 additions & 0 deletions test/fixtures/boltWorkspaces/package.json
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
}
}
8 changes: 8 additions & 0 deletions test/fixtures/boltWorkspaces/packages/a/package.json
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"
}
}
11 changes: 11 additions & 0 deletions test/fixtures/boltWorkspaces/packages/b/package.json
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"
}
}
3 changes: 3 additions & 0 deletions test/fixtures/boltWorkspaces/packages/c/.releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tagFormat": "multi-semantic-release-test-c@v${version}"
}
8 changes: 8 additions & 0 deletions test/fixtures/boltWorkspaces/packages/c/package.json
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": "*"
}
}
4 changes: 4 additions & 0 deletions test/fixtures/boltWorkspaces/packages/d/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "msr-test-d",
"version": "0.0.0"
}
23 changes: 23 additions & 0 deletions test/fixtures/boltWorkspacesIgnore/package.json
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
}
}
8 changes: 8 additions & 0 deletions test/fixtures/boltWorkspacesIgnore/packages/a/package.json
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 test/fixtures/boltWorkspacesIgnore/packages/b/package.json
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 test/fixtures/boltWorkspacesIgnore/packages/c/.releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tagFormat": "multi-semantic-release-test-c@v${version}"
}
8 changes: 8 additions & 0 deletions test/fixtures/boltWorkspacesIgnore/packages/c/package.json
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": "*"
}
}
4 changes: 4 additions & 0 deletions test/fixtures/boltWorkspacesIgnore/packages/d/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "msr-test-d",
"version": "0.0.0"
}
19 changes: 19 additions & 0 deletions test/fixtures/boltWorkspacesUndefined/package.json
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 test/fixtures/boltWorkspacesUndefined/packages/a/package.json
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"
}
}
11 changes: 11 additions & 0 deletions test/fixtures/boltWorkspacesUndefined/packages/b/package.json
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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tagFormat": "multi-semantic-release-test-c@v${version}"
}
8 changes: 8 additions & 0 deletions test/fixtures/boltWorkspacesUndefined/packages/c/package.json
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": "*"
}
}
4 changes: 4 additions & 0 deletions test/fixtures/boltWorkspacesUndefined/packages/d/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "msr-test-d",
"version": "0.0.0"
}
17 changes: 17 additions & 0 deletions test/fixtures/pnpmWorkspace/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "msr-test-pnpm",
"author": "Dave Houlbrooke <dave@shax.com>",
"version": "0.0.0-semantically-released",
"private": true,
"license": "0BSD",
"engines": {
"node": ">=8.3"
},
"release": {
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator"
],
"noCi": true
}
}
8 changes: 8 additions & 0 deletions test/fixtures/pnpmWorkspace/packages/a/package.json
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"
}
}
11 changes: 11 additions & 0 deletions test/fixtures/pnpmWorkspace/packages/b/package.json
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"
}
}
Loading

0 comments on commit 91465de

Please sign in to comment.