@sentry/wizard 3.3.2 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/bin.ts +29 -19
- package/dist/bin.js +23 -18
- package/dist/bin.js.map +1 -1
- package/dist/lib/Helper/Wizard.js +0 -9
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/ChooseIntegration.js +26 -10
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/{NextJs.d.ts → NextJsShim.d.ts} +1 -1
- package/dist/lib/Steps/Integrations/{NextJs.js → NextJsShim.js} +13 -10
- package/dist/lib/Steps/Integrations/NextJsShim.js.map +1 -0
- package/dist/lib/Steps/Integrations/SourceMapsShim.js +4 -1
- package/dist/lib/Steps/Integrations/SourceMapsShim.js.map +1 -1
- package/dist/lib/Steps/Integrations/{SvelteKit.d.ts → SvelteKitShim.d.ts} +1 -1
- package/dist/lib/Steps/Integrations/{SvelteKit.js → SvelteKitShim.js} +13 -10
- package/dist/lib/Steps/Integrations/SvelteKitShim.js.map +1 -0
- package/dist/package.json +3 -3
- package/dist/src/nextjs/nextjs-wizard.d.ts +2 -5
- package/dist/src/nextjs/nextjs-wizard.js +1 -1
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.d.ts +2 -5
- package/dist/src/sourcemaps/sourcemaps-wizard.js +68 -31
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/create-react-app.d.ts +1 -0
- package/dist/src/sourcemaps/tools/create-react-app.js +69 -0
- package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -0
- package/dist/src/sourcemaps/tools/esbuild.d.ts +2 -0
- package/dist/src/sourcemaps/tools/esbuild.js +109 -0
- package/dist/src/sourcemaps/tools/esbuild.js.map +1 -0
- package/dist/src/sourcemaps/tools/rollup.d.ts +2 -0
- package/dist/src/sourcemaps/tools/rollup.js +109 -0
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -0
- package/dist/src/sourcemaps/tools/sentry-cli.d.ts +2 -2
- package/dist/src/sourcemaps/tools/sentry-cli.js +111 -91
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.d.ts +1 -0
- package/dist/src/sourcemaps/tools/tsc.js +93 -0
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -0
- package/dist/src/sourcemaps/utils/sdk-version.d.ts +14 -0
- package/dist/src/sourcemaps/utils/sdk-version.js +275 -0
- package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -0
- package/dist/src/sveltekit/sveltekit-wizard.d.ts +2 -5
- package/dist/src/sveltekit/sveltekit-wizard.js +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +13 -2
- package/dist/src/utils/clack-utils.js +78 -45
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/types.d.ts +12 -0
- package/dist/src/utils/types.js +3 -0
- package/dist/src/utils/types.js.map +1 -0
- package/lib/Helper/Wizard.ts +0 -9
- package/lib/Setup.ts +1 -0
- package/lib/Steps/ChooseIntegration.ts +35 -11
- package/lib/Steps/Integrations/{NextJs.ts → NextJsShim.ts} +5 -2
- package/lib/Steps/Integrations/SourceMapsShim.ts +4 -1
- package/lib/Steps/Integrations/{SvelteKit.ts → SvelteKitShim.ts} +5 -2
- package/package.json +3 -3
- package/src/nextjs/nextjs-wizard.ts +3 -8
- package/src/sourcemaps/sourcemaps-wizard.ts +67 -38
- package/src/sourcemaps/tools/create-react-app.ts +19 -0
- package/src/sourcemaps/tools/esbuild.ts +65 -0
- package/src/sourcemaps/tools/rollup.ts +69 -0
- package/src/sourcemaps/tools/sentry-cli.ts +114 -105
- package/src/sourcemaps/tools/tsc.ts +39 -0
- package/src/sourcemaps/utils/sdk-version.ts +264 -0
- package/src/sveltekit/sveltekit-wizard.ts +3 -6
- package/src/utils/clack-utils.ts +71 -29
- package/src/utils/types.ts +13 -0
- package/dist/lib/Steps/Integrations/NextJs.js.map +0 -1
- package/dist/lib/Steps/Integrations/SvelteKit.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clack-utils.js","sourceRoot":"","sources":["../../../src/utils/clack-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,gDAA0B;AAC1B,gDAA0B;AAC1B,0DAA8C;AAC9C,qCAAyB;AACzB,yCAA6B;AAC7B,iCAAqC;AACrC,2BAA0B;AAC1B,6BAAiC;AACjC,mDAAuC;AACvC,oEAA8D;AAE9D,IAAM,QAAQ,GAAG,oBAAoB,CAAC;AAyBtC,SAAsB,KAAK,CAAC,OAAgB,EAAE,MAAe;;;;;;oBAC3D,KAAK,CAAC,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,yBAAyB,CAAC,CAAC;oBAC5C,SAAS,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;oBACnC,iBAAiB,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,cAAc,EAAE,CAAC;oBAChE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,SAAS,CAAC,SAAS,CAAC,CAAC;oBACxC,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,MAAM,EAAE,CAAC;oBACtB,aAAa,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,CAAC;oBACxD,IAAI,aAAa,EAAE;wBACjB,aAAa,CAAC,MAAM,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;wBAC7D,SAAS,CAAC,cAAc,CA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C,CAAA;QAC1C,CAAC,CAAC,CAAA,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,0CAAG,WAAW,CAAC,CAAA,CAC9C,CAAC;AACJ,CAAC;AARD,kDAQC;AAED,SAAe,iBAAiB;;;;;;oBAE9B,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE;wBACxD,sBAAsB,GAAG,MAAM,CAAC;qBACjC;yBAAM,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,mBAAmB,CAAC,CAAC,EAAE;wBACvE,sBAAsB,GAAG,KAAK,CAAC;qBAChC;yBAAM,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC,EAAE;wBACpE,sBAAsB,GAAG,MAAM,CAAC;qBACjC;oBAED,IAAI,sBAAsB,EAAE;wBAC1B,sBAAO,sBAAsB,EAAC;qBAC/B;oBAE+C,qBAAM,gBAAgB,CACpE,KAAK,CAAC,MAAM,CAAC;4BACX,OAAO,EAAE,qCAAqC;4BAC9C,OAAO,EAAE;gCACP,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;gCAC9B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;gCAChC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;6BACjC;yBACF,CAAC,CACH,EAAA;;oBATK,sBAAsB,GAAoB,SAS/C;oBAED,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,CAAC;oBAEzD,sBAAO,sBAAsB,EAAC;;;;CAC/B","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport axios from 'axios';\nimport chalk from 'chalk';\nimport * as childProcess from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { setInterval } from 'timers';\nimport { URL } from 'url';\nimport { promisify } from 'util';\nimport * as Sentry from '@sentry/node';\nimport { windowedSelect } from './vendor/clack-custom-select';\n\nconst SAAS_URL = 'https://sentry.io/';\n\ninterface WizardProjectData {\n apiKeys: {\n token: string;\n };\n projects: SentryProjectData[];\n}\n\nexport type PackageDotJson = {\n scripts?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n};\n\nexport interface SentryProjectData {\n id: string;\n slug: string;\n name: string;\n organization: {\n slug: string;\n };\n keys: [{ dsn: { public: string } }];\n}\n\nexport async function abort(message?: string, status?: number): Promise<never> {\n clack.outro(message ?? 'Wizard setup cancelled.');\n const sentryHub = Sentry.getCurrentHub();\n const sentryTransaction = sentryHub.getScope().getTransaction();\n sentryTransaction?.setStatus('aborted');\n sentryTransaction?.finish();\n const sentrySession = sentryHub.getScope().getSession();\n if (sentrySession) {\n sentrySession.status = status === 0 ? 'abnormal' : 'crashed';\n sentryHub.captureSession(true);\n }\n await Sentry.flush(3000);\n return process.exit(status ?? 1);\n}\n\nexport async function abortIfCancelled<T>(\n input: T | Promise<T>,\n): Promise<Exclude<T, symbol>> {\n if (clack.isCancel(await input)) {\n clack.cancel('Wizard setup cancelled.');\n const sentryHub = Sentry.getCurrentHub();\n const sentryTransaction = sentryHub.getScope().getTransaction();\n sentryTransaction?.setStatus('cancelled');\n sentryTransaction?.finish();\n sentryHub.captureSession(true);\n await Sentry.flush(3000);\n process.exit(0);\n } else {\n return input as Exclude<T, symbol>;\n }\n}\n\nexport function printWelcome(options: {\n wizardName: string;\n promoCode?: string;\n message?: string;\n}): void {\n let wizardPackage: { version?: string } = {};\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wizardPackage = require(path.join(\n path.dirname(require.resolve('@sentry/wizard')),\n '..',\n 'package.json',\n ));\n } catch {\n // We don't need to have this\n }\n\n // eslint-disable-next-line no-console\n console.log('');\n clack.intro(chalk.inverse(` ${options.wizardName} `));\n\n let welcomeText =\n options.message ||\n 'This Wizard will help you to set up Sentry for your application.\\nThank you for using Sentry :)';\n\n if (options.promoCode) {\n welcomeText += `\\n\\nUsing promo-code: ${options.promoCode}`;\n }\n\n if (wizardPackage.version) {\n welcomeText += `\\n\\nVersion: ${wizardPackage.version}`;\n }\n\n clack.note(welcomeText);\n}\n\nexport async function confirmContinueEvenThoughNoGitRepo(): Promise<void> {\n try {\n childProcess.execSync('git rev-parse --is-inside-work-tree', {\n stdio: 'ignore',\n });\n } catch {\n const continueWithoutGit = await abortIfCancelled(\n clack.confirm({\n message:\n 'You are not inside a git repository. The wizard will create and update files. Do you still want to continue?',\n }),\n );\n\n Sentry.setTag('continue-without-git', continueWithoutGit);\n\n if (!continueWithoutGit) {\n await abort(undefined, 0);\n }\n }\n}\n\nexport async function askForWizardLogin(options: {\n url: string;\n promoCode?: string;\n platform?: 'javascript-nextjs' | 'javascript-sveltekit';\n}): Promise<WizardProjectData> {\n Sentry.setTag('has-promo-code', !!options.promoCode);\n\n let hasSentryAccount = await clack.confirm({\n message: 'Do you already have a Sentry account?',\n });\n\n hasSentryAccount = await abortIfCancelled(hasSentryAccount);\n\n Sentry.setTag('already-has-sentry-account', hasSentryAccount);\n\n let wizardHash: string;\n try {\n wizardHash = (\n await axios.get<{ hash: string }>(`${options.url}api/0/wizard/`)\n ).data.hash;\n } catch {\n if (options.url !== SAAS_URL) {\n clack.log.error('Loading Wizard failed. Did you provide the right URL?');\n await abort(\n chalk.red(\n 'Please check your configuration and try again.\\n\\n Let us know if you think this is an issue with the wizard or Sentry: https://github.com/getsentry/sentry-wizard/issues',\n ),\n );\n } else {\n clack.log.error('Loading Wizard failed.');\n await abort(\n chalk.red(\n 'Please try again in a few minutes and let us know if this issue persists: https://github.com/getsentry/sentry-wizard/issues',\n ),\n );\n }\n }\n\n const loginUrl = new URL(\n `${options.url}account/settings/wizard/${wizardHash!}/`,\n );\n\n if (!hasSentryAccount) {\n loginUrl.searchParams.set('signup', '1');\n if (options.platform) {\n loginUrl.searchParams.set('project_platform', options.platform);\n }\n }\n\n if (options.promoCode) {\n loginUrl.searchParams.set('code', options.promoCode);\n }\n\n clack.log.info(\n `${chalk.bold(\n `Please open the following link in your browser to ${\n hasSentryAccount ? 'log' : 'sign'\n } into Sentry:`,\n )}\\n\\n${chalk.cyan(loginUrl.toString())}`,\n );\n\n const loginSpinner = clack.spinner();\n\n loginSpinner.start(\n 'Waiting for you to click the link above 👆. Take your time.',\n );\n\n const data = await new Promise<WizardProjectData>((resolve) => {\n const pollingInterval = setInterval(() => {\n axios\n .get<WizardProjectData>(`${options.url}api/0/wizard/${wizardHash}/`)\n .then((result) => {\n resolve(result.data);\n clearTimeout(timeout);\n clearInterval(pollingInterval);\n void axios.delete(`${options.url}api/0/wizard/${wizardHash}/`);\n })\n .catch(() => {\n // noop - just try again\n });\n }, 500);\n\n const timeout = setTimeout(() => {\n clearInterval(pollingInterval);\n loginSpinner.stop(\n 'Login timed out. No worries - it happens to the best of us.',\n );\n\n Sentry.setTag('opened-wizard-link', false);\n void abort('Please restart the Wizard and log in to complete the setup.');\n }, 180_000);\n });\n\n loginSpinner.stop('Login complete.');\n Sentry.setTag('opened-wizard-link', true);\n\n return data;\n}\n\nexport async function askForProjectSelection(\n projects: SentryProjectData[],\n): Promise<SentryProjectData> {\n const selection: SentryProjectData | symbol = await abortIfCancelled(\n windowedSelect({\n maxItems: 12,\n message: 'Select your Sentry project.',\n options: projects.map((project) => {\n return {\n value: project,\n label: `${project.organization.slug}/${project.slug}`,\n };\n }),\n }),\n );\n\n Sentry.setTag('project', selection.slug);\n Sentry.setUser({ id: selection.organization.slug });\n\n return selection;\n}\n\nexport async function installPackage({\n packageName,\n alreadyInstalled,\n}: {\n packageName: string;\n alreadyInstalled: boolean;\n}): Promise<void> {\n if (alreadyInstalled) {\n const shouldUpdatePackage = await abortIfCancelled(\n clack.confirm({\n message: `The ${chalk.bold.cyan(\n packageName,\n )} package is already installed. Do you want to update it to the latest version?`,\n }),\n );\n\n if (!shouldUpdatePackage) {\n return;\n }\n }\n\n const sdkInstallSpinner = clack.spinner();\n\n const packageManager = await getPackageManager();\n\n sdkInstallSpinner.start(\n `${alreadyInstalled ? 'Updating' : 'Installing'} ${chalk.bold.cyan(\n packageName,\n )} with ${chalk.bold(packageManager)}.`,\n );\n\n try {\n if (packageManager === 'yarn') {\n await promisify(childProcess.exec)(`yarn add ${packageName}@latest`);\n } else if (packageManager === 'pnpm') {\n await promisify(childProcess.exec)(`pnpm add ${packageName}@latest`);\n } else if (packageManager === 'npm') {\n await promisify(childProcess.exec)(`npm install ${packageName}@latest`);\n }\n } catch (e) {\n sdkInstallSpinner.stop('Installation failed.');\n clack.log.error(\n `${chalk.red(\n 'Encountered the following error during installation:',\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n )}\\n\\n${e}\\n\\n${chalk.dim(\n 'If you think this issue is caused by the Sentry wizard, let us know here:\\nhttps://github.com/getsentry/sentry-wizard/issues',\n )}`,\n );\n await abort();\n }\n\n sdkInstallSpinner.stop(\n `${alreadyInstalled ? 'Updated' : 'Installed'} ${chalk.bold.cyan(\n packageName,\n )} with ${chalk.bold(packageManager)}.`,\n );\n}\n\nexport async function askForSelfHosted(): Promise<{\n url: string;\n selfHosted: boolean;\n}> {\n const choice: 'saas' | 'self-hosted' | symbol = await abortIfCancelled(\n clack.select({\n message: 'Are you using Sentry SaaS or self-hosted Sentry?',\n options: [\n { value: 'saas', label: 'Sentry SaaS (sentry.io)' },\n { value: 'self-hosted', label: 'Self-hosted/on-premise/single-tenant' },\n ],\n }),\n );\n\n if (choice === 'saas') {\n Sentry.setTag('url', SAAS_URL);\n Sentry.setTag('self-hosted', false);\n return { url: SAAS_URL, selfHosted: false };\n }\n\n let validUrl: string | undefined;\n while (validUrl === undefined) {\n const url = await abortIfCancelled(\n clack.text({\n message: 'Please enter the URL of your self-hosted Sentry instance.',\n placeholder: 'https://sentry.io/',\n }),\n );\n\n try {\n validUrl = new URL(url).toString();\n\n // We assume everywhere else that the URL ends in a slash\n if (!validUrl.endsWith('/')) {\n validUrl += '/';\n }\n } catch {\n clack.log.error(\n 'Please enter a valid URL. (It should look something like \"http://sentry.mydomain.com/\")',\n );\n }\n }\n\n Sentry.setTag('url', validUrl);\n Sentry.setTag('self-hosted', true);\n return { url: validUrl, selfHosted: true };\n}\n\nexport async function addSentryCliRc(authToken: string): Promise<void> {\n const clircExists = fs.existsSync(path.join(process.cwd(), '.sentryclirc'));\n if (clircExists) {\n const clircContents = fs.readFileSync(\n path.join(process.cwd(), '.sentryclirc'),\n 'utf8',\n );\n\n const likelyAlreadyHasAuthToken = !!(\n clircContents.includes('[auth]') && clircContents.match(/token=./g)\n );\n\n if (likelyAlreadyHasAuthToken) {\n clack.log.warn(\n `${chalk.bold(\n '.sentryclirc',\n )} already has auth token. Will not add one.`,\n );\n } else {\n try {\n await fs.promises.writeFile(\n path.join(process.cwd(), '.sentryclirc'),\n `${clircContents}\\n[auth]\\ntoken=${authToken}\\n`,\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Added auth token to ${chalk.bold(\n '.sentryclirc',\n )} for you to test uploading source maps locally.`,\n );\n } catch {\n clack.log.warning(\n `Failed to add auth token to ${chalk.bold(\n '.sentryclirc',\n )}. Uploading source maps during build will likely not work locally.`,\n );\n }\n }\n } else {\n try {\n await fs.promises.writeFile(\n path.join(process.cwd(), '.sentryclirc'),\n `[auth]\\ntoken=${authToken}\\n`,\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created ${chalk.bold(\n '.sentryclirc',\n )} with auth token for you to test uploading source maps locally.`,\n );\n } catch {\n clack.log.warning(\n `Failed to create ${chalk.bold(\n '.sentryclirc',\n )} with auth token. Uploading source maps during build will likely not work locally.`,\n );\n }\n }\n\n await addAuthTokenFileToGitIgnore('.sentryclirc');\n}\n\nexport async function addDotEnvSentryBuildPluginFile(\n authToken: string,\n): Promise<void> {\n const DOT_ENV_FILE = '.env.sentry-build-plugin';\n\n const envVarContent = `# DO NOT commit this file to your repository!\n# The SENTRY_AUTH_TOKEN variable is picked up by the Sentry Build Plugin.\n# It's used for authentication when uploading source maps.\n# You can also set this env variable in your own \\`.env\\` files and remove this file.\nSENTRY_AUTH_TOKEN=\"${authToken}\"\n`;\n\n const dotEnvFilePath = path.join(process.cwd(), DOT_ENV_FILE);\n const dotEnvFileExists = fs.existsSync(dotEnvFilePath);\n\n if (dotEnvFileExists) {\n const dotEnvFileContent = fs.readFileSync(dotEnvFilePath, 'utf8');\n\n const hasAuthToken = !!dotEnvFileContent.match(\n /^\\s*SENTRY_AUTH_TOKEN\\s*=/g,\n );\n\n if (hasAuthToken) {\n clack.log.warn(\n `${chalk.bold(DOT_ENV_FILE)} already has auth token. Will not add one.`,\n );\n } else {\n try {\n await fs.promises.writeFile(\n dotEnvFilePath,\n `${dotEnvFileContent}\\n${envVarContent}`,\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n clack.log.success(`Added auth token to ${chalk.bold(DOT_ENV_FILE)}`);\n } catch {\n clack.log.warning(\n `Failed to add auth token to ${chalk.bold(\n DOT_ENV_FILE,\n )}. Uploading source maps during build will likely not work locally.`,\n );\n }\n }\n } else {\n try {\n await fs.promises.writeFile(dotEnvFilePath, envVarContent, {\n encoding: 'utf8',\n flag: 'w',\n });\n clack.log.success(\n `Created ${chalk.bold(\n DOT_ENV_FILE,\n )} with auth token for you to test source map uploading locally.`,\n );\n } catch {\n clack.log.warning(\n `Failed to create ${chalk.bold(\n DOT_ENV_FILE,\n )} with auth token. Uploading source maps during build will likely not work locally.`,\n );\n }\n }\n\n await addAuthTokenFileToGitIgnore(DOT_ENV_FILE);\n}\n\nasync function addAuthTokenFileToGitIgnore(filename: string): Promise<void> {\n //TODO: Add a check to see if the file is already ignored in .gitignore\n try {\n await fs.promises.appendFile(\n path.join(process.cwd(), '.gitignore'),\n `\\n# Sentry Auth Token\\n${filename}\\n`,\n { encoding: 'utf8' },\n );\n clack.log.success(\n `Added ${chalk.bold(filename)} to ${chalk.bold('.gitignore')}.`,\n );\n } catch {\n clack.log.error(\n `Failed adding ${chalk.bold(filename)} to ${chalk.bold(\n '.gitignore',\n )}. Please add it manually!`,\n );\n }\n}\n\nexport async function ensurePackageIsInstalled(\n packageJson: PackageDotJson,\n packageId: string,\n packageName: string,\n) {\n if (!hasPackageInstalled(packageId, packageJson)) {\n const continueWithoutPackage = await abortIfCancelled(\n clack.confirm({\n message: `${packageName} does not seem to be installed. Do you still want to continue?`,\n initialValue: false,\n }),\n );\n\n if (!continueWithoutPackage) {\n await abort(undefined, 0);\n }\n }\n}\n\nexport async function getPackageDotJson(): Promise<PackageDotJson> {\n const packageJsonFileContents = await fs.promises\n .readFile(path.join(process.cwd(), 'package.json'), 'utf8')\n .catch(() => {\n clack.log.error(\n 'Could not find package.json. Make sure to run the wizard in the root of your app!',\n );\n return abort();\n });\n\n let packageJson: PackageDotJson | undefined = undefined;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n packageJson = JSON.parse(packageJsonFileContents);\n } catch {\n clack.log.error(\n 'Unable to parse your package.json. Make sure it has a valid format!',\n );\n\n await abort();\n }\n\n return packageJson || {};\n}\n\nexport function hasPackageInstalled(\n packageName: string,\n packageJson: PackageDotJson,\n): boolean {\n return (\n !!packageJson?.dependencies?.[packageName] ||\n !!packageJson?.devDependencies?.[packageName]\n );\n}\n\nasync function getPackageManager(): Promise<string> {\n let detectedPackageManager;\n if (fs.existsSync(path.join(process.cwd(), 'yarn.lock'))) {\n detectedPackageManager = 'yarn';\n } else if (fs.existsSync(path.join(process.cwd(), 'package-lock.json'))) {\n detectedPackageManager = 'npm';\n } else if (fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'))) {\n detectedPackageManager = 'pnpm';\n }\n\n if (detectedPackageManager) {\n return detectedPackageManager;\n }\n\n const selectedPackageManager: string | symbol = await abortIfCancelled(\n clack.select({\n message: 'Please select your package manager.',\n options: [\n { value: 'npm', label: 'Npm' },\n { value: 'yarn', label: 'Yarn' },\n { value: 'pnpm', label: 'Pnpm' },\n ],\n }),\n );\n\n Sentry.setTag('package-manager', selectedPackageManager);\n\n return selectedPackageManager;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"clack-utils.js","sourceRoot":"","sources":["../../../src/utils/clack-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,gDAA0B;AAC1B,gDAA0B;AAC1B,0DAA8C;AAC9C,qCAAyB;AACzB,yCAA6B;AAC7B,iCAAqC;AACrC,2BAA0B;AAC1B,6BAAiC;AACjC,mDAAuC;AACvC,oEAA8D;AAE9D,IAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAEc,CAAC;AAExC,IAAM,QAAQ,GAAG,oBAAoB,CAAC;AAyBtC,SAAsB,KAAK,CAAC,OAAgB,EAAE,MAAe;;;;;;oBAC3D,KAAK,CAAC,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,yBAAyB,CAAC,CAAC;oBAC5C,SAAS,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;oBACnC,iBAAiB,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,cAAc,EAAE,CAAC;oBAChE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,SAAS,CAAC,SAAS,CAAC,CAAC;oBACxC,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,MAAM,EAAE,CAAC;oBACtB,aAAa,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,CAAC;oBACxD,IAAI,aAAa,EAAE;wBACjB,aAAa,CAAC,MAAM,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,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M,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC,EAAE;wBACpE,sBAAsB,GAAG,MAAM,CAAC;qBACjC;oBAED,IAAI,sBAAsB,EAAE;wBAC1B,sBAAO,sBAAsB,EAAC;qBAC/B;oBAE+C,qBAAM,gBAAgB,CACpE,KAAK,CAAC,MAAM,CAAC;4BACX,OAAO,EAAE,qCAAqC;4BAC9C,OAAO,EAAE;gCACP,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;gCAC9B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;gCAChC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;6BACjC;yBACF,CAAC,CACH,EAAA;;oBATK,sBAAsB,GAAoB,SAS/C;oBAED,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,CAAC;oBAEzD,sBAAO,sBAAsB,EAAC;;;;CAC/B","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport axios from 'axios';\nimport chalk from 'chalk';\nimport * as childProcess from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { setInterval } from 'timers';\nimport { URL } from 'url';\nimport { promisify } from 'util';\nimport * as Sentry from '@sentry/node';\nimport { windowedSelect } from './vendor/clack-custom-select';\n\nconst opn = require('opn') as (\n url: string,\n) => Promise<childProcess.ChildProcess>;\n\nconst SAAS_URL = 'https://sentry.io/';\n\ninterface WizardProjectData {\n apiKeys: {\n token: string;\n };\n projects: SentryProjectData[];\n}\n\nexport type PackageDotJson = {\n scripts?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n};\n\nexport interface SentryProjectData {\n id: string;\n slug: string;\n name: string;\n organization: {\n slug: string;\n };\n keys: [{ dsn: { public: string } }];\n}\n\nexport async function abort(message?: string, status?: number): Promise<never> {\n clack.outro(message ?? 'Wizard setup cancelled.');\n const sentryHub = Sentry.getCurrentHub();\n const sentryTransaction = sentryHub.getScope().getTransaction();\n sentryTransaction?.setStatus('aborted');\n sentryTransaction?.finish();\n const sentrySession = sentryHub.getScope().getSession();\n if (sentrySession) {\n sentrySession.status = status === 0 ? 'abnormal' : 'crashed';\n sentryHub.captureSession(true);\n }\n await Sentry.flush(3000);\n return process.exit(status ?? 1);\n}\n\nexport async function abortIfCancelled<T>(\n input: T | Promise<T>,\n): Promise<Exclude<T, symbol>> {\n if (clack.isCancel(await input)) {\n clack.cancel('Wizard setup cancelled.');\n const sentryHub = Sentry.getCurrentHub();\n const sentryTransaction = sentryHub.getScope().getTransaction();\n sentryTransaction?.setStatus('cancelled');\n sentryTransaction?.finish();\n sentryHub.captureSession(true);\n await Sentry.flush(3000);\n process.exit(0);\n } else {\n return input as Exclude<T, symbol>;\n }\n}\n\nexport function printWelcome(options: {\n wizardName: string;\n promoCode?: string;\n message?: string;\n}): void {\n let wizardPackage: { version?: string } = {};\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wizardPackage = require(path.join(\n path.dirname(require.resolve('@sentry/wizard')),\n '..',\n 'package.json',\n ));\n } catch {\n // We don't need to have this\n }\n\n // eslint-disable-next-line no-console\n console.log('');\n clack.intro(chalk.inverse(` ${options.wizardName} `));\n\n let welcomeText =\n options.message ||\n 'This Wizard will help you set up Sentry for your application.\\nThank you for using Sentry :)';\n\n if (options.promoCode) {\n welcomeText += `\\n\\nUsing promo-code: ${options.promoCode}`;\n }\n\n if (wizardPackage.version) {\n welcomeText += `\\n\\nVersion: ${wizardPackage.version}`;\n }\n\n clack.note(welcomeText);\n}\n\nexport async function confirmContinueEvenThoughNoGitRepo(): Promise<void> {\n try {\n childProcess.execSync('git rev-parse --is-inside-work-tree', {\n stdio: 'ignore',\n });\n } catch {\n const continueWithoutGit = await abortIfCancelled(\n clack.confirm({\n message:\n 'You are not inside a git repository. The wizard will create and update files. Do you still want to continue?',\n }),\n );\n\n Sentry.setTag('continue-without-git', continueWithoutGit);\n\n if (!continueWithoutGit) {\n await abort(undefined, 0);\n }\n }\n}\n\nexport async function askForWizardLogin(options: {\n url: string;\n promoCode?: string;\n platform?: 'javascript-nextjs' | 'javascript-sveltekit';\n}): Promise<WizardProjectData> {\n Sentry.setTag('has-promo-code', !!options.promoCode);\n\n let hasSentryAccount = await clack.confirm({\n message: 'Do you already have a Sentry account?',\n });\n\n hasSentryAccount = await abortIfCancelled(hasSentryAccount);\n\n Sentry.setTag('already-has-sentry-account', hasSentryAccount);\n\n let wizardHash: string;\n try {\n wizardHash = (\n await axios.get<{ hash: string }>(`${options.url}api/0/wizard/`)\n ).data.hash;\n } catch {\n if (options.url !== SAAS_URL) {\n clack.log.error('Loading Wizard failed. Did you provide the right URL?');\n await abort(\n chalk.red(\n 'Please check your configuration and try again.\\n\\n Let us know if you think this is an issue with the wizard or Sentry: https://github.com/getsentry/sentry-wizard/issues',\n ),\n );\n } else {\n clack.log.error('Loading Wizard failed.');\n await abort(\n chalk.red(\n 'Please try again in a few minutes and let us know if this issue persists: https://github.com/getsentry/sentry-wizard/issues',\n ),\n );\n }\n }\n\n const loginUrl = new URL(\n `${options.url}account/settings/wizard/${wizardHash!}/`,\n );\n\n if (!hasSentryAccount) {\n loginUrl.searchParams.set('signup', '1');\n if (options.platform) {\n loginUrl.searchParams.set('project_platform', options.platform);\n }\n }\n\n if (options.promoCode) {\n loginUrl.searchParams.set('code', options.promoCode);\n }\n\n const urlToOpen = loginUrl.toString();\n clack.log.info(\n `${chalk.bold(\n `If the browser window didn't open automatically, please open the following link to ${\n hasSentryAccount ? 'log' : 'sign'\n } into Sentry:`,\n )}\\n\\n${chalk.cyan(urlToOpen)}`,\n );\n\n opn(urlToOpen).catch(() => {\n // opn throws in environments that don't have a browser (e.g. remote shells) so we just noop here\n });\n\n const loginSpinner = clack.spinner();\n\n loginSpinner.start(\n \"Waiting for you to log in using the link above. Once you're logged in, return to this wizard.\",\n );\n\n const data = await new Promise<WizardProjectData>((resolve) => {\n const pollingInterval = setInterval(() => {\n axios\n .get<WizardProjectData>(`${options.url}api/0/wizard/${wizardHash}/`)\n .then((result) => {\n resolve(result.data);\n clearTimeout(timeout);\n clearInterval(pollingInterval);\n void axios.delete(`${options.url}api/0/wizard/${wizardHash}/`);\n })\n .catch(() => {\n // noop - just try again\n });\n }, 500);\n\n const timeout = setTimeout(() => {\n clearInterval(pollingInterval);\n loginSpinner.stop(\n 'Login timed out. No worries - it happens to the best of us.',\n );\n\n Sentry.setTag('opened-wizard-link', false);\n void abort('Please restart the Wizard and log in to complete the setup.');\n }, 180_000);\n });\n\n loginSpinner.stop('Login complete.');\n Sentry.setTag('opened-wizard-link', true);\n\n return data;\n}\n\nexport async function askForProjectSelection(\n projects: SentryProjectData[],\n): Promise<SentryProjectData> {\n const selection: SentryProjectData | symbol = await abortIfCancelled(\n windowedSelect({\n maxItems: 12,\n message: 'Select your Sentry project.',\n options: projects.map((project) => {\n return {\n value: project,\n label: `${project.organization.slug}/${project.slug}`,\n };\n }),\n }),\n );\n\n Sentry.setTag('project', selection.slug);\n Sentry.setUser({ id: selection.organization.slug });\n\n return selection;\n}\n\nexport async function installPackage({\n packageName,\n alreadyInstalled,\n askBeforeUpdating = true,\n}: {\n packageName: string;\n alreadyInstalled: boolean;\n askBeforeUpdating?: boolean;\n}): Promise<void> {\n if (alreadyInstalled && askBeforeUpdating) {\n const shouldUpdatePackage = await abortIfCancelled(\n clack.confirm({\n message: `The ${chalk.bold.cyan(\n packageName,\n )} package is already installed. Do you want to update it to the latest version?`,\n }),\n );\n\n if (!shouldUpdatePackage) {\n return;\n }\n }\n\n const sdkInstallSpinner = clack.spinner();\n\n const packageManager = await getPackageManager();\n\n sdkInstallSpinner.start(\n `${alreadyInstalled ? 'Updating' : 'Installing'} ${chalk.bold.cyan(\n packageName,\n )} with ${chalk.bold(packageManager)}.`,\n );\n\n try {\n if (packageManager === 'yarn') {\n await promisify(childProcess.exec)(`yarn add ${packageName}@latest`);\n } else if (packageManager === 'pnpm') {\n await promisify(childProcess.exec)(`pnpm add ${packageName}@latest`);\n } else if (packageManager === 'npm') {\n await promisify(childProcess.exec)(`npm install ${packageName}@latest`);\n }\n } catch (e) {\n sdkInstallSpinner.stop('Installation failed.');\n clack.log.error(\n `${chalk.red(\n 'Encountered the following error during installation:',\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n )}\\n\\n${e}\\n\\n${chalk.dim(\n 'If you think this issue is caused by the Sentry wizard, let us know here:\\nhttps://github.com/getsentry/sentry-wizard/issues',\n )}`,\n );\n await abort();\n }\n\n sdkInstallSpinner.stop(\n `${alreadyInstalled ? 'Updated' : 'Installed'} ${chalk.bold.cyan(\n packageName,\n )} with ${chalk.bold(packageManager)}.`,\n );\n}\n\n/**\n * Asks users if they are using SaaS or self-hosted Sentry and returns the validated URL.\n *\n * If users started the wizard with a --url arg, that URL is used as the default and we skip\n * the self-hosted question. However, the passed url is still validated and in case it's\n * invalid, users are asked to enter a new one until it is valid.\n *\n * @param urlFromArgs the url passed via the --url arg\n */\nexport async function askForSelfHosted(urlFromArgs?: string): Promise<{\n url: string;\n selfHosted: boolean;\n}> {\n if (!urlFromArgs) {\n const choice: 'saas' | 'self-hosted' | symbol = await abortIfCancelled(\n clack.select({\n message: 'Are you using Sentry SaaS or self-hosted Sentry?',\n options: [\n { value: 'saas', label: 'Sentry SaaS (sentry.io)' },\n {\n value: 'self-hosted',\n label: 'Self-hosted/on-premise/single-tenant',\n },\n ],\n }),\n );\n\n if (choice === 'saas') {\n Sentry.setTag('url', SAAS_URL);\n Sentry.setTag('self-hosted', false);\n return { url: SAAS_URL, selfHosted: false };\n }\n }\n\n let validUrl: string | undefined;\n let tmpUrlFromArgs = urlFromArgs;\n\n while (validUrl === undefined) {\n const url =\n tmpUrlFromArgs ||\n (await abortIfCancelled(\n clack.text({\n message: `Please enter the URL of your ${\n urlFromArgs ? '' : 'self-hosted '\n }Sentry instance.`,\n placeholder: 'https://sentry.io/',\n }),\n ));\n tmpUrlFromArgs = undefined;\n\n try {\n validUrl = new URL(url).toString();\n\n // We assume everywhere else that the URL ends in a slash\n if (!validUrl.endsWith('/')) {\n validUrl += '/';\n }\n } catch {\n clack.log.error(\n 'Please enter a valid URL. (It should look something like \"https://sentry.mydomain.com/\")',\n );\n }\n }\n\n const isSelfHostedUrl = new URL(validUrl).host !== new URL(SAAS_URL).host;\n\n Sentry.setTag('url', validUrl);\n Sentry.setTag('self-hosted', isSelfHostedUrl);\n\n return { url: validUrl, selfHosted: true };\n}\n\nexport async function addSentryCliRc(authToken: string): Promise<void> {\n const clircExists = fs.existsSync(path.join(process.cwd(), '.sentryclirc'));\n if (clircExists) {\n const clircContents = fs.readFileSync(\n path.join(process.cwd(), '.sentryclirc'),\n 'utf8',\n );\n\n const likelyAlreadyHasAuthToken = !!(\n clircContents.includes('[auth]') && clircContents.match(/token=./g)\n );\n\n if (likelyAlreadyHasAuthToken) {\n clack.log.warn(\n `${chalk.bold(\n '.sentryclirc',\n )} already has auth token. Will not add one.`,\n );\n } else {\n try {\n await fs.promises.writeFile(\n path.join(process.cwd(), '.sentryclirc'),\n `${clircContents}\\n[auth]\\ntoken=${authToken}\\n`,\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Added auth token to ${chalk.bold(\n '.sentryclirc',\n )} for you to test uploading source maps locally.`,\n );\n } catch {\n clack.log.warning(\n `Failed to add auth token to ${chalk.bold(\n '.sentryclirc',\n )}. Uploading source maps during build will likely not work locally.`,\n );\n }\n }\n } else {\n try {\n await fs.promises.writeFile(\n path.join(process.cwd(), '.sentryclirc'),\n `[auth]\\ntoken=${authToken}\\n`,\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created ${chalk.bold(\n '.sentryclirc',\n )} with auth token for you to test uploading source maps locally.`,\n );\n } catch {\n clack.log.warning(\n `Failed to create ${chalk.bold(\n '.sentryclirc',\n )} with auth token. Uploading source maps during build will likely not work locally.`,\n );\n }\n }\n\n await addAuthTokenFileToGitIgnore('.sentryclirc');\n}\n\nexport async function addDotEnvSentryBuildPluginFile(\n authToken: string,\n): Promise<void> {\n const DOT_ENV_FILE = '.env.sentry-build-plugin';\n\n const envVarContent = `# DO NOT commit this file to your repository!\n# The SENTRY_AUTH_TOKEN variable is picked up by the Sentry Build Plugin.\n# It's used for authentication when uploading source maps.\n# You can also set this env variable in your own \\`.env\\` files and remove this file.\nSENTRY_AUTH_TOKEN=\"${authToken}\"\n`;\n\n const dotEnvFilePath = path.join(process.cwd(), DOT_ENV_FILE);\n const dotEnvFileExists = fs.existsSync(dotEnvFilePath);\n\n if (dotEnvFileExists) {\n const dotEnvFileContent = fs.readFileSync(dotEnvFilePath, 'utf8');\n\n const hasAuthToken = !!dotEnvFileContent.match(\n /^\\s*SENTRY_AUTH_TOKEN\\s*=/g,\n );\n\n if (hasAuthToken) {\n clack.log.warn(\n `${chalk.bold(DOT_ENV_FILE)} already has auth token. Will not add one.`,\n );\n } else {\n try {\n await fs.promises.writeFile(\n dotEnvFilePath,\n `${dotEnvFileContent}\\n${envVarContent}`,\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n clack.log.success(`Added auth token to ${chalk.bold(DOT_ENV_FILE)}`);\n } catch {\n clack.log.warning(\n `Failed to add auth token to ${chalk.bold(\n DOT_ENV_FILE,\n )}. Uploading source maps during build will likely not work locally.`,\n );\n }\n }\n } else {\n try {\n await fs.promises.writeFile(dotEnvFilePath, envVarContent, {\n encoding: 'utf8',\n flag: 'w',\n });\n clack.log.success(\n `Created ${chalk.bold(\n DOT_ENV_FILE,\n )} with auth token for you to test source map uploading locally.`,\n );\n } catch {\n clack.log.warning(\n `Failed to create ${chalk.bold(\n DOT_ENV_FILE,\n )} with auth token. Uploading source maps during build will likely not work locally.`,\n );\n }\n }\n\n await addAuthTokenFileToGitIgnore(DOT_ENV_FILE);\n}\n\nasync function addAuthTokenFileToGitIgnore(filename: string): Promise<void> {\n //TODO: Add a check to see if the file is already ignored in .gitignore\n try {\n await fs.promises.appendFile(\n path.join(process.cwd(), '.gitignore'),\n `\\n# Sentry Auth Token\\n${filename}\\n`,\n { encoding: 'utf8' },\n );\n clack.log.success(\n `Added ${chalk.bold(filename)} to ${chalk.bold('.gitignore')}.`,\n );\n } catch {\n clack.log.error(\n `Failed adding ${chalk.bold(filename)} to ${chalk.bold(\n '.gitignore',\n )}. Please add it manually!`,\n );\n }\n}\n\nexport async function ensurePackageIsInstalled(\n packageJson: PackageDotJson,\n packageId: string,\n packageName: string,\n) {\n if (!hasPackageInstalled(packageId, packageJson)) {\n const continueWithoutPackage = await abortIfCancelled(\n clack.confirm({\n message: `${packageName} does not seem to be installed. Do you still want to continue?`,\n initialValue: false,\n }),\n );\n\n if (!continueWithoutPackage) {\n await abort(undefined, 0);\n }\n }\n}\n\nexport async function getPackageDotJson(): Promise<PackageDotJson> {\n const packageJsonFileContents = await fs.promises\n .readFile(path.join(process.cwd(), 'package.json'), 'utf8')\n .catch(() => {\n clack.log.error(\n 'Could not find package.json. Make sure to run the wizard in the root of your app!',\n );\n return abort();\n });\n\n let packageJson: PackageDotJson | undefined = undefined;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n packageJson = JSON.parse(packageJsonFileContents);\n } catch {\n clack.log.error(\n 'Unable to parse your package.json. Make sure it has a valid format!',\n );\n\n await abort();\n }\n\n return packageJson || {};\n}\n\nexport function hasPackageInstalled(\n packageName: string,\n packageJson: PackageDotJson,\n): boolean {\n return getPackageVersion(packageName, packageJson) !== undefined;\n}\n\nexport function getPackageVersion(\n packageName: string,\n packageJson: PackageDotJson,\n): string | undefined {\n return (\n packageJson?.dependencies?.[packageName] ||\n packageJson?.devDependencies?.[packageName]\n );\n}\n\nasync function getPackageManager(): Promise<string> {\n let detectedPackageManager;\n if (fs.existsSync(path.join(process.cwd(), 'yarn.lock'))) {\n detectedPackageManager = 'yarn';\n } else if (fs.existsSync(path.join(process.cwd(), 'package-lock.json'))) {\n detectedPackageManager = 'npm';\n } else if (fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'))) {\n detectedPackageManager = 'pnpm';\n }\n\n if (detectedPackageManager) {\n return detectedPackageManager;\n }\n\n const selectedPackageManager: string | symbol = await abortIfCancelled(\n clack.select({\n message: 'Please select your package manager.',\n options: [\n { value: 'npm', label: 'Npm' },\n { value: 'yarn', label: 'Yarn' },\n { value: 'pnpm', label: 'Pnpm' },\n ],\n }),\n );\n\n Sentry.setTag('package-manager', selectedPackageManager);\n\n return selectedPackageManager;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type WizardOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* The promo code to use while signing up for Sentry.
|
|
4
|
+
* This can be passed via the --promo-code arg.
|
|
5
|
+
*/
|
|
6
|
+
promoCode?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The url of the Sentry instance to use.
|
|
9
|
+
* This can be passed via the `-u` or `--url` arg.
|
|
10
|
+
*/
|
|
11
|
+
url?: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["export type WizardOptions = {\n /**\n * The promo code to use while signing up for Sentry.\n * This can be passed via the --promo-code arg.\n */\n promoCode?: string;\n\n /**\n * The url of the Sentry instance to use.\n * This can be passed via the `-u` or `--url` arg.\n */\n url?: string;\n};\n"]}
|
package/lib/Helper/Wizard.ts
CHANGED
|
@@ -2,25 +2,16 @@ import type { Answers } from 'inquirer';
|
|
|
2
2
|
import * as _ from 'lodash';
|
|
3
3
|
|
|
4
4
|
import type { Args } from '../Constants';
|
|
5
|
-
import { DEFAULT_URL } from '../Constants';
|
|
6
5
|
import type { IStep } from '../Steps/BaseStep';
|
|
7
6
|
import type { BaseIntegration } from '../Steps/Integrations/BaseIntegration';
|
|
8
7
|
import { BottomBar } from './BottomBar';
|
|
9
8
|
import { debug, dim, nl, red } from './Logging';
|
|
10
9
|
|
|
11
10
|
function sanitizeAndValidateArgs(argv: Args): void {
|
|
12
|
-
if (!argv.url) {
|
|
13
|
-
argv.url = DEFAULT_URL;
|
|
14
|
-
dim(`no URL provided, fallback to ${argv.url}`);
|
|
15
|
-
}
|
|
16
11
|
if (argv.quiet === undefined) {
|
|
17
12
|
argv.quiet = true;
|
|
18
13
|
dim('will activate quiet mode for you');
|
|
19
14
|
}
|
|
20
|
-
let baseUrl = argv.url;
|
|
21
|
-
baseUrl += baseUrl.endsWith('/') ? '' : '/';
|
|
22
|
-
baseUrl = baseUrl.replace(/:\/(?!\/)/g, '://');
|
|
23
|
-
argv.url = baseUrl;
|
|
24
15
|
// @ts-ignore skip-connect does not exist on args
|
|
25
16
|
if (argv['skip-connect']) {
|
|
26
17
|
// @ts-ignore skip-connect does not exist on args
|
package/lib/Setup.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { Answers } from 'inquirer';
|
|
2
2
|
import { prompt } from 'inquirer';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
|
+
import { dim } from 'picocolors';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Args,
|
|
8
|
+
DEFAULT_URL,
|
|
9
|
+
getIntegrationChoices,
|
|
10
|
+
Integration,
|
|
11
|
+
} from '../Constants';
|
|
6
12
|
import { BaseStep } from './BaseStep';
|
|
7
13
|
import { Cordova } from './Integrations/Cordova';
|
|
8
14
|
import { Electron } from './Integrations/Electron';
|
|
9
|
-
import {
|
|
15
|
+
import { NextJsShim } from './Integrations/NextJsShim';
|
|
10
16
|
import { ReactNative } from './Integrations/ReactNative';
|
|
11
17
|
import { SourceMapsShim } from './Integrations/SourceMapsShim';
|
|
12
|
-
import {
|
|
18
|
+
import { SvelteKitShim } from './Integrations/SvelteKitShim';
|
|
13
19
|
|
|
14
20
|
let projectPackage: any = {};
|
|
15
21
|
|
|
@@ -30,26 +36,24 @@ export class ChooseIntegration extends BaseStep {
|
|
|
30
36
|
|
|
31
37
|
let integration = null;
|
|
32
38
|
switch (integrationPrompt.integration) {
|
|
33
|
-
case Integration.reactNative:
|
|
34
|
-
integration = new ReactNative(this._argv);
|
|
35
|
-
break;
|
|
36
39
|
case Integration.cordova:
|
|
37
|
-
integration = new Cordova(this._argv);
|
|
40
|
+
integration = new Cordova(sanitizeUrl(this._argv));
|
|
38
41
|
break;
|
|
39
42
|
case Integration.electron:
|
|
40
|
-
integration = new Electron(this._argv);
|
|
43
|
+
integration = new Electron(sanitizeUrl(this._argv));
|
|
41
44
|
break;
|
|
42
45
|
case Integration.nextjs:
|
|
43
|
-
integration = new
|
|
46
|
+
integration = new NextJsShim(this._argv);
|
|
44
47
|
break;
|
|
45
48
|
case Integration.sveltekit:
|
|
46
|
-
integration = new
|
|
49
|
+
integration = new SvelteKitShim(this._argv);
|
|
47
50
|
break;
|
|
48
51
|
case Integration.sourcemaps:
|
|
49
52
|
integration = new SourceMapsShim(this._argv);
|
|
50
53
|
break;
|
|
54
|
+
case Integration.reactNative:
|
|
51
55
|
default:
|
|
52
|
-
integration = new ReactNative(this._argv);
|
|
56
|
+
integration = new ReactNative(sanitizeUrl(this._argv));
|
|
53
57
|
break;
|
|
54
58
|
}
|
|
55
59
|
|
|
@@ -89,3 +93,23 @@ export class ChooseIntegration extends BaseStep {
|
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* For the `clack`-based wizard flows, which we only shim here, we don't set
|
|
99
|
+
* a default url value. For backwards-compatibility with the other flows,
|
|
100
|
+
* we fill it here and sanitize a user-enterd url.
|
|
101
|
+
*/
|
|
102
|
+
function sanitizeUrl(argv: Args): Args {
|
|
103
|
+
if (!argv.url) {
|
|
104
|
+
argv.url = DEFAULT_URL;
|
|
105
|
+
dim(`no URL provided, fallback to ${argv.url}`);
|
|
106
|
+
return argv;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let baseUrl = argv.url;
|
|
110
|
+
baseUrl += baseUrl.endsWith('/') ? '' : '/';
|
|
111
|
+
baseUrl = baseUrl.replace(/:\/(?!\/)/g, '://');
|
|
112
|
+
argv.url = baseUrl;
|
|
113
|
+
|
|
114
|
+
return argv;
|
|
115
|
+
}
|
|
@@ -8,13 +8,16 @@ import { BaseIntegration } from './BaseIntegration';
|
|
|
8
8
|
* This class just redirects to the new `nextjs-wizard.ts` flow
|
|
9
9
|
* for anyone calling the wizard without the '-i nextjs' flag.
|
|
10
10
|
*/
|
|
11
|
-
export class
|
|
11
|
+
export class NextJsShim extends BaseIntegration {
|
|
12
12
|
public constructor(protected _argv: Args) {
|
|
13
13
|
super(_argv);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
public async emit(_answers: Answers): Promise<Answers> {
|
|
17
|
-
await runNextjsWizard({
|
|
17
|
+
await runNextjsWizard({
|
|
18
|
+
promoCode: this._argv.promoCode,
|
|
19
|
+
url: this._argv.url,
|
|
20
|
+
});
|
|
18
21
|
return {};
|
|
19
22
|
}
|
|
20
23
|
|
|
@@ -14,7 +14,10 @@ export class SourceMapsShim extends BaseIntegration {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
public async emit(_answers: Answers): Promise<Answers> {
|
|
17
|
-
await runSourcemapsWizard({
|
|
17
|
+
await runSourcemapsWizard({
|
|
18
|
+
promoCode: this._argv.promoCode,
|
|
19
|
+
url: this._argv.url,
|
|
20
|
+
});
|
|
18
21
|
return {};
|
|
19
22
|
}
|
|
20
23
|
|
|
@@ -8,13 +8,16 @@ import { BaseIntegration } from './BaseIntegration';
|
|
|
8
8
|
* This class just redirects to the new `sveltekit-wizard.ts` flow
|
|
9
9
|
* for anyone calling the wizard without the '-i sveltekit' flag.
|
|
10
10
|
*/
|
|
11
|
-
export class
|
|
11
|
+
export class SvelteKitShim extends BaseIntegration {
|
|
12
12
|
public constructor(protected _argv: Args) {
|
|
13
13
|
super(_argv);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
public async emit(_answers: Answers): Promise<Answers> {
|
|
17
|
-
await runSvelteKitWizard({
|
|
17
|
+
await runSvelteKitWizard({
|
|
18
|
+
promoCode: this._argv.promoCode,
|
|
19
|
+
url: this._argv.url,
|
|
20
|
+
});
|
|
18
21
|
return {};
|
|
19
22
|
}
|
|
20
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/wizard",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"homepage": "https://github.com/getsentry/sentry-wizard",
|
|
5
5
|
"repository": "https://github.com/getsentry/sentry-wizard",
|
|
6
6
|
"description": "Sentry wizard helping you to configure your project",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"opn": "^5.4.0",
|
|
37
37
|
"r2": "^2.0.1",
|
|
38
38
|
"read-env": "^1.3.0",
|
|
39
|
-
"semver": "^7.3
|
|
39
|
+
"semver": "^7.5.3",
|
|
40
40
|
"xcode": "3.0.1",
|
|
41
41
|
"yargs": "^16.2.0"
|
|
42
42
|
},
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"**/xmldom": "^0.6.0"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
|
-
"node": ">=
|
|
68
|
+
"node": ">=14.0.0",
|
|
69
69
|
"npm": ">=3.10.7",
|
|
70
70
|
"yarn": ">=1.0.2"
|
|
71
71
|
},
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
installPackage,
|
|
21
21
|
printWelcome,
|
|
22
22
|
} from '../utils/clack-utils';
|
|
23
|
+
import { WizardOptions } from '../utils/types';
|
|
23
24
|
import {
|
|
24
25
|
getNextjsConfigCjsAppendix,
|
|
25
26
|
getNextjsConfigCjsTemplate,
|
|
@@ -31,14 +32,8 @@ import {
|
|
|
31
32
|
getSentryExamplePageContents,
|
|
32
33
|
} from './templates';
|
|
33
34
|
|
|
34
|
-
interface NextjsWizardOptions {
|
|
35
|
-
promoCode?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
35
|
// eslint-disable-next-line complexity
|
|
39
|
-
export async function runNextjsWizard(
|
|
40
|
-
options: NextjsWizardOptions,
|
|
41
|
-
): Promise<void> {
|
|
36
|
+
export async function runNextjsWizard(options: WizardOptions): Promise<void> {
|
|
42
37
|
printWelcome({
|
|
43
38
|
wizardName: 'Sentry Next.js Wizard',
|
|
44
39
|
promoCode: options.promoCode,
|
|
@@ -49,7 +44,7 @@ export async function runNextjsWizard(
|
|
|
49
44
|
const packageJson = await getPackageDotJson();
|
|
50
45
|
await ensurePackageIsInstalled(packageJson, 'next', 'Next.js');
|
|
51
46
|
|
|
52
|
-
const { url: sentryUrl, selfHosted } = await askForSelfHosted();
|
|
47
|
+
const { url: sentryUrl, selfHosted } = await askForSelfHosted(options.url);
|
|
53
48
|
|
|
54
49
|
const { projects, apiKeys } = await askForWizardLogin({
|
|
55
50
|
promoCode: options.promoCode,
|
|
@@ -16,17 +16,24 @@ import { SourceMapUploadToolConfigurationOptions } from './tools/types';
|
|
|
16
16
|
import { configureVitePlugin } from './tools/vite';
|
|
17
17
|
import { configureSentryCLI } from './tools/sentry-cli';
|
|
18
18
|
import { configureWebPackPlugin } from './tools/webpack';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
type
|
|
19
|
+
import { configureTscSourcemapGenerationFlow } from './tools/tsc';
|
|
20
|
+
import { configureRollupPlugin } from './tools/rollup';
|
|
21
|
+
import { configureEsbuildPlugin } from './tools/esbuild';
|
|
22
|
+
import { WizardOptions } from '../utils/types';
|
|
23
|
+
import { configureCRASourcemapGenerationFlow } from './tools/create-react-app';
|
|
24
|
+
import { ensureMinimumSdkVersionIsInstalled } from './utils/sdk-version';
|
|
25
|
+
|
|
26
|
+
type SupportedTools =
|
|
27
|
+
| 'webpack'
|
|
28
|
+
| 'vite'
|
|
29
|
+
| 'rollup'
|
|
30
|
+
| 'esbuild'
|
|
31
|
+
| 'tsc'
|
|
32
|
+
| 'sentry-cli'
|
|
33
|
+
| 'create-react-app';
|
|
27
34
|
|
|
28
35
|
export async function runSourcemapsWizard(
|
|
29
|
-
options:
|
|
36
|
+
options: WizardOptions,
|
|
30
37
|
): Promise<void> {
|
|
31
38
|
printWelcome({
|
|
32
39
|
wizardName: 'Sentry Source Maps Upload Configuration Wizard',
|
|
@@ -37,7 +44,9 @@ export async function runSourcemapsWizard(
|
|
|
37
44
|
|
|
38
45
|
await confirmContinueEvenThoughNoGitRepo();
|
|
39
46
|
|
|
40
|
-
|
|
47
|
+
await ensureMinimumSdkVersionIsInstalled();
|
|
48
|
+
|
|
49
|
+
const { url: sentryUrl, selfHosted } = await askForSelfHosted(options.url);
|
|
41
50
|
|
|
42
51
|
const { projects, apiKeys } = await askForWizardLogin({
|
|
43
52
|
promoCode: options.promoCode,
|
|
@@ -59,7 +68,7 @@ export async function runSourcemapsWizard(
|
|
|
59
68
|
});
|
|
60
69
|
|
|
61
70
|
clack.log.step(
|
|
62
|
-
'Add the Sentry
|
|
71
|
+
'Add the Sentry authentication token as an environment variable to your CI setup:',
|
|
63
72
|
);
|
|
64
73
|
|
|
65
74
|
// Intentially logging directly to console here so that the code can be copied/pasted directly
|
|
@@ -103,53 +112,62 @@ SENTRY_AUTH_TOKEN=${apiKeys.token}
|
|
|
103
112
|
|
|
104
113
|
${chalk.cyan(`Validate your setup with the following Steps:
|
|
105
114
|
|
|
106
|
-
1. Build your application in ${chalk.bold('production mode')}
|
|
115
|
+
1. Build your application in ${chalk.bold('production mode')}.
|
|
107
116
|
${chalk.gray(
|
|
108
|
-
`${arrow} You should see source map upload logs in your console
|
|
117
|
+
`${arrow} You should see source map upload logs in your console.`,
|
|
109
118
|
)}
|
|
110
|
-
2. Run your application and throw a test error
|
|
111
|
-
${chalk.gray(`${arrow}
|
|
112
|
-
3. Open the error in Sentry and verify it's source-mapped
|
|
119
|
+
2. Run your application and throw a test error.
|
|
120
|
+
${chalk.gray(`${arrow} The error should be visible in Sentry.`)}
|
|
121
|
+
3. Open the error in Sentry and verify that it's source-mapped.
|
|
113
122
|
${chalk.gray(
|
|
114
|
-
`${arrow}
|
|
123
|
+
`${arrow} The stack trace should show your original source code.`,
|
|
115
124
|
)}
|
|
116
125
|
`)}
|
|
117
126
|
${chalk.dim(
|
|
118
|
-
`If you encounter any issues,
|
|
127
|
+
`If you encounter any issues, please refer to the Troubleshooting Guide:
|
|
119
128
|
https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js
|
|
120
129
|
|
|
121
|
-
If the guide
|
|
130
|
+
If the guide doesn't help or you encounter a bug, please let us know:
|
|
122
131
|
https://github.com/getsentry/sentry-javascript/issues`,
|
|
123
132
|
)}
|
|
124
133
|
`);
|
|
125
134
|
}
|
|
126
135
|
|
|
127
|
-
async function askForUsedBundlerTool(): Promise<
|
|
128
|
-
const selectedTool:
|
|
136
|
+
async function askForUsedBundlerTool(): Promise<SupportedTools> {
|
|
137
|
+
const selectedTool: SupportedTools | symbol = await abortIfCancelled(
|
|
129
138
|
clack.select({
|
|
130
139
|
message: 'Which bundler or build tool are you using?',
|
|
131
140
|
options: [
|
|
132
141
|
{
|
|
133
142
|
label: 'Webpack',
|
|
134
143
|
value: 'webpack',
|
|
135
|
-
hint: '
|
|
144
|
+
hint: 'Select this if you are using Webpack and you have access to your Webpack config.',
|
|
136
145
|
},
|
|
137
146
|
{
|
|
138
147
|
label: 'Vite',
|
|
139
148
|
value: 'vite',
|
|
140
|
-
hint: '
|
|
149
|
+
hint: 'Select this if you are using Vite and you have access to your Vite config.',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
label: 'esbuild',
|
|
153
|
+
value: 'esbuild',
|
|
154
|
+
hint: 'Select this if you are using esbuild and you have access to your esbuild config.',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
label: 'Rollup',
|
|
158
|
+
value: 'rollup',
|
|
159
|
+
hint: 'Select this if you are using Rollup and you have access to your Rollup config.',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: 'tsc',
|
|
163
|
+
value: 'tsc',
|
|
164
|
+
hint: 'Configure source maps when using tsc as build tool',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: 'Create React App',
|
|
168
|
+
value: 'create-react-app',
|
|
169
|
+
hint: 'Select this option if you set up your app with Create React App.',
|
|
141
170
|
},
|
|
142
|
-
// TODO: Implement rollup and esbuild flows
|
|
143
|
-
// {
|
|
144
|
-
// label: 'esbuild',
|
|
145
|
-
// value: 'esbuild',
|
|
146
|
-
// hint: 'Configure source maps upload using esbuild',
|
|
147
|
-
// },
|
|
148
|
-
// {
|
|
149
|
-
// label: 'Rollup',
|
|
150
|
-
// value: 'rollup',
|
|
151
|
-
// hint: 'Configure source maps upload using Rollup',
|
|
152
|
-
// },
|
|
153
171
|
{
|
|
154
172
|
label: 'None of the above',
|
|
155
173
|
value: 'sentry-cli',
|
|
@@ -163,17 +181,28 @@ async function askForUsedBundlerTool(): Promise<SupportedBundlersTools> {
|
|
|
163
181
|
}
|
|
164
182
|
|
|
165
183
|
async function startToolSetupFlow(
|
|
166
|
-
selctedTool:
|
|
184
|
+
selctedTool: SupportedTools,
|
|
167
185
|
options: SourceMapUploadToolConfigurationOptions,
|
|
168
186
|
): Promise<void> {
|
|
169
187
|
switch (selctedTool) {
|
|
188
|
+
case 'webpack':
|
|
189
|
+
await configureWebPackPlugin(options);
|
|
190
|
+
break;
|
|
170
191
|
case 'vite':
|
|
171
192
|
await configureVitePlugin(options);
|
|
172
193
|
break;
|
|
173
|
-
case '
|
|
174
|
-
await
|
|
194
|
+
case 'esbuild':
|
|
195
|
+
await configureEsbuildPlugin(options);
|
|
196
|
+
break;
|
|
197
|
+
case 'rollup':
|
|
198
|
+
await configureRollupPlugin(options);
|
|
199
|
+
break;
|
|
200
|
+
case 'tsc':
|
|
201
|
+
await configureSentryCLI(options, configureTscSourcemapGenerationFlow);
|
|
202
|
+
break;
|
|
203
|
+
case 'create-react-app':
|
|
204
|
+
await configureSentryCLI(options, configureCRASourcemapGenerationFlow);
|
|
175
205
|
break;
|
|
176
|
-
// TODO: implement other bundlers
|
|
177
206
|
default:
|
|
178
207
|
await configureSentryCLI(options);
|
|
179
208
|
break;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
2
|
+
import clack from '@clack/prompts';
|
|
3
|
+
import { abortIfCancelled } from '../../utils/clack-utils';
|
|
4
|
+
|
|
5
|
+
export async function configureCRASourcemapGenerationFlow(): Promise<void> {
|
|
6
|
+
await abortIfCancelled(
|
|
7
|
+
clack.select({
|
|
8
|
+
message: `Verify that you are generating source maps when building your React app.\nGenerally this should already happen unless you set the GENERATE_SOURCEMAPS environment variable to false.`,
|
|
9
|
+
options: [
|
|
10
|
+
{
|
|
11
|
+
label: 'I checked!',
|
|
12
|
+
hint: 'My build output folder contains .js.map files after a build.',
|
|
13
|
+
value: true,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
initialValue: true,
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
19
|
+
}
|