File tree Expand file tree Collapse file tree 4 files changed +51
-6
lines changed Expand file tree Collapse file tree 4 files changed +51
-6
lines changed Original file line number Diff line number Diff line change 22 "git" : {
33 "tagName" : " v${version}" ,
44 "commitMessage" : " Release v${version}" ,
5- "requireBranch" : " main"
5+ "requireBranch" : " main" ,
6+ "requireCommits" : true
67 },
78 "hooks" : {
9+ "before:init" : [
10+ " yarn before-release-init"
11+ ],
812 "after:bump" : [
913 " yarn changelog" ,
1014 " git add CHANGELOG.md"
1115 ],
1216 "before:npm:release" : [
13- " rimraf lib " ,
17+ " yarn clean-build " ,
1418 " yarn build"
1519 ]
1620 },
Original file line number Diff line number Diff line change 1+ /* eslint-disable no-console */
2+ import shell from 'shelljs' ;
3+
4+ const upstream = '@{u}' ;
5+
6+ const isUpstreamConfigured =
7+ shell . exec ( `git rev-parse --abbrev-ref --symbolic-full-name ${ upstream } ` ) . code === 0 ;
8+
9+ if ( ! isUpstreamConfigured ) {
10+ console . error ( 'You must configure upstream for the branch.' ) ;
11+ shell . exit ( ) ;
12+ }
13+
14+ const local = shell . exec ( 'git rev-parse @' ) ;
15+ const remote = shell . exec ( `git rev-parse ${ upstream } ` ) ;
16+ const base = shell . exec ( `git merge-base @ ${ upstream } ` ) ;
17+
18+ // Branch is up to date with or ahead to remote.
19+ if ( local === remote || remote === base ) {
20+ shell . exit ( 0 ) ;
21+ }
22+
23+ // The local branch is behind the remote version, a pull is needed.
24+ if ( local === base ) {
25+ console . error ( 'The local branch is behind the remote version' ) ;
26+ shell . exit ( ) ;
27+ }
28+
29+ // Local and remote diverged.
30+ console . log ( 'Local branch and remote branch diverged!' ) ;
31+ shell . exit ( ) ;
Original file line number Diff line number Diff line change 4040 "react-dom" : " ^17.0.2" ,
4141 "react-hooks-testing-library" : " ^0.6.0" ,
4242 "release-it" : " ^14.11.6" ,
43- "rimraf" : " ^3.0.2" ,
43+ "shelljs" : " ^0.8.4" ,
44+ "shx" : " ^0.3.3" ,
4445 "ts-jest" : " ^27.0.5" ,
4546 "typescript" : " ^4.4.3"
4647 },
4748 "scripts" : {
48- "rim " : " rimraf lib " ,
49+ "before-release-init " : " node ./bin/before-release-init.mjs " ,
4950 "build" : " yarn build:esm && yarn build:cjs" ,
5051 "build:prod" : " yarn build:prod:esm && yarn build:prod:cjs" ,
5152 "build:watch" : " yarn build:esm -w && yarn build:cjs -w" ,
5253 "build:esm" : " tsc" ,
5354 "build:cjs" : " tsc --module commonjs --outDir lib/cjs" ,
5455 "build:prod:esm" : " tsc -p tsconfig.prod.json" ,
5556 "build:prod:cjs" : " tsc -p tsconfig.prod.json --module commonjs --outDir lib/cjs" ,
57+ "clean-build" : " shx rm -rf lib" ,
5658 "changelog" : " auto-changelog -p --template ./changelog.template.hbs" ,
5759 "prepare" : " husky install" ,
5860 "pre-commit" : " lint-staged" ,
Original file line number Diff line number Diff line change @@ -3816,7 +3816,7 @@ minimatch@^3.0.4:
38163816 dependencies :
38173817 brace-expansion "^1.1.7"
38183818
3819- minimist@^1.2.0, minimist@^1.2.5 :
3819+ minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2. 5 :
38203820 version "1.2.5"
38213821 resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
38223822 integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
@@ -4663,7 +4663,7 @@ shebang-regex@^3.0.0:
46634663 resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
46644664 integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
46654665
4666- shelljs@0.8.4 :
4666+ shelljs@0.8.4, shelljs@^0.8.4 :
46674667 version "0.8.4"
46684668 resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
46694669 integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
@@ -4672,6 +4672,14 @@ shelljs@0.8.4:
46724672 interpret "^1.0.0"
46734673 rechoir "^0.6.2"
46744674
4675+ shx@^0.3.3 :
4676+ version "0.3.3"
4677+ resolved "https://registry.yarnpkg.com/shx/-/shx-0.3.3.tgz#681a88c7c10db15abe18525349ed474f0f1e7b9f"
4678+ integrity sha512-nZJ3HFWVoTSyyB+evEKjJ1STiixGztlqwKLTUNV5KqMWtGey9fTd4KU1gdZ1X9BV6215pswQ/Jew9NsuS/fNDA==
4679+ dependencies :
4680+ minimist "^1.2.3"
4681+ shelljs "^0.8.4"
4682+
46754683side-channel@^1.0.4 :
46764684 version "1.0.4"
46774685 resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf"
You can’t perform that action at this time.
0 commit comments