@sentry/bundler-plugin-core 0.4.0 → 0.5.1
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 +793 -137
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +771 -140
- 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 +1 -1
- package/dist/types/sentry/releasePipeline.d.ts +1 -0
- package/dist/types/types.d.ts +41 -0
- package/dist/types/utils.d.ts +21 -0
- package/package.json +8 -11
- 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,6 +946,9 @@ 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
|
|
@@ -933,7 +1088,7 @@ function makeSentryClient(dsn, allowedToSendTelemetryPromise, userProject) {
|
|
|
933
1088
|
// a dashboard.
|
|
934
1089
|
// Yes, this is slightly abusing the purpose of this field.
|
|
935
1090
|
dist: userProject,
|
|
936
|
-
release: "0.
|
|
1091
|
+
release: "0.5.1",
|
|
937
1092
|
integrations: [],
|
|
938
1093
|
tracePropagationTargets: ["sentry.io/api"],
|
|
939
1094
|
stackParser: defaultStackParser,
|
|
@@ -1035,7 +1190,8 @@ function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
|
1035
1190
|
dryRun = options.dryRun,
|
|
1036
1191
|
errorHandler = options.errorHandler,
|
|
1037
1192
|
deploy = options.deploy,
|
|
1038
|
-
include = options.include
|
|
1193
|
+
include = options.include,
|
|
1194
|
+
_experiments = options._experiments;
|
|
1039
1195
|
hub.setTag("include", include.length > 1 ? "multiple-entries" : "single-entry"); // Optional release pipeline steps
|
|
1040
1196
|
|
|
1041
1197
|
if (cleanArtifacts) {
|
|
@@ -1067,6 +1223,10 @@ function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
|
1067
1223
|
hub.setTag("error-handler", "custom");
|
|
1068
1224
|
}
|
|
1069
1225
|
|
|
1226
|
+
if (_experiments.debugIdUpload) {
|
|
1227
|
+
hub.setTag("debug-id-upload", true);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1070
1230
|
hub.setTag("node", process.version);
|
|
1071
1231
|
hub.setTags({
|
|
1072
1232
|
organization: org,
|
|
@@ -1278,74 +1438,141 @@ function _uploadSourceMaps() {
|
|
|
1278
1438
|
while (1) {
|
|
1279
1439
|
switch (_context3.prev = _context3.next) {
|
|
1280
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:
|
|
1281
1450
|
span = addSpanToTransaction(ctx, "function.plugin.upload_sourcemaps");
|
|
1282
1451
|
ctx.logger.info("Uploading Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
|
|
1283
1452
|
// we only need to pass the include option here.
|
|
1284
1453
|
|
|
1285
|
-
_context3.prev =
|
|
1286
|
-
_context3.next =
|
|
1454
|
+
_context3.prev = 5;
|
|
1455
|
+
_context3.next = 8;
|
|
1287
1456
|
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1288
1457
|
include: options.include,
|
|
1289
1458
|
dist: options.dist
|
|
1290
1459
|
});
|
|
1291
1460
|
|
|
1292
|
-
case
|
|
1293
|
-
_context3.next =
|
|
1461
|
+
case 8:
|
|
1462
|
+
_context3.next = 14;
|
|
1294
1463
|
break;
|
|
1295
1464
|
|
|
1296
|
-
case
|
|
1297
|
-
_context3.prev =
|
|
1298
|
-
_context3.t0 = _context3["catch"](
|
|
1465
|
+
case 10:
|
|
1466
|
+
_context3.prev = 10;
|
|
1467
|
+
_context3.t0 = _context3["catch"](5);
|
|
1299
1468
|
ctx.hub.captureException(new Error("CLI Error: Uploading source maps failed"));
|
|
1300
1469
|
throw _context3.t0;
|
|
1301
1470
|
|
|
1302
|
-
case
|
|
1303
|
-
_context3.prev =
|
|
1471
|
+
case 14:
|
|
1472
|
+
_context3.prev = 14;
|
|
1304
1473
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1305
|
-
return _context3.finish(
|
|
1474
|
+
return _context3.finish(14);
|
|
1306
1475
|
|
|
1307
|
-
case
|
|
1476
|
+
case 17:
|
|
1308
1477
|
ctx.hub.addBreadcrumb({
|
|
1309
1478
|
level: "info",
|
|
1310
1479
|
message: "Successfully uploaded source maps."
|
|
1311
1480
|
});
|
|
1312
1481
|
ctx.logger.info("Successfully uploaded source maps.");
|
|
1313
1482
|
|
|
1314
|
-
case
|
|
1483
|
+
case 19:
|
|
1315
1484
|
case "end":
|
|
1316
1485
|
return _context3.stop();
|
|
1317
1486
|
}
|
|
1318
1487
|
}
|
|
1319
|
-
}, _callee3, null, [[
|
|
1488
|
+
}, _callee3, null, [[5, 10, 14, 17]]);
|
|
1320
1489
|
}));
|
|
1321
1490
|
return _uploadSourceMaps.apply(this, arguments);
|
|
1322
1491
|
}
|
|
1323
1492
|
|
|
1324
|
-
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) {
|
|
1325
1552
|
return _setCommits.apply(this, arguments);
|
|
1326
1553
|
}
|
|
1327
1554
|
|
|
1328
1555
|
function _setCommits() {
|
|
1329
|
-
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1556
|
+
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx, releaseName) {
|
|
1330
1557
|
var span, _options$setCommits, auto, repo, commit, previousCommit, ignoreMissing, ignoreEmpty;
|
|
1331
1558
|
|
|
1332
|
-
return _regeneratorRuntime().wrap(function
|
|
1559
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1333
1560
|
while (1) {
|
|
1334
|
-
switch (
|
|
1561
|
+
switch (_context5.prev = _context5.next) {
|
|
1335
1562
|
case 0:
|
|
1336
1563
|
if (options.setCommits) {
|
|
1337
|
-
|
|
1564
|
+
_context5.next = 3;
|
|
1338
1565
|
break;
|
|
1339
1566
|
}
|
|
1340
1567
|
|
|
1341
1568
|
logger.debug("Skipping setting commits to release.");
|
|
1342
|
-
return
|
|
1569
|
+
return _context5.abrupt("return");
|
|
1343
1570
|
|
|
1344
1571
|
case 3:
|
|
1345
1572
|
span = addSpanToTransaction(ctx, "function.plugin.set_commits");
|
|
1346
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;
|
|
1347
|
-
|
|
1348
|
-
|
|
1574
|
+
_context5.prev = 5;
|
|
1575
|
+
_context5.next = 8;
|
|
1349
1576
|
return ctx.cli.releases.setCommits(releaseName, {
|
|
1350
1577
|
commit: commit,
|
|
1351
1578
|
previousCommit: previousCommit,
|
|
@@ -1356,46 +1583,46 @@ function _setCommits() {
|
|
|
1356
1583
|
});
|
|
1357
1584
|
|
|
1358
1585
|
case 8:
|
|
1359
|
-
|
|
1586
|
+
_context5.next = 14;
|
|
1360
1587
|
break;
|
|
1361
1588
|
|
|
1362
1589
|
case 10:
|
|
1363
|
-
|
|
1364
|
-
|
|
1590
|
+
_context5.prev = 10;
|
|
1591
|
+
_context5.t0 = _context5["catch"](5);
|
|
1365
1592
|
ctx.hub.captureException(new Error("CLI Error: Setting commits failed"));
|
|
1366
|
-
throw
|
|
1593
|
+
throw _context5.t0;
|
|
1367
1594
|
|
|
1368
1595
|
case 14:
|
|
1369
|
-
|
|
1596
|
+
_context5.prev = 14;
|
|
1370
1597
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1371
|
-
return
|
|
1598
|
+
return _context5.finish(14);
|
|
1372
1599
|
|
|
1373
1600
|
case 17:
|
|
1374
1601
|
ctx.logger.info("Successfully set commits.");
|
|
1375
1602
|
|
|
1376
1603
|
case 18:
|
|
1377
1604
|
case "end":
|
|
1378
|
-
return
|
|
1605
|
+
return _context5.stop();
|
|
1379
1606
|
}
|
|
1380
1607
|
}
|
|
1381
|
-
},
|
|
1608
|
+
}, _callee5, null, [[5, 10, 14, 17]]);
|
|
1382
1609
|
}));
|
|
1383
1610
|
return _setCommits.apply(this, arguments);
|
|
1384
1611
|
}
|
|
1385
1612
|
|
|
1386
|
-
function finalizeRelease(
|
|
1613
|
+
function finalizeRelease(_x17, _x18, _x19) {
|
|
1387
1614
|
return _finalizeRelease.apply(this, arguments);
|
|
1388
1615
|
}
|
|
1389
1616
|
|
|
1390
1617
|
function _finalizeRelease() {
|
|
1391
|
-
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1618
|
+
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx, releaseName) {
|
|
1392
1619
|
var span;
|
|
1393
|
-
return _regeneratorRuntime().wrap(function
|
|
1620
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1394
1621
|
while (1) {
|
|
1395
|
-
switch (
|
|
1622
|
+
switch (_context6.prev = _context6.next) {
|
|
1396
1623
|
case 0:
|
|
1397
1624
|
if (options.finalize) {
|
|
1398
|
-
|
|
1625
|
+
_context6.next = 4;
|
|
1399
1626
|
break;
|
|
1400
1627
|
}
|
|
1401
1628
|
|
|
@@ -1404,28 +1631,28 @@ function _finalizeRelease() {
|
|
|
1404
1631
|
message: "Skipping release finalization."
|
|
1405
1632
|
});
|
|
1406
1633
|
logger.debug("Skipping release finalization.");
|
|
1407
|
-
return
|
|
1634
|
+
return _context6.abrupt("return");
|
|
1408
1635
|
|
|
1409
1636
|
case 4:
|
|
1410
1637
|
span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
|
|
1411
|
-
|
|
1412
|
-
|
|
1638
|
+
_context6.prev = 5;
|
|
1639
|
+
_context6.next = 8;
|
|
1413
1640
|
return ctx.cli.releases.finalize(releaseName);
|
|
1414
1641
|
|
|
1415
1642
|
case 8:
|
|
1416
|
-
|
|
1643
|
+
_context6.next = 14;
|
|
1417
1644
|
break;
|
|
1418
1645
|
|
|
1419
1646
|
case 10:
|
|
1420
|
-
|
|
1421
|
-
|
|
1647
|
+
_context6.prev = 10;
|
|
1648
|
+
_context6.t0 = _context6["catch"](5);
|
|
1422
1649
|
ctx.hub.captureException(new Error("CLI Error: Finalizing release failed"));
|
|
1423
|
-
throw
|
|
1650
|
+
throw _context6.t0;
|
|
1424
1651
|
|
|
1425
1652
|
case 14:
|
|
1426
|
-
|
|
1653
|
+
_context6.prev = 14;
|
|
1427
1654
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1428
|
-
return
|
|
1655
|
+
return _context6.finish(14);
|
|
1429
1656
|
|
|
1430
1657
|
case 17:
|
|
1431
1658
|
ctx.hub.addBreadcrumb({
|
|
@@ -1436,28 +1663,28 @@ function _finalizeRelease() {
|
|
|
1436
1663
|
|
|
1437
1664
|
case 19:
|
|
1438
1665
|
case "end":
|
|
1439
|
-
return
|
|
1666
|
+
return _context6.stop();
|
|
1440
1667
|
}
|
|
1441
1668
|
}
|
|
1442
|
-
},
|
|
1669
|
+
}, _callee6, null, [[5, 10, 14, 17]]);
|
|
1443
1670
|
}));
|
|
1444
1671
|
return _finalizeRelease.apply(this, arguments);
|
|
1445
1672
|
}
|
|
1446
1673
|
|
|
1447
|
-
function addDeploy(
|
|
1674
|
+
function addDeploy(_x20, _x21, _x22) {
|
|
1448
1675
|
return _addDeploy.apply(this, arguments);
|
|
1449
1676
|
}
|
|
1450
1677
|
|
|
1451
1678
|
function _addDeploy() {
|
|
1452
|
-
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1679
|
+
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(options, ctx, releaseName) {
|
|
1453
1680
|
var span, _options$deploy, env, started, finished, time, name, url;
|
|
1454
1681
|
|
|
1455
|
-
return _regeneratorRuntime().wrap(function
|
|
1682
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1456
1683
|
while (1) {
|
|
1457
|
-
switch (
|
|
1684
|
+
switch (_context7.prev = _context7.next) {
|
|
1458
1685
|
case 0:
|
|
1459
1686
|
if (options.deploy) {
|
|
1460
|
-
|
|
1687
|
+
_context7.next = 4;
|
|
1461
1688
|
break;
|
|
1462
1689
|
}
|
|
1463
1690
|
|
|
@@ -1466,13 +1693,13 @@ function _addDeploy() {
|
|
|
1466
1693
|
message: "Skipping adding deploy info to release."
|
|
1467
1694
|
});
|
|
1468
1695
|
logger.debug("Skipping adding deploy info to release.");
|
|
1469
|
-
return
|
|
1696
|
+
return _context7.abrupt("return");
|
|
1470
1697
|
|
|
1471
1698
|
case 4:
|
|
1472
1699
|
span = addSpanToTransaction(ctx, "function.plugin.deploy");
|
|
1473
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;
|
|
1474
|
-
|
|
1475
|
-
|
|
1701
|
+
_context7.prev = 6;
|
|
1702
|
+
_context7.next = 9;
|
|
1476
1703
|
return ctx.cli.releases.newDeploy(releaseName, {
|
|
1477
1704
|
env: env,
|
|
1478
1705
|
started: started,
|
|
@@ -1483,19 +1710,19 @@ function _addDeploy() {
|
|
|
1483
1710
|
});
|
|
1484
1711
|
|
|
1485
1712
|
case 9:
|
|
1486
|
-
|
|
1713
|
+
_context7.next = 15;
|
|
1487
1714
|
break;
|
|
1488
1715
|
|
|
1489
1716
|
case 11:
|
|
1490
|
-
|
|
1491
|
-
|
|
1717
|
+
_context7.prev = 11;
|
|
1718
|
+
_context7.t0 = _context7["catch"](6);
|
|
1492
1719
|
ctx.hub.captureException(new Error("CLI Error: Adding deploy info failed"));
|
|
1493
|
-
throw
|
|
1720
|
+
throw _context7.t0;
|
|
1494
1721
|
|
|
1495
1722
|
case 15:
|
|
1496
|
-
|
|
1723
|
+
_context7.prev = 15;
|
|
1497
1724
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1498
|
-
return
|
|
1725
|
+
return _context7.finish(15);
|
|
1499
1726
|
|
|
1500
1727
|
case 18:
|
|
1501
1728
|
ctx.hub.addBreadcrumb({
|
|
@@ -1506,10 +1733,10 @@ function _addDeploy() {
|
|
|
1506
1733
|
|
|
1507
1734
|
case 20:
|
|
1508
1735
|
case "end":
|
|
1509
|
-
return
|
|
1736
|
+
return _context7.stop();
|
|
1510
1737
|
}
|
|
1511
1738
|
}
|
|
1512
|
-
},
|
|
1739
|
+
}, _callee7, null, [[6, 11, 15, 18]]);
|
|
1513
1740
|
}));
|
|
1514
1741
|
return _addDeploy.apply(this, arguments);
|
|
1515
1742
|
}
|
|
@@ -1640,18 +1867,261 @@ function getDryRunCLI(cli, logger) {
|
|
|
1640
1867
|
};
|
|
1641
1868
|
}
|
|
1642
1869
|
|
|
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
|
+
}
|
|
2110
|
+
|
|
1643
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");
|
|
1644
2114
|
/**
|
|
1645
2115
|
* The sentry bundler plugin concerns itself with two things:
|
|
1646
2116
|
* - Release injection
|
|
1647
2117
|
* - Sourcemaps upload
|
|
1648
2118
|
*
|
|
1649
2119
|
* Release injection:
|
|
1650
|
-
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into
|
|
1651
|
-
*
|
|
1652
|
-
*
|
|
1653
|
-
*
|
|
1654
|
-
* they can use the `releaseInjectionTargets` option.
|
|
2120
|
+
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into each JavaScript/TypeScript module
|
|
2121
|
+
* that is part of the bundle. On a technical level this is done by appending an import (`import "sentry-release-injector;"`)
|
|
2122
|
+
* to all entrypoint files of the user code (see `transformInclude` and `transform` hooks). This import is then resolved
|
|
2123
|
+
* by the sentry plugin to a virtual module that sets the global variable (see `resolveId` and `load` hooks).
|
|
2124
|
+
* If a user wants to inject the release into a particular set of modules they can use the `releaseInjectionTargets` option.
|
|
1655
2125
|
*
|
|
1656
2126
|
* Source maps upload:
|
|
1657
2127
|
*
|
|
@@ -1669,6 +2139,7 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"]
|
|
|
1669
2139
|
* This release creation pipeline relies on Sentry CLI to execute the different steps.
|
|
1670
2140
|
*/
|
|
1671
2141
|
|
|
2142
|
+
|
|
1672
2143
|
var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
1673
2144
|
var internalOptions = normalizeUserOptions(options);
|
|
1674
2145
|
var allowedToSendTelemetryPromise = shouldSendTelemetry(internalOptions);
|
|
@@ -1704,7 +2175,6 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1704
2175
|
});
|
|
1705
2176
|
var transaction;
|
|
1706
2177
|
var releaseInjectionSpan;
|
|
1707
|
-
var absolueEntrypointPaths = new Set();
|
|
1708
2178
|
return {
|
|
1709
2179
|
name: "sentry-plugin",
|
|
1710
2180
|
enforce: "pre",
|
|
@@ -1741,10 +2211,14 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1741
2211
|
});
|
|
1742
2212
|
}
|
|
1743
2213
|
|
|
1744
|
-
|
|
2214
|
+
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) {
|
|
2215
|
+
logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
_context.next = 8;
|
|
1745
2219
|
return releaseNamePromise;
|
|
1746
2220
|
|
|
1747
|
-
case
|
|
2221
|
+
case 8:
|
|
1748
2222
|
releaseName = _context.sent;
|
|
1749
2223
|
|
|
1750
2224
|
// At this point, we either have determined a release or we have to bail
|
|
@@ -1763,7 +2237,7 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1763
2237
|
cli: cli
|
|
1764
2238
|
}, "function.plugin.inject_release", "Release injection");
|
|
1765
2239
|
|
|
1766
|
-
case
|
|
2240
|
+
case 12:
|
|
1767
2241
|
case "end":
|
|
1768
2242
|
return _context.stop();
|
|
1769
2243
|
}
|
|
@@ -1790,11 +2264,6 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1790
2264
|
importer: importer,
|
|
1791
2265
|
isEntry: isEntry
|
|
1792
2266
|
});
|
|
1793
|
-
|
|
1794
|
-
if (isEntry) {
|
|
1795
|
-
absolueEntrypointPaths.add(path.resolve(path.normalize(id)));
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
2267
|
return undefined;
|
|
1799
2268
|
},
|
|
1800
2269
|
|
|
@@ -1809,10 +2278,19 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1809
2278
|
transformInclude: function transformInclude(id) {
|
|
1810
2279
|
logger.debug('Called "transformInclude":', {
|
|
1811
2280
|
id: id
|
|
1812
|
-
});
|
|
2281
|
+
});
|
|
2282
|
+
|
|
2283
|
+
if (id.match(/\\node_modules\\|\/node_modules\//)) {
|
|
2284
|
+
return false; // never transform 3rd party modules
|
|
2285
|
+
} // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
|
|
1813
2286
|
// a windows style path to `releaseInjectionTargets`
|
|
1814
2287
|
|
|
1815
|
-
|
|
2288
|
+
|
|
2289
|
+
var normalizedId = path__default.normalize(id);
|
|
2290
|
+
|
|
2291
|
+
if (id.includes("sentry-release-injection-file")) {
|
|
2292
|
+
return true;
|
|
2293
|
+
}
|
|
1816
2294
|
|
|
1817
2295
|
if (internalOptions.releaseInjectionTargets) {
|
|
1818
2296
|
// If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
|
|
@@ -1824,18 +2302,16 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1824
2302
|
if (entry instanceof RegExp) {
|
|
1825
2303
|
return entry.test(normalizedId);
|
|
1826
2304
|
} else {
|
|
1827
|
-
var normalizedEntry =
|
|
2305
|
+
var normalizedEntry = path__default.normalize(entry);
|
|
1828
2306
|
return normalizedId === normalizedEntry;
|
|
1829
2307
|
}
|
|
1830
2308
|
});
|
|
1831
|
-
} else
|
|
2309
|
+
} else {
|
|
1832
2310
|
var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
|
|
1833
2311
|
var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
|
|
1834
2312
|
return normalizedId.endsWith(allowedFileEnding);
|
|
1835
2313
|
});
|
|
1836
2314
|
return pathIsOrdinary && pathHasAllowedFileEnding;
|
|
1837
|
-
} else {
|
|
1838
|
-
return false;
|
|
1839
2315
|
}
|
|
1840
2316
|
},
|
|
1841
2317
|
|
|
@@ -1856,43 +2332,70 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1856
2332
|
case 0:
|
|
1857
2333
|
logger.debug('Called "transform":', {
|
|
1858
2334
|
id: id
|
|
1859
|
-
});
|
|
2335
|
+
});
|
|
2336
|
+
|
|
2337
|
+
if (internalOptions.injectRelease) {
|
|
2338
|
+
_context2.next = 3;
|
|
2339
|
+
break;
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
return _context2.abrupt("return");
|
|
1860
2343
|
|
|
2344
|
+
case 3:
|
|
2345
|
+
// The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
|
|
1861
2346
|
ms = new MagicString(code);
|
|
2347
|
+
|
|
2348
|
+
if (!code.includes("_sentry_release_injection_file")) {
|
|
2349
|
+
_context2.next = 19;
|
|
2350
|
+
break;
|
|
2351
|
+
}
|
|
2352
|
+
|
|
1862
2353
|
_context2.t0 = ms;
|
|
1863
2354
|
_context2.t1 = generateGlobalInjectorCode;
|
|
1864
|
-
_context2.next =
|
|
2355
|
+
_context2.next = 9;
|
|
1865
2356
|
return releaseNamePromise;
|
|
1866
2357
|
|
|
1867
|
-
case
|
|
2358
|
+
case 9:
|
|
1868
2359
|
_context2.t2 = _context2.sent;
|
|
1869
2360
|
_context2.t3 = internalOptions.injectReleasesMap;
|
|
1870
|
-
_context2.t4 = internalOptions.
|
|
1871
|
-
_context2.t5 = internalOptions.
|
|
1872
|
-
_context2.t6 =
|
|
2361
|
+
_context2.t4 = internalOptions._experiments.injectBuildInformation || false;
|
|
2362
|
+
_context2.t5 = internalOptions.org;
|
|
2363
|
+
_context2.t6 = internalOptions.project;
|
|
2364
|
+
_context2.t7 = {
|
|
1873
2365
|
release: _context2.t2,
|
|
1874
2366
|
injectReleasesMap: _context2.t3,
|
|
1875
|
-
|
|
1876
|
-
|
|
2367
|
+
injectBuildInformation: _context2.t4,
|
|
2368
|
+
org: _context2.t5,
|
|
2369
|
+
project: _context2.t6
|
|
1877
2370
|
};
|
|
1878
|
-
_context2.
|
|
2371
|
+
_context2.t8 = (0, _context2.t1)(_context2.t7);
|
|
1879
2372
|
|
|
1880
|
-
_context2.t0.
|
|
2373
|
+
_context2.t0.append.call(_context2.t0, _context2.t8);
|
|
1881
2374
|
|
|
2375
|
+
_context2.next = 20;
|
|
2376
|
+
break;
|
|
2377
|
+
|
|
2378
|
+
case 19:
|
|
2379
|
+
// Appending instead of prepending has less probability of mucking with user's source maps.
|
|
2380
|
+
// Luckily import statements get hoisted to the top anyways.
|
|
2381
|
+
// 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).
|
|
2382
|
+
ms.append(";\nimport \"".concat(releaseInjectionFilePath.replace(/\\/g, "\\\\"), "\";"));
|
|
2383
|
+
|
|
2384
|
+
case 20:
|
|
1882
2385
|
if (!(unpluginMetaContext.framework === "esbuild")) {
|
|
1883
|
-
_context2.next =
|
|
2386
|
+
_context2.next = 24;
|
|
1884
2387
|
break;
|
|
1885
2388
|
}
|
|
1886
2389
|
|
|
1887
2390
|
return _context2.abrupt("return", ms.toString());
|
|
1888
2391
|
|
|
1889
|
-
case
|
|
2392
|
+
case 24:
|
|
1890
2393
|
return _context2.abrupt("return", {
|
|
1891
2394
|
code: ms.toString(),
|
|
1892
2395
|
map: ms.generateMap()
|
|
1893
2396
|
});
|
|
1894
2397
|
|
|
1895
|
-
case
|
|
2398
|
+
case 25:
|
|
1896
2399
|
case "end":
|
|
1897
2400
|
return _context2.stop();
|
|
1898
2401
|
}
|
|
@@ -1906,14 +2409,14 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1906
2409
|
* Sentry.io, uploading sourcemaps, associating commits and deploys and finalizing the release)
|
|
1907
2410
|
*/
|
|
1908
2411
|
writeBundle: function writeBundle() {
|
|
1909
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2412
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1910
2413
|
var _releaseInjectionSpan;
|
|
1911
2414
|
|
|
1912
|
-
var releasePipelineSpan, ctx, releaseName, _transaction, _transaction2, _transaction3;
|
|
2415
|
+
var releasePipelineSpan, ctx, releaseName, tmpUploadFolder, _transaction, debugIdChunkFilePaths, sourceFileUploadFolderPromise, _transaction2, _transaction3;
|
|
1913
2416
|
|
|
1914
|
-
return _regeneratorRuntime().wrap(function
|
|
2417
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1915
2418
|
while (1) {
|
|
1916
|
-
switch (
|
|
2419
|
+
switch (_context4.prev = _context4.next) {
|
|
1917
2420
|
case 0:
|
|
1918
2421
|
logger.debug('Called "writeBundle"');
|
|
1919
2422
|
(_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
|
|
@@ -1933,75 +2436,172 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1933
2436
|
logger: logger,
|
|
1934
2437
|
cli: cli
|
|
1935
2438
|
};
|
|
1936
|
-
|
|
2439
|
+
_context4.next = 7;
|
|
1937
2440
|
return releaseNamePromise;
|
|
1938
2441
|
|
|
1939
2442
|
case 7:
|
|
1940
|
-
releaseName =
|
|
1941
|
-
|
|
1942
|
-
|
|
2443
|
+
releaseName = _context4.sent;
|
|
2444
|
+
_context4.prev = 8;
|
|
2445
|
+
|
|
2446
|
+
if (!internalOptions._experiments.debugIdUpload) {
|
|
2447
|
+
_context4.next = 21;
|
|
2448
|
+
break;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
_context4.next = 12;
|
|
2452
|
+
return glob(internalOptions._experiments.debugIdUpload.include, {
|
|
2453
|
+
absolute: true,
|
|
2454
|
+
nodir: true,
|
|
2455
|
+
ignore: internalOptions._experiments.debugIdUpload.ignore
|
|
2456
|
+
});
|
|
2457
|
+
|
|
2458
|
+
case 12:
|
|
2459
|
+
debugIdChunkFilePaths = _context4.sent.filter(function (p) {
|
|
2460
|
+
return p.endsWith(".js") || p.endsWith(".mjs");
|
|
2461
|
+
});
|
|
2462
|
+
sourceFileUploadFolderPromise = util__default.promisify(fs__default.mkdtemp)(path__default.join(os.tmpdir(), "sentry-bundler-plugin-upload-"));
|
|
2463
|
+
_context4.next = 16;
|
|
2464
|
+
return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
|
|
2465
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chunkFilePath, chunkIndex) {
|
|
2466
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2467
|
+
while (1) {
|
|
2468
|
+
switch (_context3.prev = _context3.next) {
|
|
2469
|
+
case 0:
|
|
2470
|
+
_context3.t0 = prepareBundleForDebugIdUpload;
|
|
2471
|
+
_context3.t1 = chunkFilePath;
|
|
2472
|
+
_context3.next = 4;
|
|
2473
|
+
return sourceFileUploadFolderPromise;
|
|
2474
|
+
|
|
2475
|
+
case 4:
|
|
2476
|
+
_context3.t2 = _context3.sent;
|
|
2477
|
+
_context3.t3 = String(chunkIndex);
|
|
2478
|
+
_context3.t4 = logger;
|
|
2479
|
+
_context3.next = 9;
|
|
2480
|
+
return (0, _context3.t0)(_context3.t1, _context3.t2, _context3.t3, _context3.t4);
|
|
2481
|
+
|
|
2482
|
+
case 9:
|
|
2483
|
+
case "end":
|
|
2484
|
+
return _context3.stop();
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
}, _callee3);
|
|
2488
|
+
}));
|
|
2489
|
+
|
|
2490
|
+
return function (_x, _x2) {
|
|
2491
|
+
return _ref2.apply(this, arguments);
|
|
2492
|
+
};
|
|
2493
|
+
}()));
|
|
2494
|
+
|
|
2495
|
+
case 16:
|
|
2496
|
+
_context4.next = 18;
|
|
2497
|
+
return sourceFileUploadFolderPromise;
|
|
2498
|
+
|
|
2499
|
+
case 18:
|
|
2500
|
+
tmpUploadFolder = _context4.sent;
|
|
2501
|
+
_context4.next = 21;
|
|
2502
|
+
return uploadDebugIdSourcemaps(internalOptions, ctx, tmpUploadFolder, releaseName);
|
|
2503
|
+
|
|
2504
|
+
case 21:
|
|
2505
|
+
_context4.next = 23;
|
|
1943
2506
|
return createNewRelease(internalOptions, ctx, releaseName);
|
|
1944
2507
|
|
|
1945
|
-
case
|
|
1946
|
-
|
|
2508
|
+
case 23:
|
|
2509
|
+
_context4.next = 25;
|
|
1947
2510
|
return cleanArtifacts(internalOptions, ctx, releaseName);
|
|
1948
2511
|
|
|
1949
|
-
case
|
|
1950
|
-
|
|
2512
|
+
case 25:
|
|
2513
|
+
_context4.next = 27;
|
|
1951
2514
|
return uploadSourceMaps(internalOptions, ctx, releaseName);
|
|
1952
2515
|
|
|
1953
|
-
case
|
|
1954
|
-
|
|
2516
|
+
case 27:
|
|
2517
|
+
_context4.next = 29;
|
|
1955
2518
|
return setCommits(internalOptions, ctx, releaseName);
|
|
1956
2519
|
|
|
1957
|
-
case
|
|
1958
|
-
|
|
2520
|
+
case 29:
|
|
2521
|
+
_context4.next = 31;
|
|
1959
2522
|
return finalizeRelease(internalOptions, ctx, releaseName);
|
|
1960
2523
|
|
|
1961
|
-
case
|
|
1962
|
-
|
|
2524
|
+
case 31:
|
|
2525
|
+
_context4.next = 33;
|
|
1963
2526
|
return addDeploy(internalOptions, ctx, releaseName);
|
|
1964
2527
|
|
|
1965
|
-
case
|
|
2528
|
+
case 33:
|
|
1966
2529
|
(_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
|
|
1967
|
-
|
|
2530
|
+
_context4.next = 41;
|
|
1968
2531
|
break;
|
|
1969
2532
|
|
|
1970
|
-
case
|
|
1971
|
-
|
|
1972
|
-
|
|
2533
|
+
case 36:
|
|
2534
|
+
_context4.prev = 36;
|
|
2535
|
+
_context4.t0 = _context4["catch"](8);
|
|
1973
2536
|
(_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
|
|
1974
2537
|
sentryHub.addBreadcrumb({
|
|
1975
2538
|
level: "error",
|
|
1976
2539
|
message: "Error during writeBundle"
|
|
1977
2540
|
});
|
|
1978
|
-
handleError(
|
|
2541
|
+
handleError(_context4.t0, logger, internalOptions.errorHandler);
|
|
2542
|
+
|
|
2543
|
+
case 41:
|
|
2544
|
+
_context4.prev = 41;
|
|
2545
|
+
|
|
2546
|
+
if (tmpUploadFolder) {
|
|
2547
|
+
fs__default.rm(tmpUploadFolder, {
|
|
2548
|
+
recursive: true,
|
|
2549
|
+
force: true
|
|
2550
|
+
}, function () {// We don't care if this errors
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
1979
2553
|
|
|
1980
|
-
case 29:
|
|
1981
|
-
_context3.prev = 29;
|
|
1982
2554
|
releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
|
|
1983
2555
|
(_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
|
|
1984
|
-
|
|
2556
|
+
_context4.next = 47;
|
|
1985
2557
|
return sentryClient.flush().then(null, function () {
|
|
1986
2558
|
logger.warn("Sending of telemetry failed");
|
|
1987
2559
|
});
|
|
1988
2560
|
|
|
1989
|
-
case
|
|
1990
|
-
return
|
|
2561
|
+
case 47:
|
|
2562
|
+
return _context4.finish(41);
|
|
1991
2563
|
|
|
1992
|
-
case
|
|
2564
|
+
case 48:
|
|
1993
2565
|
sentryHub.addBreadcrumb({
|
|
1994
2566
|
category: "writeBundle:finish",
|
|
1995
2567
|
level: "info"
|
|
1996
2568
|
});
|
|
1997
2569
|
|
|
1998
|
-
case
|
|
2570
|
+
case 49:
|
|
1999
2571
|
case "end":
|
|
2000
|
-
return
|
|
2572
|
+
return _context4.stop();
|
|
2001
2573
|
}
|
|
2002
2574
|
}
|
|
2003
|
-
},
|
|
2575
|
+
}, _callee4, null, [[8, 36, 41, 48]]);
|
|
2004
2576
|
}))();
|
|
2577
|
+
},
|
|
2578
|
+
rollup: {
|
|
2579
|
+
renderChunk: function renderChunk(code, chunk) {
|
|
2580
|
+
var _options$_experiments;
|
|
2581
|
+
|
|
2582
|
+
if ((_options$_experiments = options._experiments) !== null && _options$_experiments !== void 0 && _options$_experiments.debugIdUpload && [".js", ".mjs"].some(function (ending) {
|
|
2583
|
+
return chunk.fileName.endsWith(ending);
|
|
2584
|
+
}) // chunks could be any file (html, md, ...)
|
|
2585
|
+
) {
|
|
2586
|
+
return injectDebugIdSnippetIntoChunk(code);
|
|
2587
|
+
} else {
|
|
2588
|
+
return null; // returning null means not modifying the chunk at all
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
},
|
|
2592
|
+
vite: {
|
|
2593
|
+
renderChunk: function renderChunk(code, chunk) {
|
|
2594
|
+
var _options$_experiments2;
|
|
2595
|
+
|
|
2596
|
+
if ((_options$_experiments2 = options._experiments) !== null && _options$_experiments2 !== void 0 && _options$_experiments2.debugIdUpload && [".js", ".mjs"].some(function (ending) {
|
|
2597
|
+
return chunk.fileName.endsWith(ending);
|
|
2598
|
+
}) // chunks could be any file (html, md, ...)
|
|
2599
|
+
) {
|
|
2600
|
+
return injectDebugIdSnippetIntoChunk(code);
|
|
2601
|
+
} else {
|
|
2602
|
+
return null; // returning null means not modifying the chunk at all
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2005
2605
|
}
|
|
2006
2606
|
};
|
|
2007
2607
|
});
|
|
@@ -2024,16 +2624,17 @@ function handleError(unknownError, logger, errorHandler) {
|
|
|
2024
2624
|
}
|
|
2025
2625
|
}
|
|
2026
2626
|
/**
|
|
2027
|
-
* Generates code for the
|
|
2028
|
-
*
|
|
2627
|
+
* Generates code for the global injector which is responsible for setting the global
|
|
2628
|
+
* `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
|
|
2029
2629
|
*/
|
|
2030
2630
|
|
|
2031
2631
|
|
|
2032
|
-
function generateGlobalInjectorCode(
|
|
2033
|
-
var release =
|
|
2034
|
-
injectReleasesMap =
|
|
2035
|
-
|
|
2036
|
-
|
|
2632
|
+
function generateGlobalInjectorCode(_ref3) {
|
|
2633
|
+
var release = _ref3.release,
|
|
2634
|
+
injectReleasesMap = _ref3.injectReleasesMap,
|
|
2635
|
+
injectBuildInformation = _ref3.injectBuildInformation,
|
|
2636
|
+
org = _ref3.org,
|
|
2637
|
+
project = _ref3.project;
|
|
2037
2638
|
// The code below is mostly ternary operators because it saves bundle size.
|
|
2038
2639
|
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
2039
2640
|
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, "\"};");
|
|
@@ -2043,9 +2644,39 @@ function generateGlobalInjectorCode(_ref2) {
|
|
|
2043
2644
|
code += "\n _global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};\n _global.SENTRY_RELEASES[\"".concat(key, "\"]={id:\"").concat(release, "\"};");
|
|
2044
2645
|
}
|
|
2045
2646
|
|
|
2647
|
+
if (injectBuildInformation) {
|
|
2648
|
+
var buildInfo = getBuildInformation();
|
|
2649
|
+
code += "\n _global.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2046
2652
|
return code;
|
|
2047
|
-
}
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
function getBuildInformation() {
|
|
2656
|
+
var packageJson = getPackageJson();
|
|
2657
|
+
|
|
2658
|
+
var _ref4 = packageJson ? getDependencies(packageJson) : {
|
|
2659
|
+
deps: [],
|
|
2660
|
+
depsVersions: {}
|
|
2661
|
+
},
|
|
2662
|
+
deps = _ref4.deps,
|
|
2663
|
+
depsVersions = _ref4.depsVersions;
|
|
2664
|
+
|
|
2665
|
+
return {
|
|
2666
|
+
deps: deps,
|
|
2667
|
+
depsVersions: depsVersions,
|
|
2668
|
+
nodeVersion: parseMajorVersion(process.version)
|
|
2669
|
+
};
|
|
2670
|
+
}
|
|
2671
|
+
/**
|
|
2672
|
+
* Determines whether the Sentry CLI binary is in its expected location.
|
|
2673
|
+
* This function is useful since `@sentry/cli` installs the binary via a post-install
|
|
2674
|
+
* script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.
|
|
2675
|
+
*/
|
|
2048
2676
|
|
|
2677
|
+
function sentryCliBinaryExists() {
|
|
2678
|
+
return fs__default.existsSync(SentryCli.getPath());
|
|
2679
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2049
2680
|
|
|
2050
2681
|
var sentryVitePlugin = unplugin.vite; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2051
2682
|
|
|
@@ -2055,5 +2686,5 @@ var sentryWebpackPlugin = unplugin.webpack; // eslint-disable-next-line @typescr
|
|
|
2055
2686
|
|
|
2056
2687
|
var sentryEsbuildPlugin = unplugin.esbuild;
|
|
2057
2688
|
|
|
2058
|
-
export { sentryEsbuildPlugin, sentryRollupPlugin, sentryVitePlugin, sentryWebpackPlugin };
|
|
2689
|
+
export { getBuildInformation, sentryCliBinaryExists, sentryEsbuildPlugin, sentryRollupPlugin, sentryVitePlugin, sentryWebpackPlugin };
|
|
2059
2690
|
//# sourceMappingURL=index.mjs.map
|