Skip to content
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
26 changes: 17 additions & 9 deletions js/helper.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
'use strict';

const path = require('path');
const childProcess = require('child_process');

/**
* Absolute path to the sentry-cli binary (platform dependent).
* @type {string}
* This convoluted function resolves the path to the `sentry-cli` binary in a
* way that can't be analysed by @vercel/nft.
*
* Without this, the binary can be detected as an asset and included by bundlers
* that use @vercel/nft.
* @returns {string} The path to the sentry-cli binary
*/
let binaryPath = eval(
"require('path').resolve(__dirname, require('os').platform() === 'win32' ? '..\\sentry-cli.exe' : '../sentry-cli')"
);
function getBinaryPath() {
const parts = [];
parts.push(__dirname);
parts.push('..');
parts.push(`sentry-cli${process.platform === 'win32' ? '.exe' : ''}`);
return path.resolve(...parts);
}

/**
* NOTE: `eval` usage is a workaround for @vercel/nft detecting the binary itself as the hard dependency
* and effectively always including it in the bundle, which is not what we want.
* ref: https://github.com/getsentry/sentry-javascript/issues/3865
* ref: https://github.com/vercel/nft/issues/203
* Absolute path to the sentry-cli binary (platform dependent).
* @type {string}
*/
let binaryPath = getBinaryPath();

/**
* Overrides the default binary path with a mock value, useful for testing.
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
"fix": "npm-run-all fix:eslint fix:prettier",
"fix:eslint": "eslint --fix bin/* scripts/**/*.js js/**/*.js",
"fix:prettier": "prettier --write bin/* scripts/**/*.js js/**/*.js",
"test": "npm-run-all test:jest test:eslint test:prettier",
"test": "npm-run-all test:jest test:eslint test:prettier test:vercel-nft",
"test:jest": "jest",
"test:watch": "jest --watch --notify",
"test:eslint": "eslint bin/* scripts/**/*.js js/**/*.js",
"test:prettier": "prettier --check bin/* scripts/**/*.js js/**/*.js"
"test:prettier": "prettier --check bin/* scripts/**/*.js js/**/*.js",
"test:vercel-nft": "node scripts/test-vercel-nft.js"
},
"dependencies": {
"https-proxy-agent": "^5.0.0",
Expand All @@ -44,6 +45,7 @@
"which": "^2.0.2"
},
"devDependencies": {
"@vercel/nft": "^0.22.1",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-config-prettier": "^6.10.1",
Expand Down
27 changes: 27 additions & 0 deletions scripts/test-vercel-nft.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const major = process.versions.node.split('.')[0];

// @vercel/nft doe not support Node.js v8
if (major < 10) {
process.exit(0);
}

// eslint-disable-next-line import/no-extraneous-dependencies
const { nodeFileTrace } = require('@vercel/nft');

const entryPoint = require.resolve('..');

// Trace the module entrypoint
nodeFileTrace([entryPoint]).then(result => {
// eslint-disable-next-line no-console
console.log('@vercel/nft traced dependencies:', Array.from(result.fileList));

// If either binary is picked up, fail the test
if (result.fileList.has('sentry-cli') || result.fileList.has('sentry-cli.exe')) {
// eslint-disable-next-line no-console
console.error('ERROR: The sentry-cli binary should not be found by @vercel/nft');
process.exit(-1);
} else {
// eslint-disable-next-line no-console
console.log('The sentry-cli binary was not traced by @vercel/nft');
}
});
1 change: 1 addition & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ impl From<curl::FormError> for ApiError {
pub type ApiResult<T> = Result<T, ApiError>;

/// Represents an HTTP method that is used by the API.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(PartialEq, Debug)]
pub enum Method {
Get,
Expand Down
1 change: 1 addition & 0 deletions src/utils/file_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct UploadContext<'a> {
pub wait: bool,
}

#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum LogLevel {
Warning,
Expand Down
1 change: 1 addition & 0 deletions src/utils/xcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ impl XcodeProjectInfo {
/// Returns the config with a certain name
pub fn get_configuration(&self, name: &str) -> Option<&str> {
let name = name.to_lowercase();
#[allow(clippy::manual_find)]
for cfg in &self.configurations {
if cfg.to_lowercase() == name {
return Some(cfg);
Expand Down
Loading