@sentry/bundler-plugin-core 0.2.0 → 0.2.2
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/README.md +0 -2
- package/dist/cjs/index.js +539 -277
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/{index.js → index.mjs} +540 -279
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/options-mapping.d.ts +1 -1
- package/dist/types/sentry/logger.d.ts +0 -2
- package/dist/types/sentry/releasePipeline.d.ts +6 -6
- package/dist/types/sentry/telemetry.d.ts +5 -14
- package/package.json +10 -4
- package/dist/esm/index.js.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -4,14 +4,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var unplugin$1 = require('unplugin');
|
|
6
6
|
var MagicString = require('magic-string');
|
|
7
|
+
var SentryCli = require('@sentry/cli');
|
|
7
8
|
var node = require('@sentry/node');
|
|
8
9
|
require('@sentry/tracing');
|
|
9
|
-
var
|
|
10
|
+
var path = require('path');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
13
|
|
|
13
14
|
var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
14
15
|
var SentryCli__default = /*#__PURE__*/_interopDefaultLegacy(SentryCli);
|
|
16
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
15
17
|
|
|
16
18
|
function _regeneratorRuntime() {
|
|
17
19
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -358,16 +360,6 @@ function _regeneratorRuntime() {
|
|
|
358
360
|
}, exports;
|
|
359
361
|
}
|
|
360
362
|
|
|
361
|
-
function _typeof(obj) {
|
|
362
|
-
"@babel/helpers - typeof";
|
|
363
|
-
|
|
364
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
365
|
-
return typeof obj;
|
|
366
|
-
} : function (obj) {
|
|
367
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
368
|
-
}, _typeof(obj);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
363
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
372
364
|
try {
|
|
373
365
|
var info = gen[key](arg);
|
|
@@ -831,12 +823,7 @@ function normalizeUserOptions(userOptions) {
|
|
|
831
823
|
dist: userOptions.dist,
|
|
832
824
|
errorHandler: userOptions.errorHandler,
|
|
833
825
|
configFile: userOptions.configFile
|
|
834
|
-
};
|
|
835
|
-
// This is not the final check (we need to call Sentry CLI at a later point)
|
|
836
|
-
// but we can already at this point make a first decision.
|
|
837
|
-
// @see `turnOffTelemetryForSelfHostedSentry` (telemetry.ts) for the second check.
|
|
838
|
-
|
|
839
|
-
options.telemetry = options.telemetry && options.url === SENTRY_SAAS_URL;
|
|
826
|
+
};
|
|
840
827
|
return options;
|
|
841
828
|
}
|
|
842
829
|
/**
|
|
@@ -949,30 +936,83 @@ function validateOptions(options, logger) {
|
|
|
949
936
|
return true;
|
|
950
937
|
}
|
|
951
938
|
|
|
952
|
-
|
|
939
|
+
var SENTRY_SAAS_HOSTNAME = "sentry.io";
|
|
940
|
+
function makeSentryClient(dsn, allowedToSendTelemetryPromise) {
|
|
953
941
|
var client = new node.NodeClient({
|
|
954
942
|
dsn: dsn,
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
integrations: [new node.Integrations.Http({
|
|
960
|
-
tracing: true
|
|
961
|
-
})],
|
|
943
|
+
tracesSampleRate: 1,
|
|
944
|
+
sampleRate: 1,
|
|
945
|
+
release: "0.2.2",
|
|
946
|
+
integrations: [],
|
|
962
947
|
tracePropagationTargets: ["sentry.io/api"],
|
|
963
948
|
stackParser: node.defaultStackParser,
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
949
|
+
beforeSend: function beforeSend(event) {
|
|
950
|
+
var _event$exception, _event$exception$valu;
|
|
951
|
+
|
|
952
|
+
(_event$exception = event.exception) === null || _event$exception === void 0 ? void 0 : (_event$exception$valu = _event$exception.values) === null || _event$exception$valu === void 0 ? void 0 : _event$exception$valu.forEach(function (exception) {
|
|
953
|
+
delete exception.stacktrace;
|
|
954
|
+
});
|
|
955
|
+
delete event.server_name; // Server name might contain PII
|
|
956
|
+
|
|
957
|
+
return event;
|
|
958
|
+
},
|
|
959
|
+
beforeSendTransaction: function beforeSendTransaction(event) {
|
|
960
|
+
delete event.server_name; // Server name might contain PII
|
|
971
961
|
|
|
972
|
-
|
|
962
|
+
return event;
|
|
963
|
+
},
|
|
964
|
+
// We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
|
|
965
|
+
// us that the upload URL is the Sentry SaaS URL)
|
|
966
|
+
transport: function transport(nodeTransportOptions) {
|
|
967
|
+
var nodeTransport = node.makeNodeTransport(nodeTransportOptions);
|
|
968
|
+
return {
|
|
969
|
+
flush: function flush(timeout) {
|
|
970
|
+
return nodeTransport.flush(timeout);
|
|
971
|
+
},
|
|
972
|
+
send: function () {
|
|
973
|
+
var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
|
974
|
+
var isAllowedToSend;
|
|
975
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
976
|
+
while (1) {
|
|
977
|
+
switch (_context.prev = _context.next) {
|
|
978
|
+
case 0:
|
|
979
|
+
_context.next = 2;
|
|
980
|
+
return allowedToSendTelemetryPromise;
|
|
981
|
+
|
|
982
|
+
case 2:
|
|
983
|
+
isAllowedToSend = _context.sent;
|
|
984
|
+
|
|
985
|
+
if (!isAllowedToSend) {
|
|
986
|
+
_context.next = 7;
|
|
987
|
+
break;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
return _context.abrupt("return", nodeTransport.send(request));
|
|
991
|
+
|
|
992
|
+
case 7:
|
|
993
|
+
return _context.abrupt("return", undefined);
|
|
994
|
+
|
|
995
|
+
case 8:
|
|
996
|
+
case "end":
|
|
997
|
+
return _context.stop();
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}, _callee);
|
|
1001
|
+
}));
|
|
1002
|
+
|
|
1003
|
+
function send(_x) {
|
|
1004
|
+
return _send.apply(this, arguments);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
return send;
|
|
1008
|
+
}()
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
var hub = new node.Hub(client);
|
|
973
1013
|
return {
|
|
974
|
-
|
|
975
|
-
|
|
1014
|
+
sentryClient: client,
|
|
1015
|
+
sentryHub: hub
|
|
976
1016
|
};
|
|
977
1017
|
}
|
|
978
1018
|
/**
|
|
@@ -994,28 +1034,10 @@ function addSpanToTransaction(ctx, op, description) {
|
|
|
994
1034
|
});
|
|
995
1035
|
return span;
|
|
996
1036
|
}
|
|
997
|
-
function
|
|
998
|
-
var
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
var e = error;
|
|
1002
|
-
sentryError = {
|
|
1003
|
-
name: e.name,
|
|
1004
|
-
message: e.message,
|
|
1005
|
-
stack: e.stack
|
|
1006
|
-
};
|
|
1007
|
-
} else {
|
|
1008
|
-
sentryError = {
|
|
1009
|
-
name: "Error",
|
|
1010
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
1011
|
-
message: "".concat(error)
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
hub.captureException(sentryError);
|
|
1016
|
-
}
|
|
1017
|
-
function addPluginOptionTags(options, hub) {
|
|
1018
|
-
var cleanArtifacts = options.cleanArtifacts,
|
|
1037
|
+
function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
1038
|
+
var org = options.org,
|
|
1039
|
+
project = options.project,
|
|
1040
|
+
cleanArtifacts = options.cleanArtifacts,
|
|
1019
1041
|
finalize = options.finalize,
|
|
1020
1042
|
setCommits = options.setCommits,
|
|
1021
1043
|
injectReleasesMap = options.injectReleasesMap,
|
|
@@ -1055,90 +1077,155 @@ function addPluginOptionTags(options, hub) {
|
|
|
1055
1077
|
}
|
|
1056
1078
|
|
|
1057
1079
|
hub.setTag("node", process.version);
|
|
1080
|
+
hub.setTags({
|
|
1081
|
+
organization: org,
|
|
1082
|
+
project: project,
|
|
1083
|
+
bundler: bundler
|
|
1084
|
+
});
|
|
1085
|
+
hub.setUser({
|
|
1086
|
+
id: org
|
|
1087
|
+
});
|
|
1058
1088
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
*
|
|
1062
|
-
* We need to check and decide to use telemetry based on the CLI's respone to this call
|
|
1063
|
-
* because only at this time we checked a possibly existing .sentryclirc file. This file
|
|
1064
|
-
* could point to another URL than the default URL.
|
|
1065
|
-
*/
|
|
1066
|
-
|
|
1067
|
-
function turnOffTelemetryForSelfHostedSentry(_x, _x2) {
|
|
1068
|
-
return _turnOffTelemetryForSelfHostedSentry.apply(this, arguments);
|
|
1089
|
+
function shouldSendTelemetry(_x2) {
|
|
1090
|
+
return _shouldSendTelemetry.apply(this, arguments);
|
|
1069
1091
|
}
|
|
1070
1092
|
|
|
1071
|
-
function
|
|
1072
|
-
|
|
1093
|
+
function _shouldSendTelemetry() {
|
|
1094
|
+
_shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1073
1095
|
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1074
1096
|
|
|
1075
|
-
var
|
|
1076
|
-
return _regeneratorRuntime().wrap(function
|
|
1097
|
+
var silent, org, project, authToken, url, vcsRemote, customHeader, dist, telemetry, dryRun, cli, cliInfo, cliInfoUrl;
|
|
1098
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1077
1099
|
while (1) {
|
|
1078
|
-
switch (
|
|
1100
|
+
switch (_context2.prev = _context2.next) {
|
|
1079
1101
|
case 0:
|
|
1080
|
-
|
|
1081
|
-
return cli.execute(["info"], false);
|
|
1102
|
+
silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, vcsRemote = options.vcsRemote, customHeader = options.customHeader, dist = options.dist, telemetry = options.telemetry, dryRun = options.dryRun; // `options.telemetry` defaults to true
|
|
1082
1103
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1104
|
+
if (!(telemetry === false)) {
|
|
1105
|
+
_context2.next = 3;
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1086
1108
|
|
|
1087
|
-
|
|
1088
|
-
client = hub.getClient();
|
|
1109
|
+
return _context2.abrupt("return", false);
|
|
1089
1110
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1111
|
+
case 3:
|
|
1112
|
+
if (!dryRun) {
|
|
1113
|
+
_context2.next = 5;
|
|
1114
|
+
break;
|
|
1095
1115
|
}
|
|
1096
1116
|
|
|
1117
|
+
return _context2.abrupt("return", false);
|
|
1118
|
+
|
|
1097
1119
|
case 5:
|
|
1120
|
+
if (!(url === SENTRY_SAAS_URL)) {
|
|
1121
|
+
_context2.next = 7;
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
return _context2.abrupt("return", true);
|
|
1126
|
+
|
|
1127
|
+
case 7:
|
|
1128
|
+
cli = new SentryCli__default["default"](options.configFile, {
|
|
1129
|
+
url: url,
|
|
1130
|
+
authToken: authToken,
|
|
1131
|
+
org: org,
|
|
1132
|
+
project: project,
|
|
1133
|
+
vcsRemote: vcsRemote,
|
|
1134
|
+
dist: dist,
|
|
1135
|
+
silent: silent,
|
|
1136
|
+
customHeader: customHeader
|
|
1137
|
+
});
|
|
1138
|
+
_context2.prev = 8;
|
|
1139
|
+
_context2.next = 11;
|
|
1140
|
+
return cli.execute(["info"], false);
|
|
1141
|
+
|
|
1142
|
+
case 11:
|
|
1143
|
+
cliInfo = _context2.sent;
|
|
1144
|
+
_context2.next = 17;
|
|
1145
|
+
break;
|
|
1146
|
+
|
|
1147
|
+
case 14:
|
|
1148
|
+
_context2.prev = 14;
|
|
1149
|
+
_context2.t0 = _context2["catch"](8);
|
|
1150
|
+
throw new Error('Sentry CLI "info" command failed, make sure you have an auth token configured, and your `url` option is correct.');
|
|
1151
|
+
|
|
1152
|
+
case 17:
|
|
1153
|
+
cliInfoUrl = (_cliInfo$split$ = cliInfo.split(/(\r\n|\n|\r)/)[0]) === null || _cliInfo$split$ === void 0 ? void 0 : (_cliInfo$split$$repla = _cliInfo$split$.replace(/^Sentry Server: /, "")) === null || _cliInfo$split$$repla === void 0 ? void 0 : _cliInfo$split$$repla.trim();
|
|
1154
|
+
|
|
1155
|
+
if (!(cliInfoUrl === undefined)) {
|
|
1156
|
+
_context2.next = 20;
|
|
1157
|
+
break;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
return _context2.abrupt("return", false);
|
|
1161
|
+
|
|
1162
|
+
case 20:
|
|
1163
|
+
return _context2.abrupt("return", new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME);
|
|
1164
|
+
|
|
1165
|
+
case 21:
|
|
1098
1166
|
case "end":
|
|
1099
|
-
return
|
|
1167
|
+
return _context2.stop();
|
|
1100
1168
|
}
|
|
1101
1169
|
}
|
|
1102
|
-
},
|
|
1170
|
+
}, _callee2, null, [[8, 14]]);
|
|
1103
1171
|
}));
|
|
1104
|
-
return
|
|
1172
|
+
return _shouldSendTelemetry.apply(this, arguments);
|
|
1105
1173
|
}
|
|
1106
1174
|
|
|
1107
|
-
function createNewRelease(_x, _x2) {
|
|
1175
|
+
function createNewRelease(_x, _x2, _x3) {
|
|
1108
1176
|
return _createNewRelease.apply(this, arguments);
|
|
1109
1177
|
}
|
|
1110
1178
|
|
|
1111
1179
|
function _createNewRelease() {
|
|
1112
|
-
_createNewRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, ctx) {
|
|
1180
|
+
_createNewRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, ctx, releaseName) {
|
|
1113
1181
|
var span;
|
|
1114
1182
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1115
1183
|
while (1) {
|
|
1116
1184
|
switch (_context.prev = _context.next) {
|
|
1117
1185
|
case 0:
|
|
1118
1186
|
span = addSpanToTransaction(ctx, "function.plugin.create_release");
|
|
1119
|
-
_context.
|
|
1120
|
-
|
|
1187
|
+
_context.prev = 1;
|
|
1188
|
+
_context.next = 4;
|
|
1189
|
+
return ctx.cli.releases["new"](releaseName);
|
|
1121
1190
|
|
|
1122
|
-
case
|
|
1123
|
-
|
|
1191
|
+
case 4:
|
|
1192
|
+
_context.next = 10;
|
|
1193
|
+
break;
|
|
1194
|
+
|
|
1195
|
+
case 6:
|
|
1196
|
+
_context.prev = 6;
|
|
1197
|
+
_context.t0 = _context["catch"](1);
|
|
1198
|
+
ctx.hub.captureException(new Error("CLI Error: Creating new release failed"));
|
|
1199
|
+
throw _context.t0;
|
|
1200
|
+
|
|
1201
|
+
case 10:
|
|
1202
|
+
_context.prev = 10;
|
|
1124
1203
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1204
|
+
return _context.finish(10);
|
|
1125
1205
|
|
|
1126
|
-
case
|
|
1206
|
+
case 13:
|
|
1207
|
+
ctx.hub.addBreadcrumb({
|
|
1208
|
+
level: "info",
|
|
1209
|
+
message: "Successfully created release."
|
|
1210
|
+
});
|
|
1211
|
+
ctx.logger.info("Successfully created release.");
|
|
1212
|
+
|
|
1213
|
+
case 15:
|
|
1127
1214
|
case "end":
|
|
1128
1215
|
return _context.stop();
|
|
1129
1216
|
}
|
|
1130
1217
|
}
|
|
1131
|
-
}, _callee);
|
|
1218
|
+
}, _callee, null, [[1, 6, 10, 13]]);
|
|
1132
1219
|
}));
|
|
1133
1220
|
return _createNewRelease.apply(this, arguments);
|
|
1134
1221
|
}
|
|
1135
1222
|
|
|
1136
|
-
function cleanArtifacts(
|
|
1223
|
+
function cleanArtifacts(_x4, _x5, _x6) {
|
|
1137
1224
|
return _cleanArtifacts.apply(this, arguments);
|
|
1138
1225
|
}
|
|
1139
1226
|
|
|
1140
1227
|
function _cleanArtifacts() {
|
|
1141
|
-
_cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx) {
|
|
1228
|
+
_cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx, releaseName) {
|
|
1142
1229
|
var span;
|
|
1143
1230
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1144
1231
|
while (1) {
|
|
@@ -1154,29 +1241,48 @@ function _cleanArtifacts() {
|
|
|
1154
1241
|
|
|
1155
1242
|
case 3:
|
|
1156
1243
|
span = addSpanToTransaction(ctx, "function.plugin.clean_artifacts");
|
|
1157
|
-
_context2.
|
|
1158
|
-
|
|
1244
|
+
_context2.prev = 4;
|
|
1245
|
+
_context2.next = 7;
|
|
1246
|
+
return ctx.cli.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
|
|
1159
1247
|
|
|
1160
|
-
case
|
|
1161
|
-
|
|
1248
|
+
case 7:
|
|
1249
|
+
_context2.next = 13;
|
|
1250
|
+
break;
|
|
1251
|
+
|
|
1252
|
+
case 9:
|
|
1253
|
+
_context2.prev = 9;
|
|
1254
|
+
_context2.t0 = _context2["catch"](4);
|
|
1255
|
+
ctx.hub.captureException(new Error("CLI Error: Deleting release files failed"));
|
|
1256
|
+
throw _context2.t0;
|
|
1257
|
+
|
|
1258
|
+
case 13:
|
|
1259
|
+
_context2.prev = 13;
|
|
1162
1260
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1261
|
+
return _context2.finish(13);
|
|
1163
1262
|
|
|
1164
|
-
case
|
|
1263
|
+
case 16:
|
|
1264
|
+
ctx.hub.addBreadcrumb({
|
|
1265
|
+
level: "info",
|
|
1266
|
+
message: "Successfully cleaned previous artifacts."
|
|
1267
|
+
});
|
|
1268
|
+
ctx.logger.info("Successfully cleaned previous artifacts.");
|
|
1269
|
+
|
|
1270
|
+
case 18:
|
|
1165
1271
|
case "end":
|
|
1166
1272
|
return _context2.stop();
|
|
1167
1273
|
}
|
|
1168
1274
|
}
|
|
1169
|
-
}, _callee2);
|
|
1275
|
+
}, _callee2, null, [[4, 9, 13, 16]]);
|
|
1170
1276
|
}));
|
|
1171
1277
|
return _cleanArtifacts.apply(this, arguments);
|
|
1172
1278
|
}
|
|
1173
1279
|
|
|
1174
|
-
function uploadSourceMaps(
|
|
1280
|
+
function uploadSourceMaps(_x7, _x8, _x9) {
|
|
1175
1281
|
return _uploadSourceMaps.apply(this, arguments);
|
|
1176
1282
|
}
|
|
1177
1283
|
|
|
1178
1284
|
function _uploadSourceMaps() {
|
|
1179
|
-
_uploadSourceMaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, ctx) {
|
|
1285
|
+
_uploadSourceMaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, ctx, releaseName) {
|
|
1180
1286
|
var span;
|
|
1181
1287
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1182
1288
|
while (1) {
|
|
@@ -1186,31 +1292,50 @@ function _uploadSourceMaps() {
|
|
|
1186
1292
|
ctx.logger.info("Uploading Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
|
|
1187
1293
|
// we only need to pass the include option here.
|
|
1188
1294
|
|
|
1189
|
-
_context3.
|
|
1190
|
-
|
|
1295
|
+
_context3.prev = 2;
|
|
1296
|
+
_context3.next = 5;
|
|
1297
|
+
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1191
1298
|
include: options.include
|
|
1192
1299
|
});
|
|
1193
1300
|
|
|
1194
|
-
case
|
|
1195
|
-
|
|
1301
|
+
case 5:
|
|
1302
|
+
_context3.next = 11;
|
|
1303
|
+
break;
|
|
1304
|
+
|
|
1305
|
+
case 7:
|
|
1306
|
+
_context3.prev = 7;
|
|
1307
|
+
_context3.t0 = _context3["catch"](2);
|
|
1308
|
+
ctx.hub.captureException(new Error("CLI Error: Uploading source maps failed"));
|
|
1309
|
+
throw _context3.t0;
|
|
1310
|
+
|
|
1311
|
+
case 11:
|
|
1312
|
+
_context3.prev = 11;
|
|
1196
1313
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1314
|
+
return _context3.finish(11);
|
|
1197
1315
|
|
|
1198
|
-
case
|
|
1316
|
+
case 14:
|
|
1317
|
+
ctx.hub.addBreadcrumb({
|
|
1318
|
+
level: "info",
|
|
1319
|
+
message: "Successfully uploaded source maps."
|
|
1320
|
+
});
|
|
1321
|
+
ctx.logger.info("Successfully uploaded source maps.");
|
|
1322
|
+
|
|
1323
|
+
case 16:
|
|
1199
1324
|
case "end":
|
|
1200
1325
|
return _context3.stop();
|
|
1201
1326
|
}
|
|
1202
1327
|
}
|
|
1203
|
-
}, _callee3);
|
|
1328
|
+
}, _callee3, null, [[2, 7, 11, 14]]);
|
|
1204
1329
|
}));
|
|
1205
1330
|
return _uploadSourceMaps.apply(this, arguments);
|
|
1206
1331
|
}
|
|
1207
1332
|
|
|
1208
|
-
function setCommits(
|
|
1333
|
+
function setCommits(_x10, _x11, _x12) {
|
|
1209
1334
|
return _setCommits.apply(this, arguments);
|
|
1210
1335
|
}
|
|
1211
1336
|
|
|
1212
1337
|
function _setCommits() {
|
|
1213
|
-
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx) {
|
|
1338
|
+
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx, releaseName) {
|
|
1214
1339
|
var span, _options$setCommits, auto, repo, commit, previousCommit, ignoreMissing, ignoreEmpty;
|
|
1215
1340
|
|
|
1216
1341
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
@@ -1228,8 +1353,9 @@ function _setCommits() {
|
|
|
1228
1353
|
case 3:
|
|
1229
1354
|
span = addSpanToTransaction(ctx, "function.plugin.set_commits");
|
|
1230
1355
|
_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;
|
|
1231
|
-
_context4.
|
|
1232
|
-
|
|
1356
|
+
_context4.prev = 5;
|
|
1357
|
+
_context4.next = 8;
|
|
1358
|
+
return ctx.cli.releases.setCommits(releaseName, {
|
|
1233
1359
|
commit: commit,
|
|
1234
1360
|
previousCommit: previousCommit,
|
|
1235
1361
|
repo: repo,
|
|
@@ -1238,64 +1364,101 @@ function _setCommits() {
|
|
|
1238
1364
|
ignoreEmpty: ignoreEmpty
|
|
1239
1365
|
});
|
|
1240
1366
|
|
|
1241
|
-
case
|
|
1242
|
-
|
|
1367
|
+
case 8:
|
|
1368
|
+
_context4.next = 14;
|
|
1369
|
+
break;
|
|
1370
|
+
|
|
1371
|
+
case 10:
|
|
1372
|
+
_context4.prev = 10;
|
|
1373
|
+
_context4.t0 = _context4["catch"](5);
|
|
1374
|
+
ctx.hub.captureException(new Error("CLI Error: Setting commits failed"));
|
|
1375
|
+
throw _context4.t0;
|
|
1376
|
+
|
|
1377
|
+
case 14:
|
|
1378
|
+
_context4.prev = 14;
|
|
1243
1379
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1380
|
+
return _context4.finish(14);
|
|
1244
1381
|
|
|
1245
|
-
case
|
|
1382
|
+
case 17:
|
|
1383
|
+
ctx.logger.info("Successfully set commits.");
|
|
1384
|
+
|
|
1385
|
+
case 18:
|
|
1246
1386
|
case "end":
|
|
1247
1387
|
return _context4.stop();
|
|
1248
1388
|
}
|
|
1249
1389
|
}
|
|
1250
|
-
}, _callee4);
|
|
1390
|
+
}, _callee4, null, [[5, 10, 14, 17]]);
|
|
1251
1391
|
}));
|
|
1252
1392
|
return _setCommits.apply(this, arguments);
|
|
1253
1393
|
}
|
|
1254
1394
|
|
|
1255
|
-
function finalizeRelease(
|
|
1395
|
+
function finalizeRelease(_x13, _x14, _x15) {
|
|
1256
1396
|
return _finalizeRelease.apply(this, arguments);
|
|
1257
1397
|
}
|
|
1258
1398
|
|
|
1259
1399
|
function _finalizeRelease() {
|
|
1260
|
-
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx) {
|
|
1400
|
+
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx, releaseName) {
|
|
1261
1401
|
var span;
|
|
1262
1402
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1263
1403
|
while (1) {
|
|
1264
1404
|
switch (_context5.prev = _context5.next) {
|
|
1265
1405
|
case 0:
|
|
1266
1406
|
if (options.finalize) {
|
|
1267
|
-
_context5.next =
|
|
1407
|
+
_context5.next = 4;
|
|
1268
1408
|
break;
|
|
1269
1409
|
}
|
|
1270
1410
|
|
|
1411
|
+
ctx.hub.addBreadcrumb({
|
|
1412
|
+
level: "info",
|
|
1413
|
+
message: "Skipping release finalization."
|
|
1414
|
+
});
|
|
1271
1415
|
logger.debug("Skipping release finalization.");
|
|
1272
1416
|
return _context5.abrupt("return");
|
|
1273
1417
|
|
|
1274
|
-
case
|
|
1418
|
+
case 4:
|
|
1275
1419
|
span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
|
|
1276
|
-
_context5.
|
|
1277
|
-
|
|
1420
|
+
_context5.prev = 5;
|
|
1421
|
+
_context5.next = 8;
|
|
1422
|
+
return ctx.cli.releases.finalize(releaseName);
|
|
1278
1423
|
|
|
1279
|
-
case
|
|
1280
|
-
|
|
1424
|
+
case 8:
|
|
1425
|
+
_context5.next = 14;
|
|
1426
|
+
break;
|
|
1427
|
+
|
|
1428
|
+
case 10:
|
|
1429
|
+
_context5.prev = 10;
|
|
1430
|
+
_context5.t0 = _context5["catch"](5);
|
|
1431
|
+
ctx.hub.captureException(new Error("CLI Error: Finalizing release failed"));
|
|
1432
|
+
throw _context5.t0;
|
|
1433
|
+
|
|
1434
|
+
case 14:
|
|
1435
|
+
_context5.prev = 14;
|
|
1281
1436
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1437
|
+
return _context5.finish(14);
|
|
1282
1438
|
|
|
1283
|
-
case
|
|
1439
|
+
case 17:
|
|
1440
|
+
ctx.hub.addBreadcrumb({
|
|
1441
|
+
level: "info",
|
|
1442
|
+
message: "Successfully finalized release."
|
|
1443
|
+
});
|
|
1444
|
+
ctx.logger.info("Successfully finalized release.");
|
|
1445
|
+
|
|
1446
|
+
case 19:
|
|
1284
1447
|
case "end":
|
|
1285
1448
|
return _context5.stop();
|
|
1286
1449
|
}
|
|
1287
1450
|
}
|
|
1288
|
-
}, _callee5);
|
|
1451
|
+
}, _callee5, null, [[5, 10, 14, 17]]);
|
|
1289
1452
|
}));
|
|
1290
1453
|
return _finalizeRelease.apply(this, arguments);
|
|
1291
1454
|
}
|
|
1292
1455
|
|
|
1293
|
-
function addDeploy(
|
|
1456
|
+
function addDeploy(_x16, _x17, _x18) {
|
|
1294
1457
|
return _addDeploy.apply(this, arguments);
|
|
1295
1458
|
}
|
|
1296
1459
|
|
|
1297
1460
|
function _addDeploy() {
|
|
1298
|
-
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx) {
|
|
1461
|
+
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx, releaseName) {
|
|
1299
1462
|
var span, _options$deploy, env, started, finished, time, name, url;
|
|
1300
1463
|
|
|
1301
1464
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
@@ -1303,18 +1466,23 @@ function _addDeploy() {
|
|
|
1303
1466
|
switch (_context6.prev = _context6.next) {
|
|
1304
1467
|
case 0:
|
|
1305
1468
|
if (options.deploy) {
|
|
1306
|
-
_context6.next =
|
|
1469
|
+
_context6.next = 4;
|
|
1307
1470
|
break;
|
|
1308
1471
|
}
|
|
1309
1472
|
|
|
1473
|
+
ctx.hub.addBreadcrumb({
|
|
1474
|
+
level: "info",
|
|
1475
|
+
message: "Skipping adding deploy info to release."
|
|
1476
|
+
});
|
|
1310
1477
|
logger.debug("Skipping adding deploy info to release.");
|
|
1311
1478
|
return _context6.abrupt("return");
|
|
1312
1479
|
|
|
1313
|
-
case
|
|
1480
|
+
case 4:
|
|
1314
1481
|
span = addSpanToTransaction(ctx, "function.plugin.deploy");
|
|
1315
1482
|
_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;
|
|
1316
|
-
_context6.
|
|
1317
|
-
|
|
1483
|
+
_context6.prev = 6;
|
|
1484
|
+
_context6.next = 9;
|
|
1485
|
+
return ctx.cli.releases.newDeploy(releaseName, {
|
|
1318
1486
|
env: env,
|
|
1319
1487
|
started: started,
|
|
1320
1488
|
finished: finished,
|
|
@@ -1323,29 +1491,39 @@ function _addDeploy() {
|
|
|
1323
1491
|
url: url
|
|
1324
1492
|
});
|
|
1325
1493
|
|
|
1326
|
-
case
|
|
1327
|
-
|
|
1494
|
+
case 9:
|
|
1495
|
+
_context6.next = 15;
|
|
1496
|
+
break;
|
|
1497
|
+
|
|
1498
|
+
case 11:
|
|
1499
|
+
_context6.prev = 11;
|
|
1500
|
+
_context6.t0 = _context6["catch"](6);
|
|
1501
|
+
ctx.hub.captureException(new Error("CLI Error: Adding deploy info failed"));
|
|
1502
|
+
throw _context6.t0;
|
|
1503
|
+
|
|
1504
|
+
case 15:
|
|
1505
|
+
_context6.prev = 15;
|
|
1328
1506
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
1507
|
+
return _context6.finish(15);
|
|
1329
1508
|
|
|
1330
|
-
case
|
|
1509
|
+
case 18:
|
|
1510
|
+
ctx.hub.addBreadcrumb({
|
|
1511
|
+
level: "info",
|
|
1512
|
+
message: "Successfully added deploy."
|
|
1513
|
+
});
|
|
1514
|
+
ctx.logger.info("Successfully added deploy.");
|
|
1515
|
+
|
|
1516
|
+
case 20:
|
|
1331
1517
|
case "end":
|
|
1332
1518
|
return _context6.stop();
|
|
1333
1519
|
}
|
|
1334
1520
|
}
|
|
1335
|
-
}, _callee6);
|
|
1521
|
+
}, _callee6, null, [[6, 11, 15, 18]]);
|
|
1336
1522
|
}));
|
|
1337
1523
|
return _addDeploy.apply(this, arguments);
|
|
1338
1524
|
}
|
|
1339
1525
|
|
|
1340
1526
|
function createLogger(options) {
|
|
1341
|
-
function addBreadcrumb(level, message) {
|
|
1342
|
-
options.hub.addBreadcrumb({
|
|
1343
|
-
category: "logger",
|
|
1344
|
-
level: level,
|
|
1345
|
-
message: message
|
|
1346
|
-
});
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
1527
|
return {
|
|
1350
1528
|
info: function info(message) {
|
|
1351
1529
|
if (!options.silent) {
|
|
@@ -1358,8 +1536,6 @@ function createLogger(options) {
|
|
|
1358
1536
|
// eslint-disable-next-line no-console
|
|
1359
1537
|
(_console = console).log.apply(_console, ["".concat(options.prefix, " Info: ").concat(message)].concat(params));
|
|
1360
1538
|
}
|
|
1361
|
-
|
|
1362
|
-
addBreadcrumb("info", message);
|
|
1363
1539
|
},
|
|
1364
1540
|
warn: function warn(message) {
|
|
1365
1541
|
if (!options.silent) {
|
|
@@ -1372,8 +1548,6 @@ function createLogger(options) {
|
|
|
1372
1548
|
// eslint-disable-next-line no-console
|
|
1373
1549
|
(_console2 = console).log.apply(_console2, ["".concat(options.prefix, " Warning: ").concat(message)].concat(params));
|
|
1374
1550
|
}
|
|
1375
|
-
|
|
1376
|
-
addBreadcrumb("warning", message);
|
|
1377
1551
|
},
|
|
1378
1552
|
error: function error(message) {
|
|
1379
1553
|
if (!options.silent) {
|
|
@@ -1386,8 +1560,6 @@ function createLogger(options) {
|
|
|
1386
1560
|
// eslint-disable-next-line no-console
|
|
1387
1561
|
(_console3 = console).log.apply(_console3, ["".concat(options.prefix, " Error: ").concat(message)].concat(params));
|
|
1388
1562
|
}
|
|
1389
|
-
|
|
1390
|
-
addBreadcrumb("error", message);
|
|
1391
1563
|
},
|
|
1392
1564
|
debug: function debug(message) {
|
|
1393
1565
|
if (!options.silent && options.debug) {
|
|
@@ -1400,8 +1572,6 @@ function createLogger(options) {
|
|
|
1400
1572
|
// eslint-disable-next-line no-console
|
|
1401
1573
|
(_console4 = console).log.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params));
|
|
1402
1574
|
}
|
|
1403
|
-
|
|
1404
|
-
addBreadcrumb("debug", message);
|
|
1405
1575
|
}
|
|
1406
1576
|
};
|
|
1407
1577
|
}
|
|
@@ -1481,9 +1651,9 @@ function getDryRunCLI(cli, logger) {
|
|
|
1481
1651
|
};
|
|
1482
1652
|
}
|
|
1483
1653
|
|
|
1484
|
-
// We prefix the polyfill id with \0 to tell other plugins not to try to load or transform it.
|
|
1485
1654
|
// This hack is taken straight from https://rollupjs.org/guide/en/#resolveid.
|
|
1486
1655
|
// This probably doesn't work for all bundlers but for rollup it does.
|
|
1656
|
+
|
|
1487
1657
|
var RELEASE_INJECTOR_ID = "\0sentry-release-injector";
|
|
1488
1658
|
var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".cjs", ".mjs"];
|
|
1489
1659
|
/**
|
|
@@ -1516,13 +1686,20 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".cjs",
|
|
|
1516
1686
|
|
|
1517
1687
|
var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext) {
|
|
1518
1688
|
var internalOptions = normalizeUserOptions(options);
|
|
1689
|
+
var allowedToSendTelemetryPromise = shouldSendTelemetry(internalOptions);
|
|
1519
1690
|
|
|
1520
|
-
var _makeSentryClient = makeSentryClient("https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
1521
|
-
sentryHub = _makeSentryClient.
|
|
1691
|
+
var _makeSentryClient = makeSentryClient("https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737", allowedToSendTelemetryPromise),
|
|
1692
|
+
sentryHub = _makeSentryClient.sentryHub,
|
|
1693
|
+
sentryClient = _makeSentryClient.sentryClient;
|
|
1522
1694
|
|
|
1523
|
-
|
|
1695
|
+
addPluginOptionInformationToHub(internalOptions, sentryHub, unpluginMetaContext.framework); //TODO: This call is problematic because as soon as we set our hub as the current hub
|
|
1696
|
+
// we might interfere with other plugins that use Sentry. However, for now, we'll
|
|
1697
|
+
// leave it in because without it, we can't get distributed traces (which are pretty nice)
|
|
1698
|
+
// Let's keep it until someone complains about interference.
|
|
1699
|
+
// The ideal solution would be a code change in the JS SDK but it's not a straight-forward fix.
|
|
1700
|
+
|
|
1701
|
+
node.makeMain(sentryHub);
|
|
1524
1702
|
var logger = createLogger({
|
|
1525
|
-
hub: sentryHub,
|
|
1526
1703
|
prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
|
|
1527
1704
|
silent: internalOptions.silent,
|
|
1528
1705
|
debug: internalOptions.debug
|
|
@@ -1533,19 +1710,12 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1533
1710
|
}
|
|
1534
1711
|
|
|
1535
1712
|
var cli = getSentryCli(internalOptions, logger);
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
sentryHub.setTags({
|
|
1543
|
-
organization: internalOptions.org,
|
|
1544
|
-
project: internalOptions.project,
|
|
1545
|
-
bundler: unpluginMetaContext.framework
|
|
1546
|
-
});
|
|
1547
|
-
sentryHub.setUser({
|
|
1548
|
-
id: internalOptions.org
|
|
1713
|
+
var releaseNamePromise = new Promise(function (resolve) {
|
|
1714
|
+
if (options.release) {
|
|
1715
|
+
resolve(options.release);
|
|
1716
|
+
} else {
|
|
1717
|
+
resolve(cli.releases.proposeVersion());
|
|
1718
|
+
}
|
|
1549
1719
|
});
|
|
1550
1720
|
var transaction;
|
|
1551
1721
|
var releaseInjectionSpan;
|
|
@@ -1559,29 +1729,41 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1559
1729
|
*/
|
|
1560
1730
|
buildStart: function buildStart() {
|
|
1561
1731
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1732
|
+
var isAllowedToSendToSendTelemetry, releaseName;
|
|
1562
1733
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1563
1734
|
while (1) {
|
|
1564
1735
|
switch (_context.prev = _context.next) {
|
|
1565
1736
|
case 0:
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1737
|
+
logger.debug("Called 'buildStart'");
|
|
1738
|
+
_context.next = 3;
|
|
1739
|
+
return allowedToSendTelemetryPromise;
|
|
1740
|
+
|
|
1741
|
+
case 3:
|
|
1742
|
+
isAllowedToSendToSendTelemetry = _context.sent;
|
|
1743
|
+
|
|
1744
|
+
if (isAllowedToSendToSendTelemetry) {
|
|
1745
|
+
logger.info("Sending error and performance telemetry data to Sentry.");
|
|
1746
|
+
logger.info("To disable telemetry, set `options.telemetry` to `false`.");
|
|
1747
|
+
sentryHub.addBreadcrumb({
|
|
1748
|
+
level: "info",
|
|
1749
|
+
message: "Telemetry enabled."
|
|
1750
|
+
});
|
|
1751
|
+
} else {
|
|
1752
|
+
sentryHub.addBreadcrumb({
|
|
1753
|
+
level: "info",
|
|
1754
|
+
message: "Telemetry disabled. This should never show up in a Sentry event."
|
|
1755
|
+
});
|
|
1573
1756
|
}
|
|
1574
1757
|
|
|
1575
|
-
_context.next =
|
|
1576
|
-
return
|
|
1758
|
+
_context.next = 7;
|
|
1759
|
+
return releaseNamePromise;
|
|
1577
1760
|
|
|
1578
|
-
case
|
|
1579
|
-
|
|
1761
|
+
case 7:
|
|
1762
|
+
releaseName = _context.sent;
|
|
1580
1763
|
|
|
1581
|
-
case 6:
|
|
1582
1764
|
// At this point, we either have determined a release or we have to bail
|
|
1583
|
-
if (!
|
|
1584
|
-
handleError(new Error("Unable to determine a release name. Make sure to set the `release` option or use an environment that supports auto-detection https://docs.sentry.io/cli/releases/#creating-releases`"), logger, internalOptions.errorHandler
|
|
1765
|
+
if (!releaseName) {
|
|
1766
|
+
handleError(new Error("Unable to determine a release name. Make sure to set the `release` option or use an environment that supports auto-detection https://docs.sentry.io/cli/releases/#creating-releases`"), logger, internalOptions.errorHandler);
|
|
1585
1767
|
}
|
|
1586
1768
|
|
|
1587
1769
|
transaction = sentryHub.startTransaction({
|
|
@@ -1595,7 +1777,7 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1595
1777
|
cli: cli
|
|
1596
1778
|
}, "function.plugin.inject_release", "Release injection");
|
|
1597
1779
|
|
|
1598
|
-
case
|
|
1780
|
+
case 11:
|
|
1599
1781
|
case "end":
|
|
1600
1782
|
return _context.stop();
|
|
1601
1783
|
}
|
|
@@ -1617,10 +1799,10 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1617
1799
|
*/
|
|
1618
1800
|
resolveId: function resolveId(id, importer, _ref) {
|
|
1619
1801
|
var isEntry = _ref.isEntry;
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1802
|
+
logger.debug('Called "resolveId":', {
|
|
1803
|
+
id: id,
|
|
1804
|
+
importer: importer,
|
|
1805
|
+
isEntry: isEntry
|
|
1624
1806
|
});
|
|
1625
1807
|
|
|
1626
1808
|
if (id === RELEASE_INJECTOR_ID) {
|
|
@@ -1630,9 +1812,9 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1630
1812
|
}
|
|
1631
1813
|
},
|
|
1632
1814
|
loadInclude: function loadInclude(id) {
|
|
1633
|
-
logger.
|
|
1815
|
+
logger.debug('Called "loadInclude":', {
|
|
1634
1816
|
id: id
|
|
1635
|
-
})
|
|
1817
|
+
});
|
|
1636
1818
|
return id === RELEASE_INJECTOR_ID;
|
|
1637
1819
|
},
|
|
1638
1820
|
|
|
@@ -1644,21 +1826,47 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1644
1826
|
* @returns The global injector code when we load the "sentry-release-injector" module. Otherwise returns `undefined`.
|
|
1645
1827
|
*/
|
|
1646
1828
|
load: function load(id) {
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1829
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1830
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1831
|
+
while (1) {
|
|
1832
|
+
switch (_context2.prev = _context2.next) {
|
|
1833
|
+
case 0:
|
|
1834
|
+
logger.debug('Called "load":', {
|
|
1835
|
+
id: id
|
|
1836
|
+
});
|
|
1651
1837
|
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1838
|
+
if (!(id === RELEASE_INJECTOR_ID)) {
|
|
1839
|
+
_context2.next = 13;
|
|
1840
|
+
break;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
_context2.t0 = generateGlobalInjectorCode;
|
|
1844
|
+
_context2.next = 5;
|
|
1845
|
+
return releaseNamePromise;
|
|
1846
|
+
|
|
1847
|
+
case 5:
|
|
1848
|
+
_context2.t1 = _context2.sent;
|
|
1849
|
+
_context2.t2 = internalOptions.injectReleasesMap;
|
|
1850
|
+
_context2.t3 = internalOptions.org;
|
|
1851
|
+
_context2.t4 = internalOptions.project;
|
|
1852
|
+
_context2.t5 = {
|
|
1853
|
+
release: _context2.t1,
|
|
1854
|
+
injectReleasesMap: _context2.t2,
|
|
1855
|
+
org: _context2.t3,
|
|
1856
|
+
project: _context2.t4
|
|
1857
|
+
};
|
|
1858
|
+
return _context2.abrupt("return", (0, _context2.t0)(_context2.t5));
|
|
1859
|
+
|
|
1860
|
+
case 13:
|
|
1861
|
+
return _context2.abrupt("return", undefined);
|
|
1862
|
+
|
|
1863
|
+
case 14:
|
|
1864
|
+
case "end":
|
|
1865
|
+
return _context2.stop();
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}, _callee2);
|
|
1869
|
+
}))();
|
|
1662
1870
|
},
|
|
1663
1871
|
|
|
1664
1872
|
/**
|
|
@@ -1670,32 +1878,35 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1670
1878
|
* want to transform the release injector file.
|
|
1671
1879
|
*/
|
|
1672
1880
|
transformInclude: function transformInclude(id) {
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1881
|
+
logger.debug('Called "transformInclude":', {
|
|
1882
|
+
id: id
|
|
1883
|
+
}); // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
|
|
1884
|
+
// a windows style path to `releaseInjectionTargets`
|
|
1677
1885
|
|
|
1678
|
-
|
|
1886
|
+
var normalizedId = path__default["default"].normalize(id); // We don't want to transform our injected code.
|
|
1887
|
+
|
|
1888
|
+
if (normalizedId === RELEASE_INJECTOR_ID) {
|
|
1679
1889
|
return false;
|
|
1680
1890
|
}
|
|
1681
1891
|
|
|
1682
1892
|
if (internalOptions.releaseInjectionTargets) {
|
|
1683
1893
|
// If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
|
|
1684
1894
|
if (typeof internalOptions.releaseInjectionTargets === "function") {
|
|
1685
|
-
return internalOptions.releaseInjectionTargets(
|
|
1895
|
+
return internalOptions.releaseInjectionTargets(normalizedId);
|
|
1686
1896
|
}
|
|
1687
1897
|
|
|
1688
1898
|
return internalOptions.releaseInjectionTargets.some(function (entry) {
|
|
1689
1899
|
if (entry instanceof RegExp) {
|
|
1690
|
-
return entry.test(
|
|
1900
|
+
return entry.test(normalizedId);
|
|
1691
1901
|
} else {
|
|
1692
|
-
|
|
1902
|
+
var normalizedEntry = path__default["default"].normalize(entry);
|
|
1903
|
+
return normalizedId === normalizedEntry;
|
|
1693
1904
|
}
|
|
1694
1905
|
});
|
|
1695
1906
|
} else {
|
|
1696
|
-
var pathIsOrdinary = !
|
|
1907
|
+
var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
|
|
1697
1908
|
var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
|
|
1698
|
-
return
|
|
1909
|
+
return normalizedId.endsWith(allowedFileEnding);
|
|
1699
1910
|
});
|
|
1700
1911
|
return pathIsOrdinary && pathHasAllowedFileEnding;
|
|
1701
1912
|
}
|
|
@@ -1709,10 +1920,9 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1709
1920
|
* @param id Always the absolute (fully resolved) path to the module.
|
|
1710
1921
|
* @returns transformed code + source map
|
|
1711
1922
|
*/
|
|
1712
|
-
transform: function transform(code) {
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
level: "info"
|
|
1923
|
+
transform: function transform(code, id) {
|
|
1924
|
+
logger.debug('Called "transform":', {
|
|
1925
|
+
id: id
|
|
1716
1926
|
}); // The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
|
|
1717
1927
|
|
|
1718
1928
|
var ms = new MagicString__default["default"](code); // Appending instead of prepending has less probability of mucking with user's source maps.
|
|
@@ -1738,69 +1948,121 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1738
1948
|
* Sentry.io, uploading sourcemaps, associating commits and deploys and finalizing the release)
|
|
1739
1949
|
*/
|
|
1740
1950
|
writeBundle: function writeBundle() {
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1951
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1952
|
+
var _releaseInjectionSpan;
|
|
1953
|
+
|
|
1954
|
+
var releasePipelineSpan, ctx, releaseName, _transaction, _transaction2, _transaction3;
|
|
1955
|
+
|
|
1956
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1957
|
+
while (1) {
|
|
1958
|
+
switch (_context3.prev = _context3.next) {
|
|
1959
|
+
case 0:
|
|
1960
|
+
logger.debug('Called "writeBundle"');
|
|
1961
|
+
(_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
|
|
1962
|
+
releasePipelineSpan = transaction && addSpanToTransaction({
|
|
1963
|
+
hub: sentryHub,
|
|
1964
|
+
parentSpan: transaction,
|
|
1965
|
+
logger: logger,
|
|
1966
|
+
cli: cli
|
|
1967
|
+
}, "function.plugin.release", "Release pipeline");
|
|
1968
|
+
sentryHub.addBreadcrumb({
|
|
1969
|
+
category: "writeBundle:start",
|
|
1970
|
+
level: "info"
|
|
1971
|
+
});
|
|
1972
|
+
ctx = {
|
|
1973
|
+
hub: sentryHub,
|
|
1974
|
+
parentSpan: releasePipelineSpan,
|
|
1975
|
+
logger: logger,
|
|
1976
|
+
cli: cli
|
|
1977
|
+
};
|
|
1978
|
+
_context3.next = 7;
|
|
1979
|
+
return releaseNamePromise;
|
|
1980
|
+
|
|
1981
|
+
case 7:
|
|
1982
|
+
releaseName = _context3.sent;
|
|
1983
|
+
_context3.prev = 8;
|
|
1984
|
+
_context3.next = 11;
|
|
1985
|
+
return createNewRelease(internalOptions, ctx, releaseName);
|
|
1986
|
+
|
|
1987
|
+
case 11:
|
|
1988
|
+
_context3.next = 13;
|
|
1989
|
+
return cleanArtifacts(internalOptions, ctx, releaseName);
|
|
1990
|
+
|
|
1991
|
+
case 13:
|
|
1992
|
+
_context3.next = 15;
|
|
1993
|
+
return uploadSourceMaps(internalOptions, ctx, releaseName);
|
|
1994
|
+
|
|
1995
|
+
case 15:
|
|
1996
|
+
_context3.next = 17;
|
|
1997
|
+
return setCommits(internalOptions, ctx, releaseName);
|
|
1998
|
+
|
|
1999
|
+
case 17:
|
|
2000
|
+
_context3.next = 19;
|
|
2001
|
+
return finalizeRelease(internalOptions, ctx, releaseName);
|
|
2002
|
+
|
|
2003
|
+
case 19:
|
|
2004
|
+
_context3.next = 21;
|
|
2005
|
+
return addDeploy(internalOptions, ctx, releaseName);
|
|
2006
|
+
|
|
2007
|
+
case 21:
|
|
2008
|
+
(_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
|
|
2009
|
+
_context3.next = 29;
|
|
2010
|
+
break;
|
|
2011
|
+
|
|
2012
|
+
case 24:
|
|
2013
|
+
_context3.prev = 24;
|
|
2014
|
+
_context3.t0 = _context3["catch"](8);
|
|
2015
|
+
(_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
|
|
2016
|
+
sentryHub.addBreadcrumb({
|
|
2017
|
+
level: "error",
|
|
2018
|
+
message: "Error during writeBundle"
|
|
2019
|
+
});
|
|
2020
|
+
handleError(_context3.t0, logger, internalOptions.errorHandler);
|
|
2021
|
+
|
|
2022
|
+
case 29:
|
|
2023
|
+
_context3.prev = 29;
|
|
2024
|
+
releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
|
|
2025
|
+
(_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
|
|
2026
|
+
_context3.next = 34;
|
|
2027
|
+
return sentryClient.flush().then(null, function () {
|
|
2028
|
+
logger.warn("Sending of telemetry failed");
|
|
2029
|
+
});
|
|
2030
|
+
|
|
2031
|
+
case 34:
|
|
2032
|
+
return _context3.finish(29);
|
|
2033
|
+
|
|
2034
|
+
case 35:
|
|
2035
|
+
sentryHub.addBreadcrumb({
|
|
2036
|
+
category: "writeBundle:finish",
|
|
2037
|
+
level: "info"
|
|
2038
|
+
});
|
|
2039
|
+
|
|
2040
|
+
case 36:
|
|
2041
|
+
case "end":
|
|
2042
|
+
return _context3.stop();
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}, _callee3, null, [[8, 24, 29, 35]]);
|
|
2046
|
+
}))();
|
|
1789
2047
|
}
|
|
1790
2048
|
};
|
|
1791
2049
|
});
|
|
1792
2050
|
|
|
1793
|
-
function handleError(
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
2051
|
+
function handleError(unknownError, logger, errorHandler) {
|
|
2052
|
+
if (unknownError instanceof Error) {
|
|
2053
|
+
logger.error(unknownError.message);
|
|
2054
|
+
} else {
|
|
2055
|
+
logger.error(String(unknownError));
|
|
1798
2056
|
}
|
|
1799
2057
|
|
|
1800
2058
|
if (errorHandler) {
|
|
1801
|
-
|
|
2059
|
+
if (unknownError instanceof Error) {
|
|
2060
|
+
errorHandler(unknownError);
|
|
2061
|
+
} else {
|
|
2062
|
+
errorHandler(new Error("An unknown error occured"));
|
|
2063
|
+
}
|
|
1802
2064
|
} else {
|
|
1803
|
-
throw
|
|
2065
|
+
throw unknownError;
|
|
1804
2066
|
}
|
|
1805
2067
|
}
|
|
1806
2068
|
/**
|