Skip to content

Commit f830106

Browse files
committed
v1.0.0
1 parent 7a615cf commit f830106

File tree

3 files changed

+381
-68
lines changed

3 files changed

+381
-68
lines changed

cmd/modules/release/index.js

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { writeFile } = require('fs/promises')
22
const { resolve } = require('path')
3-
const { shell } = require('electron')
3+
// const open = require('open')
4+
const openPromise = import('open');
45

56
const { extractOwnerAndRepoFromGitRemoteURL } = require('./utils')
67
const { checkValidations } = require('./validations')
@@ -9,67 +10,71 @@ const { question, exec } = require('../../utils')
910
const { COLORS } = require('../../constants')
1011

1112
async function makeRelease() {
12-
console.clear()
13+
console.clear()
1314

14-
const { version } = packageJSON
15+
const { version } = packageJSON
1516

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} `
4919
)
5020

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(`
6974
🛑 Something went wrong!\n
7075
👀 Error: ${message}
7176
`)
72-
}
77+
}
7378
}
7479

7580
makeRelease()

0 commit comments

Comments
 (0)