|
1 |
| -import release from './release'; |
2 |
| -import { getArtifactUrl } from './evergreen'; |
3 |
| -import { downloadMongoDb } from './download-mongodb'; |
| 1 | +import path from 'path'; |
4 | 2 | import { BuildVariant } from './config';
|
| 3 | +import { downloadMongoDb } from './download-mongodb'; |
| 4 | +import { getArtifactUrl } from './evergreen'; |
| 5 | +import { release, ReleaseCommand } from './release'; |
| 6 | + |
| 7 | +export { getArtifactUrl, downloadMongoDb }; |
| 8 | + |
| 9 | +if (require.main === module) { |
| 10 | + (async() => { |
| 11 | + const config = require(path.join(__dirname, '..', '..', '..', 'config', 'build.conf.js')); |
| 12 | + |
| 13 | + const command = process.argv[2]; |
| 14 | + |
| 15 | + if (!['bump', 'compile', 'package', 'upload', 'draft', 'publish'].includes(command)) { |
| 16 | + throw new Error('USAGE: npm run evergreen-release <bump|compile|package|upload|draft|publish>'); |
| 17 | + } |
| 18 | + |
| 19 | + const cliBuildVariant = process.argv |
| 20 | + .map((arg) => arg.match(/^--build-variant=(.+)$/)) |
| 21 | + .filter(Boolean)[0]; |
| 22 | + if (cliBuildVariant) { |
| 23 | + config.buildVariant = cliBuildVariant[1]; |
| 24 | + } |
| 25 | + |
| 26 | + // Resolve 'Windows' to 'win32' etc. |
| 27 | + if (config.buildVariant in BuildVariant) { |
| 28 | + config.buildVariant = (BuildVariant as any)[config.buildVariant]; |
| 29 | + } |
5 | 30 |
|
6 |
| -export default release; |
7 |
| -export { release, BuildVariant, getArtifactUrl, downloadMongoDb }; |
| 31 | + await release(command as ReleaseCommand, config); |
| 32 | + })().then( |
| 33 | + () => process.exit(0), |
| 34 | + (err) => process.nextTick(() => { throw err; }) |
| 35 | + ); |
| 36 | +} |
0 commit comments