Skip to content

Commit 2389c6d

Browse files
committed
support git commits and version info
1 parent ff5713c commit 2389c6d

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

src/bundle.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -366,34 +366,47 @@ async function uploadSourcemapForSentry(
366366
sourcemapOutput,
367367
) {
368368
if (sourcemapOutput) {
369-
const uploadSourcemapPath = require.resolve(
370-
'@sentry/cli/bin/sentry-cli',
371-
{
372-
paths: [process.cwd()],
373-
},
374-
);
375-
if (!fs.existsSync(uploadSourcemapPath)) {
369+
const sentryCliPath = require.resolve('@sentry/cli/bin/sentry-cli', {
370+
paths: [process.cwd()],
371+
});
372+
if (!fs.existsSync(sentryCliPath)) {
376373
return;
377374
}
375+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
376+
const version = packageJson.version;
377+
378+
spawnSync('node', [
379+
sentryCliPath,
380+
'releases',
381+
'set-commits',
382+
version,
383+
'--auto'
384+
], {
385+
stdio: 'inherit',
386+
});
387+
console.log(`Sentry release created for version: ${version}`);
388+
378389
console.log('Uploading sourcemap');
379390
spawnSync(
380391
'node',
381392
[
382-
uploadSourcemapPath,
383-
'sourcemaps',
384-
'upload',
385-
'--debug-id-reference',
393+
sentryCliPath,
394+
'releases',
395+
'files',
396+
version,
397+
'upload-sourcemaps',
386398
'--strip-prefix',
387399
path.join(process.cwd(), outputFolder),
388400
path.join(outputFolder, bundleName),
389401
path.join(outputFolder, `${bundleName}.map`),
390402
],
391403
{
392-
stdio: 'ignore',
404+
stdio: 'inherit',
393405
},
394406
);
407+
408+
fs.removeSync(path.join(outputFolder, `${bundleName}.map`));
395409
}
396-
fs.removeSync(path.join(outputFolder, `${bundleName}.map`));
397410
}
398411

399412
async function pack(dir, output) {

0 commit comments

Comments
 (0)