Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add sentryCliBinaryExists function #171

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ The purpose of this option is to support module-federated projects or micro fron
The `customHeader` was used to attach an additional header to outgoing requests to Sentry when uploading source maps.
This option has been removed in favor of the `headers` option which allows for attaching multiple headers.

### Renaming of `cliBinaryExists` to `sentryCliBinaryExists`

The `cliBinaryExists` function was renamed to `sentryCliBinaryExists`.

## Upgrading from 0.3.x to 0.4.x

### Replacing default exports with named exports
Expand Down
11 changes: 11 additions & 0 deletions packages/bundler-plugin-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
uploadSourceMaps,
} from "./sentry/releasePipeline";
import "@sentry/tracing";
import SentryCli from "@sentry/cli";
import {
addPluginOptionInformationToHub,
addSpanToTransaction,
Expand All @@ -22,6 +23,7 @@ import { InternalOptions, normalizeUserOptions, validateOptions } from "./option
import { getSentryCli } from "./sentry/cli";
import { makeMain } from "@sentry/node";
import path from "path";
import fs from "fs";

const ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"];

Expand Down Expand Up @@ -364,6 +366,15 @@ function generateGlobalInjectorCode({
return code;
}

/**
* Determines whether the Sentry CLI binary is in its expected location.
* This function is useful since `@sentry/cli` installs the binary via a post-install
* script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.
*/
export function sentryCliBinaryExists(): boolean {
return fs.existsSync(SentryCli.getPath());
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const sentryVitePlugin: (options: Options) => any = unplugin.vite;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion packages/esbuild-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { sentryEsbuildPlugin } from "@sentry/bundler-plugin-core";
export { sentryEsbuildPlugin, sentryCliBinaryExists } from "@sentry/bundler-plugin-core";
export type { Options as SentryEsbuildPluginOptions } from "@sentry/bundler-plugin-core";
2 changes: 1 addition & 1 deletion packages/rollup-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { sentryRollupPlugin } from "@sentry/bundler-plugin-core";
export { sentryRollupPlugin, sentryCliBinaryExists } from "@sentry/bundler-plugin-core";
export type { Options as SentryRollupPluginOptions } from "@sentry/bundler-plugin-core";
2 changes: 1 addition & 1 deletion packages/vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { sentryVitePlugin } from "@sentry/bundler-plugin-core";
export { sentryVitePlugin, sentryCliBinaryExists } from "@sentry/bundler-plugin-core";
export type { Options as SentryVitePluginOptions } from "@sentry/bundler-plugin-core";
2 changes: 1 addition & 1 deletion packages/webpack-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { sentryWebpackPlugin } from "@sentry/bundler-plugin-core";
export { sentryWebpackPlugin, sentryCliBinaryExists } from "@sentry/bundler-plugin-core";
export type { Options as SentryWebpackPluginOptions } from "@sentry/bundler-plugin-core";