Skip to content

Commit 41e81a5

Browse files
committed
chore: configure release-it for monorepo
1 parent d3b19f5 commit 41e81a5

File tree

8 files changed

+264
-57
lines changed

8 files changed

+264
-57
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
"react-dom": "16.13.1",
3232
"react-native": "https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz",
3333
"react-test-renderer": "16.13.1",
34-
"react-native-webview": "10.7.0"
34+
"react-native-webview": "10.7.0",
35+
"@release-it/conventional-changelog": "patch:@release-it/conventional-changelog@2.0.0#patches/@release-it-conventional-changelog.patch",
36+
"release-it": "patch:release-it@14.0.4#patches/release-it.patch"
3537
},
3638
"author": "Jules Sam. Randolph <jules.sam.randolph@gmail.com> (https://github.com/jsamr)",
3739
"license": "MIT",

packages/iframe-plugin/.release-it.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const name = require('./package.json').name;
2+
const configureRelease = require("release-config");
3+
module.exports = configureRelease(name);

packages/release-config/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = function (name) {
2+
const template = name + '@${version}';
3+
return {
4+
git: {
5+
commitMessage: 'chore: release ' + template,
6+
tagName: template
7+
},
8+
npm: {
9+
publish: true
10+
},
11+
github: {
12+
release: true,
13+
releaseName: template
14+
},
15+
plugins: {
16+
'@release-it/conventional-changelog': {
17+
preset: 'angular',
18+
infile: 'CHANGELOG.md'
19+
}
20+
}
21+
};
22+
};

packages/release-config/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "release-config",
3+
"version": "1.0.0",
4+
"private": true,
5+
"main": "index.js"
6+
}

packages/table-plugin/.release-it.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const name = require('./package.json').name;
2+
const configureRelease = require("release-config");
3+
module.exports = configureRelease(name);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
diff --git a/index.js b/index.js
2+
index abbce1815895b044bac47588a327f1b049304b8d..e31f4ee93c6896fefb30552e8bf89f6c182610a4 100644
3+
--- a/index.js
4+
+++ b/index.js
5+
@@ -1,6 +1,7 @@
6+
const { EOL } = require('os');
7+
const fs = require('fs');
8+
const { Plugin } = require('release-it');
9+
+const { format } = require('release-it/lib/util');
10+
const conventionalRecommendedBump = require('conventional-recommended-bump');
11+
const conventionalChangelog = require('conventional-changelog');
12+
const semver = require('semver');
13+
@@ -14,7 +15,8 @@ class ConventionalChangelog extends Plugin {
14+
15+
getInitialOptions(options, namespace) {
16+
options[namespace].tagName = options.git.tagName;
17+
- return options[namespace];
18+
+ const tagPrefix = format(options.git.tagName || '${version}', { version: '' });
19+
+ return {...options[namespace], path: './', tagPrefix};
20+
}
21+
22+
async getChangelog(latestVersion) {
23+
@@ -68,7 +70,8 @@ class ConventionalChangelog extends Plugin {
24+
Object.assign(options, this.options),
25+
{ version, previousTag, currentTag },
26+
{
27+
- debug: this.config.isDebug ? this.debug : null
28+
+ debug: this.config.isDebug ? this.debug : null,
29+
+ path: this.options.path
30+
}
31+
);
32+
}

patches/release-it.patch

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
diff --git a/lib/plugin/GitBase.js b/lib/plugin/GitBase.js
2+
index dcf35ed4cafb14e1f823a3929e5534039e690652..f4c3129bae4c6c25fe05a72b8d831fe3bda4a7d2 100644
3+
--- a/lib/plugin/GitBase.js
4+
+++ b/lib/plugin/GitBase.js
5+
@@ -14,7 +14,7 @@ class GitBase extends Plugin {
6+
await this.fetch();
7+
const repo = parseGitUrl(this.remoteUrl);
8+
const latestTagName = await this.getLatestTagName();
9+
- const secondLatestTagName = this.options.isUpdate ? await this.getSecondLatestTagName() : null;
10+
+ const secondLatestTagName = this.options.isUpdate ? await this.getSecondLatestTagName(latestTagName) : null;
11+
const tagTemplate = this.options.tagName || ((latestTagName || '').match(/^v/) ? 'v${version}' : '${version}');
12+
this.setContext({ repo, tagTemplate, latestTagName, secondLatestTagName });
13+
this.config.setContext({ latestTag: latestTagName });
14+
@@ -89,14 +89,15 @@ class GitBase extends Plugin {
15+
}
16+
17+
getLatestTagName() {
18+
- return this.exec('git describe --tags --abbrev=0', { options }).then(
19+
+ const match = format(this.options.tagName || '${version}', { version: "*" })
20+
+ return this.exec(`git describe --tags --match "${match}" --abbrev=0`, { options }).then(
21+
stdout => stdout || null,
22+
() => null
23+
);
24+
}
25+
26+
- async getSecondLatestTagName() {
27+
- const sha = await this.exec('git rev-list --tags --skip=1 --max-count=1', { options });
28+
+ async getSecondLatestTagName(latestTag) {
29+
+ const sha = await this.exec(`git rev-list ${latestTag} --tags --max-count=1`, { options });
30+
return this.exec(`git describe --tags --abbrev=0 ${sha}`, { options }).catch(() => null);
31+
}
32+
}
33+
diff --git a/lib/plugin/npm/npm.js b/lib/plugin/npm/npm.js
34+
index 12a28d26db8d78fa7ce011d8d201668fb21b8f97..65be3f3bd7fb370cf95cee794c288ded15149558 100644
35+
--- a/lib/plugin/npm/npm.js
36+
+++ b/lib/plugin/npm/npm.js
37+
@@ -229,7 +229,7 @@ class npm extends Plugin {
38+
this.log.warn('Skip publish: package is private.');
39+
return false;
40+
}
41+
- return this.exec(`npm publish ${publishPath} --tag ${tag} ${otpArg} ${dryRunArg}`, { options })
42+
+ return (this.config.isDryRun ? this.exec(`npm publish ${publishPath} --tag ${tag} ${otpArg} ${dryRunArg}`, { options }) : this.exec(`yarn npm publish --tag ${tag}`, { options }))
43+
.then(() => {
44+
this.setContext({ isReleased: true });
45+
})

0 commit comments

Comments
 (0)