@sentry/cli
Advanced tools
Comparing version 1.27.1 to 1.28.1
# Changelog | ||
## sentry-cli 1.28.1 | ||
* Expose getPath() to not break setups | ||
## sentry-cli 1.28.0 | ||
* Change JS bindings to be conform with the cli interface | ||
Please note that this is a breaking change if you used the JS interface before. | ||
## sentry-cli 1.27.1 | ||
@@ -4,0 +13,0 @@ |
151
js/index.js
'use strict'; | ||
/* global Promise */ | ||
var childProcess = require('child_process'); | ||
var os = require('os'); | ||
var path = require('path'); | ||
var pkgInfo = require('../package.json'); | ||
var helper = require('./helper'); | ||
var DEFAULT_IGNORE = ['node_modules']; | ||
var SOURCEMAPS_OPTIONS = { | ||
ignore: { | ||
param: '--ignore', | ||
type: 'array' | ||
}, | ||
ignoreFile: { | ||
param: '--ignore-file', | ||
type: 'string' | ||
}, | ||
rewrite: { | ||
param: '--rewrite', | ||
type: 'boolean' | ||
}, | ||
sourceMapReference: { | ||
param: '--no-sourcemap-reference', | ||
type: 'inverted-boolean' | ||
}, | ||
stripPrefix: { | ||
param: '--strip-prefix', | ||
type: 'array' | ||
}, | ||
stripCommonPrefix: { | ||
param: '--strip-common-prefix', | ||
type: 'array' | ||
}, | ||
validate: { | ||
param: '--validate', | ||
type: 'boolean' | ||
}, | ||
urlPrefix: { | ||
param: '--url-prefix', | ||
type: 'string' | ||
}, | ||
ext: { | ||
param: '--ext', | ||
type: 'string' | ||
} | ||
}; | ||
var binaryPath = | ||
os.platform() === 'win32' | ||
? path.resolve(__dirname, '..\\bin\\sentry-cli.exe') | ||
: path.resolve(__dirname, '../sentry-cli'); | ||
function transformOption(option, values) { | ||
if (Array.isArray(values)) { | ||
return values | ||
.map(function(value) { | ||
return [option.param, value]; | ||
}) | ||
.reduce(function(acc, value) { | ||
return acc.concat(value); | ||
}, []); | ||
} | ||
return [option.param, values]; | ||
} | ||
function normalizeOptions(options) { | ||
return Object.keys(SOURCEMAPS_OPTIONS).reduce(function(newOptions, sourceMapOption) { | ||
var paramValue = options[sourceMapOption]; | ||
if (paramValue === undefined) { | ||
return newOptions; | ||
} | ||
var paramType = SOURCEMAPS_OPTIONS[sourceMapOption].type; | ||
var paramName = SOURCEMAPS_OPTIONS[sourceMapOption].param; | ||
if (paramType === 'array') { | ||
if (!Array.isArray(paramValue)) { | ||
throw new Error(sourceMapOption + ' should be an array'); | ||
} | ||
return newOptions.concat( | ||
transformOption(SOURCEMAPS_OPTIONS[sourceMapOption], paramValue) | ||
); | ||
} else if (paramType === 'boolean' || paramType === 'inverted-boolean') { | ||
if (typeof paramValue !== 'boolean') { | ||
throw new Error(sourceMapOption + ' should be a bool'); | ||
} | ||
if (paramType === 'boolean' && paramValue) { | ||
return newOptions.concat([paramName]); | ||
} else if (paramType === 'inverted-boolean' && paramValue === false) { | ||
return newOptions.concat([paramName]); | ||
} | ||
return newOptions; | ||
} | ||
return newOptions.concat(paramName, paramValue); | ||
}, []); | ||
} | ||
function SentryCli(configFile) { | ||
this.env = {}; | ||
if (typeof configFile === 'string') this.env.SENTRY_PROPERTIES = configFile; | ||
if (typeof configFile === 'string') process.env.SENTRY_PROPERTIES = configFile; | ||
} | ||
SentryCli.prototype.execute = function(args) { | ||
var env = Object.assign({}, process.env, this.env); | ||
return new Promise(function(resolve, reject) { | ||
childProcess.execFile(SentryCli.getPath(), args, { env: env }, function(err, stdout) { | ||
if (err) return reject(err); | ||
// eslint-disable-next-line | ||
console.log(stdout); | ||
return resolve(); | ||
}); | ||
}); | ||
}; | ||
SentryCli.prototype.getConfigStatus = function() { | ||
return this.execute(['info', '--config-status-json']); | ||
return helper.execute(['info', '--config-status-json']); | ||
}; | ||
SentryCli.prototype.createRelease = function(release) { | ||
return this.execute(['releases', 'new', release]); | ||
}; | ||
SentryCli.prototype.finalizeRelease = function(release) { | ||
return this.execute(['releases', 'finalize', release]); | ||
}; | ||
SentryCli.prototype.uploadSourceMaps = function(options) { | ||
return Promise.all( | ||
options.include.map(function(sourcemapPath) { | ||
var command = [ | ||
'releases', | ||
'files', | ||
options.release, | ||
'upload-sourcemaps', | ||
sourcemapPath | ||
]; | ||
return this.execute(this.prepareCommand(command, options)); | ||
}, this) | ||
); | ||
}; | ||
SentryCli.prototype.prepareCommand = function(command, options) { | ||
var newOptions = options || {}; | ||
if (!newOptions.ignoreFile && !newOptions.ignore) { | ||
newOptions.ignore = DEFAULT_IGNORE; | ||
} | ||
return command.concat(normalizeOptions(newOptions)); | ||
}; | ||
SentryCli.getVersion = function() { | ||
@@ -160,5 +19,7 @@ return pkgInfo.version; | ||
SentryCli.getPath = function() { | ||
return binaryPath; | ||
return helper.getPath(); | ||
}; | ||
SentryCli.prototype.releases = require('./releases'); | ||
module.exports = SentryCli; |
{ | ||
"name": "@sentry/cli", | ||
"version": "1.27.1", | ||
"version": "1.28.1", | ||
"description": "A command line utility to work with Sentry. https://docs.sentry.io/hosted/learn/cli/", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30186
10
161
3
2