@sentry/bundler-plugin-core 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +822 -214
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +799 -216
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/debug-id.d.ts +6 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/options-mapping.d.ts +2 -2
- package/dist/types/sentry/releasePipeline.d.ts +1 -0
- package/dist/types/types.d.ts +43 -11
- package/dist/types/utils.d.ts +21 -0
- package/package.json +9 -12
- package/sentry-release-injection-file.js +4 -0
package/dist/esm/index.mjs
CHANGED
|
@@ -2,8 +2,17 @@ import { createUnplugin } from 'unplugin';
|
|
|
2
2
|
import MagicString from 'magic-string';
|
|
3
3
|
import SentryCli from '@sentry/cli';
|
|
4
4
|
import { NodeClient, defaultStackParser, makeNodeTransport, Hub, makeMain } from '@sentry/node';
|
|
5
|
+
import findUp from 'find-up';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import path__default from 'path';
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import fs__default from 'fs';
|
|
10
|
+
import os from 'os';
|
|
11
|
+
import crypto from 'crypto';
|
|
5
12
|
import '@sentry/tracing';
|
|
6
|
-
import
|
|
13
|
+
import * as util from 'util';
|
|
14
|
+
import util__default from 'util';
|
|
15
|
+
import { glob } from 'glob';
|
|
7
16
|
|
|
8
17
|
function _regeneratorRuntime() {
|
|
9
18
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -759,13 +768,156 @@ timestampSource.nowSeconds.bind(timestampSource);
|
|
|
759
768
|
* @param maybeArray Input to turn into an array, if necessary
|
|
760
769
|
* @returns The input, if already an array, or an array with the input as the only element, if not
|
|
761
770
|
*/
|
|
771
|
+
|
|
762
772
|
function arrayify(maybeArray) {
|
|
763
773
|
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
764
774
|
}
|
|
765
775
|
|
|
776
|
+
/**
|
|
777
|
+
* Get the closes package.json from a given starting point upwards.
|
|
778
|
+
* This handles a few edge cases:
|
|
779
|
+
* * Check if a given file package.json appears to be an actual NPM package.json file
|
|
780
|
+
* * Stop at the home dir, to avoid looking too deeply
|
|
781
|
+
*/
|
|
782
|
+
function getPackageJson() {
|
|
783
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
784
|
+
cwd = _ref.cwd,
|
|
785
|
+
stopAt = _ref.stopAt;
|
|
786
|
+
|
|
787
|
+
return lookupPackageJson(cwd !== null && cwd !== void 0 ? cwd : process.cwd(), path__default.normalize(stopAt !== null && stopAt !== void 0 ? stopAt : os.homedir()));
|
|
788
|
+
}
|
|
789
|
+
function parseMajorVersion(version) {
|
|
790
|
+
// if it has a `v` prefix, remove it
|
|
791
|
+
if (version.startsWith("v")) {
|
|
792
|
+
version = version.slice(1);
|
|
793
|
+
} // First, try simple lookup of exact, ~ and ^ versions
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
var regex = /^[\^~]?(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
797
|
+
var match = version.match(regex);
|
|
798
|
+
|
|
799
|
+
if (match) {
|
|
800
|
+
return parseInt(match[1], 10);
|
|
801
|
+
} // Try to parse e.g. 1.x
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
var coerced = parseInt(version, 10);
|
|
805
|
+
|
|
806
|
+
if (!Number.isNaN(coerced)) {
|
|
807
|
+
return coerced;
|
|
808
|
+
} // Match <= and >= ranges.
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
var gteLteRegex = /^[<>]=\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
812
|
+
var gteLteMatch = version.match(gteLteRegex);
|
|
813
|
+
|
|
814
|
+
if (gteLteMatch) {
|
|
815
|
+
return parseInt(gteLteMatch[1], 10);
|
|
816
|
+
} // match < ranges
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
var ltRegex = /^<\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
820
|
+
var ltMatch = version.match(ltRegex);
|
|
821
|
+
|
|
822
|
+
if (ltMatch) {
|
|
823
|
+
// Two scenarios:
|
|
824
|
+
// a) < 2.0.0 --> return 1
|
|
825
|
+
// b) < 2.1.0 --> return 2
|
|
826
|
+
var major = parseInt(ltMatch[1], 10);
|
|
827
|
+
|
|
828
|
+
if ( // minor version > 0
|
|
829
|
+
typeof ltMatch[2] === "string" && parseInt(ltMatch[2].slice(1), 10) > 0 || // patch version > 0
|
|
830
|
+
typeof ltMatch[3] === "string" && parseInt(ltMatch[3].slice(1), 10) > 0) {
|
|
831
|
+
return major;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
return major - 1;
|
|
835
|
+
} // match > ranges
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
var gtRegex = /^>\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
839
|
+
var gtMatch = version.match(gtRegex);
|
|
840
|
+
|
|
841
|
+
if (gtMatch) {
|
|
842
|
+
// We always return the version here, even though it _may_ be incorrect
|
|
843
|
+
// E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3
|
|
844
|
+
// Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists
|
|
845
|
+
return parseInt(gtMatch[1], 10);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
return undefined;
|
|
849
|
+
} // This is an explicit list of packages where we want to include the (major) version number.
|
|
850
|
+
|
|
851
|
+
var PACKAGES_TO_INCLUDE_VERSION = ["react", "@angular/core", "vue", "ember-source", "svelte", "@sveltejs/kit", "webpack", "vite", "gatsby", "next", "remix", "rollup", "esbuild"];
|
|
852
|
+
function getDependencies(packageJson) {
|
|
853
|
+
var _packageJson$devDepen, _packageJson$dependen;
|
|
854
|
+
|
|
855
|
+
var dependencies = Object.assign({}, (_packageJson$devDepen = packageJson["devDependencies"]) !== null && _packageJson$devDepen !== void 0 ? _packageJson$devDepen : {}, (_packageJson$dependen = packageJson["dependencies"]) !== null && _packageJson$dependen !== void 0 ? _packageJson$dependen : {});
|
|
856
|
+
var deps = Object.keys(dependencies).sort();
|
|
857
|
+
var depsVersions = deps.reduce(function (depsVersions, depName) {
|
|
858
|
+
if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {
|
|
859
|
+
var version = dependencies[depName];
|
|
860
|
+
var majorVersion = parseMajorVersion(version);
|
|
861
|
+
|
|
862
|
+
if (majorVersion) {
|
|
863
|
+
depsVersions[depName] = majorVersion;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
return depsVersions;
|
|
868
|
+
}, {});
|
|
869
|
+
return {
|
|
870
|
+
deps: deps,
|
|
871
|
+
depsVersions: depsVersions
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
function lookupPackageJson(cwd, stopAt) {
|
|
876
|
+
var jsonPath = findUp.sync(function (dirName) {
|
|
877
|
+
// Stop if we reach this dir
|
|
878
|
+
if (path__default.normalize(dirName) === stopAt) {
|
|
879
|
+
return findUp.stop;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
return findUp.sync.exists(dirName + "/package.json") ? "package.json" : undefined;
|
|
883
|
+
}, {
|
|
884
|
+
cwd: cwd
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
if (!jsonPath) {
|
|
888
|
+
return undefined;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
try {
|
|
892
|
+
var jsonStr = fs__default.readFileSync(jsonPath, "utf8");
|
|
893
|
+
var json = JSON.parse(jsonStr); // Ensure it is an actual package.json
|
|
894
|
+
// This is very much not bulletproof, but should be good enough
|
|
895
|
+
|
|
896
|
+
if ("name" in json || "private" in json) {
|
|
897
|
+
return json;
|
|
898
|
+
}
|
|
899
|
+
} catch (error) {// Ignore and walk up
|
|
900
|
+
} // Continue up the tree, if we find a fitting package.json
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
var newCwd = path__default.dirname(path__default.resolve(jsonPath + "/.."));
|
|
904
|
+
return lookupPackageJson(newCwd, stopAt);
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Deterministically hashes a string and turns the hash into a uuid.
|
|
908
|
+
*/
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
function stringToUUID(str) {
|
|
912
|
+
var md5sum = crypto.createHash("md5");
|
|
913
|
+
md5sum.update(str);
|
|
914
|
+
var md5Hash = md5sum.digest("hex");
|
|
915
|
+
return (md5Hash.substring(0, 8) + "-" + md5Hash.substring(8, 12) + "-4" + md5Hash.substring(13, 16) + "-" + md5Hash.substring(16, 20) + "-" + md5Hash.substring(20)).toLowerCase();
|
|
916
|
+
}
|
|
917
|
+
|
|
766
918
|
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
767
919
|
function normalizeUserOptions(userOptions) {
|
|
768
|
-
var _userOptions$org, _userOptions$project, _ref, _userOptions$release, _ref2, _userOptions$url, _userOptions$finalize, _userOptions$cleanArt, _userOptions$dryRun, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$injectRe,
|
|
920
|
+
var _userOptions$org, _userOptions$project, _ref, _userOptions$release, _ref2, _userOptions$url, _userOptions$finalize, _userOptions$cleanArt, _userOptions$dryRun, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$injectRe, _userOptions$injectRe2, _userOptions$uploadSo, _userOptions$_experim;
|
|
769
921
|
|
|
770
922
|
var options = {
|
|
771
923
|
// include is the only strictly required option
|
|
@@ -794,16 +946,15 @@ function normalizeUserOptions(userOptions) {
|
|
|
794
946
|
silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
|
|
795
947
|
telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
|
|
796
948
|
injectReleasesMap: (_userOptions$injectRe = userOptions.injectReleasesMap) !== null && _userOptions$injectRe !== void 0 ? _userOptions$injectRe : false,
|
|
949
|
+
injectRelease: (_userOptions$injectRe2 = userOptions.injectRelease) !== null && _userOptions$injectRe2 !== void 0 ? _userOptions$injectRe2 : true,
|
|
950
|
+
uploadSourceMaps: (_userOptions$uploadSo = userOptions.uploadSourceMaps) !== null && _userOptions$uploadSo !== void 0 ? _userOptions$uploadSo : true,
|
|
951
|
+
_experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {},
|
|
797
952
|
// These options and can also be set via env variables or the config file.
|
|
798
953
|
// If they're set in the options, we simply pass them to the CLI constructor.
|
|
799
954
|
// Sentry CLI will internally query env variables and read its config file if
|
|
800
955
|
// the passed options are undefined.
|
|
801
956
|
authToken: userOptions.authToken,
|
|
802
957
|
// env var: `SENTRY_AUTH_TOKEN`
|
|
803
|
-
// CLI v1 (and the "old" webpack plugin) use `CUSTOM_HEADER`,
|
|
804
|
-
// but CLI v2 uses `SENTRY_HEADER` (which is also better aligned with other naming)
|
|
805
|
-
// In the spirit of maximum compatibility, we allow both here.
|
|
806
|
-
customHeader: (_ref3 = (_userOptions$customHe = userOptions.customHeader) !== null && _userOptions$customHe !== void 0 ? _userOptions$customHe : process.env["SENTRY_HEADER"]) !== null && _ref3 !== void 0 ? _ref3 : process.env["CUSTOM_HEADER"],
|
|
807
958
|
headers: userOptions.headers,
|
|
808
959
|
vcsRemote: userOptions.vcsRemote,
|
|
809
960
|
// env var: `SENTRY_VSC_REMOTE`
|
|
@@ -863,12 +1014,12 @@ function normalizeInclude(userOptions) {
|
|
|
863
1014
|
|
|
864
1015
|
|
|
865
1016
|
function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
866
|
-
var
|
|
1017
|
+
var _ref3, _includeEntry$ignore, _ref4, _includeEntry$ext, _includeEntry$ignoreF, _includeEntry$urlPref, _includeEntry$urlSuff, _includeEntry$stripPr, _ref5, _includeEntry$stripCo, _ref6, _includeEntry$sourceM, _ref7, _includeEntry$rewrite, _ref8, _includeEntry$validat;
|
|
867
1018
|
|
|
868
|
-
var ignoreOption = (
|
|
1019
|
+
var ignoreOption = (_ref3 = (_includeEntry$ignore = includeEntry.ignore) !== null && _includeEntry$ignore !== void 0 ? _includeEntry$ignore : userOptions.ignore) !== null && _ref3 !== void 0 ? _ref3 : ["node_modules"];
|
|
869
1020
|
var ignore = Array.isArray(ignoreOption) ? ignoreOption : [ignoreOption]; // We're prefixing all entries in the `ext` option with a `.` (if it isn't already) to align with Node.js' `path.extname()`
|
|
870
1021
|
|
|
871
|
-
var ext = (
|
|
1022
|
+
var ext = (_ref4 = (_includeEntry$ext = includeEntry.ext) !== null && _includeEntry$ext !== void 0 ? _includeEntry$ext : userOptions.ext) !== null && _ref4 !== void 0 ? _ref4 : ["js", "map", "jsbundle", "bundle"];
|
|
872
1023
|
var dotPrefixedExt = ext.map(function (extension) {
|
|
873
1024
|
return ".".concat(extension.replace(/^\./, ""));
|
|
874
1025
|
});
|
|
@@ -880,10 +1031,10 @@ function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
|
880
1031
|
urlPrefix: (_includeEntry$urlPref = includeEntry.urlPrefix) !== null && _includeEntry$urlPref !== void 0 ? _includeEntry$urlPref : userOptions.urlPrefix,
|
|
881
1032
|
urlSuffix: (_includeEntry$urlSuff = includeEntry.urlSuffix) !== null && _includeEntry$urlSuff !== void 0 ? _includeEntry$urlSuff : userOptions.urlSuffix,
|
|
882
1033
|
stripPrefix: (_includeEntry$stripPr = includeEntry.stripPrefix) !== null && _includeEntry$stripPr !== void 0 ? _includeEntry$stripPr : userOptions.stripPrefix,
|
|
883
|
-
stripCommonPrefix: (
|
|
884
|
-
sourceMapReference: (
|
|
885
|
-
rewrite: (
|
|
886
|
-
validate: (
|
|
1034
|
+
stripCommonPrefix: (_ref5 = (_includeEntry$stripCo = includeEntry.stripCommonPrefix) !== null && _includeEntry$stripCo !== void 0 ? _includeEntry$stripCo : userOptions.stripCommonPrefix) !== null && _ref5 !== void 0 ? _ref5 : false,
|
|
1035
|
+
sourceMapReference: (_ref6 = (_includeEntry$sourceM = includeEntry.sourceMapReference) !== null && _includeEntry$sourceM !== void 0 ? _includeEntry$sourceM : userOptions.sourceMapReference) !== null && _ref6 !== void 0 ? _ref6 : true,
|
|
1036
|
+
rewrite: (_ref7 = (_includeEntry$rewrite = includeEntry.rewrite) !== null && _includeEntry$rewrite !== void 0 ? _includeEntry$rewrite : userOptions.rewrite) !== null && _ref7 !== void 0 ? _ref7 : true,
|
|
1037
|
+
validate: (_ref8 = (_includeEntry$validat = includeEntry.validate) !== null && _includeEntry$validat !== void 0 ? _includeEntry$validat : userOptions.validate) !== null && _ref8 !== void 0 ? _ref8 : false
|
|
887
1038
|
};
|
|
888
1039
|
}
|
|
889
1040
|
/**
|
|
@@ -937,7 +1088,7 @@ function makeSentryClient(dsn, allowedToSendTelemetryPromise, userProject) {
|
|
|
937
1088
|
// a dashboard.
|
|
938
1089
|
// Yes, this is slightly abusing the purpose of this field.
|
|
939
1090
|
dist: userProject,
|
|
940
|
-
release: "0.
|
|
1091
|
+
release: "0.5.0",
|
|
941
1092
|
integrations: [],
|
|
942
1093
|
tracePropagationTargets: ["sentry.io/api"],
|
|
943
1094
|
stackParser: defaultStackParser,
|
|
@@ -1039,7 +1190,8 @@ function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
|
1039
1190
|
dryRun = options.dryRun,
|
|
1040
1191
|
errorHandler = options.errorHandler,
|
|
1041
1192
|
deploy = options.deploy,
|
|
1042
|
-
include = options.include
|
|
1193
|
+
include = options.include,
|
|
1194
|
+
_experiments = options._experiments;
|
|
1043
1195
|
hub.setTag("include", include.length > 1 ? "multiple-entries" : "single-entry"); // Optional release pipeline steps
|
|
1044
1196
|
|
|
1045
1197
|
if (cleanArtifacts) {
|
|
@@ -1071,6 +1223,10 @@ function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
|
1071
1223
|
hub.setTag("error-handler", "custom");
|
|
1072
1224
|
}
|
|
1073
1225
|
|
|
1226
|
+
if (_experiments.debugIdUpload) {
|
|
1227
|
+
hub.setTag("debug-id-upload", true);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1074
1230
|
hub.setTag("node", process.version);
|
|
1075
1231
|
hub.setTags({
|
|
1076
1232
|
organization: org,
|
|
@@ -1089,12 +1245,12 @@ function _shouldSendTelemetry() {
|
|
|
1089
1245
|
_shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1090
1246
|
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1091
1247
|
|
|
1092
|
-
var silent, org, project, authToken, url, vcsRemote,
|
|
1248
|
+
var silent, org, project, authToken, url, vcsRemote, headers, telemetry, dryRun, cli, cliInfo, cliInfoUrl;
|
|
1093
1249
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1094
1250
|
while (1) {
|
|
1095
1251
|
switch (_context2.prev = _context2.next) {
|
|
1096
1252
|
case 0:
|
|
1097
|
-
silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, vcsRemote = options.vcsRemote,
|
|
1253
|
+
silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, vcsRemote = options.vcsRemote, headers = options.headers, telemetry = options.telemetry, dryRun = options.dryRun; // `options.telemetry` defaults to true
|
|
1098
1254
|
|
|
1099
1255
|
if (!(telemetry === false)) {
|
|
1100
1256
|
_context2.next = 3;
|
|
@@ -1127,7 +1283,6 @@ function _shouldSendTelemetry() {
|
|
|
1127
1283
|
project: project,
|
|
1128
1284
|
vcsRemote: vcsRemote,
|
|
1129
1285
|
silent: silent,
|
|
1130
|
-
customHeader: customHeader,
|
|
1131
1286
|
headers: headers
|
|
1132
1287
|
});
|
|
1133
1288
|
_context2.prev = 8;
|
|
@@ -1283,74 +1438,141 @@ function _uploadSourceMaps() {
|
|
|
1283
1438
|
while (1) {
|
|
1284
1439
|
switch (_context3.prev = _context3.next) {
|
|
1285
1440
|
case 0:
|
|
1441
|
+
if (options.uploadSourceMaps) {
|
|
1442
|
+
_context3.next = 3;
|
|
1443
|
+
break;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
logger.debug("Skipping source maps upload.");
|
|
1447
|
+
return _context3.abrupt("return");
|
|
1448
|
+
|
|
1449
|
+
case 3:
|
|
1286
1450
|
span = addSpanToTransaction(ctx, "function.plugin.upload_sourcemaps");
|
|
1287
1451
|
ctx.logger.info("Uploading Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
|
|
1288
1452
|
// we only need to pass the include option here.
|
|
1289
1453
|
|
|
1290
|
-
_context3.prev =
|
|
1291
|
-
_context3.next =
|
|
1454
|
+
_context3.prev = 5;
|
|
1455
|
+
_context3.next = 8;
|
|
1292
1456
|
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1293
1457
|
include: options.include,
|
|
1294
1458
|
dist: options.dist
|
|
1295
1459
|
});
|
|
1296
1460
|
|
|
1297
|
-
case
|
|
1298
|
-
_context3.next =
|
|
1461
|
+
case 8:
|
|
1462
|
+
_context3.next = 14;
|
|
1299
1463
|
break;
|
|
1300
1464
|
|
|
1301
|
-
case
|
|
1302
|
-
_context3.prev =
|
|
1303
|
-
_context3.t0 = _context3["catch"](
|
|
1465
|
+
case 10:
|
|
1466
|
+
_context3.prev = 10;
|
|
1467
|
+
_context3.t0 = _context3["catch"](5);
|
|
1304
1468
|
ctx.hub.captureException(new Error("CLI Error: Uploading source maps failed"));
|
|
1305
1469
|
throw _context3.t0;
|
|
1306
1470
|
|
|
1307
|
-
case
|
|
1308
|
-
_context3.prev =
|
|
1471
|
+
case 14:
|
|
1472
|
+
_context3.prev = 14;
|
|
1309
1473
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1310
|
-
return _context3.finish(
|
|
1474
|
+
return _context3.finish(14);
|
|
1311
1475
|
|
|
1312
|
-
case
|
|
1476
|
+
case 17:
|
|
1313
1477
|
ctx.hub.addBreadcrumb({
|
|
1314
1478
|
level: "info",
|
|
1315
1479
|
message: "Successfully uploaded source maps."
|
|
1316
1480
|
});
|
|
1317
1481
|
ctx.logger.info("Successfully uploaded source maps.");
|
|
1318
1482
|
|
|
1319
|
-
case
|
|
1483
|
+
case 19:
|
|
1320
1484
|
case "end":
|
|
1321
1485
|
return _context3.stop();
|
|
1322
1486
|
}
|
|
1323
1487
|
}
|
|
1324
|
-
}, _callee3, null, [[
|
|
1488
|
+
}, _callee3, null, [[5, 10, 14, 17]]);
|
|
1325
1489
|
}));
|
|
1326
1490
|
return _uploadSourceMaps.apply(this, arguments);
|
|
1327
1491
|
}
|
|
1328
1492
|
|
|
1329
|
-
function
|
|
1493
|
+
function uploadDebugIdSourcemaps(_x10, _x11, _x12, _x13) {
|
|
1494
|
+
return _uploadDebugIdSourcemaps.apply(this, arguments);
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
function _uploadDebugIdSourcemaps() {
|
|
1498
|
+
_uploadDebugIdSourcemaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx, folderPathToUpload, releaseName) {
|
|
1499
|
+
var span;
|
|
1500
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1501
|
+
while (1) {
|
|
1502
|
+
switch (_context4.prev = _context4.next) {
|
|
1503
|
+
case 0:
|
|
1504
|
+
span = addSpanToTransaction(ctx, "function.plugin.upload_debug_id_sourcemaps");
|
|
1505
|
+
ctx.logger.info("Uploading debug ID Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
|
|
1506
|
+
// we only need to pass the include option here.
|
|
1507
|
+
|
|
1508
|
+
_context4.prev = 2;
|
|
1509
|
+
_context4.next = 5;
|
|
1510
|
+
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1511
|
+
include: [{
|
|
1512
|
+
paths: [folderPathToUpload],
|
|
1513
|
+
rewrite: false,
|
|
1514
|
+
dist: options.dist
|
|
1515
|
+
}],
|
|
1516
|
+
useArtifactBundle: true
|
|
1517
|
+
});
|
|
1518
|
+
|
|
1519
|
+
case 5:
|
|
1520
|
+
_context4.next = 11;
|
|
1521
|
+
break;
|
|
1522
|
+
|
|
1523
|
+
case 7:
|
|
1524
|
+
_context4.prev = 7;
|
|
1525
|
+
_context4.t0 = _context4["catch"](2);
|
|
1526
|
+
ctx.hub.captureException(new Error("CLI Error: Uploading debug ID source maps failed"));
|
|
1527
|
+
throw _context4.t0;
|
|
1528
|
+
|
|
1529
|
+
case 11:
|
|
1530
|
+
_context4.prev = 11;
|
|
1531
|
+
span === null || span === void 0 ? void 0 : span.finish();
|
|
1532
|
+
return _context4.finish(11);
|
|
1533
|
+
|
|
1534
|
+
case 14:
|
|
1535
|
+
ctx.hub.addBreadcrumb({
|
|
1536
|
+
level: "info",
|
|
1537
|
+
message: "Successfully uploaded debug ID source maps."
|
|
1538
|
+
});
|
|
1539
|
+
ctx.logger.info("Successfully uploaded debug ID source maps.");
|
|
1540
|
+
|
|
1541
|
+
case 16:
|
|
1542
|
+
case "end":
|
|
1543
|
+
return _context4.stop();
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}, _callee4, null, [[2, 7, 11, 14]]);
|
|
1547
|
+
}));
|
|
1548
|
+
return _uploadDebugIdSourcemaps.apply(this, arguments);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
function setCommits(_x14, _x15, _x16) {
|
|
1330
1552
|
return _setCommits.apply(this, arguments);
|
|
1331
1553
|
}
|
|
1332
1554
|
|
|
1333
1555
|
function _setCommits() {
|
|
1334
|
-
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1556
|
+
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx, releaseName) {
|
|
1335
1557
|
var span, _options$setCommits, auto, repo, commit, previousCommit, ignoreMissing, ignoreEmpty;
|
|
1336
1558
|
|
|
1337
|
-
return _regeneratorRuntime().wrap(function
|
|
1559
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1338
1560
|
while (1) {
|
|
1339
|
-
switch (
|
|
1561
|
+
switch (_context5.prev = _context5.next) {
|
|
1340
1562
|
case 0:
|
|
1341
1563
|
if (options.setCommits) {
|
|
1342
|
-
|
|
1564
|
+
_context5.next = 3;
|
|
1343
1565
|
break;
|
|
1344
1566
|
}
|
|
1345
1567
|
|
|
1346
1568
|
logger.debug("Skipping setting commits to release.");
|
|
1347
|
-
return
|
|
1569
|
+
return _context5.abrupt("return");
|
|
1348
1570
|
|
|
1349
1571
|
case 3:
|
|
1350
1572
|
span = addSpanToTransaction(ctx, "function.plugin.set_commits");
|
|
1351
1573
|
_options$setCommits = options.setCommits, auto = _options$setCommits.auto, repo = _options$setCommits.repo, commit = _options$setCommits.commit, previousCommit = _options$setCommits.previousCommit, ignoreMissing = _options$setCommits.ignoreMissing, ignoreEmpty = _options$setCommits.ignoreEmpty;
|
|
1352
|
-
|
|
1353
|
-
|
|
1574
|
+
_context5.prev = 5;
|
|
1575
|
+
_context5.next = 8;
|
|
1354
1576
|
return ctx.cli.releases.setCommits(releaseName, {
|
|
1355
1577
|
commit: commit,
|
|
1356
1578
|
previousCommit: previousCommit,
|
|
@@ -1361,46 +1583,46 @@ function _setCommits() {
|
|
|
1361
1583
|
});
|
|
1362
1584
|
|
|
1363
1585
|
case 8:
|
|
1364
|
-
|
|
1586
|
+
_context5.next = 14;
|
|
1365
1587
|
break;
|
|
1366
1588
|
|
|
1367
1589
|
case 10:
|
|
1368
|
-
|
|
1369
|
-
|
|
1590
|
+
_context5.prev = 10;
|
|
1591
|
+
_context5.t0 = _context5["catch"](5);
|
|
1370
1592
|
ctx.hub.captureException(new Error("CLI Error: Setting commits failed"));
|
|
1371
|
-
throw
|
|
1593
|
+
throw _context5.t0;
|
|
1372
1594
|
|
|
1373
1595
|
case 14:
|
|
1374
|
-
|
|
1596
|
+
_context5.prev = 14;
|
|
1375
1597
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1376
|
-
return
|
|
1598
|
+
return _context5.finish(14);
|
|
1377
1599
|
|
|
1378
1600
|
case 17:
|
|
1379
1601
|
ctx.logger.info("Successfully set commits.");
|
|
1380
1602
|
|
|
1381
1603
|
case 18:
|
|
1382
1604
|
case "end":
|
|
1383
|
-
return
|
|
1605
|
+
return _context5.stop();
|
|
1384
1606
|
}
|
|
1385
1607
|
}
|
|
1386
|
-
},
|
|
1608
|
+
}, _callee5, null, [[5, 10, 14, 17]]);
|
|
1387
1609
|
}));
|
|
1388
1610
|
return _setCommits.apply(this, arguments);
|
|
1389
1611
|
}
|
|
1390
1612
|
|
|
1391
|
-
function finalizeRelease(
|
|
1613
|
+
function finalizeRelease(_x17, _x18, _x19) {
|
|
1392
1614
|
return _finalizeRelease.apply(this, arguments);
|
|
1393
1615
|
}
|
|
1394
1616
|
|
|
1395
1617
|
function _finalizeRelease() {
|
|
1396
|
-
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1618
|
+
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx, releaseName) {
|
|
1397
1619
|
var span;
|
|
1398
|
-
return _regeneratorRuntime().wrap(function
|
|
1620
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1399
1621
|
while (1) {
|
|
1400
|
-
switch (
|
|
1622
|
+
switch (_context6.prev = _context6.next) {
|
|
1401
1623
|
case 0:
|
|
1402
1624
|
if (options.finalize) {
|
|
1403
|
-
|
|
1625
|
+
_context6.next = 4;
|
|
1404
1626
|
break;
|
|
1405
1627
|
}
|
|
1406
1628
|
|
|
@@ -1409,28 +1631,28 @@ function _finalizeRelease() {
|
|
|
1409
1631
|
message: "Skipping release finalization."
|
|
1410
1632
|
});
|
|
1411
1633
|
logger.debug("Skipping release finalization.");
|
|
1412
|
-
return
|
|
1634
|
+
return _context6.abrupt("return");
|
|
1413
1635
|
|
|
1414
1636
|
case 4:
|
|
1415
1637
|
span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
|
|
1416
|
-
|
|
1417
|
-
|
|
1638
|
+
_context6.prev = 5;
|
|
1639
|
+
_context6.next = 8;
|
|
1418
1640
|
return ctx.cli.releases.finalize(releaseName);
|
|
1419
1641
|
|
|
1420
1642
|
case 8:
|
|
1421
|
-
|
|
1643
|
+
_context6.next = 14;
|
|
1422
1644
|
break;
|
|
1423
1645
|
|
|
1424
1646
|
case 10:
|
|
1425
|
-
|
|
1426
|
-
|
|
1647
|
+
_context6.prev = 10;
|
|
1648
|
+
_context6.t0 = _context6["catch"](5);
|
|
1427
1649
|
ctx.hub.captureException(new Error("CLI Error: Finalizing release failed"));
|
|
1428
|
-
throw
|
|
1650
|
+
throw _context6.t0;
|
|
1429
1651
|
|
|
1430
1652
|
case 14:
|
|
1431
|
-
|
|
1653
|
+
_context6.prev = 14;
|
|
1432
1654
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1433
|
-
return
|
|
1655
|
+
return _context6.finish(14);
|
|
1434
1656
|
|
|
1435
1657
|
case 17:
|
|
1436
1658
|
ctx.hub.addBreadcrumb({
|
|
@@ -1441,28 +1663,28 @@ function _finalizeRelease() {
|
|
|
1441
1663
|
|
|
1442
1664
|
case 19:
|
|
1443
1665
|
case "end":
|
|
1444
|
-
return
|
|
1666
|
+
return _context6.stop();
|
|
1445
1667
|
}
|
|
1446
1668
|
}
|
|
1447
|
-
},
|
|
1669
|
+
}, _callee6, null, [[5, 10, 14, 17]]);
|
|
1448
1670
|
}));
|
|
1449
1671
|
return _finalizeRelease.apply(this, arguments);
|
|
1450
1672
|
}
|
|
1451
1673
|
|
|
1452
|
-
function addDeploy(
|
|
1674
|
+
function addDeploy(_x20, _x21, _x22) {
|
|
1453
1675
|
return _addDeploy.apply(this, arguments);
|
|
1454
1676
|
}
|
|
1455
1677
|
|
|
1456
1678
|
function _addDeploy() {
|
|
1457
|
-
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1679
|
+
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(options, ctx, releaseName) {
|
|
1458
1680
|
var span, _options$deploy, env, started, finished, time, name, url;
|
|
1459
1681
|
|
|
1460
|
-
return _regeneratorRuntime().wrap(function
|
|
1682
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1461
1683
|
while (1) {
|
|
1462
|
-
switch (
|
|
1684
|
+
switch (_context7.prev = _context7.next) {
|
|
1463
1685
|
case 0:
|
|
1464
1686
|
if (options.deploy) {
|
|
1465
|
-
|
|
1687
|
+
_context7.next = 4;
|
|
1466
1688
|
break;
|
|
1467
1689
|
}
|
|
1468
1690
|
|
|
@@ -1471,13 +1693,13 @@ function _addDeploy() {
|
|
|
1471
1693
|
message: "Skipping adding deploy info to release."
|
|
1472
1694
|
});
|
|
1473
1695
|
logger.debug("Skipping adding deploy info to release.");
|
|
1474
|
-
return
|
|
1696
|
+
return _context7.abrupt("return");
|
|
1475
1697
|
|
|
1476
1698
|
case 4:
|
|
1477
1699
|
span = addSpanToTransaction(ctx, "function.plugin.deploy");
|
|
1478
1700
|
_options$deploy = options.deploy, env = _options$deploy.env, started = _options$deploy.started, finished = _options$deploy.finished, time = _options$deploy.time, name = _options$deploy.name, url = _options$deploy.url;
|
|
1479
|
-
|
|
1480
|
-
|
|
1701
|
+
_context7.prev = 6;
|
|
1702
|
+
_context7.next = 9;
|
|
1481
1703
|
return ctx.cli.releases.newDeploy(releaseName, {
|
|
1482
1704
|
env: env,
|
|
1483
1705
|
started: started,
|
|
@@ -1488,19 +1710,19 @@ function _addDeploy() {
|
|
|
1488
1710
|
});
|
|
1489
1711
|
|
|
1490
1712
|
case 9:
|
|
1491
|
-
|
|
1713
|
+
_context7.next = 15;
|
|
1492
1714
|
break;
|
|
1493
1715
|
|
|
1494
1716
|
case 11:
|
|
1495
|
-
|
|
1496
|
-
|
|
1717
|
+
_context7.prev = 11;
|
|
1718
|
+
_context7.t0 = _context7["catch"](6);
|
|
1497
1719
|
ctx.hub.captureException(new Error("CLI Error: Adding deploy info failed"));
|
|
1498
|
-
throw
|
|
1720
|
+
throw _context7.t0;
|
|
1499
1721
|
|
|
1500
1722
|
case 15:
|
|
1501
|
-
|
|
1723
|
+
_context7.prev = 15;
|
|
1502
1724
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1503
|
-
return
|
|
1725
|
+
return _context7.finish(15);
|
|
1504
1726
|
|
|
1505
1727
|
case 18:
|
|
1506
1728
|
ctx.hub.addBreadcrumb({
|
|
@@ -1511,10 +1733,10 @@ function _addDeploy() {
|
|
|
1511
1733
|
|
|
1512
1734
|
case 20:
|
|
1513
1735
|
case "end":
|
|
1514
|
-
return
|
|
1736
|
+
return _context7.stop();
|
|
1515
1737
|
}
|
|
1516
1738
|
}
|
|
1517
|
-
},
|
|
1739
|
+
}, _callee7, null, [[6, 11, 15, 18]]);
|
|
1518
1740
|
}));
|
|
1519
1741
|
return _addDeploy.apply(this, arguments);
|
|
1520
1742
|
}
|
|
@@ -1585,7 +1807,6 @@ function getSentryCli(internalOptions, logger) {
|
|
|
1585
1807
|
authToken = internalOptions.authToken,
|
|
1586
1808
|
url = internalOptions.url,
|
|
1587
1809
|
vcsRemote = internalOptions.vcsRemote,
|
|
1588
|
-
customHeader = internalOptions.customHeader,
|
|
1589
1810
|
headers = internalOptions.headers;
|
|
1590
1811
|
var cli = new SentryCli(internalOptions.configFile, {
|
|
1591
1812
|
url: url,
|
|
@@ -1594,7 +1815,6 @@ function getSentryCli(internalOptions, logger) {
|
|
|
1594
1815
|
project: project,
|
|
1595
1816
|
vcsRemote: vcsRemote,
|
|
1596
1817
|
silent: silent,
|
|
1597
|
-
customHeader: customHeader,
|
|
1598
1818
|
headers: headers
|
|
1599
1819
|
});
|
|
1600
1820
|
|
|
@@ -1647,18 +1867,256 @@ function getDryRunCLI(cli, logger) {
|
|
|
1647
1867
|
};
|
|
1648
1868
|
}
|
|
1649
1869
|
|
|
1650
|
-
|
|
1651
|
-
|
|
1870
|
+
var DEBUG_ID_INJECTOR_SNIPPET = ';!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="__SENTRY_DEBUG_ID__",e._sentryDebugIdIdentifier="sentry-dbid-__SENTRY_DEBUG_ID__")}catch(e){}}();';
|
|
1871
|
+
function injectDebugIdSnippetIntoChunk(code) {
|
|
1872
|
+
var _code$match;
|
|
1873
|
+
|
|
1874
|
+
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
1875
|
+
|
|
1876
|
+
var ms = new MagicString(code);
|
|
1877
|
+
var codeToInject = DEBUG_ID_INJECTOR_SNIPPET.replace(/__SENTRY_DEBUG_ID__/g, debugId); // We need to be careful not to inject the snippet before any `"use strict";`s.
|
|
1878
|
+
// As an additional complication `"use strict";`s may come after any number of comments.
|
|
1879
|
+
|
|
1880
|
+
var commentUseStrictRegex = /^(?:\s*|\/\*(.|\r|\n)*?\*\/|\/\/.*?[\n\r])*(?:"use strict";|'use strict';)?/;
|
|
1881
|
+
|
|
1882
|
+
if ((_code$match = code.match(commentUseStrictRegex)) !== null && _code$match !== void 0 && _code$match[0]) {
|
|
1883
|
+
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
1884
|
+
ms.replace(commentUseStrictRegex, function (match) {
|
|
1885
|
+
return "".concat(match).concat(codeToInject);
|
|
1886
|
+
});
|
|
1887
|
+
} else {
|
|
1888
|
+
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
1889
|
+
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
1890
|
+
// need this special case here.
|
|
1891
|
+
ms.prepend(codeToInject);
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
return {
|
|
1895
|
+
code: ms.toString(),
|
|
1896
|
+
map: ms.generateMap()
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
function prepareBundleForDebugIdUpload(_x, _x2, _x3, _x4) {
|
|
1900
|
+
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle
|
|
1904
|
+
* source and extracts the bundle's debug ID from it.
|
|
1905
|
+
*
|
|
1906
|
+
* The string pattern is injected via the debug ID injection snipped.
|
|
1907
|
+
*/
|
|
1908
|
+
|
|
1909
|
+
function _prepareBundleForDebugIdUpload() {
|
|
1910
|
+
_prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(bundleFilePath, uploadFolder, uniqueUploadName, logger) {
|
|
1911
|
+
var bundleContent, debugId, writeSourceFilePromise, writeSourceMapFilePromise;
|
|
1912
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1913
|
+
while (1) {
|
|
1914
|
+
switch (_context2.prev = _context2.next) {
|
|
1915
|
+
case 0:
|
|
1916
|
+
_context2.prev = 0;
|
|
1917
|
+
_context2.next = 3;
|
|
1918
|
+
return util.promisify(fs.readFile)(bundleFilePath, "utf8");
|
|
1919
|
+
|
|
1920
|
+
case 3:
|
|
1921
|
+
bundleContent = _context2.sent;
|
|
1922
|
+
_context2.next = 10;
|
|
1923
|
+
break;
|
|
1924
|
+
|
|
1925
|
+
case 6:
|
|
1926
|
+
_context2.prev = 6;
|
|
1927
|
+
_context2.t0 = _context2["catch"](0);
|
|
1928
|
+
logger.warn("Could not read bundle to determine debug ID and source map: ".concat(bundleFilePath));
|
|
1929
|
+
return _context2.abrupt("return");
|
|
1930
|
+
|
|
1931
|
+
case 10:
|
|
1932
|
+
debugId = determineDebugIdFromBundleSource(bundleContent);
|
|
1933
|
+
|
|
1934
|
+
if (!(debugId === undefined)) {
|
|
1935
|
+
_context2.next = 14;
|
|
1936
|
+
break;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
logger.warn("Could not determine debug ID from bundle: ".concat(bundleFilePath));
|
|
1940
|
+
return _context2.abrupt("return");
|
|
1941
|
+
|
|
1942
|
+
case 14:
|
|
1943
|
+
bundleContent += "\n//# debugId=".concat(debugId);
|
|
1944
|
+
writeSourceFilePromise = util.promisify(fs.writeFile)(path.join(uploadFolder, "".concat(uniqueUploadName, ".js")), bundleContent, "utf-8");
|
|
1945
|
+
writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger).then( /*#__PURE__*/function () {
|
|
1946
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sourceMapPath) {
|
|
1947
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1948
|
+
while (1) {
|
|
1949
|
+
switch (_context.prev = _context.next) {
|
|
1950
|
+
case 0:
|
|
1951
|
+
if (!sourceMapPath) {
|
|
1952
|
+
_context.next = 4;
|
|
1953
|
+
break;
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
_context.next = 3;
|
|
1957
|
+
return prepareSourceMapForDebugIdUpload(sourceMapPath, path.join(uploadFolder, "".concat(uniqueUploadName, ".js.map")), debugId, logger);
|
|
1958
|
+
|
|
1959
|
+
case 3:
|
|
1960
|
+
return _context.abrupt("return", _context.sent);
|
|
1961
|
+
|
|
1962
|
+
case 4:
|
|
1963
|
+
case "end":
|
|
1964
|
+
return _context.stop();
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
}, _callee);
|
|
1968
|
+
}));
|
|
1969
|
+
|
|
1970
|
+
return function (_x12) {
|
|
1971
|
+
return _ref.apply(this, arguments);
|
|
1972
|
+
};
|
|
1973
|
+
}());
|
|
1974
|
+
return _context2.abrupt("return", Promise.all([writeSourceFilePromise, writeSourceMapFilePromise]));
|
|
1975
|
+
|
|
1976
|
+
case 18:
|
|
1977
|
+
case "end":
|
|
1978
|
+
return _context2.stop();
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
}, _callee2, null, [[0, 6]]);
|
|
1982
|
+
}));
|
|
1983
|
+
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
function determineDebugIdFromBundleSource(code) {
|
|
1987
|
+
var match = code.match(/sentry-dbid-([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/);
|
|
1988
|
+
|
|
1989
|
+
if (match) {
|
|
1990
|
+
return match[1];
|
|
1991
|
+
} else {
|
|
1992
|
+
return undefined;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
/**
|
|
1996
|
+
* Applies a set of heuristics to find the source map for a particular bundle.
|
|
1997
|
+
*
|
|
1998
|
+
* @returns the path to the bundle's source map or `undefined` if none could be found.
|
|
1999
|
+
*/
|
|
2000
|
+
|
|
2001
|
+
|
|
2002
|
+
function determineSourceMapPathFromBundle(_x5, _x6, _x7) {
|
|
2003
|
+
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* Reads a source map, injects debug ID fields, and writes the source map to the target path.
|
|
2007
|
+
*/
|
|
2008
|
+
|
|
2009
|
+
|
|
2010
|
+
function _determineSourceMapPathFromBundle() {
|
|
2011
|
+
_determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(bundlePath, bundleSource, logger) {
|
|
2012
|
+
var sourceMappingUrlMatch, sourceMappingUrl, adjacentSourceMapFilePath;
|
|
2013
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2014
|
+
while (1) {
|
|
2015
|
+
switch (_context3.prev = _context3.next) {
|
|
2016
|
+
case 0:
|
|
2017
|
+
// 1. try to find source map at `sourceMappingURL` location
|
|
2018
|
+
sourceMappingUrlMatch = bundleSource.match(/^\/\/# sourceMappingURL=(.*)$/);
|
|
2019
|
+
|
|
2020
|
+
if (!sourceMappingUrlMatch) {
|
|
2021
|
+
_context3.next = 8;
|
|
2022
|
+
break;
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
sourceMappingUrl = path.normalize(sourceMappingUrlMatch[1]);
|
|
2026
|
+
|
|
2027
|
+
if (!path.isAbsolute(sourceMappingUrl)) {
|
|
2028
|
+
_context3.next = 7;
|
|
2029
|
+
break;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
return _context3.abrupt("return", sourceMappingUrl);
|
|
2033
|
+
|
|
2034
|
+
case 7:
|
|
2035
|
+
return _context3.abrupt("return", path.join(path.dirname(bundlePath), sourceMappingUrl));
|
|
2036
|
+
|
|
2037
|
+
case 8:
|
|
2038
|
+
_context3.prev = 8;
|
|
2039
|
+
adjacentSourceMapFilePath = bundlePath + ".map";
|
|
2040
|
+
_context3.next = 12;
|
|
2041
|
+
return util.promisify(fs.access)(adjacentSourceMapFilePath);
|
|
2042
|
+
|
|
2043
|
+
case 12:
|
|
2044
|
+
return _context3.abrupt("return", adjacentSourceMapFilePath);
|
|
2045
|
+
|
|
2046
|
+
case 15:
|
|
2047
|
+
_context3.prev = 15;
|
|
2048
|
+
_context3.t0 = _context3["catch"](8);
|
|
2049
|
+
|
|
2050
|
+
case 17:
|
|
2051
|
+
logger.warn("Could not determine source map path for bundle: ".concat(bundlePath));
|
|
2052
|
+
return _context3.abrupt("return", undefined);
|
|
2053
|
+
|
|
2054
|
+
case 19:
|
|
2055
|
+
case "end":
|
|
2056
|
+
return _context3.stop();
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
}, _callee3, null, [[8, 15]]);
|
|
2060
|
+
}));
|
|
2061
|
+
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
function prepareSourceMapForDebugIdUpload(_x8, _x9, _x10, _x11) {
|
|
2065
|
+
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
function _prepareSourceMapForDebugIdUpload() {
|
|
2069
|
+
_prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(sourceMapPath, targetPath, debugId, logger) {
|
|
2070
|
+
var sourceMapFileContent, map;
|
|
2071
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
2072
|
+
while (1) {
|
|
2073
|
+
switch (_context4.prev = _context4.next) {
|
|
2074
|
+
case 0:
|
|
2075
|
+
_context4.prev = 0;
|
|
2076
|
+
_context4.next = 3;
|
|
2077
|
+
return util.promisify(fs.readFile)(sourceMapPath, {
|
|
2078
|
+
encoding: "utf8"
|
|
2079
|
+
});
|
|
2080
|
+
|
|
2081
|
+
case 3:
|
|
2082
|
+
sourceMapFileContent = _context4.sent;
|
|
2083
|
+
map = JSON.parse(sourceMapFileContent); // For now we write both fields until we know what will become the standard - if ever.
|
|
2084
|
+
|
|
2085
|
+
map["debug_id"] = debugId;
|
|
2086
|
+
map["debugId"] = debugId;
|
|
2087
|
+
_context4.next = 9;
|
|
2088
|
+
return util.promisify(fs.writeFile)(targetPath, JSON.stringify(map), {
|
|
2089
|
+
encoding: "utf8"
|
|
2090
|
+
});
|
|
2091
|
+
|
|
2092
|
+
case 9:
|
|
2093
|
+
_context4.next = 14;
|
|
2094
|
+
break;
|
|
2095
|
+
|
|
2096
|
+
case 11:
|
|
2097
|
+
_context4.prev = 11;
|
|
2098
|
+
_context4.t0 = _context4["catch"](0);
|
|
2099
|
+
logger.warn("Failed to prepare source map for debug ID upload: ".concat(sourceMapPath));
|
|
2100
|
+
|
|
2101
|
+
case 14:
|
|
2102
|
+
case "end":
|
|
2103
|
+
return _context4.stop();
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
}, _callee4, null, [[0, 11]]);
|
|
2107
|
+
}));
|
|
2108
|
+
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
2109
|
+
}
|
|
1652
2110
|
|
|
1653
|
-
var RELEASE_INJECTOR_ID = "\0sentry-release-injector";
|
|
1654
2111
|
var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"];
|
|
2112
|
+
|
|
2113
|
+
var releaseInjectionFilePath = require.resolve("@sentry/bundler-plugin-core/sentry-release-injection-file");
|
|
1655
2114
|
/**
|
|
1656
2115
|
* The sentry bundler plugin concerns itself with two things:
|
|
1657
2116
|
* - Release injection
|
|
1658
2117
|
* - Sourcemaps upload
|
|
1659
2118
|
*
|
|
1660
2119
|
* Release injection:
|
|
1661
|
-
*
|
|
1662
2120
|
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into each JavaScript/TypeScript module
|
|
1663
2121
|
* that is part of the bundle. On a technical level this is done by appending an import (`import "sentry-release-injector;"`)
|
|
1664
2122
|
* to all entrypoint files of the user code (see `transformInclude` and `transform` hooks). This import is then resolved
|
|
@@ -1667,8 +2125,9 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"]
|
|
|
1667
2125
|
*
|
|
1668
2126
|
* Source maps upload:
|
|
1669
2127
|
*
|
|
1670
|
-
* The sentry bundler plugin will also take care of uploading source maps to Sentry. This
|
|
1671
|
-
* `writeBundle` hook. In this hook the sentry plugin will execute the
|
|
2128
|
+
* The sentry bundler plugin will also take care of uploading source maps to Sentry. This
|
|
2129
|
+
* is all done in the `writeBundle` hook. In this hook the sentry plugin will execute the
|
|
2130
|
+
* release creation pipeline:
|
|
1672
2131
|
*
|
|
1673
2132
|
* 1. Create a new release
|
|
1674
2133
|
* 2. Delete already uploaded artifacts for this release (if `cleanArtifacts` is enabled)
|
|
@@ -1680,6 +2139,7 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"]
|
|
|
1680
2139
|
* This release creation pipeline relies on Sentry CLI to execute the different steps.
|
|
1681
2140
|
*/
|
|
1682
2141
|
|
|
2142
|
+
|
|
1683
2143
|
var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
1684
2144
|
var internalOptions = normalizeUserOptions(options);
|
|
1685
2145
|
var allowedToSendTelemetryPromise = shouldSendTelemetry(internalOptions);
|
|
@@ -1800,69 +2260,7 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1800
2260
|
importer: importer,
|
|
1801
2261
|
isEntry: isEntry
|
|
1802
2262
|
});
|
|
1803
|
-
|
|
1804
|
-
if (id === RELEASE_INJECTOR_ID) {
|
|
1805
|
-
return RELEASE_INJECTOR_ID;
|
|
1806
|
-
} else {
|
|
1807
|
-
return undefined;
|
|
1808
|
-
}
|
|
1809
|
-
},
|
|
1810
|
-
loadInclude: function loadInclude(id) {
|
|
1811
|
-
logger.debug('Called "loadInclude":', {
|
|
1812
|
-
id: id
|
|
1813
|
-
});
|
|
1814
|
-
return id === RELEASE_INJECTOR_ID;
|
|
1815
|
-
},
|
|
1816
|
-
|
|
1817
|
-
/**
|
|
1818
|
-
* Responsible for "virtually" loading the "sentry-release-injector" module. "Virtual" means that the module is not
|
|
1819
|
-
* read from somewhere on disk but rather just returned via a string.
|
|
1820
|
-
*
|
|
1821
|
-
* @param id Always the absolute (fully resolved) path to the module.
|
|
1822
|
-
* @returns The global injector code when we load the "sentry-release-injector" module. Otherwise returns `undefined`.
|
|
1823
|
-
*/
|
|
1824
|
-
load: function load(id) {
|
|
1825
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1826
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1827
|
-
while (1) {
|
|
1828
|
-
switch (_context2.prev = _context2.next) {
|
|
1829
|
-
case 0:
|
|
1830
|
-
logger.debug('Called "load":', {
|
|
1831
|
-
id: id
|
|
1832
|
-
});
|
|
1833
|
-
|
|
1834
|
-
if (!(id === RELEASE_INJECTOR_ID)) {
|
|
1835
|
-
_context2.next = 13;
|
|
1836
|
-
break;
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
_context2.t0 = generateGlobalInjectorCode;
|
|
1840
|
-
_context2.next = 5;
|
|
1841
|
-
return releaseNamePromise;
|
|
1842
|
-
|
|
1843
|
-
case 5:
|
|
1844
|
-
_context2.t1 = _context2.sent;
|
|
1845
|
-
_context2.t2 = internalOptions.injectReleasesMap;
|
|
1846
|
-
_context2.t3 = internalOptions.org;
|
|
1847
|
-
_context2.t4 = internalOptions.project;
|
|
1848
|
-
_context2.t5 = {
|
|
1849
|
-
release: _context2.t1,
|
|
1850
|
-
injectReleasesMap: _context2.t2,
|
|
1851
|
-
org: _context2.t3,
|
|
1852
|
-
project: _context2.t4
|
|
1853
|
-
};
|
|
1854
|
-
return _context2.abrupt("return", (0, _context2.t0)(_context2.t5));
|
|
1855
|
-
|
|
1856
|
-
case 13:
|
|
1857
|
-
return _context2.abrupt("return", undefined);
|
|
1858
|
-
|
|
1859
|
-
case 14:
|
|
1860
|
-
case "end":
|
|
1861
|
-
return _context2.stop();
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
}, _callee2);
|
|
1865
|
-
}))();
|
|
2263
|
+
return undefined;
|
|
1866
2264
|
},
|
|
1867
2265
|
|
|
1868
2266
|
/**
|
|
@@ -1879,10 +2277,10 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1879
2277
|
}); // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
|
|
1880
2278
|
// a windows style path to `releaseInjectionTargets`
|
|
1881
2279
|
|
|
1882
|
-
var normalizedId =
|
|
2280
|
+
var normalizedId = path__default.normalize(id);
|
|
1883
2281
|
|
|
1884
|
-
if (
|
|
1885
|
-
return
|
|
2282
|
+
if (id.includes("sentry-release-injection-file")) {
|
|
2283
|
+
return true;
|
|
1886
2284
|
}
|
|
1887
2285
|
|
|
1888
2286
|
if (internalOptions.releaseInjectionTargets) {
|
|
@@ -1895,17 +2293,16 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1895
2293
|
if (entry instanceof RegExp) {
|
|
1896
2294
|
return entry.test(normalizedId);
|
|
1897
2295
|
} else {
|
|
1898
|
-
var normalizedEntry =
|
|
2296
|
+
var normalizedEntry = path__default.normalize(entry);
|
|
1899
2297
|
return normalizedId === normalizedEntry;
|
|
1900
2298
|
}
|
|
1901
2299
|
});
|
|
1902
2300
|
} else {
|
|
1903
|
-
var isInNodeModules = normalizedId.split(path.sep).includes("node_modules");
|
|
1904
2301
|
var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
|
|
1905
2302
|
var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
|
|
1906
2303
|
return normalizedId.endsWith(allowedFileEnding);
|
|
1907
2304
|
});
|
|
1908
|
-
return
|
|
2305
|
+
return pathIsOrdinary && pathHasAllowedFileEnding;
|
|
1909
2306
|
}
|
|
1910
2307
|
},
|
|
1911
2308
|
|
|
@@ -1918,26 +2315,84 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1918
2315
|
* @returns transformed code + source map
|
|
1919
2316
|
*/
|
|
1920
2317
|
transform: function transform(code, id) {
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
2318
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
2319
|
+
var ms;
|
|
2320
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2321
|
+
while (1) {
|
|
2322
|
+
switch (_context2.prev = _context2.next) {
|
|
2323
|
+
case 0:
|
|
2324
|
+
logger.debug('Called "transform":', {
|
|
2325
|
+
id: id
|
|
2326
|
+
});
|
|
1924
2327
|
|
|
1925
|
-
|
|
1926
|
-
|
|
2328
|
+
if (internalOptions.injectRelease) {
|
|
2329
|
+
_context2.next = 3;
|
|
2330
|
+
break;
|
|
2331
|
+
}
|
|
1927
2332
|
|
|
1928
|
-
|
|
2333
|
+
return _context2.abrupt("return");
|
|
1929
2334
|
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
2335
|
+
case 3:
|
|
2336
|
+
// The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
|
|
2337
|
+
ms = new MagicString(code);
|
|
2338
|
+
|
|
2339
|
+
if (!code.includes("_sentry_release_injection_file")) {
|
|
2340
|
+
_context2.next = 19;
|
|
2341
|
+
break;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
_context2.t0 = ms;
|
|
2345
|
+
_context2.t1 = generateGlobalInjectorCode;
|
|
2346
|
+
_context2.next = 9;
|
|
2347
|
+
return releaseNamePromise;
|
|
2348
|
+
|
|
2349
|
+
case 9:
|
|
2350
|
+
_context2.t2 = _context2.sent;
|
|
2351
|
+
_context2.t3 = internalOptions.injectReleasesMap;
|
|
2352
|
+
_context2.t4 = internalOptions._experiments.injectBuildInformation || false;
|
|
2353
|
+
_context2.t5 = internalOptions.org;
|
|
2354
|
+
_context2.t6 = internalOptions.project;
|
|
2355
|
+
_context2.t7 = {
|
|
2356
|
+
release: _context2.t2,
|
|
2357
|
+
injectReleasesMap: _context2.t3,
|
|
2358
|
+
injectBuildInformation: _context2.t4,
|
|
2359
|
+
org: _context2.t5,
|
|
2360
|
+
project: _context2.t6
|
|
2361
|
+
};
|
|
2362
|
+
_context2.t8 = (0, _context2.t1)(_context2.t7);
|
|
2363
|
+
|
|
2364
|
+
_context2.t0.append.call(_context2.t0, _context2.t8);
|
|
2365
|
+
|
|
2366
|
+
_context2.next = 20;
|
|
2367
|
+
break;
|
|
2368
|
+
|
|
2369
|
+
case 19:
|
|
2370
|
+
// Appending instead of prepending has less probability of mucking with user's source maps.
|
|
2371
|
+
// Luckily import statements get hoisted to the top anyways.
|
|
2372
|
+
// The import needs to be an absolute path because Rollup doesn't bundle stuff in `node_modules` by default when bundling CJS (unless the import path is absolute or the node-resolve-plugin is used).
|
|
2373
|
+
ms.append(";\nimport \"".concat(releaseInjectionFilePath.replace(/\\/g, "\\\\"), "\";"));
|
|
2374
|
+
|
|
2375
|
+
case 20:
|
|
2376
|
+
if (!(unpluginMetaContext.framework === "esbuild")) {
|
|
2377
|
+
_context2.next = 24;
|
|
2378
|
+
break;
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
return _context2.abrupt("return", ms.toString());
|
|
2382
|
+
|
|
2383
|
+
case 24:
|
|
2384
|
+
return _context2.abrupt("return", {
|
|
2385
|
+
code: ms.toString(),
|
|
2386
|
+
map: ms.generateMap()
|
|
2387
|
+
});
|
|
2388
|
+
|
|
2389
|
+
case 25:
|
|
2390
|
+
case "end":
|
|
2391
|
+
return _context2.stop();
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}, _callee2);
|
|
2395
|
+
}))();
|
|
1941
2396
|
},
|
|
1942
2397
|
|
|
1943
2398
|
/**
|
|
@@ -1945,14 +2400,14 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1945
2400
|
* Sentry.io, uploading sourcemaps, associating commits and deploys and finalizing the release)
|
|
1946
2401
|
*/
|
|
1947
2402
|
writeBundle: function writeBundle() {
|
|
1948
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2403
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1949
2404
|
var _releaseInjectionSpan;
|
|
1950
2405
|
|
|
1951
|
-
var releasePipelineSpan, ctx, releaseName, _transaction, _transaction2, _transaction3;
|
|
2406
|
+
var releasePipelineSpan, ctx, releaseName, tmpUploadFolder, _transaction, debugIdChunkFilePaths, sourceFileUploadFolderPromise, _transaction2, _transaction3;
|
|
1952
2407
|
|
|
1953
|
-
return _regeneratorRuntime().wrap(function
|
|
2408
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1954
2409
|
while (1) {
|
|
1955
|
-
switch (
|
|
2410
|
+
switch (_context4.prev = _context4.next) {
|
|
1956
2411
|
case 0:
|
|
1957
2412
|
logger.debug('Called "writeBundle"');
|
|
1958
2413
|
(_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
|
|
@@ -1972,75 +2427,172 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1972
2427
|
logger: logger,
|
|
1973
2428
|
cli: cli
|
|
1974
2429
|
};
|
|
1975
|
-
|
|
2430
|
+
_context4.next = 7;
|
|
1976
2431
|
return releaseNamePromise;
|
|
1977
2432
|
|
|
1978
2433
|
case 7:
|
|
1979
|
-
releaseName =
|
|
1980
|
-
|
|
1981
|
-
|
|
2434
|
+
releaseName = _context4.sent;
|
|
2435
|
+
_context4.prev = 8;
|
|
2436
|
+
|
|
2437
|
+
if (!internalOptions._experiments.debugIdUpload) {
|
|
2438
|
+
_context4.next = 21;
|
|
2439
|
+
break;
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
_context4.next = 12;
|
|
2443
|
+
return glob(internalOptions._experiments.debugIdUpload.include, {
|
|
2444
|
+
absolute: true,
|
|
2445
|
+
nodir: true,
|
|
2446
|
+
ignore: internalOptions._experiments.debugIdUpload.ignore
|
|
2447
|
+
});
|
|
2448
|
+
|
|
2449
|
+
case 12:
|
|
2450
|
+
debugIdChunkFilePaths = _context4.sent.filter(function (p) {
|
|
2451
|
+
return p.endsWith(".js") || p.endsWith(".mjs");
|
|
2452
|
+
});
|
|
2453
|
+
sourceFileUploadFolderPromise = util__default.promisify(fs__default.mkdtemp)(path__default.join(os.tmpdir(), "sentry-bundler-plugin-upload-"));
|
|
2454
|
+
_context4.next = 16;
|
|
2455
|
+
return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
|
|
2456
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chunkFilePath, chunkIndex) {
|
|
2457
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2458
|
+
while (1) {
|
|
2459
|
+
switch (_context3.prev = _context3.next) {
|
|
2460
|
+
case 0:
|
|
2461
|
+
_context3.t0 = prepareBundleForDebugIdUpload;
|
|
2462
|
+
_context3.t1 = chunkFilePath;
|
|
2463
|
+
_context3.next = 4;
|
|
2464
|
+
return sourceFileUploadFolderPromise;
|
|
2465
|
+
|
|
2466
|
+
case 4:
|
|
2467
|
+
_context3.t2 = _context3.sent;
|
|
2468
|
+
_context3.t3 = String(chunkIndex);
|
|
2469
|
+
_context3.t4 = logger;
|
|
2470
|
+
_context3.next = 9;
|
|
2471
|
+
return (0, _context3.t0)(_context3.t1, _context3.t2, _context3.t3, _context3.t4);
|
|
2472
|
+
|
|
2473
|
+
case 9:
|
|
2474
|
+
case "end":
|
|
2475
|
+
return _context3.stop();
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
}, _callee3);
|
|
2479
|
+
}));
|
|
2480
|
+
|
|
2481
|
+
return function (_x, _x2) {
|
|
2482
|
+
return _ref2.apply(this, arguments);
|
|
2483
|
+
};
|
|
2484
|
+
}()));
|
|
2485
|
+
|
|
2486
|
+
case 16:
|
|
2487
|
+
_context4.next = 18;
|
|
2488
|
+
return sourceFileUploadFolderPromise;
|
|
2489
|
+
|
|
2490
|
+
case 18:
|
|
2491
|
+
tmpUploadFolder = _context4.sent;
|
|
2492
|
+
_context4.next = 21;
|
|
2493
|
+
return uploadDebugIdSourcemaps(internalOptions, ctx, tmpUploadFolder, releaseName);
|
|
2494
|
+
|
|
2495
|
+
case 21:
|
|
2496
|
+
_context4.next = 23;
|
|
1982
2497
|
return createNewRelease(internalOptions, ctx, releaseName);
|
|
1983
2498
|
|
|
1984
|
-
case
|
|
1985
|
-
|
|
2499
|
+
case 23:
|
|
2500
|
+
_context4.next = 25;
|
|
1986
2501
|
return cleanArtifacts(internalOptions, ctx, releaseName);
|
|
1987
2502
|
|
|
1988
|
-
case
|
|
1989
|
-
|
|
2503
|
+
case 25:
|
|
2504
|
+
_context4.next = 27;
|
|
1990
2505
|
return uploadSourceMaps(internalOptions, ctx, releaseName);
|
|
1991
2506
|
|
|
1992
|
-
case
|
|
1993
|
-
|
|
2507
|
+
case 27:
|
|
2508
|
+
_context4.next = 29;
|
|
1994
2509
|
return setCommits(internalOptions, ctx, releaseName);
|
|
1995
2510
|
|
|
1996
|
-
case
|
|
1997
|
-
|
|
2511
|
+
case 29:
|
|
2512
|
+
_context4.next = 31;
|
|
1998
2513
|
return finalizeRelease(internalOptions, ctx, releaseName);
|
|
1999
2514
|
|
|
2000
|
-
case
|
|
2001
|
-
|
|
2515
|
+
case 31:
|
|
2516
|
+
_context4.next = 33;
|
|
2002
2517
|
return addDeploy(internalOptions, ctx, releaseName);
|
|
2003
2518
|
|
|
2004
|
-
case
|
|
2519
|
+
case 33:
|
|
2005
2520
|
(_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
|
|
2006
|
-
|
|
2521
|
+
_context4.next = 41;
|
|
2007
2522
|
break;
|
|
2008
2523
|
|
|
2009
|
-
case
|
|
2010
|
-
|
|
2011
|
-
|
|
2524
|
+
case 36:
|
|
2525
|
+
_context4.prev = 36;
|
|
2526
|
+
_context4.t0 = _context4["catch"](8);
|
|
2012
2527
|
(_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
|
|
2013
2528
|
sentryHub.addBreadcrumb({
|
|
2014
2529
|
level: "error",
|
|
2015
2530
|
message: "Error during writeBundle"
|
|
2016
2531
|
});
|
|
2017
|
-
handleError(
|
|
2532
|
+
handleError(_context4.t0, logger, internalOptions.errorHandler);
|
|
2533
|
+
|
|
2534
|
+
case 41:
|
|
2535
|
+
_context4.prev = 41;
|
|
2536
|
+
|
|
2537
|
+
if (tmpUploadFolder) {
|
|
2538
|
+
fs__default.rm(tmpUploadFolder, {
|
|
2539
|
+
recursive: true,
|
|
2540
|
+
force: true
|
|
2541
|
+
}, function () {// We don't care if this errors
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2018
2544
|
|
|
2019
|
-
case 29:
|
|
2020
|
-
_context3.prev = 29;
|
|
2021
2545
|
releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
|
|
2022
2546
|
(_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
|
|
2023
|
-
|
|
2547
|
+
_context4.next = 47;
|
|
2024
2548
|
return sentryClient.flush().then(null, function () {
|
|
2025
2549
|
logger.warn("Sending of telemetry failed");
|
|
2026
2550
|
});
|
|
2027
2551
|
|
|
2028
|
-
case
|
|
2029
|
-
return
|
|
2552
|
+
case 47:
|
|
2553
|
+
return _context4.finish(41);
|
|
2030
2554
|
|
|
2031
|
-
case
|
|
2555
|
+
case 48:
|
|
2032
2556
|
sentryHub.addBreadcrumb({
|
|
2033
2557
|
category: "writeBundle:finish",
|
|
2034
2558
|
level: "info"
|
|
2035
2559
|
});
|
|
2036
2560
|
|
|
2037
|
-
case
|
|
2561
|
+
case 49:
|
|
2038
2562
|
case "end":
|
|
2039
|
-
return
|
|
2563
|
+
return _context4.stop();
|
|
2040
2564
|
}
|
|
2041
2565
|
}
|
|
2042
|
-
},
|
|
2566
|
+
}, _callee4, null, [[8, 36, 41, 48]]);
|
|
2043
2567
|
}))();
|
|
2568
|
+
},
|
|
2569
|
+
rollup: {
|
|
2570
|
+
renderChunk: function renderChunk(code, chunk) {
|
|
2571
|
+
var _options$_experiments;
|
|
2572
|
+
|
|
2573
|
+
if ((_options$_experiments = options._experiments) !== null && _options$_experiments !== void 0 && _options$_experiments.debugIdUpload && [".js", ".mjs"].some(function (ending) {
|
|
2574
|
+
return chunk.fileName.endsWith(ending);
|
|
2575
|
+
}) // chunks could be any file (html, md, ...)
|
|
2576
|
+
) {
|
|
2577
|
+
return injectDebugIdSnippetIntoChunk(code);
|
|
2578
|
+
} else {
|
|
2579
|
+
return null; // returning null means not modifying the chunk at all
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
},
|
|
2583
|
+
vite: {
|
|
2584
|
+
renderChunk: function renderChunk(code, chunk) {
|
|
2585
|
+
var _options$_experiments2;
|
|
2586
|
+
|
|
2587
|
+
if ((_options$_experiments2 = options._experiments) !== null && _options$_experiments2 !== void 0 && _options$_experiments2.debugIdUpload && [".js", ".mjs"].some(function (ending) {
|
|
2588
|
+
return chunk.fileName.endsWith(ending);
|
|
2589
|
+
}) // chunks could be any file (html, md, ...)
|
|
2590
|
+
) {
|
|
2591
|
+
return injectDebugIdSnippetIntoChunk(code);
|
|
2592
|
+
} else {
|
|
2593
|
+
return null; // returning null means not modifying the chunk at all
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2044
2596
|
}
|
|
2045
2597
|
};
|
|
2046
2598
|
});
|
|
@@ -2063,28 +2615,59 @@ function handleError(unknownError, logger, errorHandler) {
|
|
|
2063
2615
|
}
|
|
2064
2616
|
}
|
|
2065
2617
|
/**
|
|
2066
|
-
* Generates code for the
|
|
2067
|
-
*
|
|
2618
|
+
* Generates code for the global injector which is responsible for setting the global
|
|
2619
|
+
* `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
|
|
2068
2620
|
*/
|
|
2069
2621
|
|
|
2070
2622
|
|
|
2071
|
-
function generateGlobalInjectorCode(
|
|
2072
|
-
var release =
|
|
2073
|
-
injectReleasesMap =
|
|
2074
|
-
|
|
2075
|
-
|
|
2623
|
+
function generateGlobalInjectorCode(_ref3) {
|
|
2624
|
+
var release = _ref3.release,
|
|
2625
|
+
injectReleasesMap = _ref3.injectReleasesMap,
|
|
2626
|
+
injectBuildInformation = _ref3.injectBuildInformation,
|
|
2627
|
+
org = _ref3.org,
|
|
2628
|
+
project = _ref3.project;
|
|
2076
2629
|
// The code below is mostly ternary operators because it saves bundle size.
|
|
2077
2630
|
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
2078
2631
|
var code = "\n var _global =\n typeof window !== 'undefined' ?\n window :\n typeof global !== 'undefined' ?\n global :\n typeof self !== 'undefined' ?\n self :\n {};\n\n _global.SENTRY_RELEASE={id:\"".concat(release, "\"};");
|
|
2079
2632
|
|
|
2080
2633
|
if (injectReleasesMap && project) {
|
|
2081
2634
|
var key = org ? "".concat(project, "@").concat(org) : project;
|
|
2082
|
-
code += "\n _global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};\n _global.SENTRY_RELEASES[\"".concat(key, "\"]={id:\"").concat(release, "\"}
|
|
2635
|
+
code += "\n _global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};\n _global.SENTRY_RELEASES[\"".concat(key, "\"]={id:\"").concat(release, "\"};");
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
if (injectBuildInformation) {
|
|
2639
|
+
var buildInfo = getBuildInformation();
|
|
2640
|
+
code += "\n _global.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
|
|
2083
2641
|
}
|
|
2084
2642
|
|
|
2085
2643
|
return code;
|
|
2086
|
-
}
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
function getBuildInformation() {
|
|
2647
|
+
var packageJson = getPackageJson();
|
|
2087
2648
|
|
|
2649
|
+
var _ref4 = packageJson ? getDependencies(packageJson) : {
|
|
2650
|
+
deps: [],
|
|
2651
|
+
depsVersions: {}
|
|
2652
|
+
},
|
|
2653
|
+
deps = _ref4.deps,
|
|
2654
|
+
depsVersions = _ref4.depsVersions;
|
|
2655
|
+
|
|
2656
|
+
return {
|
|
2657
|
+
deps: deps,
|
|
2658
|
+
depsVersions: depsVersions,
|
|
2659
|
+
nodeVersion: parseMajorVersion(process.version)
|
|
2660
|
+
};
|
|
2661
|
+
}
|
|
2662
|
+
/**
|
|
2663
|
+
* Determines whether the Sentry CLI binary is in its expected location.
|
|
2664
|
+
* This function is useful since `@sentry/cli` installs the binary via a post-install
|
|
2665
|
+
* script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.
|
|
2666
|
+
*/
|
|
2667
|
+
|
|
2668
|
+
function sentryCliBinaryExists() {
|
|
2669
|
+
return fs__default.existsSync(SentryCli.getPath());
|
|
2670
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2088
2671
|
|
|
2089
2672
|
var sentryVitePlugin = unplugin.vite; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2090
2673
|
|
|
@@ -2094,5 +2677,5 @@ var sentryWebpackPlugin = unplugin.webpack; // eslint-disable-next-line @typescr
|
|
|
2094
2677
|
|
|
2095
2678
|
var sentryEsbuildPlugin = unplugin.esbuild;
|
|
2096
2679
|
|
|
2097
|
-
export { sentryEsbuildPlugin, sentryRollupPlugin, sentryVitePlugin, sentryWebpackPlugin };
|
|
2680
|
+
export { getBuildInformation, sentryCliBinaryExists, sentryEsbuildPlugin, sentryRollupPlugin, sentryVitePlugin, sentryWebpackPlugin };
|
|
2098
2681
|
//# sourceMappingURL=index.mjs.map
|