Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sentry/webpack-plugin

Package Overview
Dependencies
Maintainers
9
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/webpack-plugin - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.eslintrc

28

package.json

@@ -11,3 +11,3 @@ {

"author": "Sentry",
"version": "1.2.0",
"version": "1.3.0",
"license": "MIT",

@@ -21,13 +21,16 @@ "repository": "git@github.com:getsentry/sentry-webpack-plugin.git",

"dependencies": {
"@sentry/cli": "^1.28.0"
"@sentry/cli": "^1.28.1"
},
"devDependencies": {
"codecov": "^3.0.0",
"husky": "^0.14.3",
"jest": "^22.0.4",
"lint-staged": "^6.0.0",
"prettier": "^1.9.2"
"eslint": "^4.15.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.8.0",
"jest": "^22.0.6",
"prettier": "^1.10.2"
},
"scripts": {
"precommit": "lint-staged && npm test",
"fix:eslint": "eslint --fix src",
"test:eslint": "eslint src",
"test": "jest",

@@ -38,14 +41,3 @@ "codecov": "codecov"

"collectCoverage": true
},
"prettier": {
"singleQuote": true,
"bracketSpacing": false,
"printWidth": 90
},
"lint-staged": {
"*.js": [
"prettier --write",
"git add"
]
}
}

@@ -58,3 +58,3 @@ <p align="center">

* `release [optional]` - unique name of a release, can be either a `string` or a `function` which will expose you a compilation hash as it's first argument, which is 20-char long string, unique for a given codebase, defaults to `sentry-cli releases propose-version` command which should always return the correct version
* `release [optional]` - unique name of a release, must be a `string`, should uniquely identify your release, defaults to `sentry-cli releases propose-version` command which should always return the correct version
* `include [required]` - `string` or `array`, one or more paths that Sentry CLI should scan recursively for sources. It will upload all `.map` files and match associated `.js` files

@@ -61,0 +61,0 @@ * `ignoreFile [optional]` - `string`, path to a file containing list of files/directories to ignore. Can point to `.gitignore` or anything with same format

@@ -0,4 +1,7 @@

/*eslint-disable*/
const newMock = jest.fn(() => Promise.resolve());
const uploadSourceMapsMock = jest.fn(() => Promise.resolve());
const finalizeMock = jest.fn(() => Promise.resolve());
const proposeVersionMock = jest.fn(() => Promise.resolve());
const SentryCliMock = jest.fn(configFile => ({

@@ -8,4 +11,5 @@ releases: {

uploadSourceMaps: uploadSourceMapsMock,
finalize: finalizeMock
}
finalize: finalizeMock,
proposeVersion: proposeVersionMock,
},
}));

@@ -25,3 +29,3 @@

expect(sentryCliPlugin.options).toEqual({
rewrite: true
rewrite: true,
});

@@ -32,3 +36,3 @@ });

const sentryCliPlugin = new SentryCliPlugin({
foo: 42
foo: 42,
});

@@ -38,3 +42,3 @@

rewrite: true,
foo: 42
foo: 42,
});

@@ -46,3 +50,3 @@ });

include: 'foo',
ignore: 'bar'
ignore: 'bar',
});

@@ -53,3 +57,3 @@

include: ['foo'],
ignore: ['bar']
ignore: ['bar'],
});

@@ -61,3 +65,3 @@ });

include: ['foo'],
ignore: ['bar']
ignore: ['bar'],
});

@@ -68,3 +72,3 @@

include: ['foo'],
ignore: ['bar']
ignore: ['bar'],
});

@@ -79,3 +83,3 @@ });

compiler = {
plugin: jest.fn()
plugin: jest.fn(),
};

@@ -86,5 +90,5 @@ });

const sentryCliPlugin = new SentryCliPlugin({
release: 42,
release: '42',
include: 'src',
configFile: './some/file'
configFile: './some/file',
});

@@ -115,7 +119,9 @@ sentryCliPlugin.apply(compiler);

errors: [],
hash: 'someHash'
hash: 'someHash',
};
compilationDoneCallback = jest.fn();
compiler = {
plugin: jest.fn((event, callback) => callback(compilation, compilationDoneCallback))
plugin: jest.fn((event, callback) =>
callback(compilation, compilationDoneCallback)
),
};

@@ -126,3 +132,3 @@ });

const sentryCliPlugin = new SentryCliPlugin({
release: 42
release: 42,
});

@@ -132,3 +138,3 @@ sentryCliPlugin.apply(compiler);

expect(compilation.errors).toEqual([
'Sentry CLI Plugin: `include` option is required'
'Sentry CLI Plugin: `include` option is required',
]);

@@ -141,6 +147,4 @@ expect(compilationDoneCallback).toBeCalled();

const sentryCliPlugin = new SentryCliPlugin({
release(hash) {
return hash + 'Evaluated';
},
include: 'src'
release: 'someHashEvaluated',
include: 'src',
});

@@ -161,4 +165,4 @@ sentryCliPlugin.apply(compiler);

