Skip to content

Commit

Permalink
Merge branch 'master' into better-monorepo-support-for-android-react-…
Browse files Browse the repository at this point in the history
…native
  • Loading branch information
krystofwoldrich authored Aug 31, 2023
2 parents d886762 + 2f1e66a commit 196a999
Show file tree
Hide file tree
Showing 33 changed files with 1,888 additions and 26 deletions.
23 changes: 23 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ changelogPolicy: auto
preReleaseCommand: bash scripts/craft-pre-release.sh
targets:
- name: npm
- name: brew
tap: getsentry/tools
template: >
require 'language/node'
class SentryWizard < Formula
desc "The Sentry Wizard helps you set up your projects with Sentry"
homepage "https://github.com/getsentry/sentry-wizard"
url "https://registry.npmjs.org/@sentry/wizard/-/wizard-{{version}}.tgz"
sha256 "{{checksums.sentry-wizard-v__VERSION____tgz}}"
version "{{version}}"
license "MIT"
depends_on "node"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
assert_match version.to_s, shell_output("#{bin}/sentry-wizard --version").chomp
end
end
- name: registry
apps:
app:sentry-wizard:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build
node_modules
npm-debug.log
ios
android
./android
yarn-error.log

scratch/
Expand Down
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,44 @@

## Unreleased

