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 2
2
"git" : {
3
3
"tagName" : " v${version}" ,
4
4
"commitMessage" : " Release v${version}" ,
5
- "requireBranch" : " main"
5
+ "requireBranch" : " main" ,
6
+ "requireCommits" : true
6
7
},
7
8
"hooks" : {
9
+ "before:init" : [
10
+ " yarn before-release-init"
11
+ ],
8
12
"after:bump" : [
9
13
" yarn changelog" ,
10
14
" git add CHANGELOG.md"
11
15
],
12
16
"before:npm:release" : [
13
- " rimraf lib " ,
17
+ " yarn clean-build " ,
14
18
" yarn build"
15
19
]
16
20
},
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 40
40
"react-dom" : " ^17.0.2" ,
41
41
"react-hooks-testing-library" : " ^0.6.0" ,
42
42
"release-it" : " ^14.11.6" ,
43
- "rimraf" : " ^3.0.2" ,
43
+ "shelljs" : " ^0.8.4" ,
44
+ "shx" : " ^0.3.3" ,
44
45
"ts-jest" : " ^27.0.5" ,
45
46
"typescript" : " ^4.4.3"
46
47
},
47
48
"scripts" : {
48
- "rim " : " rimraf lib " ,
49
+ "before-release-init " : " node ./bin/before-release-init.mjs " ,
49
50
"build" : " yarn build:esm && yarn build:cjs" ,
50
51
"build:prod" : " yarn build:prod:esm && yarn build:prod:cjs" ,
51
52
"build:watch" : " yarn build:esm -w && yarn build:cjs -w" ,
52
53
"build:esm" : " tsc" ,
53
54
"build:cjs" : " tsc --module commonjs --outDir lib/cjs" ,
54
55
"build:prod:esm" : " tsc -p tsconfig.prod.json" ,
55
56
"build:prod:cjs" : " tsc -p tsconfig.prod.json --module commonjs --outDir lib/cjs" ,
57
+ "clean-build" : " shx rm -rf lib" ,
56
58
"changelog" : " auto-changelog -p --template ./changelog.template.hbs" ,
57
59
"prepare" : " husky install" ,
58
60
"pre-commit" : " lint-staged" ,
Original file line number Diff line number Diff line change @@ -3816,7 +3816,7 @@ minimatch@^3.0.4:
3816
3816
dependencies :
3817
3817
brace-expansion "^1.1.7"
3818
3818
3819
- minimist@^1.2.0, minimist@^1.2.5 :
3819
+ minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2. 5 :
3820
3820
version "1.2.5"
3821
3821
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
3822
3822
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
@@ -4663,7 +4663,7 @@ shebang-regex@^3.0.0:
4663
4663
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
4664
4664
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
4665
4665
4666
- shelljs@0.8.4 :
4666
+ shelljs@0.8.4, shelljs@^0.8.4 :
4667
4667
version "0.8.4"
4668
4668
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
4669
4669
integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
@@ -4672,6 +4672,14 @@ shelljs@0.8.4:
4672
4672
interpret "^1.0.0"
4673
4673
rechoir "^0.6.2"
4674
4674
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
+
4675
4683
side-channel@^1.0.4 :
4676
4684
version "1.0.4"
4677
4685
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