Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Unreleased

<details>
<summary><strong>Internal Changes</strong></summary>

- chore: migrate from `chalk` to `picocolors` ([#1069](https://github.com/getsentry/sentry-wizard/pull/1069))

</details>
<br/>

## 6.2.0

- feat(cocoa): Add structured logs opt-in option ([#1051](https://github.com/getsentry/sentry-wizard/pull/1051))
Expand Down
14 changes: 7 additions & 7 deletions lib/Helper/Logging.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Chalk from 'chalk';
import pc from 'picocolors';

export function prepareMessage(msg: unknown): string {
if (typeof msg === 'string') {
Expand All @@ -20,28 +20,28 @@ export function nl(): void {
}

export function green(msg: string): void {
return l(Chalk.green(prepareMessage(msg)));
return l(pc.green(prepareMessage(msg)));
}

export function red(msg: string): void {
return l(Chalk.red(prepareMessage(msg)));
return l(pc.red(prepareMessage(msg)));
}

export function dim(msg: string): void {
return l(Chalk.dim(prepareMessage(msg)));
return l(pc.dim(prepareMessage(msg)));
}

export function yellow(msg: string): void {
return l(Chalk.yellow(prepareMessage(msg)));
return l(pc.yellow(prepareMessage(msg)));
}

export function cyan(msg: string): void {
return l(Chalk.cyan(prepareMessage(msg)));
return l(pc.cyan(prepareMessage(msg)));
}

/**
* @deprecated Use `debug` from `src/utils/debug.ts` instead.
*/
export function debug(msg: unknown): void {
return l(Chalk.italic.yellow(prepareMessage(msg)));
return l(pc.italic(pc.yellow(prepareMessage(msg))));
}
4 changes: 2 additions & 2 deletions lib/Steps/Welcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Answers } from 'inquirer';

import { dim, green } from '../Helper/Logging';
import { BaseStep } from './BaseStep';
import chalk from 'chalk';
import pc from 'picocolors';

export class Welcome extends BaseStep {
private static _didShow = false;
Expand All @@ -15,7 +15,7 @@ export class Welcome extends BaseStep {
if (this._argv.uninstall === false) {
green('Sentry Wizard will help you to configure your project');
dim(
`This wizard sends telemetry data and crash reports to Sentry. This helps us improve the Wizard. You can turn telemetry off at any time by running sentry-wizard ${chalk.cyan(
`This wizard sends telemetry data and crash reports to Sentry. This helps us improve the Wizard. You can turn telemetry off at any time by running sentry-wizard ${pc.cyan(
'--disable-telemetry',
)}.`,
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"@clack/prompts": "0.7.0",
"@sentry/node": "^7.119.2",
"axios": "1.8.2",
"chalk": "^2.4.1",
"glob": "9.3.5",
"inquirer": "^6.2.0",
"magicast": "^0.2.10",
"opn": "^5.4.0",
"picocolors": "^1.1.1",
"read-env": "^1.3.0",
"recast": "^0.23.3",
"semver": "^7.5.3",
Expand Down
14 changes: 7 additions & 7 deletions src/android/android-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs';
// @ts-expect-error - clack is ESM and TS complains about that. It works though
import * as clack from '@clack/prompts';
import * as Sentry from '@sentry/node';
import chalk from 'chalk';
import pc from 'picocolors';
import * as path from 'path';
import { traceStep, withTelemetry } from '../telemetry';
import {
Expand Down Expand Up @@ -73,7 +73,7 @@ async function runAndroidWizardWithTelemetry(

// ======== STEP 1. Add Sentry Gradle Plugin to build.gradle(.kts) ============
clack.log.step(
`Adding ${chalk.bold('Sentry Gradle plugin')} to your app's ${chalk.cyan(
`Adding ${pc.bold('Sentry Gradle plugin')} to your app's ${pc.cyan(
'build.gradle',
)} file.`,
);
Expand All @@ -93,7 +93,7 @@ async function runAndroidWizardWithTelemetry(

// ======== STEP 2. Configure Sentry SDK via AndroidManifest ============
clack.log.step(
`Configuring Sentry SDK via ${chalk.cyan('AndroidManifest.xml')}`,
`Configuring Sentry SDK via ${pc.cyan('AndroidManifest.xml')}`,
);
const appDir = path.dirname(appFile);
const manifestFile = path.join(appDir, 'src', 'main', 'AndroidManifest.xml');
Expand All @@ -113,7 +113,7 @@ async function runAndroidWizardWithTelemetry(

// ======== STEP 3. Patch Main Activity with a test error snippet ============
clack.log.step(
`Patching ${chalk.bold('Main Activity')} with a test error snippet.`,
`Patching ${pc.bold('Main Activity')} with a test error snippet.`,
);
const mainActivity = traceStep('Find Main Activity', () =>
manifest.getMainActivity(manifestFile),
Expand Down Expand Up @@ -150,7 +150,7 @@ async function runAndroidWizardWithTelemetry(

// ======== STEP 4. Add sentry-cli config file ============
clack.log.step(
`Configuring ${chalk.bold('proguard mappings upload')} via the ${chalk.cyan(
`Configuring ${pc.bold('proguard mappings upload')} via the ${pc.cyan(
'sentry.properties',
)} file.`,
);
Expand All @@ -163,9 +163,9 @@ async function runAndroidWizardWithTelemetry(
: `https://${selectedProject.organization.slug}.sentry.io/issues/?project=${selectedProject.id}`;

clack.outro(`
${chalk.greenBright('Successfully installed the Sentry Android SDK!')}
${pc.greenBright('Successfully installed the Sentry Android SDK!')}

${chalk.cyan(
${pc.cyan(
`You can validate your setup by launching your application and checking Sentry issues page afterwards
${issuesPageLink}`,
)}
Expand Down
12 changes: 5 additions & 7 deletions src/android/code-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from 'path';
import * as Sentry from '@sentry/node';
// @ts-expect-error - clack is ESM and TS complains about that. It works though
import * as clack from '@clack/prompts';
import chalk from 'chalk';
import pc from 'picocolors';
import {
sentryImport,
sentryImportKt,
Expand Down Expand Up @@ -94,8 +94,8 @@ export function patchMainActivity(activityFile: string | undefined): boolean {
if (/import\s+io\.sentry\.Sentry;?/i.test(activityContent)) {
// sentry is already configured
clack.log.success(
chalk.greenBright(
`${chalk.bold(
pc.greenBright(
`${pc.bold(
'Main Activity',
)} is already patched with test error snippet.`,
),
Expand Down Expand Up @@ -140,10 +140,8 @@ export function patchMainActivity(activityFile: string | undefined): boolean {
fs.writeFileSync(activityFile, newActivityContent, 'utf8');

clack.log.success(
chalk.greenBright(
`Patched ${chalk.bold(
'Main Activity',
)} with the Sentry test error snippet.`,
pc.greenBright(
`Patched ${pc.bold('Main Activity')} with the Sentry test error snippet.`,
),
);

Expand Down
14 changes: 6 additions & 8 deletions src/android/gradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as bash from '../utils/bash';
import * as Sentry from '@sentry/node';
// @ts-expect-error - clack is ESM and TS complains about that. It works though
import * as clack from '@clack/prompts';
import chalk from 'chalk';
import pc from 'picocolors';
import { fetchSdkVersion } from '../utils/release-registry';

/**
Expand Down Expand Up @@ -47,7 +47,7 @@ export async function selectAppFile(
Sentry.setTag('custom-build-logic', true);
const appFile = await abortIfCancelled(
clack.text({
message: `Unable to find your app's directory.
message: `Unable to find your app's directory.
Please enter the relative path to your app's build.gradle file from the root project`,
placeholder: 'app/build.gradle.kts',
validate(value) {
Expand Down Expand Up @@ -116,10 +116,8 @@ export async function addGradlePlugin(
if (/\(?["']io\.sentry\.android\.gradle["']\)?/.test(gradleScript)) {
// sentry gradle plugin is already installed
clack.log.success(
chalk.greenBright(
`${chalk.bold(
'Sentry Gradle plugin',
)} is already added to the project.`,
pc.greenBright(
`${pc.bold('Sentry Gradle plugin')} is already added to the project.`,
),
);
maybeAddSourceContextConfig(appFile, gradleScript, orgSlug, projectSlug);
Expand Down Expand Up @@ -180,8 +178,8 @@ export async function addGradlePlugin(
try {
await bash.execute('./gradlew');
buildSpinner.stop(
chalk.greenBright(
`${chalk.bold('Sentry Gradle plugin')} added to the project.`,
pc.greenBright(
`${pc.bold('Sentry Gradle plugin')} added to the project.`,
),
);
} catch (e) {
Expand Down
8 changes: 4 additions & 4 deletions src/android/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as clack from '@clack/prompts';
import * as Sentry from '@sentry/node';
import { manifest } from './templates';
import xml, { Attributes, ElementCompact } from 'xml-js';
import chalk from 'chalk';
import pc from 'picocolors';

/**
* Looks for the closing </application> tag in the manifest and adds the Sentry config after it.
Expand Down Expand Up @@ -39,7 +39,7 @@ export function addManifestSnippet(manifestFile: string, dsn: string): boolean {

if (/android:name="io\.sentry[^"]*"/i.test(manifestContent)) {
// sentry is already configured
clack.log.success(chalk.greenBright('Sentry SDK is already configured.'));
clack.log.success(pc.greenBright('Sentry SDK is already configured.'));
return true;
}

Expand All @@ -58,8 +58,8 @@ export function addManifestSnippet(manifestFile: string, dsn: string): boolean {
fs.writeFileSync(manifestFile, newContent, 'utf8');

clack.log.success(
chalk.greenBright(
`Updated ${chalk.bold(
pc.greenBright(
`Updated ${pc.bold(
'AndroidManifest.xml',
)} with the Sentry SDK configuration.`,
),
Expand Down
22 changes: 11 additions & 11 deletions src/angular/angular-wizard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-expect-error - clack is ESM and TS complains about that. It works though
import clack from '@clack/prompts';

import chalk from 'chalk';
import pc from 'picocolors';
import type { WizardOptions } from '../utils/types';
import { traceStep, withTelemetry } from '../telemetry';
import {
Expand Down Expand Up @@ -66,7 +66,7 @@ async function runAngularWizardWithTelemetry(

installedAngularVersion = await abortIfCancelled(
clack.text({
message: `Please enter your installed Angular major version (e.g. ${chalk.cyan(
message: `Please enter your installed Angular major version (e.g. ${pc.cyan(
'18',
)} for Angular 18)`,
validate(value) {
Expand Down Expand Up @@ -104,14 +104,14 @@ async function runAngularWizardWithTelemetry(
Sentry.setTag('angular-version-compatible', false);

clack.log.warn(
`Angular version ${chalk.cyan(
`Angular version ${pc.cyan(
MIN_SUPPORTED_ANGULAR_VERSION,
)} or higher is required for the Sentry SDK.`,
);
clack.log.warn(
`Please refer to Sentry's version compatibility table for more information:

${chalk.underline(
${pc.underline(
'https://docs.sentry.io/platforms/javascript/guides/angular/#angular-version-compatibility',
)}
`,
Expand All @@ -124,14 +124,14 @@ ${chalk.underline(
Sentry.setTag('angular-wizard-version-compatible', false);

clack.log.warn(
`The Sentry Angular Wizard requires Angular version ${chalk.cyan(
`The Sentry Angular Wizard requires Angular version ${pc.cyan(
MIN_SUPPORTED_WIZARD_ANGULAR_VERSION,
)} or higher.`,
);
clack.log.warn(
`Your Angular version (${installedAngularVersion}) is compatible with the Sentry SDK but you need to set it up manually by following our documentation:

${chalk.underline('https://docs.sentry.io/platforms/javascript/guides/angular')}
${pc.underline('https://docs.sentry.io/platforms/javascript/guides/angular')}

Apologies for the inconvenience!`,
);
Expand Down Expand Up @@ -160,21 +160,21 @@ Apologies for the inconvenience!`,
const selectedFeatures = await featureSelectionPrompt([
{
id: 'performance',
prompt: `Do you want to enable ${chalk.bold(
prompt: `Do you want to enable ${pc.bold(
'Tracing',
)} to track the performance of your application?`,
enabledHint: 'recommended',
},
{
id: 'replay',
prompt: `Do you want to enable ${chalk.bold(
prompt: `Do you want to enable ${pc.bold(
'Sentry Session Replay',
)} to get a video-like reproduction of errors during a user session?`,
enabledHint: 'recommended, but increases bundle size',
},
{
id: 'logs',
prompt: `Do you want to enable ${chalk.bold(
prompt: `Do you want to enable ${pc.bold(
'Logs',
)} to send your application logs to Sentry?`,
enabledHint: 'recommended',
Expand Down Expand Up @@ -247,10 +247,10 @@ Apologies for the inconvenience!`,
}

export function buildOutroMessage(createdExampleComponent: boolean): string {
let msg = chalk.green('\nSuccessfully installed the Sentry Angular SDK!');
let msg = pc.green('\nSuccessfully installed the Sentry Angular SDK!');

if (createdExampleComponent) {
msg += `\n\nYou can validate your setup by starting your dev environment (${chalk.cyan(
msg += `\n\nYou can validate your setup by starting your dev environment (${pc.cyan(
'ng serve',
)}) and throwing an error in the example component.`;
}
Expand Down
4 changes: 2 additions & 2 deletions src/angular/codemods/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { ProxifiedModule } from 'magicast';
import * as clack from '@clack/prompts';
import { gte, type SemVer } from 'semver';
import * as recast from 'recast';
import chalk from 'chalk';
import pc from 'picocolors';

export function updateAppConfigMod(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -204,7 +204,7 @@ function addProviders(
if (hasErrorHandlerProvider) {
clack.log.warn(`ErrorHandler provider already exists in your app config.
Please refer to the Sentry Angular SDK documentation to combine it manually with Sentry's ErrorHandler.
${chalk.underline(
${pc.underline(
'https://docs.sentry.io/platforms/javascript/guides/angular/features/error-handler/',
)}
`);
Expand Down
Loading
Loading