- feat(android): Add wizard support for Android (#389)

Set up the Sentry Android SDK in your app with one command:

```sh
npx @sentry/wizard -i android
# or via brew
brew install getsentry/tools/sentry-wizard && sentry-wizard -i android
```

- feat(craft): Add `brew` target for automatically publishing `sentry-wizard` to Sentry's custom Homebrew tap (#406)

You can now install `sentry-wizard` via Homebrew:

```sh
brew update
brew install getsentry/tools/sentry-wizard
```

- fix: Support org auth tokens in old wizards (#409)
- feat(reactnative): Improve `build.gradle` patch so that it's more likely to work without changes in monorepos (#352)

## 3.10.0

- feat(remix): Add Remix wizard (#387)

Set up the Sentry Remix SDK in your app with one command:

```sh
npx @sentry/wizard -i remix
```

- fix(cordova): Fallback to the default Sentry CLI path if not defined. (#401)

## 3.9.2

- fix(sentry-cli-sourcemaps): Fix writing of build command (#398)

## 3.9.1

- ref(sourcemaps): Handle no vite config found case (#391)
Expand Down
10 changes: 10 additions & 0 deletions lib/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
export enum Integration {
reactNative = 'reactNative',
ios = 'ios',
android = 'android',
cordova = 'cordova',
electron = 'electron',
nextjs = 'nextjs',
remix = 'remix',
sveltekit = 'sveltekit',
sourcemaps = 'sourcemaps',
}
Expand Down Expand Up @@ -34,6 +36,8 @@ export function getPlatformDescription(type: string): string {

export function getIntegrationDescription(type: string): string {
switch (type) {
case Integration.android:
return 'Android';
case Integration.reactNative:
return 'React Native';
case Integration.cordova:
Expand All @@ -42,6 +46,8 @@ export function getIntegrationDescription(type: string): string {
return 'Electron';
case Integration.nextjs:
return 'Next.js';
case Integration.remix:
return 'Remix';
case Integration.sveltekit:
return 'SvelteKit';
case Integration.sourcemaps:
Expand All @@ -55,6 +61,8 @@ export function getIntegrationDescription(type: string): string {

export function mapIntegrationToPlatform(type: string): string | undefined {
switch (type) {
case Integration.android:
return 'android';
case Integration.reactNative:
return 'react-native';
case Integration.cordova:
Expand All @@ -63,6 +71,8 @@ export function mapIntegrationToPlatform(type: string): string | undefined {
return 'javascript-electron';
case Integration.nextjs:
return 'javascript-nextjs';
case Integration.remix:
return 'javascript-remix';
case Integration.sveltekit:
return 'javascript-sveltekit';
case Integration.sourcemaps:
Expand Down
15 changes: 13 additions & 2 deletions lib/Steps/ChooseIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { SourceMapsShim } from './Integrations/SourceMapsShim';
import { Apple } from './Integrations/Apple';
import { SvelteKitShim } from './Integrations/SvelteKitShim';
import { hasPackageInstalled } from '../../src/utils/package-json';
import { Remix } from './Integrations/Remix';
import { Android } from './Integrations/Android';

let projectPackage: any = {};

Expand All @@ -37,6 +39,9 @@ export class ChooseIntegration extends BaseStep {

let integration = null;
switch (integrationPrompt.integration) {
case Integration.android:
integration = new Android(this._argv);
break;
case Integration.cordova:
integration = new Cordova(sanitizeUrl(this._argv));
break;
Expand All @@ -46,6 +51,9 @@ export class ChooseIntegration extends BaseStep {
case Integration.nextjs:
integration = new NextJsShim(this._argv);
break;
case Integration.remix:
integration = new Remix(this._argv);
break;
case Integration.sveltekit:
integration = new SvelteKitShim(this._argv);
break;
Expand Down Expand Up @@ -77,6 +85,9 @@ export class ChooseIntegration extends BaseStep {
if (hasPackageInstalled('next', projectPackage)) {
return Integration.nextjs;
}
if (hasPackageInstalled('remix-run', projectPackage)) {
return Integration.remix;
}
if (hasPackageInstalled('@sveltejs/kit', projectPackage)) {
return Integration.sveltekit;
}
Expand All @@ -90,7 +101,7 @@ export class ChooseIntegration extends BaseStep {
return { integration: this._argv.integration };
} else {
if (this._argv.quiet) {
throw new Error('You need to choose a integration');
throw new Error('You need to choose a platform');
}

const detectedDefaultSelection = this.tryDetectingIntegration();
Expand All @@ -99,7 +110,7 @@ export class ChooseIntegration extends BaseStep {
{
choices: getIntegrationChoices(),
default: detectedDefaultSelection,
message: 'What integration do you want to set up?',
message: 'What platform do you want to set up?',
name: 'integration',
type: 'list',
},
Expand Down
23 changes: 23 additions & 0 deletions lib/Steps/Integrations/Android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Answers } from 'inquirer';
import { BaseIntegration } from './BaseIntegration';
import { Args } from '../../Constants';
import { runAndroidWizard } from '../../../src/android/android-wizard';

export class Android extends BaseIntegration {
public constructor(protected _argv: Args) {
super(_argv);
}

public async emit(_answers: Answers): Promise<Answers> {
await runAndroidWizard({
promoCode: this._argv.promoCode,
url: this._argv.url,
telemetryEnabled: !this._argv.disableTelemetry,
});
return {};
}

public shouldConfigure(_answers: Answers): Promise<Answers> {
return this._shouldConfigure;
}
}
6 changes: 5 additions & 1 deletion lib/Steps/Integrations/Cordova.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ export class Cordova extends BaseIntegration {
'function getProperty {\\n' +
' PROP_KEY=$1\\n' +
' PROP_VALUE=`cat $SENTRY_PROPERTIES | grep "$PROP_KEY" | cut -d\'=\' -f2`\\n' +
' echo $PROP_VALUE\\n' +
' if [ -z "$PROP_VALUE" ]; then\\n' +
' echo "plugins/sentry-cordova/node_modules/@sentry/cli/bin/sentry-cli"\\n' +
' else\\n' +
' echo $PROP_VALUE\\n' +
' fi\\n' +
'}\\n' +
'if [ ! -f $SENTRY_PROPERTIES ]; then\\n' +
' echo "warning: SENTRY: sentry.properties file not found! Skipping symbol upload."\\n' +
Expand Down
32 changes: 32 additions & 0 deletions lib/Steps/Integrations/Remix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Answers } from 'inquirer';

import type { Args } from '../../Constants';
import { BaseIntegration } from './BaseIntegration';
import { runRemixWizard } from '../../../src/remix/remix-wizard';

/**
* This class just redirects to the new `remix-wizard.ts` flow.
*/
export class Remix extends BaseIntegration {
public constructor(protected _argv: Args) {
super(_argv);
}

public async emit(_answers: Answers): Promise<Answers> {
await runRemixWizard({
promoCode: this._argv.promoCode,
url: this._argv.url,
telemetryEnabled: !this._argv.disableTelemetry,
});
return {};
}

public async shouldConfigure(_answers: Answers): Promise<Answers> {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
if (this._shouldConfigure) {
return this._shouldConfigure;
}
// eslint-disable-next-line @typescript-eslint/unbound-method
return this.shouldConfigure;
}
}
47 changes: 46 additions & 1 deletion lib/Steps/PromptForParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,16 @@ export class PromptForParameters extends BaseStep {
}

private _validateAuthToken(input: string): boolean | string {
if (!input.match(/[0-9a-f]{64}/g)) {
const isOrgToken = input.startsWith('sntrys_');

if (isOrgToken) {
if (!isValidOrgToken(input)) {
return 'Make sure you correctly copied your auth token. It should start with "sntrys_"';
}
return true;
}

if (!input.match(/(sntrys_)?[0-9a-f]{64}/g)) {
return 'Make sure you copied the correct auth token, it should be 64 hex chars';
}
return true;
Expand Down Expand Up @@ -149,3 +158,39 @@ export class PromptForParameters extends BaseStep {
return true;
}
}

type MaybeOrgAuthToken = {
iat?: number;
url?: string;
org?: string;
region_url?: string;
};

/**
* Trying to parse and decode an org auth token. Based on:
* - https://github.com/getsentry/rfcs/blob/main/text/0091-ci-upload-tokens.md#parsing-tokens
* - https://github.com/getsentry/rfcs/blob/main/text/0091-ci-upload-tokens.md#token-facts
*/
function isValidOrgToken(input: string): boolean {
if (!input.startsWith('sntrys_')) {
return false;
}

const tokenParts = input.split('_');
if (tokenParts.length < 3) {
return false;
}

try {
const payload = tokenParts[1];
const decodedPayload = Buffer.from(payload, 'base64').toString();
const jsonPayload = JSON.parse(decodedPayload) as MaybeOrgAuthToken;
if (!jsonPayload.iat || !jsonPayload.url || !jsonPayload.org) {
return false;
}
} catch {
return false;
}

return true;
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry/wizard",
"version": "3.9.1",
"version": "3.10.0",
"homepage": "https://github.com/getsentry/sentry-wizard",
"repository": "https://github.com/getsentry/sentry-wizard",
"description": "Sentry wizard helping you to configure your project",
Expand Down Expand Up @@ -38,6 +38,7 @@
"read-env": "^1.3.0",
"semver": "^7.5.3",
"xcode": "3.0.1",
"xml-js": "^1.6.11",
"yargs": "^16.2.0"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 196a999

Please sign in to comment.