-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathindex.ts
73 lines (64 loc) · 1.88 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import path from 'path';
import { validatePackageVariant } from './config';
import { downloadMongoDb } from '@mongodb-js/mongodb-downloader';
import { getArtifactUrl } from './evergreen';
import { triggerRelease } from './local';
import type { ReleaseCommand } from './release';
import { release } from './release';
import type { Config, PackageVariant } from './config';
export { getArtifactUrl, downloadMongoDb };
const validCommands: (ReleaseCommand | 'trigger-release')[] = [
'bump',
'compile',
'package',
'upload',
'draft',
'publish',
'sign',
'download-crypt-shared-library',
'download-and-list-artifacts',
'trigger-release',
] as const;
const isValidCommand = (
cmd: string
): cmd is ReleaseCommand | 'trigger-release' =>
(validCommands as string[]).includes(cmd);
if (require.main === module) {
Error.stackTraceLimit = 200;
(async () => {
const command = process.argv[2];
if (!isValidCommand(command)) {
throw new Error(
`USAGE: npm run evergreen-release <${validCommands.join('|')}>`
);
}
if (command === 'trigger-release') {
await triggerRelease(process.argv.slice(3));
} else {
const config: Config = require(path.join(
__dirname,
'..',
'..',
'..',
'config',
'build.conf.js'
));
const cliBuildVariant = process.argv
.map((arg) => /^--build-variant=(.+)$/.exec(arg))
.filter(Boolean)[0];
if (cliBuildVariant) {
config.packageVariant = cliBuildVariant[1] as PackageVariant;
validatePackageVariant(config.packageVariant);
}
config.isDryRun ||= process.argv.includes('--dry-run');
config.useAuxiliaryPackagesOnly ||= process.argv.includes('--auxiliary');
await release(command, config);
}
})().then(
() => process.exit(0),
(err) =>
process.nextTick(() => {
throw err;
})
);
}