sentryCliPlugin = new SentryCliPlugin({
release: 42,
include: 'src'
release: '42',
include: 'src',
});

@@ -172,10 +176,10 @@ });

setImmediate(() => {
expect(newMock).toBeCalledWith(42);
expect(uploadSourceMapsMock).toBeCalledWith(42, {
expect(newMock).toBeCalledWith('42');
expect(uploadSourceMapsMock).toBeCalledWith('42', {
ignore: undefined,
release: 42,
release: '42',
include: ['src'],
rewrite: true
rewrite: true,
});
expect(finalizeMock).toBeCalledWith(42);
expect(finalizeMock).toBeCalledWith('42');
expect(compilationDoneCallback).toBeCalled();

@@ -190,4 +194,4 @@ done();

releases: {
new: jest.fn(() => Promise.reject(new Error('Pickle Rick')))
}
new: jest.fn(() => Promise.reject(new Error('Pickle Rick'))),
},
}));

@@ -194,0 +198,0 @@

@@ -1,32 +0,65 @@

var SentryCli = require('@sentry/cli');
const SentryCli = require('@sentry/cli');
const path = require('path');
function SentryCliPlugin(options = {}) {
// By default we want that rewrite is true
this.options = Object.assign({rewrite: true}, options);
this.options.include =
options.include &&
(Array.isArray(options.include) ? options.include : [options.include]);
this.options.ignore =
options.ignore && (Array.isArray(options.ignore) ? options.ignore : [options.ignore]);
function injectEntry(originalEntry, newEntry) {
if (Array.isArray(originalEntry)) {
return [newEntry].concat(originalEntry);
}
if (originalEntry !== null && typeof originalEntry === 'object') {
const nextEntries = {};
Object.keys(originalEntry).forEach(key => {
nextEntries[key] = injectEntry(originalEntry[key], newEntry);
});
return nextEntries;
}
if (typeof originalEntry === 'string') {
return [newEntry, originalEntry];
}
return newEntry;
}
SentryCliPlugin.prototype.apply = function(compiler) {
var sentryCli = new SentryCli(this.options.configFile);
var release = this.options.release;
var include = this.options.include;
var options = this.options;
function injectRelease(compiler, versionPromise) {
if (typeof compiler.options === 'undefined') {
// Gatekeeper because we are not running in webpack env
// probably just tests
return;
}
const changedCompiler = compiler;
changedCompiler.options.entry = injectEntry(
changedCompiler.options.entry,
path.join(__dirname, 'sentry-webpack.module.js')
);
changedCompiler.options.module = {};
changedCompiler.options.module.rules = [];
changedCompiler.options.module.rules.push({
test: /sentry-webpack\.module\.js$/,
use: [
{
loader: path.resolve(__dirname, 'sentry.loader.js'),
query: { versionPromise },
},
],
});
}
compiler.plugin('after-emit', function(compilation, cb) {
function handleError(message, cb) {
compilation.errors.push(`Sentry CLI Plugin: ${message}`);
return cb();
}
class SentryCliPlugin {
constructor(options = {}) {
// By default we want that rewrite is true
this.options = Object.assign({ rewrite: true }, options);
this.options.include =
options.include &&
(Array.isArray(options.include) ? options.include : [options.include]);
this.options.ignore =
options.ignore &&
(Array.isArray(options.ignore) ? options.ignore : [options.ignore]);
}
if (!include) return handleError('`include` option is required', cb);
apply(compiler) {
const sentryCli = new SentryCli(this.options.configFile);
const { release, include } = this.options;
if (typeof release === 'function') {
release = release(compilation.hash);
}
var versionPromise = Promise.resolve(release);
let versionPromise = Promise.resolve(release);
if (typeof release === 'undefined') {

@@ -36,22 +69,27 @@ versionPromise = sentryCli.releases.proposeVersion();

return versionPromise
.then(function(proposedVersion) {
options.release = proposedVersion;
return sentryCli.releases.new(options.release);
})
.then(function() {
return sentryCli.releases.uploadSourceMaps(options.release, options);
})
.then(function() {
return sentryCli.releases.finalize(options.release);
})
.then(function() {
return cb();
})
.catch(function(err) {
return handleError(err.message, cb);
});
});
};
injectRelease(compiler, versionPromise);
compiler.plugin('after-emit', (compilation, cb) => {
function handleError(message, errorCb) {
compilation.errors.push(`Sentry CLI Plugin: ${message}`);
return errorCb();
}
if (!include) return handleError('`include` option is required', cb);
return versionPromise
.then(proposedVersion => {
this.options.release = `${proposedVersion}`.trim();
return sentryCli.releases.new(this.options.release);
})
.then(() =>
sentryCli.releases.uploadSourceMaps(this.options.release, this.options)
)
.then(() => sentryCli.releases.finalize(this.options.release))
.then(() => cb())
.catch(err => handleError(err.message, cb));
});
}
}
module.exports = SentryCliPlugin;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc