Skip to content

Commit 95769e0

Browse files
authored
feat: add option to ignore git changes (#898)
1 parent bd9f9e5 commit 95769e0

18 files changed

+174
-124
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- fix(utils): Bail package manager detection if multiple candidates are detected ([#864](https://github.com/getsentry/sentry-wizard/pull/864))
77
- fix(nextjs): Create root layout for example page if it doesn't exist([#863](https://github.com/getsentry/sentry-wizard/pull/863))
88
- ref(utils): Unify `getPackageManger` and `detectPackageManager` ([#865](https://github.com/getsentry/sentry-wizard/pull/865))
9+
- feat: add option to ignore git changes ([#898](https://github.com/getsentry/sentry-wizard/pull/898))
910

1011
## 4.5.0
1112

@@ -25,6 +26,7 @@
2526

2627
The NextJS and Remix flows have been removed when running the wizard with `npx @sentry/wizard -i sourcemaps`.
2728
Please use `npx @sentry/wizard -i nextjs` and `npx @sentry/wizard -i remix` instead.
29+
2830
- ref: Reword Replay feature selection ([#847](https://github.com/getsentry/sentry-wizard/pull/847))
2931
- ref: Fix auth token env variable wording in flutter and apple wizards ([#853](https://github.com/getsentry/sentry-wizard/pull/853))
3032

README.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,34 @@ yarn sentry-wizard
4848
npx @sentry/wizard
4949
```
5050

51-
At the current moment, the wizard can be used for Next.js, react-native, iOS, Flutter, Nuxt, Remix, Sveltekit, Android, Electron, Cordova, and for sourcemaps setup. If you have other platforms you would like the wizard to support, please open a [GitHub issue](https://github.com/getsentry/sentry-wizard/issues)!
51+
At the current moment, the wizard can be used for Next.js, react-native, iOS,
52+
Flutter, Nuxt, Remix, Sveltekit, Android, Electron, Cordova, and for sourcemaps
53+
setup. If you have other platforms you would like the wizard to support, please
54+
open a [GitHub issue](https://github.com/getsentry/sentry-wizard/issues)!
5255

5356
# Options
5457

5558
The following CLI arguments are available:
5659

57-
| Option | Description | Type | Default | Choices | Environment Variable |
58-
| --------------------- | ----------------------------------------------------------------- | ------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
59-
| `--help` | Show help | boolean | | | |
60-
| `--version` | Show version number | boolean | | | |
61-
| `--debug` | Enable verbose logging | boolean | `false` | | `SENTRY_WIZARD_DEBUG` |
62-
| `--uninstall` | Revert project setup process. Not available for all integrations. | boolean | `false` | | `SENTRY_WIZARD_UNINSTALL` |
63-
| `--skip-connect` | Skips the connection to the server | boolean | `false` | | `SENTRY_WIZARD_SKIP_CONNECT` |
64-
| `--quiet` | Do not fallback to prompting user asking questions | boolean | `false` | | `SENTRY_WIZARD_QUIET` |
65-
| `-i, --integration` | Choose the integration to setup | choices | Select integration during setup | "reactNative", "flutter", ios", "android", "cordova", "electron", "nextjs", "nuxt", "remix", "sveltekit", "sourcemaps" | `SENTRY_WIZARD_INTEGRATION` |
66-
| `-p, --platform` | Choose platform(s) | array | Select platform(s) during setup | "ios", "android" | `SENTRY_WIZARD_PLATFORM` |
67-
| `-u, --url` | The URL to your Sentry installation | string | `https://sentry.io` | | `SENTRY_WIZARD_URL` |
68-
| `--project` | The Sentry project slug to use | string | Select project during setup | | |
69-
| `--org` | The Sentry org slug to use | string | Select org during setup | | |
70-
| `--saas` | Skip the self-hosted or SaaS URL selection process | boolean | Select self-hosted or SaaS during setup | | |
71-
| `-s, --signup` | Redirect to signup page if not logged in | boolean | `false` | | |
72-
| `--disable-telemetry` | Don't send telemetry data to Sentry | boolean | `false` | | |
73-
| `--force-install` | Force install the SDK NPM package (use with caution!) | boolean | `false` | | |
74-
| `--coming-from` | Specify the partner organization initiating this command. | string | | | |
60+
| Option | Description | Type | Default | Choices | Environment Variable |
61+
| ---------------------- | ----------------------------------------------------------------- | ------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
62+
| `--help` | Show help | boolean | | | |
63+
| `--version` | Show version number | boolean | | | |
64+
| `--debug` | Enable verbose logging | boolean | `false` | | `SENTRY_WIZARD_DEBUG` |
65+
| `--uninstall` | Revert project setup process. Not available for all integrations. | boolean | `false` | | `SENTRY_WIZARD_UNINSTALL` |
66+
| `--skip-connect` | Skips the connection to the server | boolean | `false` | | `SENTRY_WIZARD_SKIP_CONNECT` |
67+
| `--quiet` | Do not fallback to prompting user asking questions | boolean | `false` | | `SENTRY_WIZARD_QUIET` |
68+
| `-i, --integration` | Choose the integration to setup | choices | Select integration during setup | "reactNative", "flutter", ios", "android", "cordova", "electron", "nextjs", "nuxt", "remix", "sveltekit", "sourcemaps" | `SENTRY_WIZARD_INTEGRATION` |
69+
| `-p, --platform` | Choose platform(s) | array | Select platform(s) during setup | "ios", "android" | `SENTRY_WIZARD_PLATFORM` |
70+
| `-u, --url` | The URL to your Sentry installation | string | `https://sentry.io` | | `SENTRY_WIZARD_URL` |
71+
| `--project` | The Sentry project slug to use | string | Select project during setup | | |
72+
| `--org` | The Sentry org slug to use | string | Select org during setup | | |
73+
| `--saas` | Skip the self-hosted or SaaS URL selection process | boolean | Select self-hosted or SaaS during setup | | |
74+
| `-s, --signup` | Redirect to signup page if not logged in | boolean | `false` | | |
75+
| `--disable-telemetry` | Don't send telemetry data to Sentry | boolean | `false` | | |
76+
| `--force-install` | Force install the SDK NPM package (use with caution!) | boolean | `false` | | |
77+
| `--coming-from` | Specify the partner organization initiating this command. | string | | | |
78+
| `--ignore-git-changes` | Ignore git changes in the project and not prompt for confirmation | boolean | `false` | | |
7579

7680
## Resources
7781

bin.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ const argv = yargs(hideBin(process.argv), process.cwd())
132132
describe: 'Force install the SDK NPM package',
133133
type: 'boolean',
134134
},
135+
'ignore-git-changes': {
136+
default: false,
137+
describe: 'Ignore git changes in the project',
138+
type: 'boolean',
139+
},
135140
...PRESELECTED_PROJECT_OPTIONS,
136141
})
137142
// This prevents `yargs` from trying to read the local package.json

lib/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export interface Args {
114114
promoCode?: string;
115115
disableTelemetry?: boolean;
116116
comingFrom?: string;
117+
ignoreGitChanges?: boolean;
117118
}
118119

119120
export const DEFAULT_URL = 'https://sentry.io/';

lib/Helper/Wizard.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ function sanitizeAndValidateArgs(argv: Args & Record<string, unknown>): void {
1616
delete argv['skip-connect'];
1717
}
1818
argv.promoCode = argv['promo-code'] as Args['promoCode'];
19+
if (argv['ignore-git-changes']) {
20+
argv.ignoreGitChanges = argv[
21+
'ignore-git-changes'
22+
] as Args['ignoreGitChanges'];
23+
delete argv['ignore-git-changes'];
24+
}
1925
}
2026

2127
export function getCurrentIntegration(answers: Answers): BaseIntegration {

src/android/android-wizard.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
import * as fs from 'fs';
33
// @ts-expect-error - clack is ESM and TS complains about that. It works though
44
import * as clack from '@clack/prompts';
5-
import * as path from 'path';
65
import * as Sentry from '@sentry/node';
7-
import * as gradle from './gradle';
8-
import * as manifest from './manifest';
9-
import * as codetools from './code-tools';
6+
import chalk from 'chalk';
7+
import * as path from 'path';
8+
import { traceStep, withTelemetry } from '../telemetry';
109
import {
1110
CliSetupConfig,
1211
abort,
@@ -17,8 +16,9 @@ import {
1716
propertiesCliSetupConfig,
1817
} from '../utils/clack-utils';
1918
import { WizardOptions } from '../utils/types';
20-
import { traceStep, withTelemetry } from '../telemetry';
21-
import chalk from 'chalk';
19+
import * as codetools from './code-tools';
20+
import * as gradle from './gradle';
21+
import * as manifest from './manifest';
2222

2323
const proguardMappingCliSetupConfig: CliSetupConfig = {
2424
...propertiesCliSetupConfig,
@@ -44,7 +44,9 @@ async function runAndroidWizardWithTelemetry(
4444
promoCode: options.promoCode,
4545
});
4646

47-
await confirmContinueIfNoOrDirtyGitRepo();
47+
await confirmContinueIfNoOrDirtyGitRepo({
48+
ignoreGitChanges: options.ignoreGitChanges,
49+
});
4850

4951
const projectDir = process.cwd();
5052
const buildGradleFiles = findFilesWithExtensions(projectDir, [

src/apple/apple-wizard.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@
55
/* eslint-disable @typescript-eslint/no-unused-vars */
66
// @ts-expect-error - clack is ESM and TS complains about that. It works though
77
import clack from '@clack/prompts';
8+
import * as Sentry from '@sentry/node';
89
import chalk from 'chalk';
910
import * as fs from 'fs';
1011
import * as path from 'path';
11-
import { XcodeProject } from './xcode-manager';
12-
import * as codeTools from './code-tools';
12+
import { traceStep, withTelemetry } from '../telemetry';
1313
import * as bash from '../utils/bash';
1414
import * as SentryUtils from '../utils/sentrycli-utils';
1515
import { SentryProjectData, WizardOptions } from '../utils/types';
16-
import * as Sentry from '@sentry/node';
17-
import { traceStep, withTelemetry } from '../telemetry';
1816
import * as cocoapod from './cocoapod';
17+
import * as codeTools from './code-tools';
1918
import * as fastlane from './fastlane';
19+
import { XcodeProject } from './xcode-manager';
2020

2121
/* eslint-enable @typescript-eslint/no-unused-vars */
2222

2323
import {
24-
askToInstallSentryCLI,
25-
printWelcome,
2624
abort,
2725
askForItemSelection,
26+
askToInstallSentryCLI,
2827
confirmContinueIfNoOrDirtyGitRepo,
2928
getOrAskForProjectData,
29+
printWelcome,
3030
} from '../utils/clack-utils';
3131

3232
export async function runAppleWizard(options: WizardOptions): Promise<void> {
@@ -48,7 +48,9 @@ async function runAppleWizardWithTelementry(
4848
promoCode: options.promoCode,
4949
});
5050

51-
await confirmContinueIfNoOrDirtyGitRepo();
51+
await confirmContinueIfNoOrDirtyGitRepo({
52+
ignoreGitChanges: options.ignoreGitChanges,
53+
});
5254

5355
const hasCli = bash.hasSentryCLI();
5456
Sentry.setTag('has-cli', hasCli);

src/flutter/flutter-wizard.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { WizardOptions } from '../utils/types';
21
import * as Sentry from '@sentry/node';
3-
import * as codetools from './code-tools';
42
import * as fs from 'fs';
53
import * as path from 'path';
64
import { showCopyPasteInstructions } from '../utils/clack-utils';
7-
import { pubspecSnippetColored, initSnippetColored } from './templates';
85
import { fetchSdkVersion } from '../utils/release-registry';
6+
import { WizardOptions } from '../utils/types';
7+
import * as codetools from './code-tools';
8+
import { initSnippetColored, pubspecSnippetColored } from './templates';
99
// @ts-expect-error - clack is ESM and TS complains about that. It works though
1010
import * as clack from '@clack/prompts';
1111
import chalk from 'chalk';
@@ -38,7 +38,9 @@ async function runFlutterWizardWithTelemetry(
3838
promoCode: options.promoCode,
3939
});
4040

41-
await confirmContinueIfNoOrDirtyGitRepo();
41+
await confirmContinueIfNoOrDirtyGitRepo({
42+
ignoreGitChanges: options.ignoreGitChanges,
43+
});
4244

4345
const { selectedProject, selfHosted, sentryUrl, authToken } =
4446
await getOrAskForProjectData(options, 'flutter');

src/nextjs/nextjs-wizard.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import * as path from 'path';
99

1010
import * as Sentry from '@sentry/node';
1111

12+
import { setupCI } from '../sourcemaps/sourcemaps-wizard';
13+
import { traceStep, withTelemetry } from '../telemetry';
1214
import {
1315
abort,
1416
abortIfCancelled,
@@ -27,6 +29,7 @@ import {
2729
runPrettierIfInstalled,
2830
showCopyPasteInstructions,
2931
} from '../utils/clack-utils';
32+
import { getPackageVersion, hasPackageInstalled } from '../utils/package-json';
3033
import type { SentryProjectData, WizardOptions } from '../utils/types';
3134
import {
3235
getFullUnderscoreErrorCopyPasteSnippet,
@@ -36,21 +39,18 @@ import {
3639
getNextjsConfigCjsAppendix,
3740
getNextjsConfigCjsTemplate,
3841
getNextjsConfigEsmCopyPasteSnippet,
42+
getNextjsConfigMjsTemplate,
43+
getRootLayout,
3944
getSentryConfigContents,
4045
getSentryDefaultGlobalErrorPage,
4146
getSentryDefaultUnderscoreErrorPage,
42-
getSentryExamplePagesDirApiRoute,
4347
getSentryExampleAppDirApiRoute,
4448
getSentryExamplePageContents,
49+
getSentryExamplePagesDirApiRoute,
4550
getSimpleUnderscoreErrorCopyPasteSnippet,
4651
getWithSentryConfigOptionsTemplate,
47-
getNextjsConfigMjsTemplate,
48-
getRootLayout,
4952
} from './templates';
50-
import { traceStep, withTelemetry } from '../telemetry';
51-
import { getPackageVersion, hasPackageInstalled } from '../utils/package-json';
5253
import { getNextJsVersionBucket } from './utils';
53-
import { setupCI } from '../sourcemaps/sourcemaps-wizard';
5454

5555
export function runNextjsWizard(options: WizardOptions) {
5656
return withTelemetry(
@@ -76,7 +76,9 @@ export async function runNextjsWizardWithTelemetry(
7676

7777
const typeScriptDetected = isUsingTypeScript();
7878

79-
await confirmContinueIfNoOrDirtyGitRepo();
79+
await confirmContinueIfNoOrDirtyGitRepo({
80+
ignoreGitChanges: options.ignoreGitChanges,
81+
});
8082

8183
const packageJson = await getPackageDotJson();
8284

0 commit comments

Comments
 (0)