diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c1b6622..a6f66e784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## Unreleased + +
+Internal Changes + +- chore: migrate from `chalk` to `picocolors` ([#1069](https://github.com/getsentry/sentry-wizard/pull/1069)) + +
+
+ ## 6.2.0 - feat(cocoa): Add structured logs opt-in option ([#1051](https://github.com/getsentry/sentry-wizard/pull/1051)) diff --git a/lib/Helper/Logging.ts b/lib/Helper/Logging.ts index a2bbf7211..2586cea1f 100644 --- a/lib/Helper/Logging.ts +++ b/lib/Helper/Logging.ts @@ -1,4 +1,4 @@ -import Chalk from 'chalk'; +import pc from 'picocolors'; export function prepareMessage(msg: unknown): string { if (typeof msg === 'string') { @@ -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)))); } diff --git a/lib/Steps/Welcome.ts b/lib/Steps/Welcome.ts index ba4a3691a..c55e04235 100755 --- a/lib/Steps/Welcome.ts +++ b/lib/Steps/Welcome.ts @@ -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; @@ -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', )}.`, ); diff --git a/package.json b/package.json index f62387bf2..a5d6b21f7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/android/android-wizard.ts b/src/android/android-wizard.ts index a7c0007be..6e08d021b 100644 --- a/src/android/android-wizard.ts +++ b/src/android/android-wizard.ts @@ -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 { @@ -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.`, ); @@ -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'); @@ -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), @@ -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.`, ); @@ -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}`, )} diff --git a/src/android/code-tools.ts b/src/android/code-tools.ts index 324bdbc74..c2716b071 100644 --- a/src/android/code-tools.ts +++ b/src/android/code-tools.ts @@ -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, @@ -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.`, ), @@ -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.`, ), ); diff --git a/src/android/gradle.ts b/src/android/gradle.ts index a79d32bb6..6f29dfb9a 100644 --- a/src/android/gradle.ts +++ b/src/android/gradle.ts @@ -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'; /** @@ -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) { @@ -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); @@ -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) { diff --git a/src/android/manifest.ts b/src/android/manifest.ts index 92b9f3c4a..c754db88d 100644 --- a/src/android/manifest.ts +++ b/src/android/manifest.ts @@ -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 tag in the manifest and adds the Sentry config after it. @@ -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; } @@ -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.`, ), diff --git a/src/angular/angular-wizard.ts b/src/angular/angular-wizard.ts index 09c471201..f1ed3946d 100644 --- a/src/angular/angular-wizard.ts +++ b/src/angular/angular-wizard.ts @@ -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 { @@ -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) { @@ -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', )} `, @@ -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!`, ); @@ -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', @@ -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.`; } diff --git a/src/angular/codemods/app-config.ts b/src/angular/codemods/app-config.ts index be500c457..f48f88e59 100644 --- a/src/angular/codemods/app-config.ts +++ b/src/angular/codemods/app-config.ts @@ -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 @@ -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/', )} `); diff --git a/src/angular/example-component.ts b/src/angular/example-component.ts index 35f1ba1ee..0cf3c1a77 100644 --- a/src/angular/example-component.ts +++ b/src/angular/example-component.ts @@ -8,7 +8,7 @@ import { // @ts-expect-error - clack is ESM and TS complains about that. It works though import * as clack from '@clack/prompts'; import { getIssueStreamUrl } from '../utils/url'; -import chalk from 'chalk'; +import pc from 'picocolors'; interface ExampleComponentOptions { url: string; @@ -42,7 +42,7 @@ export async function createExampleComponent(options: ExampleComponentOptions) { fs.writeFileSync(componentFilePath, componentCode); clack.log.success( - `Created example component at ${chalk.cyan(componentFilePath)}`, + `Created example component at ${pc.cyan(componentFilePath)}`, ); const addComponentCodeSnippet = makeCodeSnippet(true, (unchanged, plus) => @@ -65,7 +65,7 @@ export async function createExampleComponent(options: ExampleComponentOptions) { ); await showCopyPasteInstructions({ - instructions: `Add the example component one of your pages or components (for example, in ${chalk.cyan( + instructions: `Add the example component one of your pages or components (for example, in ${pc.cyan( 'app.component.ts', )}).`, codeSnippet: addComponentCodeSnippet, @@ -166,7 +166,7 @@ import * as Sentry from '@sentry/angular'; p { margin: 0; font-size: 20px; - } + } a { color: #6341F0; @@ -245,7 +245,7 @@ import * as Sentry from '@sentry/angular'; margin: 0; max-width: 400px; } - + .connectivity-error a { color: #FFFFFF; text-decoration: underline; diff --git a/src/angular/sdk-setup.ts b/src/angular/sdk-setup.ts index 29b7afb3c..d0598379e 100644 --- a/src/angular/sdk-setup.ts +++ b/src/angular/sdk-setup.ts @@ -8,7 +8,7 @@ import * as path from 'path'; // @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 { updateAppConfigMod } from './codemods/app-config'; import { updateAppEntryMod } from './codemods/main'; import { hasSentryContent } from '../utils/ast-utils'; @@ -32,8 +32,8 @@ export async function initializeSentryOnApplicationEntry( if (hasSentryContent(originalAppEntry.$ast as t.Program)) { clack.log.warn( - `File ${chalk.cyan(appEntryFilename)} already contains Sentry. -Skipping adding Sentry functionality to ${chalk.cyan(appEntryFilename)}.`, + `File ${pc.cyan(appEntryFilename)} already contains Sentry. +Skipping adding Sentry functionality to ${pc.cyan(appEntryFilename)}.`, ); return; @@ -49,12 +49,12 @@ Skipping adding Sentry functionality to ${chalk.cyan(appEntryFilename)}.`, await writeFile(updatedAppEntryMod.$ast, appEntryPath); } catch (error: unknown) { clack.log.error( - `Error while adding Sentry to ${chalk.cyan(appEntryFilename)}`, + `Error while adding Sentry to ${pc.cyan(appEntryFilename)}`, ); clack.log.warn( `Please refer to the documentation for manual setup: -${chalk.underline( +${pc.underline( 'https://docs.sentry.io/platforms/javascript/guides/angular/#configure', )}`, ); @@ -63,7 +63,7 @@ ${chalk.underline( } clack.log.success( - `Successfully initialized Sentry on ${chalk.cyan(appEntryFilename)}`, + `Successfully initialized Sentry on ${pc.cyan(appEntryFilename)}`, ); } @@ -83,13 +83,13 @@ export async function updateAppConfig( Sentry.setTag('angular-app-config-found', false); clack.log.warn( - `File ${chalk.cyan( + `File ${pc.cyan( appConfigFilename, )} not found. Skipping adding Sentry functionality.`, ); clack.log.warn(`Please refer to the documentation for manual setup: -${chalk.underline( +${pc.underline( 'https://docs.sentry.io/platforms/javascript/guides/angular/#configure', )}`); @@ -102,8 +102,8 @@ ${chalk.underline( if (hasSentryContent(appConfig.$ast as t.Program)) { clack.log.warn( - `File ${chalk.cyan(appConfigFilename)} already contains Sentry. - Skipping adding Sentry functionality to ${chalk.cyan(appConfigFilename)}.`, + `File ${pc.cyan(appConfigFilename)} already contains Sentry. + Skipping adding Sentry functionality to ${pc.cyan(appConfigFilename)}.`, ); return; @@ -119,11 +119,11 @@ ${chalk.underline( await writeFile(updatedAppConfigMod.$ast, appConfigPath); } catch (error: unknown) { clack.log.error( - `Error while updating your app config ${chalk.cyan(appConfigFilename)}.`, + `Error while updating your app config ${pc.cyan(appConfigFilename)}.`, ); clack.log.info( - chalk.dim( + pc.dim( typeof error === 'object' && error != null && 'toString' in error ? error.toString() : typeof error === 'string' @@ -133,7 +133,7 @@ ${chalk.underline( ); clack.log.warn(`Please refer to the documentation for manual setup: -${chalk.underline( +${pc.underline( 'https://docs.sentry.io/platforms/javascript/guides/angular/#configure', )}`); @@ -141,6 +141,6 @@ ${chalk.underline( } clack.log.success( - `Successfully updated your app config ${chalk.cyan(appConfigFilename)}`, + `Successfully updated your app config ${pc.cyan(appConfigFilename)}`, ); } diff --git a/src/apple/apple-wizard.ts b/src/apple/apple-wizard.ts index 85225f396..0bb5b855d 100644 --- a/src/apple/apple-wizard.ts +++ b/src/apple/apple-wizard.ts @@ -1,6 +1,6 @@ // @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 { withTelemetry } from '../telemetry'; import { @@ -88,7 +88,7 @@ async function runAppleWizardWithTelementry( const selectedFeatures = await featureSelectionPrompt([ { 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: 'optional', diff --git a/src/apple/cocoapod.ts b/src/apple/cocoapod.ts index ac5a76868..b87387ca8 100644 --- a/src/apple/cocoapod.ts +++ b/src/apple/cocoapod.ts @@ -4,7 +4,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'; export function usesCocoaPod(projPath: string): boolean { return fs.existsSync(path.join(projPath, 'Podfile')); @@ -61,10 +61,10 @@ export async function podInstall(dir = '.') { installSpinner.stop('Failed to install pods.'); Sentry.setTag('pods-installed', false); clack.log.error( - `${chalk.red( + `${pc.red( 'Encountered the following error during pods installation:', // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - )}\n\n${e}\n\n${chalk.dim( + )}\n\n${e}\n\n${pc.dim( 'If you think this issue is caused by the Sentry wizard, let us know here:\nhttps://github.com/getsentry/sentry-wizard/issues', )}`, ); diff --git a/src/apple/configure-fastlane.ts b/src/apple/configure-fastlane.ts index 1c0065d0d..cb1e3dd9f 100644 --- a/src/apple/configure-fastlane.ts +++ b/src/apple/configure-fastlane.ts @@ -1,7 +1,7 @@ // @ts-expect-error - clack is ESM and TS complains about that. It works though import clack from '@clack/prompts'; import * as Sentry from '@sentry/node'; -import chalk from 'chalk'; +import pc from 'picocolors'; import { traceStep } from '../telemetry'; import { debug } from '../utils/debug'; import * as fastlane from './fastlane'; @@ -15,7 +15,7 @@ export async function configureFastlane({ orgSlug: string; projectSlug: string; }) { - debug(`Checking if Fastfile exists in directory: ${chalk.cyan(projectDir)}`); + debug(`Checking if Fastfile exists in directory: ${pc.cyan(projectDir)}`); const isFastlaneAvailable = fastlane.fastFile(projectDir); Sentry.setTag('fastlane-exists', isFastlaneAvailable); if (!isFastlaneAvailable) { @@ -29,7 +29,7 @@ export async function configureFastlane({ message: 'Found a Fastfile in your project. Do you want to configure a lane to upload debug symbols to Sentry?', }); - debug(`User wants to add lane: ${chalk.cyan(shouldAddLane.toString())}`); + debug(`User wants to add lane: ${pc.cyan(shouldAddLane.toString())}`); Sentry.setTag('fastlane-desired', shouldAddLane); if (shouldAddLane) { @@ -38,7 +38,7 @@ export async function configureFastlane({ fastlane.addSentryToFastlane(projectDir, orgSlug, projectSlug), ); Sentry.setTag('fastlane-added', added); - debug(`Fastlane added: ${chalk.cyan(added.toString())}`); + debug(`Fastlane added: ${pc.cyan(added.toString())}`); if (added) { clack.log.step( diff --git a/src/apple/configure-package-manager.ts b/src/apple/configure-package-manager.ts index 4f1f36eb4..b7af97e20 100644 --- a/src/apple/configure-package-manager.ts +++ b/src/apple/configure-package-manager.ts @@ -1,7 +1,7 @@ // @ts-expect-error - clack is ESM and TS complains about that. It works though import clack from '@clack/prompts'; import * as Sentry from '@sentry/node'; -import chalk from 'chalk'; +import pc from 'picocolors'; import { traceStep } from '../telemetry'; import { askForItemSelection } from '../utils/clack'; @@ -13,9 +13,7 @@ export async function configurePackageManager({ }: { projectDir: string; }) { - debug( - `Checking if CocoaPods is installed at path: ${chalk.cyan(projectDir)}`, - ); + debug(`Checking if CocoaPods is installed at path: ${pc.cyan(projectDir)}`); // Xcode ships with the Swift Package Manager and potentially using CocoaPods. // We need to check if the user has CocoaPods set up. @@ -37,7 +35,7 @@ export async function configurePackageManager({ ), ) ).value; - debug(`User chose package manager: ${chalk.cyan(pm)}`); + debug(`User chose package manager: ${pc.cyan(pm)}`); shouldUseSPM = pm === 'Swift Package Manager'; @@ -47,7 +45,7 @@ export async function configurePackageManager({ cocoapod.addCocoaPods(projectDir), ); Sentry.setTag('cocoapod-added', podAdded); - debug(`CocoaPods reference added: ${chalk.cyan(podAdded.toString())}`); + debug(`CocoaPods reference added: ${pc.cyan(podAdded.toString())}`); if (!podAdded) { clack.log.warn( @@ -56,7 +54,7 @@ export async function configurePackageManager({ } } } - debug(`Should use SPM: ${chalk.cyan(shouldUseSPM.toString())}`); + debug(`Should use SPM: ${pc.cyan(shouldUseSPM.toString())}`); Sentry.setTag('package-manager', shouldUseSPM ? 'SPM' : 'cocoapods'); return { shouldUseSPM }; diff --git a/src/apple/configure-sentry-cli.ts b/src/apple/configure-sentry-cli.ts index a5e5af747..64e539a24 100644 --- a/src/apple/configure-sentry-cli.ts +++ b/src/apple/configure-sentry-cli.ts @@ -1,7 +1,7 @@ // @ts-expect-error - clack is ESM and TS complains about that. It works though import clack from '@clack/prompts'; import * as Sentry from '@sentry/node'; -import chalk from 'chalk'; +import pc from 'picocolors'; import { debug } from '../utils/debug'; import * as SentryUtils from '../utils/sentrycli-utils'; @@ -13,18 +13,18 @@ export function configureSentryCLI({ projectDir: string; authToken: string; }) { - debug(`Creating sentryclirc file at path: ${chalk.cyan(projectDir)}`); + debug(`Creating sentryclirc file at path: ${pc.cyan(projectDir)}`); SentryUtils.createSentryCLIRC(projectDir, { auth_token: authToken }); clack.log.info( - `Created a ${chalk.cyan( + `Created a ${pc.cyan( '.sentryclirc', )} file in your project directory to provide an auth token for Sentry CLI. - -It was also added to your ${chalk.cyan('.gitignore')} file. -Set the ${chalk.cyan( + +It was also added to your ${pc.cyan('.gitignore')} file. +Set the ${pc.cyan( 'SENTRY_AUTH_TOKEN', )} environment variable in your CI environment. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`, ); Sentry.setTag('sentry-cli-configured', true); - debug(`Sentry CLI configured: ${chalk.cyan(true.toString())}`); + debug(`Sentry CLI configured: ${pc.cyan(true.toString())}`); } diff --git a/src/apple/inject-code-snippet.ts b/src/apple/inject-code-snippet.ts index 4e0a2aff7..dd3eeb441 100644 --- a/src/apple/inject-code-snippet.ts +++ b/src/apple/inject-code-snippet.ts @@ -1,7 +1,7 @@ // @ts-expect-error - clack is ESM and TS complains about that. It works though import clack from '@clack/prompts'; import * as Sentry from '@sentry/node'; -import chalk from 'chalk'; +import pc from 'picocolors'; import { traceStep } from '../telemetry'; import { debug } from '../utils/debug'; import * as codeTools from './code-tools'; @@ -19,9 +19,7 @@ export function injectCodeSnippet({ enableLogs: boolean; }) { debug( - `Injecting code snippet into project at path: ${chalk.cyan( - project.baseDir, - )}`, + `Injecting code snippet into project at path: ${pc.cyan(project.baseDir)}`, ); const codeAdded = traceStep('Add code snippet', () => { const files = project.getSourceFilesForTarget(target); @@ -35,7 +33,7 @@ export function injectCodeSnippet({ return codeTools.addCodeSnippetToProject(files, dsn, enableLogs); }); Sentry.setTag('Snippet-Added', codeAdded); - debug(`Snippet added: ${chalk.cyan(codeAdded.toString())}`); + debug(`Snippet added: ${pc.cyan(codeAdded.toString())}`); if (!codeAdded) { clack.log.warn( diff --git a/src/apple/lookup-xcode-project.ts b/src/apple/lookup-xcode-project.ts index 4281a3cad..544f60fd2 100644 --- a/src/apple/lookup-xcode-project.ts +++ b/src/apple/lookup-xcode-project.ts @@ -1,7 +1,7 @@ // @ts-expect-error - clack is ESM and TS complains about that. It works though import clack from '@clack/prompts'; import * as Sentry from '@sentry/node'; -import chalk from 'chalk'; +import pc from 'picocolors'; import * as fs from 'fs'; import * as path from 'path'; @@ -19,7 +19,7 @@ export async function lookupXcodeProject({ xcProject: XcodeProject; target: string; }> { - debug(`Looking for Xcode project in directory: ${chalk.cyan(projectDir)}`); + debug(`Looking for Xcode project in directory: ${pc.cyan(projectDir)}`); const xcodeProjFiles = searchXcodeProjectAtPath(projectDir); if (xcodeProjFiles.length === 0) { clack.log.error( @@ -29,7 +29,7 @@ export async function lookupXcodeProject({ return await abort(); } debug( - `Found ${chalk.cyan( + `Found ${pc.cyan( xcodeProjFiles.length.toString(), )} candidates for Xcode project`, ); @@ -56,7 +56,7 @@ export async function lookupXcodeProject({ // Load the pbxproj file const pathToPbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj'); - debug(`Loading Xcode project pbxproj at path: ${chalk.cyan(pathToPbxproj)}`); + debug(`Loading Xcode project pbxproj at path: ${pc.cyan(pathToPbxproj)}`); if (!fs.existsSync(pathToPbxproj)) { clack.log.error(`No pbxproj found at ${xcodeProjFile}`); Sentry.setTag('pbxproj-not-found', true); @@ -71,7 +71,7 @@ export async function lookupXcodeProject({ return await abort(); } debug( - `Found ${chalk.cyan( + `Found ${pc.cyan( availableTargets.length.toString(), )} targets in Xcode project`, ); @@ -94,7 +94,7 @@ export async function lookupXcodeProject({ ) ).value; } - debug(`Selected target: ${chalk.cyan(target)}`); + debug(`Selected target: ${pc.cyan(target)}`); return { xcProject, diff --git a/src/flutter/code-tools.ts b/src/flutter/code-tools.ts index ccc141ad5..154a3205c 100644 --- a/src/flutter/code-tools.ts +++ b/src/flutter/code-tools.ts @@ -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, pubspecOptions, @@ -63,14 +63,12 @@ export function patchPubspec( pubspecContent.slice(dependenciesIndex); clack.log.success( - chalk.greenBright( - `${chalk.bold('sentry_flutter')} added to pubspec.yaml`, - ), + pc.greenBright(`${pc.bold('sentry_flutter')} added to pubspec.yaml`), ); } else { clack.log.success( - chalk.greenBright( - `${chalk.bold('sentry_flutter')} is already included in pubspec.yaml`, + pc.greenBright( + `${pc.bold('sentry_flutter')} is already included in pubspec.yaml`, ), ); } @@ -83,14 +81,14 @@ export function patchPubspec( pubspecContent.slice(devDependenciesIndex); clack.log.success( - chalk.greenBright( - `${chalk.bold('sentry_dart_plugin')} added to pubspec.yaml`, + pc.greenBright( + `${pc.bold('sentry_dart_plugin')} added to pubspec.yaml`, ), ); } else { clack.log.success( - chalk.greenBright( - `${chalk.bold( + pc.greenBright( + `${pc.bold( 'sentry_dart_plugin', )} is already included in pubspec.yaml`, ), @@ -102,14 +100,14 @@ export function patchPubspec( pubspecContent += pubspecOptions(project, org); clack.log.success( - chalk.greenBright( - `${chalk.bold('sentry plugin configuration')} added to pubspec.yaml`, + pc.greenBright( + `${pc.bold('sentry plugin configuration')} added to pubspec.yaml`, ), ); } else { clack.log.success( - chalk.greenBright( - `${chalk.bold( + pc.greenBright( + `${pc.bold( 'sentry plugin configuration', )} is already included in pubspec.yaml`, ), @@ -120,7 +118,7 @@ export function patchPubspec( return true; } catch (error) { - clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`); + clack.log.warn(`Failed to read/write ${pc.cyan('pubspec.yaml')} file.`); Sentry.captureException(error); return false; } @@ -150,7 +148,7 @@ export function addProperties(pubspecFile: string | null, authToken: string) { } return true; } catch (error) { - clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`); + clack.log.warn(`Failed to read/write ${pc.cyan('pubspec.yaml')} file.`); Sentry.captureException(error); return false; } @@ -174,8 +172,8 @@ export async function patchMain( ) { // sentry is already configured clack.log.success( - chalk.greenBright( - `${chalk.bold('main.dart')} already has Sentry configured.`, + pc.greenBright( + `${pc.bold('main.dart')} already has Sentry configured.`, ), ); return true; @@ -184,7 +182,7 @@ export async function patchMain( const features = [ { id: 'tracing', - 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', @@ -193,7 +191,7 @@ export async function patchMain( if (canEnableProfiling) { features.push({ id: 'profiling', - prompt: `Do you want to enable ${chalk.bold( + prompt: `Do you want to enable ${pc.bold( 'Profiling', )} to analyze CPU usage and optimize performance-critical code on iOS & macOS?`, enabledHint: 'recommended, tracing must be enabled', @@ -201,14 +199,14 @@ export async function patchMain( } features.push({ id: 'replay', - prompt: `Do you want to enable ${chalk.bold( + prompt: `Do you want to enable ${pc.bold( 'Session Replay', )} to record user interactions and debug issues?`, enabledHint: 'recommended', }); features.push({ 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: 'optional', @@ -239,8 +237,8 @@ export async function patchMain( fs.writeFileSync(mainFile, mainContent, 'utf8'); clack.log.success( - chalk.greenBright( - `Patched ${chalk.bold( + pc.greenBright( + `Patched ${pc.bold( 'main.dart', )} with the Sentry setup and test error snippet.`, ), @@ -248,7 +246,7 @@ export async function patchMain( return true; } catch (error) { - clack.log.warn(`Failed to read/write ${chalk.cyan('main.dart')} file.`); + clack.log.warn(`Failed to read/write ${pc.cyan('main.dart')} file.`); Sentry.captureException(error); return false; } diff --git a/src/flutter/flutter-wizard.ts b/src/flutter/flutter-wizard.ts index 4db72b221..bfb1e8294 100644 --- a/src/flutter/flutter-wizard.ts +++ b/src/flutter/flutter-wizard.ts @@ -7,7 +7,7 @@ import * as codetools from './code-tools'; import { initSnippetColored, pubspecSnippetColored } from './templates'; // @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 { confirmContinueIfNoOrDirtyGitRepo, @@ -50,7 +50,7 @@ async function runFlutterWizardWithTelemetry( const pubspecFile = path.join(projectDir, 'pubspec.yaml'); if (!fs.existsSync(pubspecFile)) { clack.log.error( - `Could not find ${chalk.cyan( + `Could not find ${pc.cyan( 'pubspec.yaml', )}. Make sure you run the wizard in the projects root folder.`, ); @@ -60,9 +60,7 @@ async function runFlutterWizardWithTelemetry( // ======== STEP 1. Add sentry_flutter and sentry_dart_plugin to pubspec.yaml ============ clack.log.step( - `Adding ${chalk.bold('Sentry')} to your apps ${chalk.cyan( - 'pubspec.yaml', - )} file.`, + `Adding ${pc.bold('Sentry')} to your apps ${pc.cyan('pubspec.yaml')} file.`, ); const flutterVersion = await fetchSdkVersion('sentry.dart.flutter'); @@ -82,9 +80,7 @@ async function runFlutterWizardWithTelemetry( ); if (!pubspecPatched) { clack.log.warn( - `Could not patch ${chalk.cyan( - 'pubspec.yaml', - )}. Add the dependencies to it.`, + `Could not patch ${pc.cyan('pubspec.yaml')}. Add the dependencies to it.`, ); await showCopyPasteInstructions({ filename: 'pubspec.yaml', @@ -106,17 +102,17 @@ async function runFlutterWizardWithTelemetry( ); if (!propertiesAdded) { clack.log.warn( - `We could not add ${chalk.cyan( + `We could not add ${pc.cyan( 'sentry.properties', )} file in your project directory in order to provide an auth token for Sentry CLI. You'll have to add it manually, or you can set the SENTRY_AUTH_TOKEN environment variable instead. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`, ); } else { clack.log.info( - `Created a ${chalk.cyan( + `Created a ${pc.cyan( 'sentry.properties', )} file in your project directory to provide an auth token for Sentry CLI. -It was also added to your ${chalk.cyan('.gitignore')} file. -Set the ${chalk.cyan( +It was also added to your ${pc.cyan('.gitignore')} file. +Set the ${pc.cyan( 'SENTRY_AUTH_TOKEN', )} environment variable in your CI environment. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`, ); @@ -126,7 +122,7 @@ Set the ${chalk.cyan( // ======== STEP 3. Patch main.dart with setup and a test error snippet ============ clack.log.step( - `Next, the wizard will patch your ${chalk.cyan( + `Next, the wizard will patch your ${pc.cyan( 'main.dart', )} file with the SDK init and a test error snippet.`, ); @@ -141,7 +137,7 @@ Set the ${chalk.cyan( ); if (!mainPatched) { clack.log.warn( - `Could not patch ${chalk.cyan( + `Could not patch ${pc.cyan( 'main.dart', )} file. Place the following code snippet within the apps main function.`, ); @@ -160,20 +156,20 @@ Set the ${chalk.cyan( : `https://${selectedProject.organization.slug}.sentry.io/issues/?project=${selectedProject.id}`; clack.outro(` - ${chalk.greenBright('Successfully installed the Sentry Flutter SDK!')} - - ${chalk.cyan('Next steps:')} - 1. Run ${chalk.bold( + ${pc.greenBright('Successfully installed the Sentry Flutter SDK!')} + + ${pc.cyan('Next steps:')} + 1. Run ${pc.bold( 'flutter run', )} to test the setup - we've added a test error that will trigger on app start - 2. For production builds, run ${chalk.bold( + 2. For production builds, run ${pc.bold( 'flutter build apk --obfuscate --split-debug-info=build/debug-info', - )} (or ios/macos) then ${chalk.bold( + )} (or ios/macos) then ${pc.bold( 'flutter pub run sentry_dart_plugin', )} to upload debug symbols 3. View your test error and transaction data at ${issuesPageLink} - - ${chalk.cyan('Learn more:')} + + ${pc.cyan('Learn more:')} - Debug Symbols: https://docs.sentry.io/platforms/dart/guides/flutter/debug-symbols/ - Performance Monitoring: https://docs.sentry.io/platforms/dart/guides/flutter/performance/ - Integrations: https://docs.sentry.io/platforms/dart/guides/flutter/integrations/ diff --git a/src/nextjs/nextjs-wizard.ts b/src/nextjs/nextjs-wizard.ts index 6ec34ba96..666f428a0 100644 --- a/src/nextjs/nextjs-wizard.ts +++ b/src/nextjs/nextjs-wizard.ts @@ -1,7 +1,7 @@ /* eslint-disable max-lines */ // @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 * as fs from 'fs'; // @ts-expect-error - magicast is ESM and TS complains about that. It works though import { parseModule } from 'magicast'; @@ -165,7 +165,7 @@ export async function runNextjsWizardWithTelemetry( ); clack.log.success( - `Created ${chalk.cyan( + `Created ${pc.cyan( path.join(...pagesLocation, underscoreErrorFileName), )}.`, ); @@ -178,9 +178,9 @@ export async function runNextjsWizardWithTelemetry( .includes('getInitialProps') ) { clack.log.info( - `It seems like you already have a custom error page.\n\nPlease put the following function call in the ${chalk.bold( + `It seems like you already have a custom error page.\n\nPlease put the following function call in the ${pc.bold( 'getInitialProps', - )}\nmethod of your custom error page at ${chalk.bold( + )}\nmethod of your custom error page at ${pc.bold( path.join(...pagesLocation, underscoreErrorPageFile), )}:`, ); @@ -190,7 +190,7 @@ export async function runNextjsWizardWithTelemetry( const shouldContinue = await abortIfCancelled( clack.confirm({ - message: `Did you modify your ${chalk.cyan( + message: `Did you modify your ${pc.cyan( path.join(...pagesLocation, underscoreErrorPageFile), )} file as described above?`, active: 'Yes', @@ -203,7 +203,7 @@ export async function runNextjsWizardWithTelemetry( } } else { clack.log.info( - `It seems like you already have a custom error page.\n\nPlease add the following code to your custom error page\nat ${chalk.cyan( + `It seems like you already have a custom error page.\n\nPlease add the following code to your custom error page\nat ${pc.cyan( path.join(...pagesLocation, underscoreErrorPageFile), )}:`, ); @@ -218,7 +218,7 @@ export async function runNextjsWizardWithTelemetry( const shouldContinue = await abortIfCancelled( clack.confirm({ - message: `Did you add the code to your ${chalk.cyan( + message: `Did you add the code to your ${pc.cyan( path.join(...pagesLocation, underscoreErrorPageFile), )} file as described above?`, active: 'Yes', @@ -269,13 +269,13 @@ export async function runNextjsWizardWithTelemetry( ); clack.log.success( - `Created ${chalk.cyan( + `Created ${pc.cyan( path.join(...appDirLocation, newGlobalErrorFileName), )}.`, ); } else { clack.log.info( - `It seems like you already have a custom error page for your app directory.\n\nPlease add the following code to your custom error page\nat ${chalk.cyan( + `It seems like you already have a custom error page for your app directory.\n\nPlease add the following code to your custom error page\nat ${pc.cyan( path.join(...appDirLocation, globalErrorPageFile), )}:\n`, ); @@ -290,7 +290,7 @@ export async function runNextjsWizardWithTelemetry( const shouldContinue = await abortIfCancelled( clack.confirm({ - message: `Did you add the code to your ${chalk.cyan( + message: `Did you add the code to your ${pc.cyan( path.join(...appDirLocation, globalErrorPageFile), )} file as described above?`, active: 'Yes', @@ -328,7 +328,7 @@ export async function runNextjsWizardWithTelemetry( ); clack.log.success( - `Created ${chalk.cyan( + `Created ${pc.cyan( path.join(...appDirLocation, newRootLayoutFilename), )}.`, ); @@ -362,7 +362,7 @@ export async function runNextjsWizardWithTelemetry( if (isLikelyUsingTurbopack || isLikelyUsingTurbopack === null) { await abortIfCancelled( clack.select({ - message: `Warning: The Sentry SDK is only compatible with Turbopack on Next.js version 15.3.0 (or 15.3.0-canary.8) or later. ${chalk.bold( + message: `Warning: The Sentry SDK is only compatible with Turbopack on Next.js version 15.3.0 (or 15.3.0-canary.8) or later. ${pc.bold( `If you are using Turbopack with an older Next.js version, temporarily remove \`--turbo\` or \`--turbopack\` from your dev command until you have verified the SDK is working as expected. Note that the SDK will continue to work for non-Turbopack production builds.`, )}`, options: [ @@ -396,11 +396,11 @@ export async function runNextjsWizardWithTelemetry( await runPrettierIfInstalled({ cwd: undefined }); clack.outro(` -${chalk.green('Successfully installed the Sentry Next.js SDK!')} ${ +${pc.green('Successfully installed the Sentry Next.js SDK!')} ${ shouldCreateExamplePage - ? `\n\nYou can validate your setup by (re)starting your dev environment (e.g. ${chalk.cyan( + ? `\n\nYou can validate your setup by (re)starting your dev environment (e.g. ${pc.cyan( `${packageManagerForOutro.runScriptCommand} dev`, - )}) and visiting ${chalk.cyan('"/sentry-example-page"')}` + )}) and visiting ${pc.cyan('"/sentry-example-page"')}` : '' }${ shouldCreateExamplePage && isLikelyUsingTurbopack @@ -408,7 +408,7 @@ ${chalk.green('Successfully installed the Sentry Next.js SDK!')} ${ : '' } -${chalk.dim( +${pc.dim( 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-javascript/issues', )}`); } @@ -426,21 +426,21 @@ async function createOrMergeNextJsFiles( 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( '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', @@ -489,11 +489,11 @@ async function createOrMergeNextJsFiles( if (overwriteExistingConfigs) { if (jsConfigExists) { fs.unlinkSync(path.join(process.cwd(), jsConfig)); - clack.log.warn(`Removed existing ${chalk.cyan(jsConfig)}.`); + clack.log.warn(`Removed existing ${pc.cyan(jsConfig)}.`); } if (tsConfigExists) { fs.unlinkSync(path.join(process.cwd(), tsConfig)); - clack.log.warn(`Removed existing ${chalk.cyan(tsConfig)}.`); + clack.log.warn(`Removed existing ${pc.cyan(tsConfig)}.`); } } } @@ -509,9 +509,7 @@ async function createOrMergeNextJsFiles( { encoding: 'utf8', flag: 'w' }, ); clack.log.success( - `Created fresh ${chalk.cyan( - typeScriptDetected ? tsConfig : jsConfig, - )}.`, + `Created fresh ${pc.cyan(typeScriptDetected ? tsConfig : jsConfig)}.`, ); Sentry.setTag(`created-${configVariant}-config`, true); } @@ -761,7 +759,7 @@ async function createOrMergeNextJsFiles( ); clack.log.success( - `Created ${chalk.cyan(configFilename)} with Sentry configuration.`, + `Created ${pc.cyan(configFilename)} with Sentry configuration.`, ); return; @@ -787,7 +785,7 @@ async function createOrMergeNextJsFiles( if (probablyIncludesSdk) { const injectAnyhow = await abortIfCancelled( clack.confirm({ - message: `${chalk.cyan( + message: `${pc.cyan( foundNextConfigFileFilename, )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`, }), @@ -804,9 +802,9 @@ async function createOrMergeNextJsFiles( ); clack.log.success( - `Added Sentry configuration to ${chalk.cyan( + `Added Sentry configuration to ${pc.cyan( foundNextConfigFileFilename, - )}. ${chalk.dim('(you probably want to clean this up a bit!)')}`, + )}. ${pc.dim('(you probably want to clean this up a bit!)')}`, ); } @@ -833,7 +831,7 @@ async function createOrMergeNextJsFiles( if (probablyIncludesSdk) { const injectAnyhow = await abortIfCancelled( clack.confirm({ - message: `${chalk.cyan( + message: `${pc.cyan( foundNextConfigFileFilename, )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`, }), @@ -883,7 +881,7 @@ async function createOrMergeNextJsFiles( probablyIncludesSdk ? 'Updated' : 'Added' } Sentry configuration ${ probablyIncludesSdk ? 'in' : 'to' - } ${chalk.cyan(foundNextConfigFileFilename)}. ${chalk.dim( + } ${pc.cyan(foundNextConfigFileFilename)}. ${pc.dim( '(you probably want to clean this up a bit!)', )}`, ); @@ -893,16 +891,16 @@ async function createOrMergeNextJsFiles( } catch { Sentry.setTag('next-config-mod-result', 'fail'); clack.log.warn( - chalk.yellow( - `Something went wrong writing to ${chalk.cyan( + pc.yellow( + `Something went wrong writing to ${pc.cyan( foundNextConfigFileFilename, )}.`, ), ); clack.log.info( - `Please put the following code snippet into ${chalk.cyan( + `Please put the following code snippet into ${pc.cyan( foundNextConfigFileFilename, - )}: ${chalk.dim('You probably have to clean it up a bit.')}\n`, + )}: ${pc.dim('You probably have to clean it up a bit.')}\n`, ); // eslint-disable-next-line no-console @@ -912,7 +910,7 @@ async function createOrMergeNextJsFiles( const shouldContinue = await abortIfCancelled( clack.confirm({ - message: `Are you done putting the snippet above into ${chalk.cyan( + message: `Are you done putting the snippet above into ${pc.cyan( foundNextConfigFileFilename, )}?`, active: 'Yes', @@ -997,7 +995,7 @@ async function createExamplePage( ); clack.log.success( - `Created ${chalk.cyan( + `Created ${pc.cyan( path.join(...appFolderLocation, newRootLayoutFilename), )}.`, ); @@ -1025,7 +1023,7 @@ async function createExamplePage( ); clack.log.success( - `Created ${chalk.cyan( + `Created ${pc.cyan( path.join(...appFolderLocation, 'sentry-example-page', newPageFileName), )}.`, ); @@ -1043,7 +1041,7 @@ async function createExamplePage( ); clack.log.success( - `Created ${chalk.cyan( + `Created ${pc.cyan( path.join( ...appFolderLocation, 'api', @@ -1073,7 +1071,7 @@ async function createExamplePage( ); clack.log.success( - `Created ${chalk.cyan( + `Created ${pc.cyan( path.join(...pagesFolderLocation, examplePageFileName), )}.`, ); @@ -1093,7 +1091,7 @@ async function createExamplePage( ); clack.log.success( - `Created ${chalk.cyan( + `Created ${pc.cyan( path.join(...pagesFolderLocation, 'api', apiRouteFileName), )}.`, ); diff --git a/src/nextjs/templates.ts b/src/nextjs/templates.ts index df326a6a9..ce606ef83 100644 --- a/src/nextjs/templates.ts +++ b/src/nextjs/templates.ts @@ -1,4 +1,4 @@ -import chalk from 'chalk'; +import pc from 'picocolors'; import { makeCodeSnippet } from '../utils/clack'; type WithSentryConfigOptions = { @@ -263,7 +263,7 @@ class SentryExampleFrontendError extends Error { export default function Page() { const [hasSentError, setHasSentError] = useState(false); const [isConnected, setIsConnected] = useState(true); - + useEffect(() => { async function checkConnectivity() { const result = await Sentry.diagnoseSdkConnectivity(); @@ -328,7 +328,7 @@ export default function Page() { )}
- +