Skip to content

Commit f6fa169

Browse files
devjiwonchoieps1lon
andcommitted
throw when not match
Co-authored-by: Sebastian "Sebbie" Silbermann <[email protected]>
1 parent dfebe59 commit f6fa169

File tree

1 file changed

+54
-45
lines changed

1 file changed

+54
-45
lines changed

scripts/release/version-packages.ts

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -37,60 +37,69 @@ async function versionPackages() {
3737
}
3838

3939
const releaseType = process.env.RELEASE_TYPE
40+
switch (releaseType) {
41+
case 'canary': {
42+
// Enter pre mode as "canary" tag.
43+
await execa('pnpm', ['changeset', 'pre', 'enter', 'canary'], {
44+
stdio: 'inherit',
45+
})
4046

41-
if (releaseType === 'canary') {
42-
// Enter pre mode as "canary" tag.
43-
await execa('pnpm', ['changeset', 'pre', 'enter', 'canary'], {
44-
stdio: 'inherit',
45-
})
47+
console.log(
48+
'▲ Preparing to bump the canary version, checking if there are any changesets.'
49+
)
4650

47-
console.log(
48-
'▲ Preparing to bump the canary version, checking if there are any changesets.'
49-
)
51+
// Create an empty changeset for `next` to bump the canary version
52+
// even if there are no changesets for `next`.
53+
await execa('pnpm', [
54+
'changeset',
55+
'status',
56+
'--output',
57+
'./changeset-status.json',
58+
])
5059

51-
// Create an empty changeset for `next` to bump the canary version
52-
// even if there are no changesets for `next`.
53-
await execa('pnpm', [
54-
'changeset',
55-
'status',
56-
'--output',
57-
'./changeset-status.json',
58-
])
60+
let hasNextChangeset = false
61+
if (existsSync('./changeset-status.json')) {
62+
const changesetStatus: ChangesetStatusJson = JSON.parse(
63+
await readFile('./changeset-status.json', 'utf8')
64+
)
5965

60-
let hasNextChangeset = false
61-
if (existsSync('./changeset-status.json')) {
62-
const changesetStatus: ChangesetStatusJson = JSON.parse(
63-
await readFile('./changeset-status.json', 'utf8')
64-
)
66+
console.log('▲ Changeset Status:')
67+
console.log(changesetStatus)
6568

66-
console.log('▲ Changeset Status:')
67-
console.log(changesetStatus)
69+
hasNextChangeset =
70+
changesetStatus.releases.find(
71+
(release) => release.name === 'next'
72+
) !== undefined
6873

69-
hasNextChangeset =
70-
changesetStatus.releases.find((release) => release.name === 'next') !==
71-
undefined
74+
await unlink('./changeset-status.json')
75+
}
7276

73-
await unlink('./changeset-status.json')
77+
if (!hasNextChangeset) {
78+
console.log(
79+
'▲ No changesets found for `next`, creating an empty changeset.'
80+
)
81+
// TODO: Since this is temporary until we hard-require a changeset, we will
82+
// need to remove this in the future to prevent publishing empty releases.
83+
await writeFile(
84+
join(process.cwd(), '.changeset', `next-canary-${Date.now()}.md`),
85+
`---\n'next': patch\n---`
86+
)
87+
}
88+
break
7489
}
75-
76-
if (!hasNextChangeset) {
77-
console.log(
78-
'▲ No changesets found for `next`, creating an empty changeset.'
79-
)
80-
// TODO: Since this is temporary until we hard-require a changeset, we will
81-
// need to remove this in the future to prevent publishing empty releases.
82-
await writeFile(
83-
join(process.cwd(), '.changeset', `next-canary-${Date.now()}.md`),
84-
`---\n'next': patch\n---`
85-
)
90+
case 'release-candidate': {
91+
// Enter pre mode as "rc" tag.
92+
await execa('pnpm', ['changeset', 'pre', 'enter', 'rc'], {
93+
stdio: 'inherit',
94+
})
95+
break
96+
}
97+
case 'stable': {
98+
break
99+
}
100+
default: {
101+
throw new Error(`Invalid release type: ${releaseType}`)
86102
}
87-
}
88-
89-
if (releaseType === 'release-candidate') {
90-
// Enter pre mode as "rc" tag.
91-
await execa('pnpm', ['changeset', 'pre', 'enter', 'rc'], {
92-
stdio: 'inherit',
93-
})
94103
}
95104

96105
await execa('pnpm', ['changeset', 'version'], {

0 commit comments

Comments
 (0)