(args: ReadonlyArray<string>)
| 83 | } |
| 84 | |
| 85 | export async function run(args: ReadonlyArray<string>): Promise<void> { |
| 86 | if (args.length === 0) { |
| 87 | throw new Error( |
| 88 | `You have not specified a channel to draft this release for. Choose one of 'production' or 'beta'` |
| 89 | ) |
| 90 | } |
| 91 | |
| 92 | const channel = parseChannel(args[0]) |
| 93 | const draftPretext = args[1] === '--pretext' |
| 94 | const previousVersion = await getLatestRelease({ |
| 95 | excludeBetaReleases: channel === 'production' || channel === 'test', |
| 96 | excludeTestReleases: channel === 'production' || channel === 'beta', |
| 97 | }) |
| 98 | const nextVersion = getNextVersionNumber(previousVersion, channel) |
| 99 | |
| 100 | console.log(`Creating release branch for "${nextVersion}"...`) |
| 101 | createReleaseBranch(nextVersion) |
| 102 | console.log(`Done!`) |
| 103 | |
| 104 | console.log(`Setting app version to "${nextVersion}" in app/package.json...`) |
| 105 | |
| 106 | try { |
| 107 | // this can throw |
| 108 | // sets the npm version in app/ |
| 109 | execSync(`npm version ${nextVersion} --allow-same-version`, { |
| 110 | cwd: join(__dirname, '..', '..', 'app'), |
| 111 | encoding: 'utf8', |
| 112 | }) |
| 113 | console.log(`Set!`) |
| 114 | } catch (e) { |
| 115 | console.warn(`Setting the app version failed 😿 |
| 116 | (${e instanceof Error ? e.message : e}) |
| 117 | Please manually set it to ${nextVersion} in app/package.json.`) |
| 118 | } |
| 119 | |
| 120 | console.log('Determining changelog entries...') |
| 121 | |
| 122 | const currentChangelog: IChangelog = require(changelogPath) |
| 123 | const newEntries = new Array<string>() |
| 124 | |
| 125 | if (draftPretext) { |
| 126 | const pretext = await getPretext() |
| 127 | if (pretext !== null) { |
| 128 | newEntries.push(pretext) |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | switch (channel) { |
| 133 | case 'production': { |
| 134 | // if it's a new production release, make sure we only include |
| 135 | // entries since the latest production release |
| 136 | newEntries.push(...getChangelogEntriesSince(previousVersion)) |
| 137 | break |
| 138 | } |
| 139 | case 'beta': { |
| 140 | const logLines = await getLogLines(`release-${previousVersion}`) |
| 141 | const changelogLines = await convertToChangelogFormat(logLines) |
| 142 | newEntries.push(...changelogLines) |
no test coverage detected