@sentry/webpack-plugin
Advanced tools
Comparing version 1.9.3 to 1.10.0
# Changelog | ||
## v1.10.0 | ||
- feat: Allow for skiping release finalization (#157) | ||
- fix: Ensure afterEmit hook exists (#165) | ||
- chore: Update TS definitions (#168) | ||
## v1.9.3 | ||
@@ -4,0 +10,0 @@ |
import { Plugin, Compiler } from 'webpack'; | ||
export interface SentryCliPluginOptions { | ||
/** Unique name of a release, must be a string, should uniquely identify your release, | ||
/** | ||
* 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 | ||
@@ -12,3 +13,3 @@ * (requires access to git CLI and root directory to be a valid repository). | ||
* One or more paths that Sentry CLI should scan recursively for sources. | ||
* It will upload all .map files and match associated .js files | ||
* It will upload all .map files and match associated .js files. | ||
*/ | ||
@@ -25,3 +26,3 @@ include: string | string[]; | ||
* Path to a file containing list of files/directories to ignore. | ||
* Can point to .gitignore or anything with same format | ||
* Can point to .gitignore or anything with same format. | ||
*/ | ||
@@ -32,3 +33,3 @@ ignoreFile?: string; | ||
* One or more paths to ignore during upload. Overrides entries in ignoreFile file. | ||
* If neither ignoreFile or ignore are present, defaults to ['node_modules'] | ||
* If neither ignoreFile or ignore are present, defaults to ['node_modules']. | ||
*/ | ||
@@ -39,3 +40,3 @@ ignore?: string | string[]; | ||
* Path to Sentry CLI config properties, as described in https://docs.sentry.io/learn/cli/configuration/#properties-files. | ||
* By default, the config file is looked for upwards from the current path and defaults from ~/.sentryclirc are always loaded | ||
* By default, the config file is looked for upwards from the current path and defaults from ~/.sentryclirc are always loaded. | ||
*/ | ||
@@ -53,3 +54,3 @@ configFile?: string; | ||
* This defaults to ~/ but you might want to set this to the full URL. | ||
* This is also useful if your files are stored in a sub folder. eg: url-prefix '~/static/js' | ||
* This is also useful if your files are stored in a sub folder. eg: url-prefix '~/static/js'. | ||
*/ | ||
@@ -89,3 +90,3 @@ urlPrefix?: string; | ||
* Enables rewriting of matching sourcemaps so that indexed maps are flattened | ||
* and missing sources are inlined if possible., defaults to true | ||
* and missing sources are inlined if possible., defaults to `true`. | ||
*/ | ||
@@ -95,8 +96,14 @@ rewrite?: boolean; | ||
/** | ||
* Attempts a dry run (useful for dev environments) | ||
* Determines whether processed release should be automatically finalized after artifacts upload. | ||
* Defaults to `true`. | ||
*/ | ||
finalize?: boolean; | ||
/** | ||
* Attempts a dry run (useful for dev environments). | ||
*/ | ||
dryRun?: boolean; | ||
/** | ||
* Print some useful debug information | ||
* Print some useful debug information. | ||
*/ | ||
@@ -106,3 +113,3 @@ debug?: boolean; | ||
/** | ||
* If true, all logs are suppressed (useful for --json option) | ||
* If true, all logs are suppressed (useful for --json option). | ||
*/ | ||
@@ -114,5 +121,27 @@ silent?: boolean; | ||
* webpack compilation failure can be chosen by calling invokeErr callback or not. | ||
* default (err, invokeErr) => { invokeErr() } | ||
* defaults to `(err, invokeErr) => { invokeErr() }` | ||
*/ | ||
errorHandler?: (err: Error, invokeErr: () => void) => void; | ||
/** | ||
* The current (last) commit in the release. | ||
*/ | ||
commit?: string; | ||
/** | ||
* The commit before the beginning of this release (in other words, the last commit of the previous release). | ||
* If omitted, this will default to the last commit of the previous release in Sentry. | ||
* If there was no previous release, the last 10 commits will be used. | ||
*/ | ||
previousCommit?: string; | ||
/** | ||
* The full repo name as defined in Sentry. | ||
*/ | ||
repo?: string; | ||
/** | ||
* Automatically choose the associated commit (uses the current commit). Overrides other set-commit options. | ||
*/ | ||
auto?: boolean; | ||
} | ||
@@ -119,0 +148,0 @@ |
@@ -11,3 +11,3 @@ { | ||
"author": "Sentry", | ||
"version": "1.9.3", | ||
"version": "1.10.0", | ||
"license": "MIT", | ||
@@ -14,0 +14,0 @@ "repository": "git@github.com:getsentry/sentry-webpack-plugin.git", |
@@ -78,2 +78,3 @@ <p align="center"> | ||
| rewrite | `boolean` | optional | enables rewriting of matching sourcemaps so that indexed maps are flattened and missing sources are inlined if possible. defaults to `true` | | ||
| finalize | `boolean` | optional | determines whether processed release should be automatically finalized after artifacts upload. defaults to `true` | | ||
| dryRun | `boolean` | optional | attempts a dry run (useful for dev environments) | | ||
@@ -80,0 +81,0 @@ | debug | `boolean` | optional | print some useful debug information | |
@@ -24,2 +24,8 @@ /*eslint-disable*/ | ||
const defaults = { | ||
debug: false, | ||
finalize: true, | ||
rewrite: true, | ||
}; | ||
describe('constructor', () => { | ||
@@ -29,5 +35,3 @@ test('uses defaults without options', () => { | ||
expect(sentryCliPlugin.options).toEqual({ | ||
rewrite: true, | ||
}); | ||
expect(sentryCliPlugin.options).toEqual(defaults); | ||
}); | ||
@@ -40,6 +44,4 @@ | ||
expect(sentryCliPlugin.options).toEqual({ | ||
rewrite: true, | ||
foo: 42, | ||
}); | ||
expect(sentryCliPlugin.options).toEqual(expect.objectContaining(defaults)); | ||
expect(sentryCliPlugin.options.foo).toEqual(42); | ||
}); | ||
@@ -52,17 +54,5 @@ | ||
expect(sentryCliPlugin.options).toEqual({ | ||
rewrite: false, | ||
}); | ||
expect(sentryCliPlugin.options.rewrite).toEqual(false); | ||
}); | ||
test('allows to provide debug mode', () => { | ||
let sentryCliPlugin = new SentryCliPlugin(); | ||
expect(sentryCliPlugin.debug).toEqual(false); | ||
sentryCliPlugin = new SentryCliPlugin({ | ||
debug: true, | ||
}); | ||
expect(sentryCliPlugin.debug).toEqual(true); | ||
}); | ||
test('sanitizes array options `include` and `ignore`', () => { | ||
@@ -73,8 +63,4 @@ const sentryCliPlugin = new SentryCliPlugin({ | ||
}); | ||
expect(sentryCliPlugin.options).toEqual({ | ||
rewrite: true, | ||
include: ['foo'], | ||
ignore: ['bar'], | ||
}); | ||
expect(sentryCliPlugin.options.include).toEqual(['foo']); | ||
expect(sentryCliPlugin.options.ignore).toEqual(['bar']); | ||
}); | ||
@@ -87,8 +73,4 @@ | ||
}); | ||
expect(sentryCliPlugin.options).toEqual({ | ||
rewrite: true, | ||
include: ['foo'], | ||
ignore: ['bar'], | ||
}); | ||
expect(sentryCliPlugin.options.include).toEqual(['foo']); | ||
expect(sentryCliPlugin.options.ignore).toEqual(['bar']); | ||
}); | ||
@@ -182,8 +164,9 @@ }); | ||
expect(mockCli.releases.new).toBeCalledWith('42'); | ||
expect(mockCli.releases.uploadSourceMaps).toBeCalledWith('42', { | ||
ignore: undefined, | ||
release: 42, | ||
include: ['src'], | ||
rewrite: true, | ||
}); | ||
expect(mockCli.releases.uploadSourceMaps).toBeCalledWith( | ||
'42', | ||
expect.objectContaining({ | ||
release: 42, | ||
include: ['src'], | ||
}) | ||
); | ||
expect(mockCli.releases.finalize).toBeCalledWith('42'); | ||
@@ -195,2 +178,27 @@ expect(compilationDoneCallback).toBeCalled(); | ||
test('skips finalizing release if finalize:false', done => { | ||
expect.assertions(4); | ||
const sentryCliPlugin = new SentryCliPlugin({ | ||
include: 'src', | ||
release: 42, | ||
finalize: false, | ||
}); | ||
sentryCliPlugin.apply(compiler); | ||
setImmediate(() => { | ||
expect(mockCli.releases.new).toBeCalledWith('42'); | ||
expect(mockCli.releases.uploadSourceMaps).toBeCalledWith( | ||
'42', | ||
expect.objectContaining({ | ||
release: 42, | ||
include: ['src'], | ||
}) | ||
); | ||
expect(mockCli.releases.finalize).not.toBeCalled(); | ||
expect(compilationDoneCallback).toBeCalled(); | ||
done(); | ||
}); | ||
}); | ||
test('handles errors during releasing', done => { | ||
@@ -197,0 +205,0 @@ expect.assertions(2); |
@@ -65,3 +65,3 @@ const SentryCli = require('@sentry/cli'); | ||
function attachAfterEmitHook(compiler, callback) { | ||
if (compiler.hooks) { | ||
if (compiler.hooks && compiler.hooks.afterEmit) { | ||
compiler.hooks.afterEmit.tapAsync('SentryCliPlugin', callback); | ||
@@ -75,6 +75,9 @@ } else { | ||
constructor(options = {}) { | ||
this.debug = options.debug || false; | ||
const defaults = { | ||
debug: false, | ||
finalize: true, | ||
rewrite: true, | ||
}; | ||
// By default we want that rewrite is true | ||
this.options = Object.assign({ rewrite: true }, options); | ||
this.options = Object.assign({}, defaults, options); | ||
@@ -344,3 +347,8 @@ if (options.include) this.options.include = toArray(options.include); | ||
}) | ||
.then(() => this.cli.releases.finalize(release)) | ||
.then(() => { | ||
if (this.options.finalize) { | ||
return this.cli.releases.finalize(release); | ||
} | ||
return undefined; | ||
}) | ||
.catch(err => | ||
@@ -360,3 +368,3 @@ errorHandler( | ||
if (this.debug) { | ||
if (this.options.debug) { | ||
this.injectReleaseWithDebug(compilerOptions); | ||
@@ -363,0 +371,0 @@ } else { |
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
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
42002
919
97