@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/cjs/index.js
CHANGED
|
@@ -6,14 +6,46 @@ var unplugin$1 = require('unplugin');
|
|
|
6
6
|
var MagicString = require('magic-string');
|
|
7
7
|
var SentryCli = require('@sentry/cli');
|
|
8
8
|
var node = require('@sentry/node');
|
|
9
|
-
require('
|
|
9
|
+
var findUp = require('find-up');
|
|
10
10
|
var path = require('path');
|
|
11
|
+
var fs = require('fs');
|
|
12
|
+
var os = require('os');
|
|
13
|
+
var crypto = require('crypto');
|
|
14
|
+
require('@sentry/tracing');
|
|
15
|
+
var util = require('util');
|
|
16
|
+
var glob = require('glob');
|
|
11
17
|
|
|
12
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
19
|
|
|
20
|
+
function _interopNamespace(e) {
|
|
21
|
+
if (e && e.__esModule) return e;
|
|
22
|
+
var n = Object.create(null);
|
|
23
|
+
if (e) {
|
|
24
|
+
Object.keys(e).forEach(function (k) {
|
|
25
|
+
if (k !== 'default') {
|
|
26
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return e[k]; }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
n["default"] = e;
|
|
35
|
+
return Object.freeze(n);
|
|
36
|
+
}
|
|
37
|
+
|
|
14
38
|
var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
15
39
|
var SentryCli__default = /*#__PURE__*/_interopDefaultLegacy(SentryCli);
|
|
40
|
+
var findUp__default = /*#__PURE__*/_interopDefaultLegacy(findUp);
|
|
16
41
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
42
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
43
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
44
|
+
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
45
|
+
var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
|
|
46
|
+
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
47
|
+
var util__namespace = /*#__PURE__*/_interopNamespace(util);
|
|
48
|
+
var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
|
|
17
49
|
|
|
18
50
|
function _regeneratorRuntime() {
|
|
19
51
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -769,13 +801,156 @@ timestampSource.nowSeconds.bind(timestampSource);
|
|
|
769
801
|
* @param maybeArray Input to turn into an array, if necessary
|
|
770
802
|
* @returns The input, if already an array, or an array with the input as the only element, if not
|
|
771
803
|
*/
|
|
804
|
+
|
|
772
805
|
function arrayify(maybeArray) {
|
|
773
806
|
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
774
807
|
}
|
|
775
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Get the closes package.json from a given starting point upwards.
|
|
811
|
+
* This handles a few edge cases:
|
|
812
|
+
* * Check if a given file package.json appears to be an actual NPM package.json file
|
|
813
|
+
* * Stop at the home dir, to avoid looking too deeply
|
|
814
|
+
*/
|
|
815
|
+
function getPackageJson() {
|
|
816
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
817
|
+
cwd = _ref.cwd,
|
|
818
|
+
stopAt = _ref.stopAt;
|
|
819
|
+
|
|
820
|
+
return lookupPackageJson(cwd !== null && cwd !== void 0 ? cwd : process.cwd(), path__default["default"].normalize(stopAt !== null && stopAt !== void 0 ? stopAt : os__default["default"].homedir()));
|
|
821
|
+
}
|
|
822
|
+
function parseMajorVersion(version) {
|
|
823
|
+
// if it has a `v` prefix, remove it
|
|
824
|
+
if (version.startsWith("v")) {
|
|
825
|
+
version = version.slice(1);
|
|
826
|
+
} // First, try simple lookup of exact, ~ and ^ versions
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
var regex = /^[\^~]?(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
830
|
+
var match = version.match(regex);
|
|
831
|
+
|
|
832
|
+
if (match) {
|
|
833
|
+
return parseInt(match[1], 10);
|
|
834
|
+
} // Try to parse e.g. 1.x
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
var coerced = parseInt(version, 10);
|
|
838
|
+
|
|
839
|
+
if (!Number.isNaN(coerced)) {
|
|
840
|
+
return coerced;
|
|
841
|
+
} // Match <= and >= ranges.
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
var gteLteRegex = /^[<>]=\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
845
|
+
var gteLteMatch = version.match(gteLteRegex);
|
|
846
|
+
|
|
847
|
+
if (gteLteMatch) {
|
|
848
|
+
return parseInt(gteLteMatch[1], 10);
|
|
849
|
+
} // match < ranges
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
var ltRegex = /^<\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
853
|
+
var ltMatch = version.match(ltRegex);
|
|
854
|
+
|
|
855
|
+
if (ltMatch) {
|
|
856
|
+
// Two scenarios:
|
|
857
|
+
// a) < 2.0.0 --> return 1
|
|
858
|
+
// b) < 2.1.0 --> return 2
|
|
859
|
+
var major = parseInt(ltMatch[1], 10);
|
|
860
|
+
|
|
861
|
+
if ( // minor version > 0
|
|
862
|
+
typeof ltMatch[2] === "string" && parseInt(ltMatch[2].slice(1), 10) > 0 || // patch version > 0
|
|
863
|
+
typeof ltMatch[3] === "string" && parseInt(ltMatch[3].slice(1), 10) > 0) {
|
|
864
|
+
return major;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
return major - 1;
|
|
868
|
+
} // match > ranges
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
var gtRegex = /^>\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
872
|
+
var gtMatch = version.match(gtRegex);
|
|
873
|
+
|
|
874
|
+
if (gtMatch) {
|
|
875
|
+
// We always return the version here, even though it _may_ be incorrect
|
|
876
|
+
// E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3
|
|
877
|
+
// Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists
|
|
878
|
+
return parseInt(gtMatch[1], 10);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
return undefined;
|
|
882
|
+
} // This is an explicit list of packages where we want to include the (major) version number.
|
|
883
|
+
|
|
884
|
+
var PACKAGES_TO_INCLUDE_VERSION = ["react", "@angular/core", "vue", "ember-source", "svelte", "@sveltejs/kit", "webpack", "vite", "gatsby", "next", "remix", "rollup", "esbuild"];
|
|
885
|
+
function getDependencies(packageJson) {
|
|
886
|
+
var _packageJson$devDepen, _packageJson$dependen;
|
|
887
|
+
|
|
888
|
+
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 : {});
|
|
889
|
+
var deps = Object.keys(dependencies).sort();
|
|
890
|
+
var depsVersions = deps.reduce(function (depsVersions, depName) {
|
|
891
|
+
if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {
|
|
892
|
+
var version = dependencies[depName];
|
|
893
|
+
var majorVersion = parseMajorVersion(version);
|
|
894
|
+
|
|
895
|
+
if (majorVersion) {
|
|
896
|
+
depsVersions[depName] = majorVersion;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
return depsVersions;
|
|
901
|
+
}, {});
|
|
902
|
+
return {
|
|
903
|
+
deps: deps,
|
|
904
|
+
depsVersions: depsVersions
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
function lookupPackageJson(cwd, stopAt) {
|
|
909
|
+
var jsonPath = findUp__default["default"].sync(function (dirName) {
|
|
910
|
+
// Stop if we reach this dir
|
|
911
|
+
if (path__default["default"].normalize(dirName) === stopAt) {
|
|
912
|
+
return findUp__default["default"].stop;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
return findUp__default["default"].sync.exists(dirName + "/package.json") ? "package.json" : undefined;
|
|
916
|
+
}, {
|
|
917
|
+
cwd: cwd
|
|
918
|
+
});
|
|
919
|
+
|
|
920
|
+
if (!jsonPath) {
|
|
921
|
+
return undefined;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
try {
|
|
925
|
+
var jsonStr = fs__default["default"].readFileSync(jsonPath, "utf8");
|
|
926
|
+
var json = JSON.parse(jsonStr); // Ensure it is an actual package.json
|
|
927
|
+
// This is very much not bulletproof, but should be good enough
|
|
928
|
+
|
|
929
|
+
if ("name" in json || "private" in json) {
|
|
930
|
+
return json;
|
|
931
|
+
}
|
|
932
|
+
} catch (error) {// Ignore and walk up
|
|
933
|
+
} // Continue up the tree, if we find a fitting package.json
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
var newCwd = path__default["default"].dirname(path__default["default"].resolve(jsonPath + "/.."));
|
|
937
|
+
return lookupPackageJson(newCwd, stopAt);
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Deterministically hashes a string and turns the hash into a uuid.
|
|
941
|
+
*/
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
function stringToUUID(str) {
|
|
945
|
+
var md5sum = crypto__default["default"].createHash("md5");
|
|
946
|
+
md5sum.update(str);
|
|
947
|
+
var md5Hash = md5sum.digest("hex");
|
|
948
|
+
return (md5Hash.substring(0, 8) + "-" + md5Hash.substring(8, 12) + "-4" + md5Hash.substring(13, 16) + "-" + md5Hash.substring(16, 20) + "-" + md5Hash.substring(20)).toLowerCase();
|
|
949
|
+
}
|
|
950
|
+
|
|
776
951
|
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
777
952
|
function normalizeUserOptions(userOptions) {
|
|
778
|
-
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,
|
|
953
|
+
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;
|
|
779
954
|
|
|
780
955
|
var options = {
|
|
781
956
|
// include is the only strictly required option
|
|
@@ -804,16 +979,15 @@ function normalizeUserOptions(userOptions) {
|
|
|
804
979
|
silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
|
|
805
980
|
telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
|
|
806
981
|
injectReleasesMap: (_userOptions$injectRe = userOptions.injectReleasesMap) !== null && _userOptions$injectRe !== void 0 ? _userOptions$injectRe : false,
|
|
982
|
+
injectRelease: (_userOptions$injectRe2 = userOptions.injectRelease) !== null && _userOptions$injectRe2 !== void 0 ? _userOptions$injectRe2 : true,
|
|
983
|
+
uploadSourceMaps: (_userOptions$uploadSo = userOptions.uploadSourceMaps) !== null && _userOptions$uploadSo !== void 0 ? _userOptions$uploadSo : true,
|
|
984
|
+
_experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {},
|
|
807
985
|
// These options and can also be set via env variables or the config file.
|
|
808
986
|
// If they're set in the options, we simply pass them to the CLI constructor.
|
|
809
987
|
// Sentry CLI will internally query env variables and read its config file if
|
|
810
988
|
// the passed options are undefined.
|
|
811
989
|
authToken: userOptions.authToken,
|
|
812
990
|
// env var: `SENTRY_AUTH_TOKEN`
|
|
813
|
-
// CLI v1 (and the "old" webpack plugin) use `CUSTOM_HEADER`,
|
|
814
|
-
// but CLI v2 uses `SENTRY_HEADER` (which is also better aligned with other naming)
|
|
815
|
-
// In the spirit of maximum compatibility, we allow both here.
|
|
816
|
-
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"],
|
|
817
991
|
headers: userOptions.headers,
|
|
818
992
|
vcsRemote: userOptions.vcsRemote,
|
|
819
993
|
// env var: `SENTRY_VSC_REMOTE`
|
|
@@ -873,12 +1047,12 @@ function normalizeInclude(userOptions) {
|
|
|
873
1047
|
|
|
874
1048
|
|
|
875
1049
|
function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
876
|
-
var
|
|
1050
|
+
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;
|
|
877
1051
|
|
|
878
|
-
var ignoreOption = (
|
|
1052
|
+
var ignoreOption = (_ref3 = (_includeEntry$ignore = includeEntry.ignore) !== null && _includeEntry$ignore !== void 0 ? _includeEntry$ignore : userOptions.ignore) !== null && _ref3 !== void 0 ? _ref3 : ["node_modules"];
|
|
879
1053
|
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()`
|
|
880
1054
|
|
|
881
|
-
var ext = (
|
|
1055
|
+
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"];
|
|
882
1056
|
var dotPrefixedExt = ext.map(function (extension) {
|
|
883
1057
|
return ".".concat(extension.replace(/^\./, ""));
|
|
884
1058
|
});
|
|
@@ -890,10 +1064,10 @@ function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
|
890
1064
|
urlPrefix: (_includeEntry$urlPref = includeEntry.urlPrefix) !== null && _includeEntry$urlPref !== void 0 ? _includeEntry$urlPref : userOptions.urlPrefix,
|
|
891
1065
|
urlSuffix: (_includeEntry$urlSuff = includeEntry.urlSuffix) !== null && _includeEntry$urlSuff !== void 0 ? _includeEntry$urlSuff : userOptions.urlSuffix,
|
|
892
1066
|
stripPrefix: (_includeEntry$stripPr = includeEntry.stripPrefix) !== null && _includeEntry$stripPr !== void 0 ? _includeEntry$stripPr : userOptions.stripPrefix,
|
|
893
|
-
stripCommonPrefix: (
|
|
894
|
-
sourceMapReference: (
|
|
895
|
-
rewrite: (
|
|
896
|
-
validate: (
|
|
1067
|
+
stripCommonPrefix: (_ref5 = (_includeEntry$stripCo = includeEntry.stripCommonPrefix) !== null && _includeEntry$stripCo !== void 0 ? _includeEntry$stripCo : userOptions.stripCommonPrefix) !== null && _ref5 !== void 0 ? _ref5 : false,
|
|
1068
|
+
sourceMapReference: (_ref6 = (_includeEntry$sourceM = includeEntry.sourceMapReference) !== null && _includeEntry$sourceM !== void 0 ? _includeEntry$sourceM : userOptions.sourceMapReference) !== null && _ref6 !== void 0 ? _ref6 : true,
|
|
1069
|
+
rewrite: (_ref7 = (_includeEntry$rewrite = includeEntry.rewrite) !== null && _includeEntry$rewrite !== void 0 ? _includeEntry$rewrite : userOptions.rewrite) !== null && _ref7 !== void 0 ? _ref7 : true,
|
|
1070
|
+
validate: (_ref8 = (_includeEntry$validat = includeEntry.validate) !== null && _includeEntry$validat !== void 0 ? _includeEntry$validat : userOptions.validate) !== null && _ref8 !== void 0 ? _ref8 : false
|
|
897
1071
|
};
|
|
898
1072
|
}
|
|
899
1073
|
/**
|
|
@@ -947,7 +1121,7 @@ function makeSentryClient(dsn, allowedToSendTelemetryPromise, userProject) {
|
|
|
947
1121
|
// a dashboard.
|
|
948
1122
|
// Yes, this is slightly abusing the purpose of this field.
|
|
949
1123
|
dist: userProject,
|
|
950
|
-
release: "0.
|
|
1124
|
+
release: "0.5.0",
|
|
951
1125
|
integrations: [],
|
|
952
1126
|
tracePropagationTargets: ["sentry.io/api"],
|
|
953
1127
|
stackParser: node.defaultStackParser,
|
|
@@ -1049,7 +1223,8 @@ function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
|
1049
1223
|
dryRun = options.dryRun,
|
|
1050
1224
|
errorHandler = options.errorHandler,
|
|
1051
1225
|
deploy = options.deploy,
|
|
1052
|
-
include = options.include
|
|
1226
|
+
include = options.include,
|
|
1227
|
+
_experiments = options._experiments;
|
|
1053
1228
|
hub.setTag("include", include.length > 1 ? "multiple-entries" : "single-entry"); // Optional release pipeline steps
|
|
1054
1229
|
|
|
1055
1230
|
if (cleanArtifacts) {
|
|
@@ -1081,6 +1256,10 @@ function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
|
1081
1256
|
hub.setTag("error-handler", "custom");
|
|
1082
1257
|
}
|
|
1083
1258
|
|
|
1259
|
+
if (_experiments.debugIdUpload) {
|
|
1260
|
+
hub.setTag("debug-id-upload", true);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1084
1263
|
hub.setTag("node", process.version);
|
|
1085
1264
|
hub.setTags({
|
|
1086
1265
|
organization: org,
|
|
@@ -1099,12 +1278,12 @@ function _shouldSendTelemetry() {
|
|
|
1099
1278
|
_shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1100
1279
|
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1101
1280
|
|
|
1102
|
-
var silent, org, project, authToken, url, vcsRemote,
|
|
1281
|
+
var silent, org, project, authToken, url, vcsRemote, headers, telemetry, dryRun, cli, cliInfo, cliInfoUrl;
|
|
1103
1282
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1104
1283
|
while (1) {
|
|
1105
1284
|
switch (_context2.prev = _context2.next) {
|
|
1106
1285
|
case 0:
|
|
1107
|
-
silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, vcsRemote = options.vcsRemote,
|
|
1286
|
+
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
|
|
1108
1287
|
|
|
1109
1288
|
if (!(telemetry === false)) {
|
|
1110
1289
|
_context2.next = 3;
|
|
@@ -1137,7 +1316,6 @@ function _shouldSendTelemetry() {
|
|
|
1137
1316
|
project: project,
|
|
1138
1317
|
vcsRemote: vcsRemote,
|
|
1139
1318
|
silent: silent,
|
|
1140
|
-
customHeader: customHeader,
|
|
1141
1319
|
headers: headers
|
|
1142
1320
|
});
|
|
1143
1321
|
_context2.prev = 8;
|
|
@@ -1293,74 +1471,141 @@ function _uploadSourceMaps() {
|
|
|
1293
1471
|
while (1) {
|
|
1294
1472
|
switch (_context3.prev = _context3.next) {
|
|
1295
1473
|
case 0:
|
|
1474
|
+
if (options.uploadSourceMaps) {
|
|
1475
|
+
_context3.next = 3;
|
|
1476
|
+
break;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
logger.debug("Skipping source maps upload.");
|
|
1480
|
+
return _context3.abrupt("return");
|
|
1481
|
+
|
|
1482
|
+
case 3:
|
|
1296
1483
|
span = addSpanToTransaction(ctx, "function.plugin.upload_sourcemaps");
|
|
1297
1484
|
ctx.logger.info("Uploading Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
|
|
1298
1485
|
// we only need to pass the include option here.
|
|
1299
1486
|
|
|
1300
|
-
_context3.prev =
|
|
1301
|
-
_context3.next =
|
|
1487
|
+
_context3.prev = 5;
|
|
1488
|
+
_context3.next = 8;
|
|
1302
1489
|
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1303
1490
|
include: options.include,
|
|
1304
1491
|
dist: options.dist
|
|
1305
1492
|
});
|
|
1306
1493
|
|
|
1307
|
-
case
|
|
1308
|
-
_context3.next =
|
|
1494
|
+
case 8:
|
|
1495
|
+
_context3.next = 14;
|
|
1309
1496
|
break;
|
|
1310
1497
|
|
|
1311
|
-
case
|
|
1312
|
-
_context3.prev =
|
|
1313
|
-
_context3.t0 = _context3["catch"](
|
|
1498
|
+
case 10:
|
|
1499
|
+
_context3.prev = 10;
|
|
1500
|
+
_context3.t0 = _context3["catch"](5);
|
|
1314
1501
|
ctx.hub.captureException(new Error("CLI Error: Uploading source maps failed"));
|
|
1315
1502
|
throw _context3.t0;
|
|
1316
1503
|
|
|
1317
|
-
case
|
|
1318
|
-
_context3.prev =
|
|
1504
|
+
case 14:
|
|
1505
|
+
_context3.prev = 14;
|
|
1319
1506
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1320
|
-
return _context3.finish(
|
|
1507
|
+
return _context3.finish(14);
|
|
1321
1508
|
|
|
1322
|
-
case
|
|
1509
|
+
case 17:
|
|
1323
1510
|
ctx.hub.addBreadcrumb({
|
|
1324
1511
|
level: "info",
|
|
1325
1512
|
message: "Successfully uploaded source maps."
|
|
1326
1513
|
});
|
|
1327
1514
|
ctx.logger.info("Successfully uploaded source maps.");
|
|
1328
1515
|
|
|
1329
|
-
case
|
|
1516
|
+
case 19:
|
|
1330
1517
|
case "end":
|
|
1331
1518
|
return _context3.stop();
|
|
1332
1519
|
}
|
|
1333
1520
|
}
|
|
1334
|
-
}, _callee3, null, [[
|
|
1521
|
+
}, _callee3, null, [[5, 10, 14, 17]]);
|
|
1335
1522
|
}));
|
|
1336
1523
|
return _uploadSourceMaps.apply(this, arguments);
|
|
1337
1524
|
}
|
|
1338
1525
|
|
|
1339
|
-
function
|
|
1526
|
+
function uploadDebugIdSourcemaps(_x10, _x11, _x12, _x13) {
|
|
1527
|
+
return _uploadDebugIdSourcemaps.apply(this, arguments);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
function _uploadDebugIdSourcemaps() {
|
|
1531
|
+
_uploadDebugIdSourcemaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx, folderPathToUpload, releaseName) {
|
|
1532
|
+
var span;
|
|
1533
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1534
|
+
while (1) {
|
|
1535
|
+
switch (_context4.prev = _context4.next) {
|
|
1536
|
+
case 0:
|
|
1537
|
+
span = addSpanToTransaction(ctx, "function.plugin.upload_debug_id_sourcemaps");
|
|
1538
|
+
ctx.logger.info("Uploading debug ID Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
|
|
1539
|
+
// we only need to pass the include option here.
|
|
1540
|
+
|
|
1541
|
+
_context4.prev = 2;
|
|
1542
|
+
_context4.next = 5;
|
|
1543
|
+
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1544
|
+
include: [{
|
|
1545
|
+
paths: [folderPathToUpload],
|
|
1546
|
+
rewrite: false,
|
|
1547
|
+
dist: options.dist
|
|
1548
|
+
}],
|
|
1549
|
+
useArtifactBundle: true
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1552
|
+
case 5:
|
|
1553
|
+
_context4.next = 11;
|
|
1554
|
+
break;
|
|
1555
|
+
|
|
1556
|
+
case 7:
|
|
1557
|
+
_context4.prev = 7;
|
|
1558
|
+
_context4.t0 = _context4["catch"](2);
|
|
1559
|
+
ctx.hub.captureException(new Error("CLI Error: Uploading debug ID source maps failed"));
|
|
1560
|
+
throw _context4.t0;
|
|
1561
|
+
|
|
1562
|
+
case 11:
|
|
1563
|
+
_context4.prev = 11;
|
|
1564
|
+
span === null || span === void 0 ? void 0 : span.finish();
|
|
1565
|
+
return _context4.finish(11);
|
|
1566
|
+
|
|
1567
|
+
case 14:
|
|
1568
|
+
ctx.hub.addBreadcrumb({
|
|
1569
|
+
level: "info",
|
|
1570
|
+
message: "Successfully uploaded debug ID source maps."
|
|
1571
|
+
});
|
|
1572
|
+
ctx.logger.info("Successfully uploaded debug ID source maps.");
|
|
1573
|
+
|
|
1574
|
+
case 16:
|
|
1575
|
+
case "end":
|
|
1576
|
+
return _context4.stop();
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
}, _callee4, null, [[2, 7, 11, 14]]);
|
|
1580
|
+
}));
|
|
1581
|
+
return _uploadDebugIdSourcemaps.apply(this, arguments);
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
function setCommits(_x14, _x15, _x16) {
|
|
1340
1585
|
return _setCommits.apply(this, arguments);
|
|
1341
1586
|
}
|
|
1342
1587
|
|
|
1343
1588
|
function _setCommits() {
|
|
1344
|
-
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1589
|
+
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx, releaseName) {
|
|
1345
1590
|
var span, _options$setCommits, auto, repo, commit, previousCommit, ignoreMissing, ignoreEmpty;
|
|
1346
1591
|
|
|
1347
|
-
return _regeneratorRuntime().wrap(function
|
|
1592
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1348
1593
|
while (1) {
|
|
1349
|
-
switch (
|
|
1594
|
+
switch (_context5.prev = _context5.next) {
|
|
1350
1595
|
case 0:
|
|
1351
1596
|
if (options.setCommits) {
|
|
1352
|
-
|
|
1597
|
+
_context5.next = 3;
|
|
1353
1598
|
break;
|
|
1354
1599
|
}
|
|
1355
1600
|
|
|
1356
1601
|
logger.debug("Skipping setting commits to release.");
|
|
1357
|
-
return
|
|
1602
|
+
return _context5.abrupt("return");
|
|
1358
1603
|
|
|
1359
1604
|
case 3:
|
|
1360
1605
|
span = addSpanToTransaction(ctx, "function.plugin.set_commits");
|
|
1361
1606
|
_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;
|
|
1362
|
-
|
|
1363
|
-
|
|
1607
|
+
_context5.prev = 5;
|
|
1608
|
+
_context5.next = 8;
|
|
1364
1609
|
return ctx.cli.releases.setCommits(releaseName, {
|
|
1365
1610
|
commit: commit,
|
|
1366
1611
|
previousCommit: previousCommit,
|
|
@@ -1371,46 +1616,46 @@ function _setCommits() {
|
|
|
1371
1616
|
});
|
|
1372
1617
|
|
|
1373
1618
|
case 8:
|
|
1374
|
-
|
|
1619
|
+
_context5.next = 14;
|
|
1375
1620
|
break;
|
|
1376
1621
|
|
|
1377
1622
|
case 10:
|
|
1378
|
-
|
|
1379
|
-
|
|
1623
|
+
_context5.prev = 10;
|
|
1624
|
+
_context5.t0 = _context5["catch"](5);
|
|
1380
1625
|
ctx.hub.captureException(new Error("CLI Error: Setting commits failed"));
|
|
1381
|
-
throw
|
|
1626
|
+
throw _context5.t0;
|
|
1382
1627
|
|
|
1383
1628
|
case 14:
|
|
1384
|
-
|
|
1629
|
+
_context5.prev = 14;
|
|
1385
1630
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1386
|
-
return
|
|
1631
|
+
return _context5.finish(14);
|
|
1387
1632
|
|
|
1388
1633
|
case 17:
|
|
1389
1634
|
ctx.logger.info("Successfully set commits.");
|
|
1390
1635
|
|
|
1391
1636
|
case 18:
|
|
1392
1637
|
case "end":
|
|
1393
|
-
return
|
|
1638
|
+
return _context5.stop();
|
|
1394
1639
|
}
|
|
1395
1640
|
}
|
|
1396
|
-
},
|
|
1641
|
+
}, _callee5, null, [[5, 10, 14, 17]]);
|
|
1397
1642
|
}));
|
|
1398
1643
|
return _setCommits.apply(this, arguments);
|
|
1399
1644
|
}
|
|
1400
1645
|
|
|
1401
|
-
function finalizeRelease(
|
|
1646
|
+
function finalizeRelease(_x17, _x18, _x19) {
|
|
1402
1647
|
return _finalizeRelease.apply(this, arguments);
|
|
1403
1648
|
}
|
|
1404
1649
|
|
|
1405
1650
|
function _finalizeRelease() {
|
|
1406
|
-
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1651
|
+
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx, releaseName) {
|
|
1407
1652
|
var span;
|
|
1408
|
-
return _regeneratorRuntime().wrap(function
|
|
1653
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1409
1654
|
while (1) {
|
|
1410
|
-
switch (
|
|
1655
|
+
switch (_context6.prev = _context6.next) {
|
|
1411
1656
|
case 0:
|
|
1412
1657
|
if (options.finalize) {
|
|
1413
|
-
|
|
1658
|
+
_context6.next = 4;
|
|
1414
1659
|
break;
|
|
1415
1660
|
}
|
|
1416
1661
|
|
|
@@ -1419,28 +1664,28 @@ function _finalizeRelease() {
|
|
|
1419
1664
|
message: "Skipping release finalization."
|
|
1420
1665
|
});
|
|
1421
1666
|
logger.debug("Skipping release finalization.");
|
|
1422
|
-
return
|
|
1667
|
+
return _context6.abrupt("return");
|
|
1423
1668
|
|
|
1424
1669
|
case 4:
|
|
1425
1670
|
span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
|
|
1426
|
-
|
|
1427
|
-
|
|
1671
|
+
_context6.prev = 5;
|
|
1672
|
+
_context6.next = 8;
|
|
1428
1673
|
return ctx.cli.releases.finalize(releaseName);
|
|
1429
1674
|
|
|
1430
1675
|
case 8:
|
|
1431
|
-
|
|
1676
|
+
_context6.next = 14;
|
|
1432
1677
|
break;
|
|
1433
1678
|
|
|
1434
1679
|
case 10:
|
|
1435
|
-
|
|
1436
|
-
|
|
1680
|
+
_context6.prev = 10;
|
|
1681
|
+
_context6.t0 = _context6["catch"](5);
|
|
1437
1682
|
ctx.hub.captureException(new Error("CLI Error: Finalizing release failed"));
|
|
1438
|
-
throw
|
|
1683
|
+
throw _context6.t0;
|
|
1439
1684
|
|
|
1440
1685
|
case 14:
|
|
1441
|
-
|
|
1686
|
+
_context6.prev = 14;
|
|
1442
1687
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1443
|
-
return
|
|
1688
|
+
return _context6.finish(14);
|
|
1444
1689
|
|
|
1445
1690
|
case 17:
|
|
1446
1691
|
ctx.hub.addBreadcrumb({
|
|
@@ -1451,28 +1696,28 @@ function _finalizeRelease() {
|
|
|
1451
1696
|
|
|
1452
1697
|
case 19:
|
|
1453
1698
|
case "end":
|
|
1454
|
-
return
|
|
1699
|
+
return _context6.stop();
|
|
1455
1700
|
}
|
|
1456
1701
|
}
|
|
1457
|
-
},
|
|
1702
|
+
}, _callee6, null, [[5, 10, 14, 17]]);
|
|
1458
1703
|
}));
|
|
1459
1704
|
return _finalizeRelease.apply(this, arguments);
|
|
1460
1705
|
}
|
|
1461
1706
|
|
|
1462
|
-
function addDeploy(
|
|
1707
|
+
function addDeploy(_x20, _x21, _x22) {
|
|
1463
1708
|
return _addDeploy.apply(this, arguments);
|
|
1464
1709
|
}
|
|
1465
1710
|
|
|
1466
1711
|
function _addDeploy() {
|
|
1467
|
-
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1712
|
+
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(options, ctx, releaseName) {
|
|
1468
1713
|
var span, _options$deploy, env, started, finished, time, name, url;
|
|
1469
1714
|
|
|
1470
|
-
return _regeneratorRuntime().wrap(function
|
|
1715
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1471
1716
|
while (1) {
|
|
1472
|
-
switch (
|
|
1717
|
+
switch (_context7.prev = _context7.next) {
|
|
1473
1718
|
case 0:
|
|
1474
1719
|
if (options.deploy) {
|
|
1475
|
-
|
|
1720
|
+
_context7.next = 4;
|
|
1476
1721
|
break;
|
|
1477
1722
|
}
|
|
1478
1723
|
|
|
@@ -1481,13 +1726,13 @@ function _addDeploy() {
|
|
|
1481
1726
|
message: "Skipping adding deploy info to release."
|
|
1482
1727
|
});
|
|
1483
1728
|
logger.debug("Skipping adding deploy info to release.");
|
|
1484
|
-
return
|
|
1729
|
+
return _context7.abrupt("return");
|
|
1485
1730
|
|
|
1486
1731
|
case 4:
|
|
1487
1732
|
span = addSpanToTransaction(ctx, "function.plugin.deploy");
|
|
1488
1733
|
_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;
|
|
1489
|
-
|
|
1490
|
-
|
|
1734
|
+
_context7.prev = 6;
|
|
1735
|
+
_context7.next = 9;
|
|
1491
1736
|
return ctx.cli.releases.newDeploy(releaseName, {
|
|
1492
1737
|
env: env,
|
|
1493
1738
|
started: started,
|
|
@@ -1498,19 +1743,19 @@ function _addDeploy() {
|
|
|
1498
1743
|
});
|
|
1499
1744
|
|
|
1500
1745
|
case 9:
|
|
1501
|
-
|
|
1746
|
+
_context7.next = 15;
|
|
1502
1747
|
break;
|
|
1503
1748
|
|
|
1504
1749
|
case 11:
|
|
1505
|
-
|
|
1506
|
-
|
|
1750
|
+
_context7.prev = 11;
|
|
1751
|
+
_context7.t0 = _context7["catch"](6);
|
|
1507
1752
|
ctx.hub.captureException(new Error("CLI Error: Adding deploy info failed"));
|
|
1508
|
-
throw
|
|
1753
|
+
throw _context7.t0;
|
|
1509
1754
|
|
|
1510
1755
|
case 15:
|
|
1511
|
-
|
|
1756
|
+
_context7.prev = 15;
|
|
1512
1757
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1513
|
-
return
|
|
1758
|
+
return _context7.finish(15);
|
|
1514
1759
|
|
|
1515
1760
|
case 18:
|
|
1516
1761
|
ctx.hub.addBreadcrumb({
|
|
@@ -1521,10 +1766,10 @@ function _addDeploy() {
|
|
|
1521
1766
|
|
|
1522
1767
|
case 20:
|
|
1523
1768
|
case "end":
|
|
1524
|
-
return
|
|
1769
|
+
return _context7.stop();
|
|
1525
1770
|
}
|
|
1526
1771
|
}
|
|
1527
|
-
},
|
|
1772
|
+
}, _callee7, null, [[6, 11, 15, 18]]);
|
|
1528
1773
|
}));
|
|
1529
1774
|
return _addDeploy.apply(this, arguments);
|
|
1530
1775
|
}
|
|
@@ -1595,7 +1840,6 @@ function getSentryCli(internalOptions, logger) {
|
|
|
1595
1840
|
authToken = internalOptions.authToken,
|
|
1596
1841
|
url = internalOptions.url,
|
|
1597
1842
|
vcsRemote = internalOptions.vcsRemote,
|
|
1598
|
-
customHeader = internalOptions.customHeader,
|
|
1599
1843
|
headers = internalOptions.headers;
|
|
1600
1844
|
var cli = new SentryCli__default["default"](internalOptions.configFile, {
|
|
1601
1845
|
url: url,
|
|
@@ -1604,7 +1848,6 @@ function getSentryCli(internalOptions, logger) {
|
|
|
1604
1848
|
project: project,
|
|
1605
1849
|
vcsRemote: vcsRemote,
|
|
1606
1850
|
silent: silent,
|
|
1607
|
-
customHeader: customHeader,
|
|
1608
1851
|
headers: headers
|
|
1609
1852
|
});
|
|
1610
1853
|
|
|
@@ -1657,18 +1900,256 @@ function getDryRunCLI(cli, logger) {
|
|
|
1657
1900
|
};
|
|
1658
1901
|
}
|
|
1659
1902
|
|
|
1660
|
-
|
|
1661
|
-
|
|
1903
|
+
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){}}();';
|
|
1904
|
+
function injectDebugIdSnippetIntoChunk(code) {
|
|
1905
|
+
var _code$match;
|
|
1906
|
+
|
|
1907
|
+
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
1908
|
+
|
|
1909
|
+
var ms = new MagicString__default["default"](code);
|
|
1910
|
+
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.
|
|
1911
|
+
// As an additional complication `"use strict";`s may come after any number of comments.
|
|
1912
|
+
|
|
1913
|
+
var commentUseStrictRegex = /^(?:\s*|\/\*(.|\r|\n)*?\*\/|\/\/.*?[\n\r])*(?:"use strict";|'use strict';)?/;
|
|
1914
|
+
|
|
1915
|
+
if ((_code$match = code.match(commentUseStrictRegex)) !== null && _code$match !== void 0 && _code$match[0]) {
|
|
1916
|
+
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
1917
|
+
ms.replace(commentUseStrictRegex, function (match) {
|
|
1918
|
+
return "".concat(match).concat(codeToInject);
|
|
1919
|
+
});
|
|
1920
|
+
} else {
|
|
1921
|
+
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
1922
|
+
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
1923
|
+
// need this special case here.
|
|
1924
|
+
ms.prepend(codeToInject);
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
return {
|
|
1928
|
+
code: ms.toString(),
|
|
1929
|
+
map: ms.generateMap()
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
function prepareBundleForDebugIdUpload(_x, _x2, _x3, _x4) {
|
|
1933
|
+
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle
|
|
1937
|
+
* source and extracts the bundle's debug ID from it.
|
|
1938
|
+
*
|
|
1939
|
+
* The string pattern is injected via the debug ID injection snipped.
|
|
1940
|
+
*/
|
|
1941
|
+
|
|
1942
|
+
function _prepareBundleForDebugIdUpload() {
|
|
1943
|
+
_prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(bundleFilePath, uploadFolder, uniqueUploadName, logger) {
|
|
1944
|
+
var bundleContent, debugId, writeSourceFilePromise, writeSourceMapFilePromise;
|
|
1945
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1946
|
+
while (1) {
|
|
1947
|
+
switch (_context2.prev = _context2.next) {
|
|
1948
|
+
case 0:
|
|
1949
|
+
_context2.prev = 0;
|
|
1950
|
+
_context2.next = 3;
|
|
1951
|
+
return util__namespace.promisify(fs__namespace.readFile)(bundleFilePath, "utf8");
|
|
1952
|
+
|
|
1953
|
+
case 3:
|
|
1954
|
+
bundleContent = _context2.sent;
|
|
1955
|
+
_context2.next = 10;
|
|
1956
|
+
break;
|
|
1957
|
+
|
|
1958
|
+
case 6:
|
|
1959
|
+
_context2.prev = 6;
|
|
1960
|
+
_context2.t0 = _context2["catch"](0);
|
|
1961
|
+
logger.warn("Could not read bundle to determine debug ID and source map: ".concat(bundleFilePath));
|
|
1962
|
+
return _context2.abrupt("return");
|
|
1963
|
+
|
|
1964
|
+
case 10:
|
|
1965
|
+
debugId = determineDebugIdFromBundleSource(bundleContent);
|
|
1966
|
+
|
|
1967
|
+
if (!(debugId === undefined)) {
|
|
1968
|
+
_context2.next = 14;
|
|
1969
|
+
break;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
logger.warn("Could not determine debug ID from bundle: ".concat(bundleFilePath));
|
|
1973
|
+
return _context2.abrupt("return");
|
|
1974
|
+
|
|
1975
|
+
case 14:
|
|
1976
|
+
bundleContent += "\n//# debugId=".concat(debugId);
|
|
1977
|
+
writeSourceFilePromise = util__namespace.promisify(fs__namespace.writeFile)(path__namespace.join(uploadFolder, "".concat(uniqueUploadName, ".js")), bundleContent, "utf-8");
|
|
1978
|
+
writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger).then( /*#__PURE__*/function () {
|
|
1979
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sourceMapPath) {
|
|
1980
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1981
|
+
while (1) {
|
|
1982
|
+
switch (_context.prev = _context.next) {
|
|
1983
|
+
case 0:
|
|
1984
|
+
if (!sourceMapPath) {
|
|
1985
|
+
_context.next = 4;
|
|
1986
|
+
break;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
_context.next = 3;
|
|
1990
|
+
return prepareSourceMapForDebugIdUpload(sourceMapPath, path__namespace.join(uploadFolder, "".concat(uniqueUploadName, ".js.map")), debugId, logger);
|
|
1991
|
+
|
|
1992
|
+
case 3:
|
|
1993
|
+
return _context.abrupt("return", _context.sent);
|
|
1994
|
+
|
|
1995
|
+
case 4:
|
|
1996
|
+
case "end":
|
|
1997
|
+
return _context.stop();
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
}, _callee);
|
|
2001
|
+
}));
|
|
2002
|
+
|
|
2003
|
+
return function (_x12) {
|
|
2004
|
+
return _ref.apply(this, arguments);
|
|
2005
|
+
};
|
|
2006
|
+
}());
|
|
2007
|
+
return _context2.abrupt("return", Promise.all([writeSourceFilePromise, writeSourceMapFilePromise]));
|
|
2008
|
+
|
|
2009
|
+
case 18:
|
|
2010
|
+
case "end":
|
|
2011
|
+
return _context2.stop();
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
}, _callee2, null, [[0, 6]]);
|
|
2015
|
+
}));
|
|
2016
|
+
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
function determineDebugIdFromBundleSource(code) {
|
|
2020
|
+
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})/);
|
|
2021
|
+
|
|
2022
|
+
if (match) {
|
|
2023
|
+
return match[1];
|
|
2024
|
+
} else {
|
|
2025
|
+
return undefined;
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Applies a set of heuristics to find the source map for a particular bundle.
|
|
2030
|
+
*
|
|
2031
|
+
* @returns the path to the bundle's source map or `undefined` if none could be found.
|
|
2032
|
+
*/
|
|
2033
|
+
|
|
2034
|
+
|
|
2035
|
+
function determineSourceMapPathFromBundle(_x5, _x6, _x7) {
|
|
2036
|
+
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
2037
|
+
}
|
|
2038
|
+
/**
|
|
2039
|
+
* Reads a source map, injects debug ID fields, and writes the source map to the target path.
|
|
2040
|
+
*/
|
|
2041
|
+
|
|
2042
|
+
|
|
2043
|
+
function _determineSourceMapPathFromBundle() {
|
|
2044
|
+
_determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(bundlePath, bundleSource, logger) {
|
|
2045
|
+
var sourceMappingUrlMatch, sourceMappingUrl, adjacentSourceMapFilePath;
|
|
2046
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2047
|
+
while (1) {
|
|
2048
|
+
switch (_context3.prev = _context3.next) {
|
|
2049
|
+
case 0:
|
|
2050
|
+
// 1. try to find source map at `sourceMappingURL` location
|
|
2051
|
+
sourceMappingUrlMatch = bundleSource.match(/^\/\/# sourceMappingURL=(.*)$/);
|
|
2052
|
+
|
|
2053
|
+
if (!sourceMappingUrlMatch) {
|
|
2054
|
+
_context3.next = 8;
|
|
2055
|
+
break;
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
sourceMappingUrl = path__namespace.normalize(sourceMappingUrlMatch[1]);
|
|
2059
|
+
|
|
2060
|
+
if (!path__namespace.isAbsolute(sourceMappingUrl)) {
|
|
2061
|
+
_context3.next = 7;
|
|
2062
|
+
break;
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
return _context3.abrupt("return", sourceMappingUrl);
|
|
2066
|
+
|
|
2067
|
+
case 7:
|
|
2068
|
+
return _context3.abrupt("return", path__namespace.join(path__namespace.dirname(bundlePath), sourceMappingUrl));
|
|
2069
|
+
|
|
2070
|
+
case 8:
|
|
2071
|
+
_context3.prev = 8;
|
|
2072
|
+
adjacentSourceMapFilePath = bundlePath + ".map";
|
|
2073
|
+
_context3.next = 12;
|
|
2074
|
+
return util__namespace.promisify(fs__namespace.access)(adjacentSourceMapFilePath);
|
|
2075
|
+
|
|
2076
|
+
case 12:
|
|
2077
|
+
return _context3.abrupt("return", adjacentSourceMapFilePath);
|
|
2078
|
+
|
|
2079
|
+
case 15:
|
|
2080
|
+
_context3.prev = 15;
|
|
2081
|
+
_context3.t0 = _context3["catch"](8);
|
|
2082
|
+
|
|
2083
|
+
case 17:
|
|
2084
|
+
logger.warn("Could not determine source map path for bundle: ".concat(bundlePath));
|
|
2085
|
+
return _context3.abrupt("return", undefined);
|
|
2086
|
+
|
|
2087
|
+
case 19:
|
|
2088
|
+
case "end":
|
|
2089
|
+
return _context3.stop();
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
}, _callee3, null, [[8, 15]]);
|
|
2093
|
+
}));
|
|
2094
|
+
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
function prepareSourceMapForDebugIdUpload(_x8, _x9, _x10, _x11) {
|
|
2098
|
+
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
function _prepareSourceMapForDebugIdUpload() {
|
|
2102
|
+
_prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(sourceMapPath, targetPath, debugId, logger) {
|
|
2103
|
+
var sourceMapFileContent, map;
|
|
2104
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
2105
|
+
while (1) {
|
|
2106
|
+
switch (_context4.prev = _context4.next) {
|
|
2107
|
+
case 0:
|
|
2108
|
+
_context4.prev = 0;
|
|
2109
|
+
_context4.next = 3;
|
|
2110
|
+
return util__namespace.promisify(fs__namespace.readFile)(sourceMapPath, {
|
|
2111
|
+
encoding: "utf8"
|
|
2112
|
+
});
|
|
2113
|
+
|
|
2114
|
+
case 3:
|
|
2115
|
+
sourceMapFileContent = _context4.sent;
|
|
2116
|
+
map = JSON.parse(sourceMapFileContent); // For now we write both fields until we know what will become the standard - if ever.
|
|
2117
|
+
|
|
2118
|
+
map["debug_id"] = debugId;
|
|
2119
|
+
map["debugId"] = debugId;
|
|
2120
|
+
_context4.next = 9;
|
|
2121
|
+
return util__namespace.promisify(fs__namespace.writeFile)(targetPath, JSON.stringify(map), {
|
|
2122
|
+
encoding: "utf8"
|
|
2123
|
+
});
|
|
2124
|
+
|
|
2125
|
+
case 9:
|
|
2126
|
+
_context4.next = 14;
|
|
2127
|
+
break;
|
|
2128
|
+
|
|
2129
|
+
case 11:
|
|
2130
|
+
_context4.prev = 11;
|
|
2131
|
+
_context4.t0 = _context4["catch"](0);
|
|
2132
|
+
logger.warn("Failed to prepare source map for debug ID upload: ".concat(sourceMapPath));
|
|
2133
|
+
|
|
2134
|
+
case 14:
|
|
2135
|
+
case "end":
|
|
2136
|
+
return _context4.stop();
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
}, _callee4, null, [[0, 11]]);
|
|
2140
|
+
}));
|
|
2141
|
+
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
2142
|
+
}
|
|
1662
2143
|
|
|
1663
|
-
var RELEASE_INJECTOR_ID = "\0sentry-release-injector";
|
|
1664
2144
|
var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"];
|
|
2145
|
+
|
|
2146
|
+
var releaseInjectionFilePath = require.resolve("@sentry/bundler-plugin-core/sentry-release-injection-file");
|
|
1665
2147
|
/**
|
|
1666
2148
|
* The sentry bundler plugin concerns itself with two things:
|
|
1667
2149
|
* - Release injection
|
|
1668
2150
|
* - Sourcemaps upload
|
|
1669
2151
|
*
|
|
1670
2152
|
* Release injection:
|
|
1671
|
-
*
|
|
1672
2153
|
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into each JavaScript/TypeScript module
|
|
1673
2154
|
* that is part of the bundle. On a technical level this is done by appending an import (`import "sentry-release-injector;"`)
|
|
1674
2155
|
* to all entrypoint files of the user code (see `transformInclude` and `transform` hooks). This import is then resolved
|
|
@@ -1677,8 +2158,9 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"]
|
|
|
1677
2158
|
*
|
|
1678
2159
|
* Source maps upload:
|
|
1679
2160
|
*
|
|
1680
|
-
* The sentry bundler plugin will also take care of uploading source maps to Sentry. This
|
|
1681
|
-
* `writeBundle` hook. In this hook the sentry plugin will execute the
|
|
2161
|
+
* The sentry bundler plugin will also take care of uploading source maps to Sentry. This
|
|
2162
|
+
* is all done in the `writeBundle` hook. In this hook the sentry plugin will execute the
|
|
2163
|
+
* release creation pipeline:
|
|
1682
2164
|
*
|
|
1683
2165
|
* 1. Create a new release
|
|
1684
2166
|
* 2. Delete already uploaded artifacts for this release (if `cleanArtifacts` is enabled)
|
|
@@ -1690,6 +2172,7 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"]
|
|
|
1690
2172
|
* This release creation pipeline relies on Sentry CLI to execute the different steps.
|
|
1691
2173
|
*/
|
|
1692
2174
|
|
|
2175
|
+
|
|
1693
2176
|
var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext) {
|
|
1694
2177
|
var internalOptions = normalizeUserOptions(options);
|
|
1695
2178
|
var allowedToSendTelemetryPromise = shouldSendTelemetry(internalOptions);
|
|
@@ -1810,69 +2293,7 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1810
2293
|
importer: importer,
|
|
1811
2294
|
isEntry: isEntry
|
|
1812
2295
|
});
|
|
1813
|
-
|
|
1814
|
-
if (id === RELEASE_INJECTOR_ID) {
|
|
1815
|
-
return RELEASE_INJECTOR_ID;
|
|
1816
|
-
} else {
|
|
1817
|
-
return undefined;
|
|
1818
|
-
}
|
|
1819
|
-
},
|
|
1820
|
-
loadInclude: function loadInclude(id) {
|
|
1821
|
-
logger.debug('Called "loadInclude":', {
|
|
1822
|
-
id: id
|
|
1823
|
-
});
|
|
1824
|
-
return id === RELEASE_INJECTOR_ID;
|
|
1825
|
-
},
|
|
1826
|
-
|
|
1827
|
-
/**
|
|
1828
|
-
* Responsible for "virtually" loading the "sentry-release-injector" module. "Virtual" means that the module is not
|
|
1829
|
-
* read from somewhere on disk but rather just returned via a string.
|
|
1830
|
-
*
|
|
1831
|
-
* @param id Always the absolute (fully resolved) path to the module.
|
|
1832
|
-
* @returns The global injector code when we load the "sentry-release-injector" module. Otherwise returns `undefined`.
|
|
1833
|
-
*/
|
|
1834
|
-
load: function load(id) {
|
|
1835
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1836
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1837
|
-
while (1) {
|
|
1838
|
-
switch (_context2.prev = _context2.next) {
|
|
1839
|
-
case 0:
|
|
1840
|
-
logger.debug('Called "load":', {
|
|
1841
|
-
id: id
|
|
1842
|
-
});
|
|
1843
|
-
|
|
1844
|
-
if (!(id === RELEASE_INJECTOR_ID)) {
|
|
1845
|
-
_context2.next = 13;
|
|
1846
|
-
break;
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
_context2.t0 = generateGlobalInjectorCode;
|
|
1850
|
-
_context2.next = 5;
|
|
1851
|
-
return releaseNamePromise;
|
|
1852
|
-
|
|
1853
|
-
case 5:
|
|
1854
|
-
_context2.t1 = _context2.sent;
|
|
1855
|
-
_context2.t2 = internalOptions.injectReleasesMap;
|
|
1856
|
-
_context2.t3 = internalOptions.org;
|
|
1857
|
-
_context2.t4 = internalOptions.project;
|
|
1858
|
-
_context2.t5 = {
|
|
1859
|
-
release: _context2.t1,
|
|
1860
|
-
injectReleasesMap: _context2.t2,
|
|
1861
|
-
org: _context2.t3,
|
|
1862
|
-
project: _context2.t4
|
|
1863
|
-
};
|
|
1864
|
-
return _context2.abrupt("return", (0, _context2.t0)(_context2.t5));
|
|
1865
|
-
|
|
1866
|
-
case 13:
|
|
1867
|
-
return _context2.abrupt("return", undefined);
|
|
1868
|
-
|
|
1869
|
-
case 14:
|
|
1870
|
-
case "end":
|
|
1871
|
-
return _context2.stop();
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
}, _callee2);
|
|
1875
|
-
}))();
|
|
2296
|
+
return undefined;
|
|
1876
2297
|
},
|
|
1877
2298
|
|
|
1878
2299
|
/**
|
|
@@ -1889,10 +2310,10 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1889
2310
|
}); // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
|
|
1890
2311
|
// a windows style path to `releaseInjectionTargets`
|
|
1891
2312
|
|
|
1892
|
-
var normalizedId = path__default["default"].normalize(id);
|
|
2313
|
+
var normalizedId = path__default["default"].normalize(id);
|
|
1893
2314
|
|
|
1894
|
-
if (
|
|
1895
|
-
return
|
|
2315
|
+
if (id.includes("sentry-release-injection-file")) {
|
|
2316
|
+
return true;
|
|
1896
2317
|
}
|
|
1897
2318
|
|
|
1898
2319
|
if (internalOptions.releaseInjectionTargets) {
|
|
@@ -1910,12 +2331,11 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1910
2331
|
}
|
|
1911
2332
|
});
|
|
1912
2333
|
} else {
|
|
1913
|
-
var isInNodeModules = normalizedId.split(path__default["default"].sep).includes("node_modules");
|
|
1914
2334
|
var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
|
|
1915
2335
|
var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
|
|
1916
2336
|
return normalizedId.endsWith(allowedFileEnding);
|
|
1917
2337
|
});
|
|
1918
|
-
return
|
|
2338
|
+
return pathIsOrdinary && pathHasAllowedFileEnding;
|
|
1919
2339
|
}
|
|
1920
2340
|
},
|
|
1921
2341
|
|
|
@@ -1928,26 +2348,84 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1928
2348
|
* @returns transformed code + source map
|
|
1929
2349
|
*/
|
|
1930
2350
|
transform: function transform(code, id) {
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
2351
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
2352
|
+
var ms;
|
|
2353
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2354
|
+
while (1) {
|
|
2355
|
+
switch (_context2.prev = _context2.next) {
|
|
2356
|
+
case 0:
|
|
2357
|
+
logger.debug('Called "transform":', {
|
|
2358
|
+
id: id
|
|
2359
|
+
});
|
|
1934
2360
|
|
|
1935
|
-
|
|
1936
|
-
|
|
2361
|
+
if (internalOptions.injectRelease) {
|
|
2362
|
+
_context2.next = 3;
|
|
2363
|
+
break;
|
|
2364
|
+
}
|
|
1937
2365
|
|
|
1938
|
-
|
|
2366
|
+
return _context2.abrupt("return");
|
|
1939
2367
|
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
2368
|
+
case 3:
|
|
2369
|
+
// The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
|
|
2370
|
+
ms = new MagicString__default["default"](code);
|
|
2371
|
+
|
|
2372
|
+
if (!code.includes("_sentry_release_injection_file")) {
|
|
2373
|
+
_context2.next = 19;
|
|
2374
|
+
break;
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
_context2.t0 = ms;
|
|
2378
|
+
_context2.t1 = generateGlobalInjectorCode;
|
|
2379
|
+
_context2.next = 9;
|
|
2380
|
+
return releaseNamePromise;
|
|
2381
|
+
|
|
2382
|
+
case 9:
|
|
2383
|
+
_context2.t2 = _context2.sent;
|
|
2384
|
+
_context2.t3 = internalOptions.injectReleasesMap;
|
|
2385
|
+
_context2.t4 = internalOptions._experiments.injectBuildInformation || false;
|
|
2386
|
+
_context2.t5 = internalOptions.org;
|
|
2387
|
+
_context2.t6 = internalOptions.project;
|
|
2388
|
+
_context2.t7 = {
|
|
2389
|
+
release: _context2.t2,
|
|
2390
|
+
injectReleasesMap: _context2.t3,
|
|
2391
|
+
injectBuildInformation: _context2.t4,
|
|
2392
|
+
org: _context2.t5,
|
|
2393
|
+
project: _context2.t6
|
|
2394
|
+
};
|
|
2395
|
+
_context2.t8 = (0, _context2.t1)(_context2.t7);
|
|
2396
|
+
|
|
2397
|
+
_context2.t0.append.call(_context2.t0, _context2.t8);
|
|
2398
|
+
|
|
2399
|
+
_context2.next = 20;
|
|
2400
|
+
break;
|
|
2401
|
+
|
|
2402
|
+
case 19:
|
|
2403
|
+
// Appending instead of prepending has less probability of mucking with user's source maps.
|
|
2404
|
+
// Luckily import statements get hoisted to the top anyways.
|
|
2405
|
+
// 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).
|
|
2406
|
+
ms.append(";\nimport \"".concat(releaseInjectionFilePath.replace(/\\/g, "\\\\"), "\";"));
|
|
2407
|
+
|
|
2408
|
+
case 20:
|
|
2409
|
+
if (!(unpluginMetaContext.framework === "esbuild")) {
|
|
2410
|
+
_context2.next = 24;
|
|
2411
|
+
break;
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
return _context2.abrupt("return", ms.toString());
|
|
2415
|
+
|
|
2416
|
+
case 24:
|
|
2417
|
+
return _context2.abrupt("return", {
|
|
2418
|
+
code: ms.toString(),
|
|
2419
|
+
map: ms.generateMap()
|
|
2420
|
+
});
|
|
2421
|
+
|
|
2422
|
+
case 25:
|
|
2423
|
+
case "end":
|
|
2424
|
+
return _context2.stop();
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
}, _callee2);
|
|
2428
|
+
}))();
|
|
1951
2429
|
},
|
|
1952
2430
|
|
|
1953
2431
|
/**
|
|
@@ -1955,14 +2433,14 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1955
2433
|
* Sentry.io, uploading sourcemaps, associating commits and deploys and finalizing the release)
|
|
1956
2434
|
*/
|
|
1957
2435
|
writeBundle: function writeBundle() {
|
|
1958
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2436
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1959
2437
|
var _releaseInjectionSpan;
|
|
1960
2438
|
|
|
1961
|
-
var releasePipelineSpan, ctx, releaseName, _transaction, _transaction2, _transaction3;
|
|
2439
|
+
var releasePipelineSpan, ctx, releaseName, tmpUploadFolder, _transaction, debugIdChunkFilePaths, sourceFileUploadFolderPromise, _transaction2, _transaction3;
|
|
1962
2440
|
|
|
1963
|
-
return _regeneratorRuntime().wrap(function
|
|
2441
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1964
2442
|
while (1) {
|
|
1965
|
-
switch (
|
|
2443
|
+
switch (_context4.prev = _context4.next) {
|
|
1966
2444
|
case 0:
|
|
1967
2445
|
logger.debug('Called "writeBundle"');
|
|
1968
2446
|
(_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
|
|
@@ -1982,75 +2460,172 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1982
2460
|
logger: logger,
|
|
1983
2461
|
cli: cli
|
|
1984
2462
|
};
|
|
1985
|
-
|
|
2463
|
+
_context4.next = 7;
|
|
1986
2464
|
return releaseNamePromise;
|
|
1987
2465
|
|
|
1988
2466
|
case 7:
|
|
1989
|
-
releaseName =
|
|
1990
|
-
|
|
1991
|
-
|
|
2467
|
+
releaseName = _context4.sent;
|
|
2468
|
+
_context4.prev = 8;
|
|
2469
|
+
|
|
2470
|
+
if (!internalOptions._experiments.debugIdUpload) {
|
|
2471
|
+
_context4.next = 21;
|
|
2472
|
+
break;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
_context4.next = 12;
|
|
2476
|
+
return glob.glob(internalOptions._experiments.debugIdUpload.include, {
|
|
2477
|
+
absolute: true,
|
|
2478
|
+
nodir: true,
|
|
2479
|
+
ignore: internalOptions._experiments.debugIdUpload.ignore
|
|
2480
|
+
});
|
|
2481
|
+
|
|
2482
|
+
case 12:
|
|
2483
|
+
debugIdChunkFilePaths = _context4.sent.filter(function (p) {
|
|
2484
|
+
return p.endsWith(".js") || p.endsWith(".mjs");
|
|
2485
|
+
});
|
|
2486
|
+
sourceFileUploadFolderPromise = util__default["default"].promisify(fs__default["default"].mkdtemp)(path__default["default"].join(os__default["default"].tmpdir(), "sentry-bundler-plugin-upload-"));
|
|
2487
|
+
_context4.next = 16;
|
|
2488
|
+
return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
|
|
2489
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chunkFilePath, chunkIndex) {
|
|
2490
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2491
|
+
while (1) {
|
|
2492
|
+
switch (_context3.prev = _context3.next) {
|
|
2493
|
+
case 0:
|
|
2494
|
+
_context3.t0 = prepareBundleForDebugIdUpload;
|
|
2495
|
+
_context3.t1 = chunkFilePath;
|
|
2496
|
+
_context3.next = 4;
|
|
2497
|
+
return sourceFileUploadFolderPromise;
|
|
2498
|
+
|
|
2499
|
+
case 4:
|
|
2500
|
+
_context3.t2 = _context3.sent;
|
|
2501
|
+
_context3.t3 = String(chunkIndex);
|
|
2502
|
+
_context3.t4 = logger;
|
|
2503
|
+
_context3.next = 9;
|
|
2504
|
+
return (0, _context3.t0)(_context3.t1, _context3.t2, _context3.t3, _context3.t4);
|
|
2505
|
+
|
|
2506
|
+
case 9:
|
|
2507
|
+
case "end":
|
|
2508
|
+
return _context3.stop();
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
}, _callee3);
|
|
2512
|
+
}));
|
|
2513
|
+
|
|
2514
|
+
return function (_x, _x2) {
|
|
2515
|
+
return _ref2.apply(this, arguments);
|
|
2516
|
+
};
|
|
2517
|
+
}()));
|
|
2518
|
+
|
|
2519
|
+
case 16:
|
|
2520
|
+
_context4.next = 18;
|
|
2521
|
+
return sourceFileUploadFolderPromise;
|
|
2522
|
+
|
|
2523
|
+
case 18:
|
|
2524
|
+
tmpUploadFolder = _context4.sent;
|
|
2525
|
+
_context4.next = 21;
|
|
2526
|
+
return uploadDebugIdSourcemaps(internalOptions, ctx, tmpUploadFolder, releaseName);
|
|
2527
|
+
|
|
2528
|
+
case 21:
|
|
2529
|
+
_context4.next = 23;
|
|
1992
2530
|
return createNewRelease(internalOptions, ctx, releaseName);
|
|
1993
2531
|
|
|
1994
|
-
case
|
|
1995
|
-
|
|
2532
|
+
case 23:
|
|
2533
|
+
_context4.next = 25;
|
|
1996
2534
|
return cleanArtifacts(internalOptions, ctx, releaseName);
|
|
1997
2535
|
|
|
1998
|
-
case
|
|
1999
|
-
|
|
2536
|
+
case 25:
|
|
2537
|
+
_context4.next = 27;
|
|
2000
2538
|
return uploadSourceMaps(internalOptions, ctx, releaseName);
|
|
2001
2539
|
|
|
2002
|
-
case
|
|
2003
|
-
|
|
2540
|
+
case 27:
|
|
2541
|
+
_context4.next = 29;
|
|
2004
2542
|
return setCommits(internalOptions, ctx, releaseName);
|
|
2005
2543
|
|
|
2006
|
-
case
|
|
2007
|
-
|
|
2544
|
+
case 29:
|
|
2545
|
+
_context4.next = 31;
|
|
2008
2546
|
return finalizeRelease(internalOptions, ctx, releaseName);
|
|
2009
2547
|
|
|
2010
|
-
case
|
|
2011
|
-
|
|
2548
|
+
case 31:
|
|
2549
|
+
_context4.next = 33;
|
|
2012
2550
|
return addDeploy(internalOptions, ctx, releaseName);
|
|
2013
2551
|
|
|
2014
|
-
case
|
|
2552
|
+
case 33:
|
|
2015
2553
|
(_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
|
|
2016
|
-
|
|
2554
|
+
_context4.next = 41;
|
|
2017
2555
|
break;
|
|
2018
2556
|
|
|
2019
|
-
case
|
|
2020
|
-
|
|
2021
|
-
|
|
2557
|
+
case 36:
|
|
2558
|
+
_context4.prev = 36;
|
|
2559
|
+
_context4.t0 = _context4["catch"](8);
|
|
2022
2560
|
(_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
|
|
2023
2561
|
sentryHub.addBreadcrumb({
|
|
2024
2562
|
level: "error",
|
|
2025
2563
|
message: "Error during writeBundle"
|
|
2026
2564
|
});
|
|
2027
|
-
handleError(
|
|
2565
|
+
handleError(_context4.t0, logger, internalOptions.errorHandler);
|
|
2566
|
+
|
|
2567
|
+
case 41:
|
|
2568
|
+
_context4.prev = 41;
|
|
2569
|
+
|
|
2570
|
+
if (tmpUploadFolder) {
|
|
2571
|
+
fs__default["default"].rm(tmpUploadFolder, {
|
|
2572
|
+
recursive: true,
|
|
2573
|
+
force: true
|
|
2574
|
+
}, function () {// We don't care if this errors
|
|
2575
|
+
});
|
|
2576
|
+
}
|
|
2028
2577
|
|
|
2029
|
-
case 29:
|
|
2030
|
-
_context3.prev = 29;
|
|
2031
2578
|
releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
|
|
2032
2579
|
(_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
|
|
2033
|
-
|
|
2580
|
+
_context4.next = 47;
|
|
2034
2581
|
return sentryClient.flush().then(null, function () {
|
|
2035
2582
|
logger.warn("Sending of telemetry failed");
|
|
2036
2583
|
});
|
|
2037
2584
|
|
|
2038
|
-
case
|
|
2039
|
-
return
|
|
2585
|
+
case 47:
|
|
2586
|
+
return _context4.finish(41);
|
|
2040
2587
|
|
|
2041
|
-
case
|
|
2588
|
+
case 48:
|
|
2042
2589
|
sentryHub.addBreadcrumb({
|
|
2043
2590
|
category: "writeBundle:finish",
|
|
2044
2591
|
level: "info"
|
|
2045
2592
|
});
|
|
2046
2593
|
|
|
2047
|
-
case
|
|
2594
|
+
case 49:
|
|
2048
2595
|
case "end":
|
|
2049
|
-
return
|
|
2596
|
+
return _context4.stop();
|
|
2050
2597
|
}
|
|
2051
2598
|
}
|
|
2052
|
-
},
|
|
2599
|
+
}, _callee4, null, [[8, 36, 41, 48]]);
|
|
2053
2600
|
}))();
|
|
2601
|
+
},
|
|
2602
|
+
rollup: {
|
|
2603
|
+
renderChunk: function renderChunk(code, chunk) {
|
|
2604
|
+
var _options$_experiments;
|
|
2605
|
+
|
|
2606
|
+
if ((_options$_experiments = options._experiments) !== null && _options$_experiments !== void 0 && _options$_experiments.debugIdUpload && [".js", ".mjs"].some(function (ending) {
|
|
2607
|
+
return chunk.fileName.endsWith(ending);
|
|
2608
|
+
}) // chunks could be any file (html, md, ...)
|
|
2609
|
+
) {
|
|
2610
|
+
return injectDebugIdSnippetIntoChunk(code);
|
|
2611
|
+
} else {
|
|
2612
|
+
return null; // returning null means not modifying the chunk at all
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
},
|
|
2616
|
+
vite: {
|
|
2617
|
+
renderChunk: function renderChunk(code, chunk) {
|
|
2618
|
+
var _options$_experiments2;
|
|
2619
|
+
|
|
2620
|
+
if ((_options$_experiments2 = options._experiments) !== null && _options$_experiments2 !== void 0 && _options$_experiments2.debugIdUpload && [".js", ".mjs"].some(function (ending) {
|
|
2621
|
+
return chunk.fileName.endsWith(ending);
|
|
2622
|
+
}) // chunks could be any file (html, md, ...)
|
|
2623
|
+
) {
|
|
2624
|
+
return injectDebugIdSnippetIntoChunk(code);
|
|
2625
|
+
} else {
|
|
2626
|
+
return null; // returning null means not modifying the chunk at all
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2054
2629
|
}
|
|
2055
2630
|
};
|
|
2056
2631
|
});
|
|
@@ -2073,28 +2648,59 @@ function handleError(unknownError, logger, errorHandler) {
|
|
|
2073
2648
|
}
|
|
2074
2649
|
}
|
|
2075
2650
|
/**
|
|
2076
|
-
* Generates code for the
|
|
2077
|
-
*
|
|
2651
|
+
* Generates code for the global injector which is responsible for setting the global
|
|
2652
|
+
* `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
|
|
2078
2653
|
*/
|
|
2079
2654
|
|
|
2080
2655
|
|
|
2081
|
-
function generateGlobalInjectorCode(
|
|
2082
|
-
var release =
|
|
2083
|
-
injectReleasesMap =
|
|
2084
|
-
|
|
2085
|
-
|
|
2656
|
+
function generateGlobalInjectorCode(_ref3) {
|
|
2657
|
+
var release = _ref3.release,
|
|
2658
|
+
injectReleasesMap = _ref3.injectReleasesMap,
|
|
2659
|
+
injectBuildInformation = _ref3.injectBuildInformation,
|
|
2660
|
+
org = _ref3.org,
|
|
2661
|
+
project = _ref3.project;
|
|
2086
2662
|
// The code below is mostly ternary operators because it saves bundle size.
|
|
2087
2663
|
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
2088
2664
|
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, "\"};");
|
|
2089
2665
|
|
|
2090
2666
|
if (injectReleasesMap && project) {
|
|
2091
2667
|
var key = org ? "".concat(project, "@").concat(org) : project;
|
|
2092
|
-
code += "\n _global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};\n _global.SENTRY_RELEASES[\"".concat(key, "\"]={id:\"").concat(release, "\"}
|
|
2668
|
+
code += "\n _global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};\n _global.SENTRY_RELEASES[\"".concat(key, "\"]={id:\"").concat(release, "\"};");
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
if (injectBuildInformation) {
|
|
2672
|
+
var buildInfo = getBuildInformation();
|
|
2673
|
+
code += "\n _global.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
|
|
2093
2674
|
}
|
|
2094
2675
|
|
|
2095
2676
|
return code;
|
|
2096
|
-
}
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
function getBuildInformation() {
|
|
2680
|
+
var packageJson = getPackageJson();
|
|
2681
|
+
|
|
2682
|
+
var _ref4 = packageJson ? getDependencies(packageJson) : {
|
|
2683
|
+
deps: [],
|
|
2684
|
+
depsVersions: {}
|
|
2685
|
+
},
|
|
2686
|
+
deps = _ref4.deps,
|
|
2687
|
+
depsVersions = _ref4.depsVersions;
|
|
2688
|
+
|
|
2689
|
+
return {
|
|
2690
|
+
deps: deps,
|
|
2691
|
+
depsVersions: depsVersions,
|
|
2692
|
+
nodeVersion: parseMajorVersion(process.version)
|
|
2693
|
+
};
|
|
2694
|
+
}
|
|
2695
|
+
/**
|
|
2696
|
+
* Determines whether the Sentry CLI binary is in its expected location.
|
|
2697
|
+
* This function is useful since `@sentry/cli` installs the binary via a post-install
|
|
2698
|
+
* script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.
|
|
2699
|
+
*/
|
|
2097
2700
|
|
|
2701
|
+
function sentryCliBinaryExists() {
|
|
2702
|
+
return fs__default["default"].existsSync(SentryCli__default["default"].getPath());
|
|
2703
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2098
2704
|
|
|
2099
2705
|
var sentryVitePlugin = unplugin.vite; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2100
2706
|
|
|
@@ -2104,6 +2710,8 @@ var sentryWebpackPlugin = unplugin.webpack; // eslint-disable-next-line @typescr
|
|
|
2104
2710
|
|
|
2105
2711
|
var sentryEsbuildPlugin = unplugin.esbuild;
|
|
2106
2712
|
|
|
2713
|
+
exports.getBuildInformation = getBuildInformation;
|
|
2714
|
+
exports.sentryCliBinaryExists = sentryCliBinaryExists;
|
|
2107
2715
|
exports.sentryEsbuildPlugin = sentryEsbuildPlugin;
|
|
2108
2716
|
exports.sentryRollupPlugin = sentryRollupPlugin;
|
|
2109
2717
|
exports.sentryVitePlugin = sentryVitePlugin;
|