1
1
const { writeFile } = require ( 'fs/promises' )
2
2
const { resolve } = require ( 'path' )
3
- const { shell } = require ( 'electron' )
3
+ // const open = require('open')
4
+ const openPromise = import ( 'open' ) ;
4
5
5
6
const { extractOwnerAndRepoFromGitRemoteURL } = require ( './utils' )
6
7
const { checkValidations } = require ( './validations' )
@@ -9,67 +10,71 @@ const { question, exec } = require('../../utils')
9
10
const { COLORS } = require ( '../../constants' )
10
11
11
12
async function makeRelease ( ) {
12
- console . clear ( )
13
+ console . clear ( )
13
14
14
- const { version } = packageJSON
15
+ const { version } = packageJSON
15
16
16
- const newVersion = await question (
17
- `Enter a new version: ${ COLORS . SOFT_GRAY } (current is ${ version } )${ COLORS . RESET } `
18
- )
19
-
20
- if ( checkValidations ( { version, newVersion } ) ) {
21
- return
22
- }
23
-
24
- packageJSON . version = newVersion
25
-
26
- try {
27
- console . log (
28
- `${ COLORS . CYAN } > Updating package.json version...${ COLORS . RESET } `
29
- )
30
-
31
- await writeFile (
32
- resolve ( 'package.json' ) ,
33
- JSON . stringify ( packageJSON , null , 2 )
34
- )
35
-
36
- console . log ( `\n${ COLORS . GREEN } Done!${ COLORS . RESET } \n` )
37
- console . log ( `${ COLORS . CYAN } > Trying to release it...${ COLORS . RESET } ` )
38
-
39
- exec (
40
- [
41
- `git commit -am v${ newVersion } ` ,
42
- `git tag v${ newVersion } ` ,
43
- `git push` ,
44
- `git push --tags` ,
45
- ] ,
46
- {
47
- inherit : true ,
48
- }
17
+ const newVersion = await question (
18
+ `Enter a new version: ${ COLORS . SOFT_GRAY } (current is ${ version } )${ COLORS . RESET } `
49
19
)
50
20
51
- const [ repository ] = exec ( [ `git remote get-url --push origin` ] )
52
- const ownerAndRepo = extractOwnerAndRepoFromGitRemoteURL ( repository )
53
-
54
- console . log (
55
- `${ COLORS . CYAN } > Opening the repository releases page...${ COLORS . RESET } `
56
- )
57
-
58
- await shell . openExternal ( `https://github.com/${ ownerAndRepo } /releases` )
59
-
60
- console . log (
61
- `${ COLORS . CYAN } > Opening the repository actions page...${ COLORS . RESET } `
62
- )
63
-
64
- await shell . openExternal ( `https://github.com/${ ownerAndRepo } /actions` )
65
-
66
- console . log ( `\n${ COLORS . GREEN } Done!${ COLORS . RESET } \n` )
67
- } catch ( { message } ) {
68
- console . log ( `
21
+ if ( checkValidations ( { version, newVersion } ) ) {
22
+ return
23
+ }
24
+
25
+ packageJSON . version = newVersion
26
+
27
+ try {
28
+ console . log (
29
+ `${ COLORS . CYAN } > Updating package.json version...${ COLORS . RESET } `
30
+ )
31
+
32
+ await writeFile (
33
+ resolve ( 'package.json' ) ,
34
+ JSON . stringify ( packageJSON , null , 2 )
35
+ )
36
+
37
+ console . log ( `\n${ COLORS . GREEN } Done!${ COLORS . RESET } \n` )
38
+ console . log ( `${ COLORS . CYAN } > Trying to release it...${ COLORS . RESET } ` )
39
+
40
+ exec (
41
+ [
42
+ `git commit -am v${ newVersion } ` ,
43
+ `git tag v${ newVersion } ` ,
44
+ `git push` ,
45
+ `git push --tags` ,
46
+ ] ,
47
+ {
48
+ inherit : true ,
49
+ }
50
+ )
51
+
52
+ const [ repository ] = exec ( [ `git remote get-url --push origin` ] )
53
+ const ownerAndRepo = extractOwnerAndRepoFromGitRemoteURL ( repository )
54
+
55
+ console . log (
56
+ `${ COLORS . CYAN } > Opening the repository releases page...${ COLORS . RESET } `
57
+ )
58
+
59
+ openPromise . then ( openModule => {
60
+ openModule . default ( `https://github.com/${ ownerAndRepo } /releases` ) ;
61
+ } )
62
+
63
+ console . log (
64
+ `${ COLORS . CYAN } > Opening the repository actions page...${ COLORS . RESET } `
65
+ )
66
+
67
+ openPromise . then ( openModule => {
68
+ openModule . default ( `https://github.com/${ ownerAndRepo } /actions` ) ;
69
+ } )
70
+
71
+ console . log ( `\n${ COLORS . GREEN } Done!${ COLORS . RESET } \n` )
72
+ } catch ( { message } ) {
73
+ console . log ( `
69
74
🛑 Something went wrong!\n
70
75
👀 Error: ${ message }
71
76
` )
72
- }
77
+ }
73
78
}
74
79
75
80
makeRelease ( )
0 commit comments