|
1 | 1 | #! /usr/bin/env node
|
2 | 2 | const SentryCli = require('@sentry/cli');
|
3 |
| -const argv = require('yargs/yargs')(process.argv.slice(2)) |
4 |
| - .option('release', { type: 'string', describe: 'The release number' }) |
5 |
| - .option('urlPrefix', { type: 'string', describe: 'The url prefix for the sourcemaps' }) |
6 |
| - .option('buildPath', { type: 'string', describe: 'The path to the build directory' }) |
| 3 | +const yargs = require('yargs/yargs'); |
| 4 | + |
| 5 | +const DEFAULT_URL_PREFIX = '~/build/'; |
| 6 | +const DEFAULT_BUILD_PATH = 'public/build'; |
| 7 | + |
| 8 | +const argv = yargs(process.argv.slice(2)) |
| 9 | + .option('release', { |
| 10 | + type: 'string', |
| 11 | + describe: |
| 12 | + 'The release number\n' + |
| 13 | + "If not provided, a new release id will be determined by Sentry CLI's `propose-version`.\n" + |
| 14 | + 'See: https://docs.sentry.io/product/releases/suspect-commits/#using-the-cli\n', |
| 15 | + }) |
| 16 | + .option('urlPrefix', { |
| 17 | + type: 'string', |
| 18 | + describe: 'URL prefix to add to the beginning of all filenames', |
| 19 | + default: DEFAULT_URL_PREFIX, |
| 20 | + }) |
| 21 | + .option('buildPath', { |
| 22 | + type: 'string', |
| 23 | + describe: 'The path to the build directory', |
| 24 | + default: DEFAULT_BUILD_PATH, |
| 25 | + }) |
7 | 26 | .usage(
|
8 |
| - 'Usage: $0 [--release RELEASE] [--urlPrefix URL_PREFIX] [--buildPath BUILD_PATH] \n\n' + |
| 27 | + 'Usage: $0\n' + |
| 28 | + ' [--release RELEASE]\n' + |
| 29 | + ' [--urlPrefix URL_PREFIX]\n' + |
| 30 | + ' [--buildPath BUILD_PATH]\n\n' + |
| 31 | + 'This CLI tool will upload sourcemaps to Sentry for the given release.\n' + |
| 32 | + 'It has defaults for URL prefix and build path for Remix builds, but you can override them.\n\n' + |
9 | 33 | 'If you need a more advanced configuration, you can use `sentry-cli` instead.\n' +
|
10 | 34 | 'https://github.com/getsentry/sentry-cli',
|
11 |
| - ).argv; |
| 35 | + ) |
| 36 | + .wrap(120).argv; |
12 | 37 |
|
13 | 38 | const sentry = new SentryCli();
|
14 | 39 |
|
15 | 40 | async function createRelease() {
|
16 | 41 | const RELEASE = argv.release || (await sentry.releases.proposeVersion());
|
17 |
| - const URL_PREFIX = argv.urlPrefix || '~/build/'; |
18 |
| - const BUILD_PATH = argv.buildPath || 'public/build'; |
| 42 | + const URL_PREFIX = argv.urlPrefix || DEFAULT_URL_PREFIX; |
| 43 | + const BUILD_PATH = argv.buildPath || DEFAULT_BUILD_PATH; |
19 | 44 |
|
20 | 45 | await sentry.releases.new(RELEASE);
|
21 | 46 |
|
|
0 commit comments