Skip to content

Commit 178e36e

Browse files
authored
Merge pull request #99 from bugsnag/je/plat-14318-missing-cli-options-to-webpack
Ensure we have all the BugSnag CLI options available in the webpack plugin
2 parents 0066ada + a0afe8d commit 178e36e

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [2.2.1] - 2025-05-27
4+
5+
- Ensure we expose all options in the Webpack plugin that are available in the Bugsnag CLI (#99)
6+
- Allow BugsnagBuildReporterPlugin to pass all options in a single object (#99)
7+
38
## [2.2.0] - 2025-05-13
49

510
- Ensure webpack plugin callback is called when running the source map upload and create build plugins (#95)

build-reporter-plugin.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const LOG_PREFIX = '[BugsnagBuildReporterPlugin]'
66

77
class BugsnagBuildReporterPlugin {
88
constructor (build, options) {
9-
this.build = Object.assign({ buildTool: 'webpack-bugsnag-plugins' }, build)
9+
this.build = Object.assign({ buildTool: 'webpack-bugsnag-plugins', sourceControl: {}, logLevel: 'warn', path: process.cwd() }, build)
1010
this.options = Object.assign({ logLevel: 'warn' }, options)
1111
}
1212

@@ -17,14 +17,15 @@ class BugsnagBuildReporterPlugin {
1717
const logger = compiler.getInfrastructureLogger ? compiler.getInfrastructureLogger('BugsnagBuildReporterPlugin') : console
1818
const logPrefix = compiler.getInfrastructureLogger ? '' : `${LOG_PREFIX} `
1919
const cmdopts = this.getBuildOpts(this)
20+
const path = this.options.path || this.build.path
2021

2122
logger.info(`${logPrefix}creating build for version "${cmdopts.versionName}" using the bugsnag-cli`)
2223

2324
for (const [key, value] of Object.entries(cmdopts)) {
2425
logger.debug(`${logPrefix}${key}: ${value}`)
2526
}
2627

27-
BugsnagCLI.CreateBuild(cmdopts, process.cwd())
28+
BugsnagCLI.CreateBuild(cmdopts, path)
2829
.then((output) => {
2930
// Split output by lines, prefix each line, and log them
3031
output.split('\n').forEach((line) => {
@@ -62,12 +63,16 @@ class BugsnagBuildReporterPlugin {
6263
autoAssignRelease: opts.build.autoAssignRelease,
6364
builderName: opts.build.builderName,
6465
metadata: opts.build.metadata,
65-
provider: opts.build.provider,
66+
provider: opts.build.sourceControl.provider,
67+
repository: opts.build.sourceControl.repository,
68+
revision: opts.build.sourceControl.revision,
6669
releaseStage: opts.build.releaseStage,
67-
repository: opts.build.repository,
68-
revision: opts.build.revision,
6970
buildApiRootUrl: opts.build.endpoint,
70-
logLevel: opts.options.logLevel
71+
logLevel: opts.build.logLevel || opts.options.logLevel,
72+
dryRun: opts.build.dryRun || opts.options.dryRun,
73+
verbose: opts.build.verbose || opts.options.verbose,
74+
retries: opts.build.retries || opts.options.retries,
75+
timeout: opts.build.timeout || opts.options.timeout
7176
}
7277

7378
for (const [key, value] of Object.entries(optionalOpts)) {

source-map-uploader-plugin.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class BugsnagSourceMapUploaderPlugin {
2525
this.bundle = options.bundle
2626
this.bundleUrl = options.bundleUrl
2727
this.ignoredBundleExtensions = options.ignoredBundleExtensions || ['.css']
28+
this.dryRun = options.dryRun
29+
this.logLevel = options.logLevel
30+
this.verbose = options.verbose
31+
this.retries = options.retries
32+
this.timeout = options.timeout
2833
this.validate()
2934
}
3035

@@ -133,12 +138,6 @@ class BugsnagSourceMapUploaderPlugin {
133138
}
134139

135140
bugsnagCliUploadOpts (sm) {
136-
// Validate required fields
137-
if (!this.apiKey) {
138-
console.error('Error: API key is required but was not provided.')
139-
return null
140-
}
141-
142141
// Command base
143142
const cmdOpts = {
144143
apiKey: this.apiKey,
@@ -153,7 +152,12 @@ class BugsnagSourceMapUploaderPlugin {
153152
sourceMap: sm.map,
154153
bundle: this.bundle || sm.source,
155154
codeBundleId: this.codeBundleId,
156-
overwrite: this.overwrite
155+
overwrite: this.overwrite,
156+
dryRun: this.dryRun,
157+
logLevel: this.logLevel,
158+
verbose: this.verbose,
159+
retries: this.retries,
160+
timeout: this.timeout
157161
}
158162

159163
for (const [key, value] of Object.entries(optionalParams)) {

0 commit comments

Comments
 (0)