Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release-it-yarn-workspaces when ran within a monorepo. #48

Merged
merged 2 commits into from
Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions bin/rwjblue-release-it-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const RELEASE_IT_LERNA_CHANGELOG_VERSION = (() => {
return pkg.devDependencies['release-it-lerna-changelog'];
})();

const RELEASE_IT_YARN_WORKSPACES_VERSION = (() => {
let pkg = require('../package');

return pkg.devDependencies['release-it-yarn-workspaces'];
})();

const DETECT_TRAILING_WHITESPACE = /\s+$/;

function getDependencyRange(theirs, ours) {
Expand Down Expand Up @@ -57,6 +63,7 @@ function updatePackageJSON() {
let contents = fs.readFileSync('package.json', { encoding: 'utf8' });
let trailingWhitespace = DETECT_TRAILING_WHITESPACE.exec(contents);
let pkg = JSON.parse(contents);
let hasWorkspaces = !!pkg.workspaces;

if (labelsOnly) {
return pkg;
Expand All @@ -72,6 +79,13 @@ function updatePackageJSON() {
RELEASE_IT_LERNA_CHANGELOG_VERSION
);

if (hasWorkspaces) {
pkg.devDependencies['release-it-yarn-workspaces'] = getDependencyRange(
pkg.devDependencies['release-it-yarn-workspaces'],
RELEASE_IT_YARN_WORKSPACES_VERSION
);
}

let releaseItConfig = pkg['release-it'] || {};
pkg['release-it'] = releaseItConfig;

Expand All @@ -83,6 +97,10 @@ function updatePackageJSON() {
},
releaseItConfig.plugins['release-it-lerna-changelog']
);
if (hasWorkspaces && releaseItConfig.plugins['release-it-yarn-workspaces'] !== false) {
releaseItConfig.plugins['release-it-yarn-workspaces'] = true;
}

releaseItConfig.git = Object.assign(
{
tagName: 'v${version}',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"prettier": "^2.0.2",
"qunit": "^2.9.3",
"release-it": "^13.1.2",
"release-it-lerna-changelog": "^2.1.1"
"release-it-lerna-changelog": "^2.1.1",
"release-it-yarn-workspaces": "^1.0.2"
},
"engines": {
"node": ">= 10"
Expand Down
45 changes: 45 additions & 0 deletions tests/bin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,51 @@ QUnit.module('main binary', function (hooks) {
assert.deepEqual(pkg, expected);
});

QUnit.test('adds release-it configuration for monoreposa to package.json', async function (
assert
) {
project.pkg.workspaces = ['packages/*'];
project.writeSync();

let premodificationPackageJSON = JSON.parse(project.toJSON('package.json'));

await exec(['--no-install', '--no-label-updates']);

let pkg = JSON.parse(fs.readFileSync('package.json', { encoding: 'utf8' }));
let expected = mergePackageJSON(premodificationPackageJSON, {
devDependencies: {
'release-it': require('../package').devDependencies['release-it'],
'release-it-lerna-changelog': require('../package').devDependencies[
'release-it-lerna-changelog'
],
'release-it-yarn-workspaces': require('../package').devDependencies[
'release-it-yarn-workspaces'
],
},
publishConfig: {
registry: 'https://registry.npmjs.org',
},
'release-it': {
plugins: {
'release-it-lerna-changelog': {
infile: 'CHANGELOG.md',
launchEditor: true,
},
'release-it-yarn-workspaces': true,
},
git: {
tagName: 'v${version}',
},
github: {
release: true,
tokenRef: 'GITHUB_AUTH',
},
},
});

assert.deepEqual(pkg, expected);
});

QUnit.test('does not remove existing release-it configuration', async function (assert) {
project.pkg['release-it'] = {
hooks: {
Expand Down
71 changes: 43 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@
resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e"
integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw==

"@octokit/plugin-rest-endpoint-methods@^3.3.0":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-3.3.1.tgz#279920ee391bd7e944ae4aa7fa435ba0c51fbb6a"
integrity sha512-iLAXPLWBZaP6ocy1GFfZUCzyN4cwg3y2JE6yZjQo0zLE3UaewC3TI68/TnS4ilyhXDxh81Jr1qwPN1AqTp8t3w==
"@octokit/plugin-rest-endpoint-methods@3.4.0", "@octokit/plugin-rest-endpoint-methods@^3.3.0":
version "3.4.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-3.4.0.tgz#27b1dac7fba4d0d6e488967919b6a5bd3595ffbc"
integrity sha512-Tvctk0u5SVrSLAzi8SLo0KrLSBl5biAHBgWy3L65vsbO/2fjzr62HVkoDPyr+WRT+eHhhqpKAERF3dQWOIUOvQ==
dependencies:
"@octokit/types" "^2.0.1"
deprecation "^2.3.1"
Expand Down Expand Up @@ -148,6 +148,16 @@
"@octokit/plugin-request-log" "^1.0.0"
"@octokit/plugin-rest-endpoint-methods" "^3.3.0"

"@octokit/rest@17.1.4":
version "17.1.4"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-17.1.4.tgz#b03eb97635de62b48428f998ad1cb9244edd2d10"
integrity sha512-LGghhepxoXyvi7ew0OdedrlwXQog8gvTbcdXoQ6RDKnzoYW2rBpcqeWC4fTuPUp9K0UEykcMix8kFnQ5b+64JQ==
dependencies:
"@octokit/core" "^2.4.3"
"@octokit/plugin-paginate-rest" "^2.0.0"
"@octokit/plugin-request-log" "^1.0.0"
"@octokit/plugin-rest-endpoint-methods" "3.4.0"

"@octokit/types@^2.0.0", "@octokit/types@^2.0.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.3.1.tgz#40cd61c125a6161cfb3bfabc75805ac7a54213b4"
Expand Down Expand Up @@ -868,7 +878,7 @@ detect-indent@^6.0.0:
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.0.0.tgz#0abd0f549f69fc6659a254fe96786186b6f528fd"
integrity sha512-oSyFlqaTHCItVRGK5RmrmjB+CmaMOW7IaNA/kdxqhoa6d17j/5ce9O9eWXmV/KEdRwqpQA+Vqe8a8Bsybu4YnA==

detect-newline@3.1.0:
detect-newline@3.1.0, detect-newline@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==
Expand Down Expand Up @@ -2851,13 +2861,25 @@ release-it-lerna-changelog@^2.1.1:
release-it "^13.3.0"
tmp "^0.1.0"

release-it@^13.1.2, release-it@^13.3.0:
version "13.3.1"
resolved "https://registry.yarnpkg.com/release-it/-/release-it-13.3.1.tgz#3792f3fdf3bd209e0c294c21ea40cfed599246fb"
integrity sha512-juKrG8sReAHbEot6VCWbFSaoUnyu7o2WWDFbdu5BbX8FZAIvF3SOYM1fS9GRIwG10xBDogokMFqu/eO1UK8WRQ==
release-it-yarn-workspaces@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/release-it-yarn-workspaces/-/release-it-yarn-workspaces-1.0.2.tgz#011ef318adb2145c0605636fe17dc847e028ace2"
integrity sha512-1naW1SqBc2/t7w5HBA8bkQ1xfYZ+ZuSk+DiyWvDsHpddWv75cQgzPfrCCa2dEqieumlLsWpLSf2DysnJEmwkNA==
dependencies:
detect-indent "^6.0.0"
detect-newline "^3.1.0"
release-it "^13.3.2"
semver "^7.1.3"
url-join "^4.0.1"
walk-sync "^2.0.2"

release-it@^13.1.2, release-it@^13.3.0, release-it@^13.3.2:
version "13.5.0"
resolved "https://registry.yarnpkg.com/release-it/-/release-it-13.5.0.tgz#716ec42c4c06ae1b5f7c667466aa62b3c645faaf"
integrity sha512-jArSTUaGzQiWjEUCwWG5chNmE1xNTaI9HQQhPPIJfzk+cL6KvT5MwRkaUQeJbTkrqlB5UjIM9sF35OMndEUuUA==
dependencies:
"@iarna/toml" "2.2.3"
"@octokit/rest" "17.1.2"
"@octokit/rest" "17.1.4"
async-retry "1.3.1"
chalk "3.0.0"
cosmiconfig "6.0.0"
Expand Down Expand Up @@ -2886,7 +2908,7 @@ release-it@^13.1.2, release-it@^13.3.0:
uuid "7.0.2"
window-size "1.1.1"
yaml "1.8.3"
yargs-parser "18.1.1"
yargs-parser "18.1.2"

request@^2.72.0:
version "2.88.2"
Expand Down Expand Up @@ -3477,7 +3499,7 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

url-join@4.0.1:
url-join@4.0.1, url-join@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.1.tgz#b642e21a2646808ffa178c4c5fda39844e12cde7"
integrity sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==
Expand Down Expand Up @@ -3652,20 +3674,13 @@ yallist@^4.0.0:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

yaml@1.8.3:
yaml@1.8.3, yaml@^1.7.2:
version "1.8.3"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.8.3.tgz#2f420fca58b68ce3a332d0ca64be1d191dd3f87a"
integrity sha512-X/v7VDnK+sxbQ2Imq4Jt2PRUsRsP7UcpSl3Llg6+NRRqWLIvxkMFYtH1FmvwNGYRKKPa+EPA4qDBlI9WVG1UKw==
dependencies:
"@babel/runtime" "^7.8.7"

yaml@^1.7.2:
version "1.8.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.8.2.tgz#a29c03f578faafd57dcb27055f9a5d569cb0c3d9"
integrity sha512-omakb0d7FjMo3R1D2EbTKVIk6dAVLRxFXdLZMEUToeAvuqgG/YuHMuQOZ5fgk+vQ8cx+cnGKwyg+8g8PNT0xQg==
dependencies:
"@babel/runtime" "^7.8.7"

yargs-parser@18.1.1:
version "18.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.1.tgz#bf7407b915427fc760fcbbccc6c82b4f0ffcbd37"
Expand All @@ -3674,18 +3689,18 @@ yargs-parser@18.1.1:
camelcase "^5.0.0"
decamelize "^1.2.0"

yargs-parser@^13.1.1:
version "13.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.1.tgz#d26058532aa06d365fe091f6a1fc06b2f7e5eca0"
integrity sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==
yargs-parser@18.1.2, yargs-parser@^18.1.0:
version "18.1.2"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.2.tgz#2f482bea2136dbde0861683abea7756d30b504f1"
integrity sha512-hlIPNR3IzC1YuL1c2UwwDKpXlNFBqD1Fswwh1khz5+d8Cq/8yc/Mn0i+rQXduu8hcrFKvO7Eryk+09NecTQAAQ==
dependencies:
camelcase "^5.0.0"
decamelize "^1.2.0"

yargs-parser@^18.1.0:
version "18.1.0"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.0.tgz#1b0ab1118ebd41f68bb30e729f4c83df36ae84c3"
integrity sha512-o/Jr6JBOv6Yx3pL+5naWSoIA2jJ+ZkMYQG/ie9qFbukBe4uzmBatlXFOiu/tNKRWEtyf+n5w7jc/O16ufqOTdQ==
yargs-parser@^13.1.1:
version "13.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.1.tgz#d26058532aa06d365fe091f6a1fc06b2f7e5eca0"
integrity sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==
dependencies:
camelcase "^5.0.0"
decamelize "^1.2.0"
Expand Down