@sentry/bundler-plugin-core 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +955 -1078
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +954 -1078
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/{plugins/debug-id-upload.d.ts → debug-id-upload.d.ts} +3 -4
- package/dist/types/index.d.ts +10 -1
- package/dist/types/options-mapping.d.ts +3 -3
- package/dist/types/plugins/telemetry.d.ts +3 -3
- package/dist/types/sentry/logger.d.ts +1 -1
- package/dist/types/types.d.ts +8 -6
- package/dist/types/utils.d.ts +2 -1
- package/package.json +4 -4
package/dist/esm/index.mjs
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import SentryCli from '@sentry/cli';
|
|
2
|
-
import fs from 'fs';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import fs__default from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import path__default from 'path';
|
|
3
6
|
import MagicString from 'magic-string';
|
|
4
7
|
import { createUnplugin } from 'unplugin';
|
|
5
|
-
import { glob } from 'glob';
|
|
6
|
-
import os from 'os';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import * as util from 'util';
|
|
9
|
-
import { promisify } from 'util';
|
|
10
8
|
import findUp from 'find-up';
|
|
9
|
+
import os from 'os';
|
|
11
10
|
import crypto from 'crypto';
|
|
12
11
|
import childProcess from 'child_process';
|
|
12
|
+
import { glob } from 'glob';
|
|
13
|
+
import * as util from 'util';
|
|
14
|
+
import { promisify } from 'util';
|
|
13
15
|
import { NodeClient, defaultStackParser, makeNodeTransport, Hub } from '@sentry/node';
|
|
14
16
|
|
|
15
17
|
function ownKeys(object, enumerableOnly) {
|
|
16
18
|
var keys = Object.keys(object);
|
|
17
|
-
|
|
18
19
|
if (Object.getOwnPropertySymbols) {
|
|
19
20
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
20
21
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
21
22
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
22
23
|
})), keys.push.apply(keys, symbols);
|
|
23
24
|
}
|
|
24
|
-
|
|
25
25
|
return keys;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
27
|
function _objectSpread2(target) {
|
|
29
28
|
for (var i = 1; i < arguments.length; i++) {
|
|
30
29
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -34,25 +33,22 @@ function _objectSpread2(target) {
|
|
|
34
33
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
return target;
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
function _regeneratorRuntime() {
|
|
42
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
43
|
-
|
|
44
39
|
_regeneratorRuntime = function () {
|
|
45
40
|
return exports;
|
|
46
41
|
};
|
|
47
|
-
|
|
48
42
|
var exports = {},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
Op = Object.prototype,
|
|
44
|
+
hasOwn = Op.hasOwnProperty,
|
|
45
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
46
|
+
obj[key] = desc.value;
|
|
47
|
+
},
|
|
48
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
49
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
50
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
51
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
56
52
|
function define(obj, key, value) {
|
|
57
53
|
return Object.defineProperty(obj, key, {
|
|
58
54
|
value: value,
|
|
@@ -61,7 +57,6 @@ function _regeneratorRuntime() {
|
|
|
61
57
|
writable: !0
|
|
62
58
|
}), obj[key];
|
|
63
59
|
}
|
|
64
|
-
|
|
65
60
|
try {
|
|
66
61
|
define({}, "");
|
|
67
62
|
} catch (err) {
|
|
@@ -69,54 +64,14 @@ function _regeneratorRuntime() {
|
|
|
69
64
|
return obj[key] = value;
|
|
70
65
|
};
|
|
71
66
|
}
|
|
72
|
-
|
|
73
67
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
74
68
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return generator
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
81
|
-
|
|
82
|
-
if ("completed" === state) {
|
|
83
|
-
if ("throw" === method) throw arg;
|
|
84
|
-
return doneResult();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
for (context.method = method, context.arg = arg;;) {
|
|
88
|
-
var delegate = context.delegate;
|
|
89
|
-
|
|
90
|
-
if (delegate) {
|
|
91
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
92
|
-
|
|
93
|
-
if (delegateResult) {
|
|
94
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
95
|
-
return delegateResult;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
100
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
101
|
-
context.dispatchException(context.arg);
|
|
102
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
103
|
-
state = "executing";
|
|
104
|
-
var record = tryCatch(innerFn, self, context);
|
|
105
|
-
|
|
106
|
-
if ("normal" === record.type) {
|
|
107
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
108
|
-
return {
|
|
109
|
-
value: record.arg,
|
|
110
|
-
done: context.done
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}(innerFn, self, context), generator;
|
|
69
|
+
generator = Object.create(protoGenerator.prototype),
|
|
70
|
+
context = new Context(tryLocsList || []);
|
|
71
|
+
return defineProperty(generator, "_invoke", {
|
|
72
|
+
value: makeInvokeMethod(innerFn, self, context)
|
|
73
|
+
}), generator;
|
|
118
74
|
}
|
|
119
|
-
|
|
120
75
|
function tryCatch(fn, obj, arg) {
|
|
121
76
|
try {
|
|
122
77
|
return {
|
|
@@ -130,25 +85,19 @@ function _regeneratorRuntime() {
|
|
|
130
85
|
};
|
|
131
86
|
}
|
|
132
87
|
}
|
|
133
|
-
|
|
134
88
|
exports.wrap = wrap;
|
|
135
89
|
var ContinueSentinel = {};
|
|
136
|
-
|
|
137
90
|
function Generator() {}
|
|
138
|
-
|
|
139
91
|
function GeneratorFunction() {}
|
|
140
|
-
|
|
141
92
|
function GeneratorFunctionPrototype() {}
|
|
142
|
-
|
|
143
93
|
var IteratorPrototype = {};
|
|
144
94
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
145
95
|
return this;
|
|
146
96
|
});
|
|
147
97
|
var getProto = Object.getPrototypeOf,
|
|
148
|
-
|
|
98
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
149
99
|
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
150
100
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
151
|
-
|
|
152
101
|
function defineIteratorMethods(prototype) {
|
|
153
102
|
["next", "throw", "return"].forEach(function (method) {
|
|
154
103
|
define(prototype, method, function (arg) {
|
|
@@ -156,14 +105,12 @@ function _regeneratorRuntime() {
|
|
|
156
105
|
});
|
|
157
106
|
});
|
|
158
107
|
}
|
|
159
|
-
|
|
160
108
|
function AsyncIterator(generator, PromiseImpl) {
|
|
161
109
|
function invoke(method, arg, resolve, reject) {
|
|
162
110
|
var record = tryCatch(generator[method], generator, arg);
|
|
163
|
-
|
|
164
111
|
if ("throw" !== record.type) {
|
|
165
112
|
var result = record.arg,
|
|
166
|
-
|
|
113
|
+
value = result.value;
|
|
167
114
|
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
168
115
|
invoke("next", value, resolve, reject);
|
|
169
116
|
}, function (err) {
|
|
@@ -174,90 +121,109 @@ function _regeneratorRuntime() {
|
|
|
174
121
|
return invoke("throw", error, resolve, reject);
|
|
175
122
|
});
|
|
176
123
|
}
|
|
177
|
-
|
|
178
124
|
reject(record.arg);
|
|
179
125
|
}
|
|
180
|
-
|
|
181
126
|
var previousPromise;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
127
|
+
defineProperty(this, "_invoke", {
|
|
128
|
+
value: function (method, arg) {
|
|
129
|
+
function callInvokeWithMethodAndArg() {
|
|
130
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
131
|
+
invoke(method, arg, resolve, reject);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
139
|
+
var state = "suspendedStart";
|
|
140
|
+
return function (method, arg) {
|
|
141
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
142
|
+
if ("completed" === state) {
|
|
143
|
+
if ("throw" === method) throw arg;
|
|
144
|
+
return doneResult();
|
|
145
|
+
}
|
|
146
|
+
for (context.method = method, context.arg = arg;;) {
|
|
147
|
+
var delegate = context.delegate;
|
|
148
|
+
if (delegate) {
|
|
149
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
150
|
+
if (delegateResult) {
|
|
151
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
152
|
+
return delegateResult;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
156
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
157
|
+
context.dispatchException(context.arg);
|
|
158
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
159
|
+
state = "executing";
|
|
160
|
+
var record = tryCatch(innerFn, self, context);
|
|
161
|
+
if ("normal" === record.type) {
|
|
162
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
163
|
+
return {
|
|
164
|
+
value: record.arg,
|
|
165
|
+
done: context.done
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
188
169
|
}
|
|
189
|
-
|
|
190
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
191
170
|
};
|
|
192
171
|
}
|
|
193
|
-
|
|
194
172
|
function maybeInvokeDelegate(delegate, context) {
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
if (undefined === method)
|
|
198
|
-
if (context.delegate = null, "throw" === context.method) {
|
|
199
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
200
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return ContinueSentinel;
|
|
204
|
-
}
|
|
205
|
-
|
|
173
|
+
var methodName = context.method,
|
|
174
|
+
method = delegate.iterator[methodName];
|
|
175
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
206
176
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
207
177
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
208
178
|
var info = record.arg;
|
|
209
179
|
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
210
180
|
}
|
|
211
|
-
|
|
212
181
|
function pushTryEntry(locs) {
|
|
213
182
|
var entry = {
|
|
214
183
|
tryLoc: locs[0]
|
|
215
184
|
};
|
|
216
185
|
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
217
186
|
}
|
|
218
|
-
|
|
219
187
|
function resetTryEntry(entry) {
|
|
220
188
|
var record = entry.completion || {};
|
|
221
189
|
record.type = "normal", delete record.arg, entry.completion = record;
|
|
222
190
|
}
|
|
223
|
-
|
|
224
191
|
function Context(tryLocsList) {
|
|
225
192
|
this.tryEntries = [{
|
|
226
193
|
tryLoc: "root"
|
|
227
194
|
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
228
195
|
}
|
|
229
|
-
|
|
230
196
|
function values(iterable) {
|
|
231
197
|
if (iterable) {
|
|
232
198
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
233
199
|
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
234
200
|
if ("function" == typeof iterable.next) return iterable;
|
|
235
|
-
|
|
236
201
|
if (!isNaN(iterable.length)) {
|
|
237
202
|
var i = -1,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
};
|
|
243
|
-
|
|
203
|
+
next = function next() {
|
|
204
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
205
|
+
return next.value = undefined, next.done = !0, next;
|
|
206
|
+
};
|
|
244
207
|
return next.next = next;
|
|
245
208
|
}
|
|
246
209
|
}
|
|
247
|
-
|
|
248
210
|
return {
|
|
249
211
|
next: doneResult
|
|
250
212
|
};
|
|
251
213
|
}
|
|
252
|
-
|
|
253
214
|
function doneResult() {
|
|
254
215
|
return {
|
|
255
216
|
value: undefined,
|
|
256
217
|
done: !0
|
|
257
218
|
};
|
|
258
219
|
}
|
|
259
|
-
|
|
260
|
-
|
|
220
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
221
|
+
value: GeneratorFunctionPrototype,
|
|
222
|
+
configurable: !0
|
|
223
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
224
|
+
value: GeneratorFunction,
|
|
225
|
+
configurable: !0
|
|
226
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
261
227
|
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
262
228
|
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
263
229
|
}, exports.mark = function (genFun) {
|
|
@@ -278,17 +244,15 @@ function _regeneratorRuntime() {
|
|
|
278
244
|
return this;
|
|
279
245
|
}), define(Gp, "toString", function () {
|
|
280
246
|
return "[object Generator]";
|
|
281
|
-
}), exports.keys = function (
|
|
282
|
-
var
|
|
283
|
-
|
|
247
|
+
}), exports.keys = function (val) {
|
|
248
|
+
var object = Object(val),
|
|
249
|
+
keys = [];
|
|
284
250
|
for (var key in object) keys.push(key);
|
|
285
|
-
|
|
286
251
|
return keys.reverse(), function next() {
|
|
287
252
|
for (; keys.length;) {
|
|
288
253
|
var key = keys.pop();
|
|
289
254
|
if (key in object) return next.value = key, next.done = !1, next;
|
|
290
255
|
}
|
|
291
|
-
|
|
292
256
|
return next.done = !0, next;
|
|
293
257
|
};
|
|
294
258
|
}, exports.values = values, Context.prototype = {
|
|
@@ -305,20 +269,16 @@ function _regeneratorRuntime() {
|
|
|
305
269
|
dispatchException: function (exception) {
|
|
306
270
|
if (this.done) throw exception;
|
|
307
271
|
var context = this;
|
|
308
|
-
|
|
309
272
|
function handle(loc, caught) {
|
|
310
273
|
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
311
274
|
}
|
|
312
|
-
|
|
313
275
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
314
276
|
var entry = this.tryEntries[i],
|
|
315
|
-
|
|
277
|
+
record = entry.completion;
|
|
316
278
|
if ("root" === entry.tryLoc) return handle("end");
|
|
317
|
-
|
|
318
279
|
if (entry.tryLoc <= this.prev) {
|
|
319
280
|
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
320
|
-
|
|
321
|
-
|
|
281
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
322
282
|
if (hasCatch && hasFinally) {
|
|
323
283
|
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
324
284
|
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
@@ -334,13 +294,11 @@ function _regeneratorRuntime() {
|
|
|
334
294
|
abrupt: function (type, arg) {
|
|
335
295
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
336
296
|
var entry = this.tryEntries[i];
|
|
337
|
-
|
|
338
297
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
339
298
|
var finallyEntry = entry;
|
|
340
299
|
break;
|
|
341
300
|
}
|
|
342
301
|
}
|
|
343
|
-
|
|
344
302
|
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
345
303
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
346
304
|
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
@@ -358,19 +316,15 @@ function _regeneratorRuntime() {
|
|
|
358
316
|
catch: function (tryLoc) {
|
|
359
317
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
360
318
|
var entry = this.tryEntries[i];
|
|
361
|
-
|
|
362
319
|
if (entry.tryLoc === tryLoc) {
|
|
363
320
|
var record = entry.completion;
|
|
364
|
-
|
|
365
321
|
if ("throw" === record.type) {
|
|
366
322
|
var thrown = record.arg;
|
|
367
323
|
resetTryEntry(entry);
|
|
368
324
|
}
|
|
369
|
-
|
|
370
325
|
return thrown;
|
|
371
326
|
}
|
|
372
327
|
}
|
|
373
|
-
|
|
374
328
|
throw new Error("illegal catch attempt");
|
|
375
329
|
},
|
|
376
330
|
delegateYield: function (iterable, resultName, nextLoc) {
|
|
@@ -382,7 +336,6 @@ function _regeneratorRuntime() {
|
|
|
382
336
|
}
|
|
383
337
|
}, exports;
|
|
384
338
|
}
|
|
385
|
-
|
|
386
339
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
387
340
|
try {
|
|
388
341
|
var info = gen[key](arg);
|
|
@@ -391,35 +344,30 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
391
344
|
reject(error);
|
|
392
345
|
return;
|
|
393
346
|
}
|
|
394
|
-
|
|
395
347
|
if (info.done) {
|
|
396
348
|
resolve(value);
|
|
397
349
|
} else {
|
|
398
350
|
Promise.resolve(value).then(_next, _throw);
|
|
399
351
|
}
|
|
400
352
|
}
|
|
401
|
-
|
|
402
353
|
function _asyncToGenerator(fn) {
|
|
403
354
|
return function () {
|
|
404
355
|
var self = this,
|
|
405
|
-
|
|
356
|
+
args = arguments;
|
|
406
357
|
return new Promise(function (resolve, reject) {
|
|
407
358
|
var gen = fn.apply(self, args);
|
|
408
|
-
|
|
409
359
|
function _next(value) {
|
|
410
360
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
411
361
|
}
|
|
412
|
-
|
|
413
362
|
function _throw(err) {
|
|
414
363
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
415
364
|
}
|
|
416
|
-
|
|
417
365
|
_next(undefined);
|
|
418
366
|
});
|
|
419
367
|
};
|
|
420
368
|
}
|
|
421
|
-
|
|
422
369
|
function _defineProperty(obj, key, value) {
|
|
370
|
+
key = _toPropertyKey(key);
|
|
423
371
|
if (key in obj) {
|
|
424
372
|
Object.defineProperty(obj, key, {
|
|
425
373
|
value: value,
|
|
@@ -430,787 +378,725 @@ function _defineProperty(obj, key, value) {
|
|
|
430
378
|
} else {
|
|
431
379
|
obj[key] = value;
|
|
432
380
|
}
|
|
433
|
-
|
|
434
381
|
return obj;
|
|
435
382
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
url: (_ref = (_userOptions$url = userOptions.url) !== null && _userOptions$url !== void 0 ? _userOptions$url : process.env["SENTRY_URL"]) !== null && _ref !== void 0 ? _ref : SENTRY_SAAS_URL,
|
|
446
|
-
headers: userOptions.headers,
|
|
447
|
-
debug: (_userOptions$debug = userOptions.debug) !== null && _userOptions$debug !== void 0 ? _userOptions$debug : false,
|
|
448
|
-
silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
|
|
449
|
-
errorHandler: userOptions.errorHandler,
|
|
450
|
-
telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
|
|
451
|
-
disable: (_userOptions$disable = userOptions.disable) !== null && _userOptions$disable !== void 0 ? _userOptions$disable : false,
|
|
452
|
-
sourcemaps: userOptions.sourcemaps,
|
|
453
|
-
release: _objectSpread2(_objectSpread2({}, userOptions.release), {}, {
|
|
454
|
-
inject: (_userOptions$release$ = (_userOptions$release = userOptions.release) === null || _userOptions$release === void 0 ? void 0 : _userOptions$release.inject) !== null && _userOptions$release$ !== void 0 ? _userOptions$release$ : true,
|
|
455
|
-
create: (_userOptions$release$2 = (_userOptions$release2 = userOptions.release) === null || _userOptions$release2 === void 0 ? void 0 : _userOptions$release2.create) !== null && _userOptions$release$2 !== void 0 ? _userOptions$release$2 : true,
|
|
456
|
-
finalize: (_userOptions$release$3 = (_userOptions$release3 = userOptions.release) === null || _userOptions$release3 === void 0 ? void 0 : _userOptions$release3.finalize) !== null && _userOptions$release$3 !== void 0 ? _userOptions$release$3 : true,
|
|
457
|
-
vcsRemote: (_ref2 = (_userOptions$release$4 = (_userOptions$release4 = userOptions.release) === null || _userOptions$release4 === void 0 ? void 0 : _userOptions$release4.vcsRemote) !== null && _userOptions$release$4 !== void 0 ? _userOptions$release$4 : process.env["SENTRY_VSC_REMOTE"]) !== null && _ref2 !== void 0 ? _ref2 : "origin",
|
|
458
|
-
cleanArtifacts: (_userOptions$release$5 = (_userOptions$release5 = userOptions.release) === null || _userOptions$release5 === void 0 ? void 0 : _userOptions$release5.cleanArtifacts) !== null && _userOptions$release$5 !== void 0 ? _userOptions$release$5 : false
|
|
459
|
-
}),
|
|
460
|
-
_experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
|
|
461
|
-
};
|
|
462
|
-
return options;
|
|
383
|
+
function _toPrimitive(input, hint) {
|
|
384
|
+
if (typeof input !== "object" || input === null) return input;
|
|
385
|
+
var prim = input[Symbol.toPrimitive];
|
|
386
|
+
if (prim !== undefined) {
|
|
387
|
+
var res = prim.call(input, hint || "default");
|
|
388
|
+
if (typeof res !== "object") return res;
|
|
389
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
390
|
+
}
|
|
391
|
+
return (hint === "string" ? String : Number)(input);
|
|
463
392
|
}
|
|
393
|
+
function _toPropertyKey(arg) {
|
|
394
|
+
var key = _toPrimitive(arg, "string");
|
|
395
|
+
return typeof key === "symbol" ? key : String(key);
|
|
396
|
+
}
|
|
397
|
+
|
|
464
398
|
/**
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
* For all other options, we can rely on Sentry CLI to validate them. In fact,
|
|
468
|
-
* we can't validate them in the plugin because Sentry CLI might pick up options from
|
|
469
|
-
* its config file.
|
|
470
|
-
*
|
|
471
|
-
* @param options the internal options
|
|
472
|
-
* @param logger the logger
|
|
399
|
+
* Checks whether the given input is already an array, and if it isn't, wraps it in one.
|
|
473
400
|
*
|
|
474
|
-
* @
|
|
401
|
+
* @param maybeArray Input to turn into an array, if necessary
|
|
402
|
+
* @returns The input, if already an array, or an array with the input as the only element, if not
|
|
403
|
+
*/
|
|
404
|
+
function arrayify(maybeArray) {
|
|
405
|
+
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Get the closes package.json from a given starting point upwards.
|
|
409
|
+
* This handles a few edge cases:
|
|
410
|
+
* * Check if a given file package.json appears to be an actual NPM package.json file
|
|
411
|
+
* * Stop at the home dir, to avoid looking too deeply
|
|
475
412
|
*/
|
|
413
|
+
function getPackageJson() {
|
|
414
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
415
|
+
cwd = _ref.cwd,
|
|
416
|
+
stopAt = _ref.stopAt;
|
|
417
|
+
return lookupPackageJson(cwd !== null && cwd !== void 0 ? cwd : process.cwd(), path__default.normalize(stopAt !== null && stopAt !== void 0 ? stopAt : os.homedir()));
|
|
418
|
+
}
|
|
419
|
+
function parseMajorVersion(version) {
|
|
420
|
+
// if it has a `v` prefix, remove it
|
|
421
|
+
if (version.startsWith("v")) {
|
|
422
|
+
version = version.slice(1);
|
|
423
|
+
}
|
|
476
424
|
|
|
477
|
-
|
|
478
|
-
var
|
|
425
|
+
// First, try simple lookup of exact, ~ and ^ versions
|
|
426
|
+
var regex = /^[\^~]?(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
427
|
+
var match = version.match(regex);
|
|
428
|
+
if (match) {
|
|
429
|
+
return parseInt(match[1], 10);
|
|
430
|
+
}
|
|
479
431
|
|
|
480
|
-
|
|
432
|
+
// Try to parse e.g. 1.x
|
|
433
|
+
var coerced = parseInt(version, 10);
|
|
434
|
+
if (!Number.isNaN(coerced)) {
|
|
435
|
+
return coerced;
|
|
436
|
+
}
|
|
481
437
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
438
|
+
// Match <= and >= ranges.
|
|
439
|
+
var gteLteRegex = /^[<>]=\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
440
|
+
var gteLteMatch = version.match(gteLteRegex);
|
|
441
|
+
if (gteLteMatch) {
|
|
442
|
+
return parseInt(gteLteMatch[1], 10);
|
|
443
|
+
}
|
|
487
444
|
|
|
488
|
-
|
|
489
|
-
|
|
445
|
+
// match < ranges
|
|
446
|
+
var ltRegex = /^<\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
447
|
+
var ltMatch = version.match(ltRegex);
|
|
448
|
+
if (ltMatch) {
|
|
449
|
+
// Two scenarios:
|
|
450
|
+
// a) < 2.0.0 --> return 1
|
|
451
|
+
// b) < 2.1.0 --> return 2
|
|
452
|
+
|
|
453
|
+
var major = parseInt(ltMatch[1], 10);
|
|
454
|
+
if (
|
|
455
|
+
// minor version > 0
|
|
456
|
+
typeof ltMatch[2] === "string" && parseInt(ltMatch[2].slice(1), 10) > 0 ||
|
|
457
|
+
// patch version > 0
|
|
458
|
+
typeof ltMatch[3] === "string" && parseInt(ltMatch[3].slice(1), 10) > 0) {
|
|
459
|
+
return major;
|
|
490
460
|
}
|
|
461
|
+
return major - 1;
|
|
491
462
|
}
|
|
492
463
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
464
|
+
// match > ranges
|
|
465
|
+
var gtRegex = /^>\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
466
|
+
var gtMatch = version.match(gtRegex);
|
|
467
|
+
if (gtMatch) {
|
|
468
|
+
// We always return the version here, even though it _may_ be incorrect
|
|
469
|
+
// E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3
|
|
470
|
+
// Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists
|
|
471
|
+
return parseInt(gtMatch[1], 10);
|
|
496
472
|
}
|
|
497
|
-
|
|
498
|
-
return true;
|
|
473
|
+
return undefined;
|
|
499
474
|
}
|
|
500
475
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
476
|
+
// This is an explicit list of packages where we want to include the (major) version number.
|
|
477
|
+
var PACKAGES_TO_INCLUDE_VERSION = ["react", "@angular/core", "vue", "ember-source", "svelte", "@sveltejs/kit", "webpack", "vite", "gatsby", "next", "remix", "rollup", "esbuild"];
|
|
478
|
+
function getDependencies(packageJson) {
|
|
479
|
+
var _packageJson$devDepen, _packageJson$dependen;
|
|
480
|
+
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 : {});
|
|
481
|
+
var deps = Object.keys(dependencies).sort();
|
|
482
|
+
var depsVersions = deps.reduce(function (depsVersions, depName) {
|
|
483
|
+
if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {
|
|
484
|
+
var version = dependencies[depName];
|
|
485
|
+
var majorVersion = parseMajorVersion(version);
|
|
486
|
+
if (majorVersion) {
|
|
487
|
+
depsVersions[depName] = majorVersion;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return depsVersions;
|
|
491
|
+
}, {});
|
|
513
492
|
return {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
ignore: ignore
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
case 8:
|
|
538
|
-
debugIdChunkFilePaths = _context2.sent.filter(function (debugIdChunkFilePath) {
|
|
539
|
-
return debugIdChunkFilePath.endsWith(".js") || debugIdChunkFilePath.endsWith(".mjs") || debugIdChunkFilePath.endsWith(".cjs");
|
|
540
|
-
});
|
|
541
|
-
_context2.next = 11;
|
|
542
|
-
return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
|
|
543
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(chunkFilePath, chunkIndex) {
|
|
544
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
545
|
-
while (1) {
|
|
546
|
-
switch (_context.prev = _context.next) {
|
|
547
|
-
case 0:
|
|
548
|
-
_context.next = 2;
|
|
549
|
-
return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, rewriteSourcesHook !== null && rewriteSourcesHook !== void 0 ? rewriteSourcesHook : defaultRewriteSourcesHook);
|
|
550
|
-
|
|
551
|
-
case 2:
|
|
552
|
-
case "end":
|
|
553
|
-
return _context.stop();
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}, _callee);
|
|
557
|
-
}));
|
|
558
|
-
|
|
559
|
-
return function (_x, _x2) {
|
|
560
|
-
return _ref2.apply(this, arguments);
|
|
561
|
-
};
|
|
562
|
-
}()));
|
|
493
|
+
deps: deps,
|
|
494
|
+
depsVersions: depsVersions
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
function lookupPackageJson(cwd, stopAt) {
|
|
498
|
+
var jsonPath = findUp.sync(function (dirName) {
|
|
499
|
+
// Stop if we reach this dir
|
|
500
|
+
if (path__default.normalize(dirName) === stopAt) {
|
|
501
|
+
return findUp.stop;
|
|
502
|
+
}
|
|
503
|
+
return findUp.sync.exists(dirName + "/package.json") ? "package.json" : undefined;
|
|
504
|
+
}, {
|
|
505
|
+
cwd: cwd
|
|
506
|
+
});
|
|
507
|
+
if (!jsonPath) {
|
|
508
|
+
return undefined;
|
|
509
|
+
}
|
|
510
|
+
try {
|
|
511
|
+
var jsonStr = fs__default.readFileSync(jsonPath, "utf8");
|
|
512
|
+
var json = JSON.parse(jsonStr);
|
|
563
513
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
}],
|
|
573
|
-
useArtifactBundle: true
|
|
574
|
-
});
|
|
514
|
+
// Ensure it is an actual package.json
|
|
515
|
+
// This is very much not bulletproof, but should be good enough
|
|
516
|
+
if ("name" in json || "private" in json) {
|
|
517
|
+
return json;
|
|
518
|
+
}
|
|
519
|
+
} catch (error) {
|
|
520
|
+
// Ignore and walk up
|
|
521
|
+
}
|
|
575
522
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
523
|
+
// Continue up the tree, if we find a fitting package.json
|
|
524
|
+
var newCwd = path__default.dirname(path__default.resolve(jsonPath + "/.."));
|
|
525
|
+
return lookupPackageJson(newCwd, stopAt);
|
|
526
|
+
}
|
|
581
527
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
528
|
+
/**
|
|
529
|
+
* Deterministically hashes a string and turns the hash into a uuid.
|
|
530
|
+
*/
|
|
531
|
+
function stringToUUID(str) {
|
|
532
|
+
var md5sum = crypto.createHash("md5");
|
|
533
|
+
md5sum.update(str);
|
|
534
|
+
var md5Hash = md5sum.digest("hex");
|
|
535
|
+
return (md5Hash.substring(0, 8) + "-" + md5Hash.substring(8, 12) + "-4" + md5Hash.substring(13, 16) + "-" + md5Hash.substring(16, 20) + "-" + md5Hash.substring(20)).toLowerCase();
|
|
536
|
+
}
|
|
587
537
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
_context2.prev = 28;
|
|
616
|
-
|
|
617
|
-
if (folderToCleanUp) {
|
|
618
|
-
void fs.promises.rm(folderToCleanUp, {
|
|
619
|
-
recursive: true,
|
|
620
|
-
force: true
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
return _context2.finish(28);
|
|
538
|
+
/**
|
|
539
|
+
* Tries to guess a release name based on environmental data.
|
|
540
|
+
*/
|
|
541
|
+
function determineReleaseName() {
|
|
542
|
+
var gitRevision;
|
|
543
|
+
try {
|
|
544
|
+
gitRevision = childProcess.execSync("git rev-parse --short HEAD").toString().trim();
|
|
545
|
+
} catch (e) {
|
|
546
|
+
// noop
|
|
547
|
+
}
|
|
548
|
+
return (
|
|
549
|
+
// GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
550
|
+
process.env["GITHUB_SHA"] ||
|
|
551
|
+
// Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
|
|
552
|
+
process.env["COMMIT_REF"] ||
|
|
553
|
+
// Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
|
|
554
|
+
process.env["CF_PAGES_COMMIT_SHA"] ||
|
|
555
|
+
// AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
|
556
|
+
process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] ||
|
|
557
|
+
// CircleCI - https://circleci.com/docs/2.0/env-vars/
|
|
558
|
+
process.env["CIRCLE_SHA1"] ||
|
|
559
|
+
// Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
|
|
560
|
+
process.env["VERCEL_GIT_COMMIT_SHA"] || process.env["VERCEL_GITHUB_COMMIT_SHA"] || process.env["VERCEL_GITLAB_COMMIT_SHA"] || process.env["VERCEL_BITBUCKET_COMMIT_SHA"] ||
|
|
561
|
+
// Zeit (now known as Vercel)
|
|
562
|
+
process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] || gitRevision
|
|
563
|
+
);
|
|
564
|
+
}
|
|
625
565
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
566
|
+
/**
|
|
567
|
+
* Generates code for the global injector which is responsible for setting the global
|
|
568
|
+
* `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
|
|
569
|
+
*/
|
|
570
|
+
function generateGlobalInjectorCode(_ref2) {
|
|
571
|
+
var release = _ref2.release,
|
|
572
|
+
injectBuildInformation = _ref2.injectBuildInformation;
|
|
573
|
+
// The code below is mostly ternary operators because it saves bundle size.
|
|
574
|
+
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
575
|
+
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, "\"};");
|
|
576
|
+
if (injectBuildInformation) {
|
|
577
|
+
var buildInfo = getBuildInformation$1();
|
|
578
|
+
code += "\n _global.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
|
|
579
|
+
}
|
|
580
|
+
return code;
|
|
581
|
+
}
|
|
582
|
+
function getBuildInformation$1() {
|
|
583
|
+
var packageJson = getPackageJson();
|
|
584
|
+
var _ref3 = packageJson ? getDependencies(packageJson) : {
|
|
585
|
+
deps: [],
|
|
586
|
+
depsVersions: {}
|
|
587
|
+
},
|
|
588
|
+
deps = _ref3.deps,
|
|
589
|
+
depsVersions = _ref3.depsVersions;
|
|
590
|
+
return {
|
|
591
|
+
deps: deps,
|
|
592
|
+
depsVersions: depsVersions,
|
|
593
|
+
nodeVersion: parseMajorVersion(process.version)
|
|
634
594
|
};
|
|
635
595
|
}
|
|
636
|
-
function
|
|
637
|
-
|
|
596
|
+
function stripQueryAndHashFromPath(path) {
|
|
597
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
598
|
+
return path.split("?")[0].split("#")[0];
|
|
638
599
|
}
|
|
639
|
-
/**
|
|
640
|
-
* Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle
|
|
641
|
-
* source and extracts the bundle's debug ID from it.
|
|
642
|
-
*
|
|
643
|
-
* The string pattern is injected via the debug ID injection snipped.
|
|
644
|
-
*/
|
|
645
|
-
|
|
646
|
-
function _prepareBundleForDebugIdUpload() {
|
|
647
|
-
_prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook) {
|
|
648
|
-
var bundleContent, debugId, uniqueUploadName, writeSourceFilePromise, writeSourceMapFilePromise;
|
|
649
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
650
|
-
while (1) {
|
|
651
|
-
switch (_context4.prev = _context4.next) {
|
|
652
|
-
case 0:
|
|
653
|
-
_context4.prev = 0;
|
|
654
|
-
_context4.next = 3;
|
|
655
|
-
return promisify(fs.readFile)(bundleFilePath, "utf8");
|
|
656
|
-
|
|
657
|
-
case 3:
|
|
658
|
-
bundleContent = _context4.sent;
|
|
659
|
-
_context4.next = 10;
|
|
660
|
-
break;
|
|
661
600
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
case 0:
|
|
689
|
-
if (!sourceMapPath) {
|
|
690
|
-
_context3.next = 4;
|
|
691
|
-
break;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
_context3.next = 3;
|
|
695
|
-
return prepareSourceMapForDebugIdUpload(sourceMapPath, path.join(uploadFolder, "".concat(uniqueUploadName, ".js.map")), debugId, rewriteSourcesHook, logger);
|
|
696
|
-
|
|
697
|
-
case 3:
|
|
698
|
-
return _context3.abrupt("return", _context3.sent);
|
|
699
|
-
|
|
700
|
-
case 4:
|
|
701
|
-
case "end":
|
|
702
|
-
return _context3.stop();
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
}, _callee3);
|
|
706
|
-
}));
|
|
707
|
-
|
|
708
|
-
return function (_x16) {
|
|
709
|
-
return _ref3.apply(this, arguments);
|
|
710
|
-
};
|
|
711
|
-
}());
|
|
712
|
-
return _context4.abrupt("return", Promise.all([writeSourceFilePromise, writeSourceMapFilePromise]));
|
|
713
|
-
|
|
714
|
-
case 19:
|
|
715
|
-
case "end":
|
|
716
|
-
return _context4.stop();
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
}, _callee4, null, [[0, 6]]);
|
|
720
|
-
}));
|
|
721
|
-
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
601
|
+
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
602
|
+
function normalizeUserOptions(userOptions) {
|
|
603
|
+
var _userOptions$org, _userOptions$project, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _userOptions$release$, _userOptions$release, _userOptions$release$2, _userOptions$release2, _userOptions$release$3, _userOptions$release3, _userOptions$release$4, _userOptions$release4, _ref2, _userOptions$release$5, _userOptions$release5, _userOptions$release$6, _userOptions$release6, _userOptions$_experim;
|
|
604
|
+
var options = {
|
|
605
|
+
org: (_userOptions$org = userOptions.org) !== null && _userOptions$org !== void 0 ? _userOptions$org : process.env["SENTRY_ORG"],
|
|
606
|
+
project: (_userOptions$project = userOptions.project) !== null && _userOptions$project !== void 0 ? _userOptions$project : process.env["SENTRY_PROJECT"],
|
|
607
|
+
authToken: (_userOptions$authToke = userOptions.authToken) !== null && _userOptions$authToke !== void 0 ? _userOptions$authToke : process.env["SENTRY_AUTH_TOKEN"],
|
|
608
|
+
url: (_ref = (_userOptions$url = userOptions.url) !== null && _userOptions$url !== void 0 ? _userOptions$url : process.env["SENTRY_URL"]) !== null && _ref !== void 0 ? _ref : SENTRY_SAAS_URL,
|
|
609
|
+
headers: userOptions.headers,
|
|
610
|
+
debug: (_userOptions$debug = userOptions.debug) !== null && _userOptions$debug !== void 0 ? _userOptions$debug : false,
|
|
611
|
+
silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
|
|
612
|
+
errorHandler: userOptions.errorHandler,
|
|
613
|
+
telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
|
|
614
|
+
disable: (_userOptions$disable = userOptions.disable) !== null && _userOptions$disable !== void 0 ? _userOptions$disable : false,
|
|
615
|
+
sourcemaps: userOptions.sourcemaps,
|
|
616
|
+
release: _objectSpread2(_objectSpread2({}, userOptions.release), {}, {
|
|
617
|
+
name: (_userOptions$release$ = (_userOptions$release = userOptions.release) === null || _userOptions$release === void 0 ? void 0 : _userOptions$release.name) !== null && _userOptions$release$ !== void 0 ? _userOptions$release$ : determineReleaseName(),
|
|
618
|
+
inject: (_userOptions$release$2 = (_userOptions$release2 = userOptions.release) === null || _userOptions$release2 === void 0 ? void 0 : _userOptions$release2.inject) !== null && _userOptions$release$2 !== void 0 ? _userOptions$release$2 : true,
|
|
619
|
+
create: (_userOptions$release$3 = (_userOptions$release3 = userOptions.release) === null || _userOptions$release3 === void 0 ? void 0 : _userOptions$release3.create) !== null && _userOptions$release$3 !== void 0 ? _userOptions$release$3 : true,
|
|
620
|
+
finalize: (_userOptions$release$4 = (_userOptions$release4 = userOptions.release) === null || _userOptions$release4 === void 0 ? void 0 : _userOptions$release4.finalize) !== null && _userOptions$release$4 !== void 0 ? _userOptions$release$4 : true,
|
|
621
|
+
vcsRemote: (_ref2 = (_userOptions$release$5 = (_userOptions$release5 = userOptions.release) === null || _userOptions$release5 === void 0 ? void 0 : _userOptions$release5.vcsRemote) !== null && _userOptions$release$5 !== void 0 ? _userOptions$release$5 : process.env["SENTRY_VSC_REMOTE"]) !== null && _ref2 !== void 0 ? _ref2 : "origin",
|
|
622
|
+
cleanArtifacts: (_userOptions$release$6 = (_userOptions$release6 = userOptions.release) === null || _userOptions$release6 === void 0 ? void 0 : _userOptions$release6.cleanArtifacts) !== null && _userOptions$release$6 !== void 0 ? _userOptions$release$6 : false
|
|
623
|
+
}),
|
|
624
|
+
_experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
|
|
625
|
+
};
|
|
626
|
+
return options;
|
|
722
627
|
}
|
|
723
628
|
|
|
724
|
-
function determineDebugIdFromBundleSource(code) {
|
|
725
|
-
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})/);
|
|
726
|
-
|
|
727
|
-
if (match) {
|
|
728
|
-
return match[1];
|
|
729
|
-
} else {
|
|
730
|
-
return undefined;
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
629
|
/**
|
|
734
|
-
*
|
|
630
|
+
* Validates a few combinations of options that are not checked by Sentry CLI.
|
|
735
631
|
*
|
|
736
|
-
*
|
|
632
|
+
* For all other options, we can rely on Sentry CLI to validate them. In fact,
|
|
633
|
+
* we can't validate them in the plugin because Sentry CLI might pick up options from
|
|
634
|
+
* its config file.
|
|
635
|
+
*
|
|
636
|
+
* @param options the internal options
|
|
637
|
+
* @param logger the logger
|
|
638
|
+
*
|
|
639
|
+
* @returns `true` if the options are valid, `false` otherwise
|
|
737
640
|
*/
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
641
|
+
function validateOptions(options, logger) {
|
|
642
|
+
var _options$release, _options$release2, _options$release3;
|
|
643
|
+
var setCommits = (_options$release = options.release) === null || _options$release === void 0 ? void 0 : _options$release.setCommits;
|
|
644
|
+
if (setCommits) {
|
|
645
|
+
if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {
|
|
646
|
+
logger.error("The `setCommits` option was specified but is missing required properties.", "Please set either `auto` or both, `repo` and `commit`.");
|
|
647
|
+
return false;
|
|
648
|
+
}
|
|
649
|
+
if (setCommits.auto && setCommits.repo && setCommits) {
|
|
650
|
+
logger.warn("The `setCommits` options includes `auto` but also `repo` and `commit`.", "Ignoring `repo` and `commit`.", "Please only set either `auto` or both, `repo` and `commit`.");
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
if ((_options$release2 = options.release) !== null && _options$release2 !== void 0 && _options$release2.deploy && !((_options$release3 = options.release) !== null && _options$release3 !== void 0 && _options$release3.deploy.env)) {
|
|
654
|
+
logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
return true;
|
|
742
658
|
}
|
|
743
|
-
/**
|
|
744
|
-
* Reads a source map, injects debug ID fields, and writes the source map to the target path.
|
|
745
|
-
*/
|
|
746
659
|
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
660
|
+
function createDebugIdUploadFunction(_ref) {
|
|
661
|
+
var assets = _ref.assets,
|
|
662
|
+
ignore = _ref.ignore,
|
|
663
|
+
logger = _ref.logger,
|
|
664
|
+
releaseName = _ref.releaseName,
|
|
665
|
+
dist = _ref.dist,
|
|
666
|
+
handleRecoverableError = _ref.handleRecoverableError,
|
|
667
|
+
sentryHub = _ref.sentryHub,
|
|
668
|
+
sentryClient = _ref.sentryClient,
|
|
669
|
+
sentryCliOptions = _ref.sentryCliOptions,
|
|
670
|
+
rewriteSourcesHook = _ref.rewriteSourcesHook,
|
|
671
|
+
deleteFilesAfterUpload = _ref.deleteFilesAfterUpload;
|
|
672
|
+
return /*#__PURE__*/function () {
|
|
673
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(buildArtifactPaths) {
|
|
674
|
+
var folderToCleanUp, cliInstance, tmpUploadFolder, globAssets, debugIdChunkFilePaths, filePathsToDelete;
|
|
675
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
676
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
754
677
|
case 0:
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
678
|
+
cliInstance = new SentryCli(null, sentryCliOptions);
|
|
679
|
+
_context2.prev = 1;
|
|
680
|
+
_context2.next = 4;
|
|
681
|
+
return fs__default.promises.mkdtemp(path__default.join(os.tmpdir(), "sentry-bundler-plugin-upload-"));
|
|
682
|
+
case 4:
|
|
683
|
+
tmpUploadFolder = _context2.sent;
|
|
684
|
+
folderToCleanUp = tmpUploadFolder;
|
|
685
|
+
if (assets) {
|
|
686
|
+
globAssets = assets;
|
|
687
|
+
} else {
|
|
688
|
+
logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
|
|
689
|
+
globAssets = buildArtifactPaths;
|
|
761
690
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
691
|
+
_context2.next = 9;
|
|
692
|
+
return glob(globAssets, {
|
|
693
|
+
absolute: true,
|
|
694
|
+
nodir: true,
|
|
695
|
+
ignore: ignore
|
|
696
|
+
});
|
|
697
|
+
case 9:
|
|
698
|
+
debugIdChunkFilePaths = _context2.sent.filter(function (debugIdChunkFilePath) {
|
|
699
|
+
return debugIdChunkFilePath.endsWith(".js") || debugIdChunkFilePath.endsWith(".mjs") || debugIdChunkFilePath.endsWith(".cjs");
|
|
700
|
+
});
|
|
701
|
+
if (!(Array.isArray(assets) && assets.length === 0)) {
|
|
702
|
+
_context2.next = 14;
|
|
767
703
|
break;
|
|
768
704
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
case 7:
|
|
773
|
-
return _context5.abrupt("return", path.join(path.dirname(bundlePath), sourceMappingUrl));
|
|
774
|
-
|
|
775
|
-
case 8:
|
|
776
|
-
_context5.prev = 8;
|
|
777
|
-
adjacentSourceMapFilePath = bundlePath + ".map";
|
|
778
|
-
_context5.next = 12;
|
|
779
|
-
return util.promisify(fs.access)(adjacentSourceMapFilePath);
|
|
780
|
-
|
|
781
|
-
case 12:
|
|
782
|
-
return _context5.abrupt("return", adjacentSourceMapFilePath);
|
|
783
|
-
|
|
784
|
-
case 15:
|
|
785
|
-
_context5.prev = 15;
|
|
786
|
-
_context5.t0 = _context5["catch"](8);
|
|
787
|
-
|
|
788
|
-
case 17:
|
|
789
|
-
// This is just a debug message because it can be quite spammy for some frameworks
|
|
790
|
-
logger.debug("Could not determine source map path for bundle: ".concat(bundlePath));
|
|
791
|
-
return _context5.abrupt("return", undefined);
|
|
792
|
-
|
|
793
|
-
case 19:
|
|
794
|
-
case "end":
|
|
795
|
-
return _context5.stop();
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
}, _callee5, null, [[8, 15]]);
|
|
799
|
-
}));
|
|
800
|
-
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
function prepareSourceMapForDebugIdUpload(_x11, _x12, _x13, _x14, _x15) {
|
|
804
|
-
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
function _prepareSourceMapForDebugIdUpload() {
|
|
808
|
-
_prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(sourceMapPath, targetPath, debugId, rewriteSourcesHook, logger) {
|
|
809
|
-
var sourceMapFileContent, map;
|
|
810
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
811
|
-
while (1) {
|
|
812
|
-
switch (_context6.prev = _context6.next) {
|
|
813
|
-
case 0:
|
|
814
|
-
_context6.prev = 0;
|
|
815
|
-
_context6.next = 3;
|
|
816
|
-
return util.promisify(fs.readFile)(sourceMapPath, {
|
|
817
|
-
encoding: "utf8"
|
|
818
|
-
});
|
|
819
|
-
|
|
820
|
-
case 3:
|
|
821
|
-
sourceMapFileContent = _context6.sent;
|
|
822
|
-
_context6.next = 10;
|
|
705
|
+
logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
|
|
706
|
+
_context2.next = 22;
|
|
823
707
|
break;
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
case 10:
|
|
832
|
-
_context6.prev = 10;
|
|
833
|
-
map = JSON.parse(sourceMapFileContent); // For now we write both fields until we know what will become the standard - if ever.
|
|
834
|
-
|
|
835
|
-
map["debug_id"] = debugId;
|
|
836
|
-
map["debugId"] = debugId;
|
|
837
|
-
_context6.next = 20;
|
|
708
|
+
case 14:
|
|
709
|
+
if (!(debugIdChunkFilePaths.length === 0)) {
|
|
710
|
+
_context2.next = 18;
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
|
|
714
|
+
_context2.next = 22;
|
|
838
715
|
break;
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
716
|
+
case 18:
|
|
717
|
+
_context2.next = 20;
|
|
718
|
+
return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
|
|
719
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(chunkFilePath, chunkIndex) {
|
|
720
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
721
|
+
while (1) switch (_context.prev = _context.next) {
|
|
722
|
+
case 0:
|
|
723
|
+
_context.next = 2;
|
|
724
|
+
return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, rewriteSourcesHook !== null && rewriteSourcesHook !== void 0 ? rewriteSourcesHook : defaultRewriteSourcesHook);
|
|
725
|
+
case 2:
|
|
726
|
+
case "end":
|
|
727
|
+
return _context.stop();
|
|
728
|
+
}
|
|
729
|
+
}, _callee);
|
|
730
|
+
}));
|
|
731
|
+
return function (_x2, _x3) {
|
|
732
|
+
return _ref3.apply(this, arguments);
|
|
733
|
+
};
|
|
734
|
+
}()));
|
|
846
735
|
case 20:
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
736
|
+
_context2.next = 22;
|
|
737
|
+
return cliInstance.releases.uploadSourceMaps(releaseName !== null && releaseName !== void 0 ? releaseName : "undefined",
|
|
738
|
+
// unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
|
|
739
|
+
{
|
|
740
|
+
include: [{
|
|
741
|
+
paths: [tmpUploadFolder],
|
|
742
|
+
rewrite: false,
|
|
743
|
+
dist: dist
|
|
744
|
+
}],
|
|
745
|
+
useArtifactBundle: true
|
|
746
|
+
});
|
|
747
|
+
case 22:
|
|
748
|
+
if (!deleteFilesAfterUpload) {
|
|
749
|
+
_context2.next = 29;
|
|
750
|
+
break;
|
|
851
751
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
encoding: "utf8"
|
|
752
|
+
_context2.next = 25;
|
|
753
|
+
return glob(deleteFilesAfterUpload, {
|
|
754
|
+
absolute: true,
|
|
755
|
+
nodir: true
|
|
857
756
|
});
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
757
|
+
case 25:
|
|
758
|
+
filePathsToDelete = _context2.sent;
|
|
759
|
+
filePathsToDelete.forEach(function (filePathToDelete) {
|
|
760
|
+
logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
|
|
761
|
+
});
|
|
762
|
+
_context2.next = 29;
|
|
763
|
+
return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
|
|
764
|
+
return fs__default.promises.rm(filePathToDelete, {
|
|
765
|
+
force: true
|
|
766
|
+
});
|
|
767
|
+
}));
|
|
768
|
+
case 29:
|
|
769
|
+
_context2.next = 37;
|
|
861
770
|
break;
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
return
|
|
868
|
-
|
|
869
|
-
|
|
771
|
+
case 31:
|
|
772
|
+
_context2.prev = 31;
|
|
773
|
+
_context2.t0 = _context2["catch"](1);
|
|
774
|
+
sentryHub.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
|
|
775
|
+
_context2.next = 36;
|
|
776
|
+
return sentryClient.flush();
|
|
777
|
+
case 36:
|
|
778
|
+
handleRecoverableError(_context2.t0);
|
|
779
|
+
case 37:
|
|
780
|
+
_context2.prev = 37;
|
|
781
|
+
if (folderToCleanUp) {
|
|
782
|
+
void fs__default.promises.rm(folderToCleanUp, {
|
|
783
|
+
recursive: true,
|
|
784
|
+
force: true
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
return _context2.finish(37);
|
|
788
|
+
case 40:
|
|
870
789
|
case "end":
|
|
871
|
-
return
|
|
790
|
+
return _context2.stop();
|
|
872
791
|
}
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
|
|
792
|
+
}, _callee2, null, [[1, 31, 37, 40]]);
|
|
793
|
+
}));
|
|
794
|
+
return function (_x) {
|
|
795
|
+
return _ref2.apply(this, arguments);
|
|
796
|
+
};
|
|
797
|
+
}();
|
|
877
798
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
function defaultRewriteSourcesHook(source) {
|
|
882
|
-
if (source.match(PROTOCOL_REGEX)) {
|
|
883
|
-
return source.replace(PROTOCOL_REGEX, "");
|
|
884
|
-
} else {
|
|
885
|
-
return path.relative(process.cwd(), path.normalize(source));
|
|
886
|
-
}
|
|
799
|
+
function prepareBundleForDebugIdUpload(_x4, _x5, _x6, _x7, _x8) {
|
|
800
|
+
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
887
801
|
}
|
|
888
802
|
|
|
889
803
|
/**
|
|
890
|
-
*
|
|
804
|
+
* Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle
|
|
805
|
+
* source and extracts the bundle's debug ID from it.
|
|
891
806
|
*
|
|
892
|
-
*
|
|
893
|
-
* @returns The input, if already an array, or an array with the input as the only element, if not
|
|
894
|
-
*/
|
|
895
|
-
|
|
896
|
-
function arrayify(maybeArray) {
|
|
897
|
-
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Get the closes package.json from a given starting point upwards.
|
|
902
|
-
* This handles a few edge cases:
|
|
903
|
-
* * Check if a given file package.json appears to be an actual NPM package.json file
|
|
904
|
-
* * Stop at the home dir, to avoid looking too deeply
|
|
807
|
+
* The string pattern is injected via the debug ID injection snipped.
|
|
905
808
|
*/
|
|
906
|
-
function
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
var gtMatch = version.match(gtRegex);
|
|
964
|
-
|
|
965
|
-
if (gtMatch) {
|
|
966
|
-
// We always return the version here, even though it _may_ be incorrect
|
|
967
|
-
// E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3
|
|
968
|
-
// Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists
|
|
969
|
-
return parseInt(gtMatch[1], 10);
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
return undefined;
|
|
973
|
-
} // This is an explicit list of packages where we want to include the (major) version number.
|
|
974
|
-
|
|
975
|
-
var PACKAGES_TO_INCLUDE_VERSION = ["react", "@angular/core", "vue", "ember-source", "svelte", "@sveltejs/kit", "webpack", "vite", "gatsby", "next", "remix", "rollup", "esbuild"];
|
|
976
|
-
function getDependencies(packageJson) {
|
|
977
|
-
var _packageJson$devDepen, _packageJson$dependen;
|
|
978
|
-
|
|
979
|
-
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 : {});
|
|
980
|
-
var deps = Object.keys(dependencies).sort();
|
|
981
|
-
var depsVersions = deps.reduce(function (depsVersions, depName) {
|
|
982
|
-
if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {
|
|
983
|
-
var version = dependencies[depName];
|
|
984
|
-
var majorVersion = parseMajorVersion(version);
|
|
985
|
-
|
|
986
|
-
if (majorVersion) {
|
|
987
|
-
depsVersions[depName] = majorVersion;
|
|
809
|
+
function _prepareBundleForDebugIdUpload() {
|
|
810
|
+
_prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook) {
|
|
811
|
+
var bundleContent, debugId, uniqueUploadName, writeSourceFilePromise, writeSourceMapFilePromise;
|
|
812
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
813
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
814
|
+
case 0:
|
|
815
|
+
_context4.prev = 0;
|
|
816
|
+
_context4.next = 3;
|
|
817
|
+
return promisify(fs__default.readFile)(bundleFilePath, "utf8");
|
|
818
|
+
case 3:
|
|
819
|
+
bundleContent = _context4.sent;
|
|
820
|
+
_context4.next = 10;
|
|
821
|
+
break;
|
|
822
|
+
case 6:
|
|
823
|
+
_context4.prev = 6;
|
|
824
|
+
_context4.t0 = _context4["catch"](0);
|
|
825
|
+
logger.error("Could not read bundle to determine debug ID and source map: ".concat(bundleFilePath), _context4.t0);
|
|
826
|
+
return _context4.abrupt("return");
|
|
827
|
+
case 10:
|
|
828
|
+
debugId = determineDebugIdFromBundleSource(bundleContent);
|
|
829
|
+
if (!(debugId === undefined)) {
|
|
830
|
+
_context4.next = 14;
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
logger.debug("Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ".concat(bundleFilePath));
|
|
834
|
+
return _context4.abrupt("return");
|
|
835
|
+
case 14:
|
|
836
|
+
uniqueUploadName = "".concat(debugId, "-").concat(chunkIndex);
|
|
837
|
+
bundleContent += "\n//# debugId=".concat(debugId);
|
|
838
|
+
writeSourceFilePromise = fs__default.promises.writeFile(path__default.join(uploadFolder, "".concat(uniqueUploadName, ".js")), bundleContent, "utf-8");
|
|
839
|
+
writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger).then( /*#__PURE__*/function () {
|
|
840
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sourceMapPath) {
|
|
841
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
842
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
843
|
+
case 0:
|
|
844
|
+
if (!sourceMapPath) {
|
|
845
|
+
_context3.next = 4;
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
_context3.next = 3;
|
|
849
|
+
return prepareSourceMapForDebugIdUpload(sourceMapPath, path__default.join(uploadFolder, "".concat(uniqueUploadName, ".js.map")), debugId, rewriteSourcesHook, logger);
|
|
850
|
+
case 3:
|
|
851
|
+
return _context3.abrupt("return", _context3.sent);
|
|
852
|
+
case 4:
|
|
853
|
+
case "end":
|
|
854
|
+
return _context3.stop();
|
|
855
|
+
}
|
|
856
|
+
}, _callee3);
|
|
857
|
+
}));
|
|
858
|
+
return function (_x17) {
|
|
859
|
+
return _ref4.apply(this, arguments);
|
|
860
|
+
};
|
|
861
|
+
}());
|
|
862
|
+
return _context4.abrupt("return", Promise.all([writeSourceFilePromise, writeSourceMapFilePromise]));
|
|
863
|
+
case 19:
|
|
864
|
+
case "end":
|
|
865
|
+
return _context4.stop();
|
|
988
866
|
}
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
}, {});
|
|
993
|
-
return {
|
|
994
|
-
deps: deps,
|
|
995
|
-
depsVersions: depsVersions
|
|
996
|
-
};
|
|
867
|
+
}, _callee4, null, [[0, 6]]);
|
|
868
|
+
}));
|
|
869
|
+
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
997
870
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
return findUp.stop;
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
return findUp.sync.exists(dirName + "/package.json") ? "package.json" : undefined;
|
|
1007
|
-
}, {
|
|
1008
|
-
cwd: cwd
|
|
1009
|
-
});
|
|
1010
|
-
|
|
1011
|
-
if (!jsonPath) {
|
|
871
|
+
function determineDebugIdFromBundleSource(code) {
|
|
872
|
+
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})/);
|
|
873
|
+
if (match) {
|
|
874
|
+
return match[1];
|
|
875
|
+
} else {
|
|
1012
876
|
return undefined;
|
|
1013
877
|
}
|
|
1014
|
-
|
|
1015
|
-
try {
|
|
1016
|
-
var jsonStr = fs.readFileSync(jsonPath, "utf8");
|
|
1017
|
-
var json = JSON.parse(jsonStr); // Ensure it is an actual package.json
|
|
1018
|
-
// This is very much not bulletproof, but should be good enough
|
|
1019
|
-
|
|
1020
|
-
if ("name" in json || "private" in json) {
|
|
1021
|
-
return json;
|
|
1022
|
-
}
|
|
1023
|
-
} catch (error) {// Ignore and walk up
|
|
1024
|
-
} // Continue up the tree, if we find a fitting package.json
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
var newCwd = path.dirname(path.resolve(jsonPath + "/.."));
|
|
1028
|
-
return lookupPackageJson(newCwd, stopAt);
|
|
1029
878
|
}
|
|
1030
|
-
/**
|
|
1031
|
-
* Deterministically hashes a string and turns the hash into a uuid.
|
|
1032
|
-
*/
|
|
1033
879
|
|
|
1034
|
-
|
|
1035
|
-
function stringToUUID(str) {
|
|
1036
|
-
var md5sum = crypto.createHash("md5");
|
|
1037
|
-
md5sum.update(str);
|
|
1038
|
-
var md5Hash = md5sum.digest("hex");
|
|
1039
|
-
return (md5Hash.substring(0, 8) + "-" + md5Hash.substring(8, 12) + "-4" + md5Hash.substring(13, 16) + "-" + md5Hash.substring(16, 20) + "-" + md5Hash.substring(20)).toLowerCase();
|
|
1040
|
-
}
|
|
1041
880
|
/**
|
|
1042
|
-
*
|
|
881
|
+
* Applies a set of heuristics to find the source map for a particular bundle.
|
|
882
|
+
*
|
|
883
|
+
* @returns the path to the bundle's source map or `undefined` if none could be found.
|
|
1043
884
|
*/
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
var gitRevision;
|
|
1047
|
-
|
|
1048
|
-
try {
|
|
1049
|
-
gitRevision = childProcess.execSync("git rev-parse --short HEAD").toString().trim();
|
|
1050
|
-
} catch (e) {// noop
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
return (// GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
1054
|
-
process.env["GITHUB_SHA"] || // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
|
|
1055
|
-
process.env["COMMIT_REF"] || // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
|
|
1056
|
-
process.env["CF_PAGES_COMMIT_SHA"] || // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
|
1057
|
-
process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] || // CircleCI - https://circleci.com/docs/2.0/env-vars/
|
|
1058
|
-
process.env["CIRCLE_SHA1"] || // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
|
|
1059
|
-
process.env["VERCEL_GIT_COMMIT_SHA"] || process.env["VERCEL_GITHUB_COMMIT_SHA"] || process.env["VERCEL_GITLAB_COMMIT_SHA"] || process.env["VERCEL_BITBUCKET_COMMIT_SHA"] || // Zeit (now known as Vercel)
|
|
1060
|
-
process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] || gitRevision
|
|
1061
|
-
);
|
|
885
|
+
function determineSourceMapPathFromBundle(_x9, _x10, _x11) {
|
|
886
|
+
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
1062
887
|
}
|
|
1063
888
|
/**
|
|
1064
|
-
*
|
|
1065
|
-
* `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
|
|
889
|
+
* Reads a source map, injects debug ID fields, and writes the source map to the target path.
|
|
1066
890
|
*/
|
|
1067
|
-
|
|
1068
|
-
function
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
891
|
+
function _determineSourceMapPathFromBundle() {
|
|
892
|
+
_determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(bundlePath, bundleSource, logger) {
|
|
893
|
+
var sourceMappingUrlMatch, sourceMappingUrl, adjacentSourceMapFilePath;
|
|
894
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
895
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
896
|
+
case 0:
|
|
897
|
+
// 1. try to find source map at `sourceMappingURL` location
|
|
898
|
+
sourceMappingUrlMatch = bundleSource.match(/^\/\/# sourceMappingURL=(.*)$/);
|
|
899
|
+
if (!sourceMappingUrlMatch) {
|
|
900
|
+
_context5.next = 8;
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
sourceMappingUrl = path__default.normalize(sourceMappingUrlMatch[1]);
|
|
904
|
+
if (!path__default.isAbsolute(sourceMappingUrl)) {
|
|
905
|
+
_context5.next = 7;
|
|
906
|
+
break;
|
|
907
|
+
}
|
|
908
|
+
return _context5.abrupt("return", sourceMappingUrl);
|
|
909
|
+
case 7:
|
|
910
|
+
return _context5.abrupt("return", path__default.join(path__default.dirname(bundlePath), sourceMappingUrl));
|
|
911
|
+
case 8:
|
|
912
|
+
_context5.prev = 8;
|
|
913
|
+
adjacentSourceMapFilePath = bundlePath + ".map";
|
|
914
|
+
_context5.next = 12;
|
|
915
|
+
return util.promisify(fs__default.access)(adjacentSourceMapFilePath);
|
|
916
|
+
case 12:
|
|
917
|
+
return _context5.abrupt("return", adjacentSourceMapFilePath);
|
|
918
|
+
case 15:
|
|
919
|
+
_context5.prev = 15;
|
|
920
|
+
_context5.t0 = _context5["catch"](8);
|
|
921
|
+
case 17:
|
|
922
|
+
// This is just a debug message because it can be quite spammy for some frameworks
|
|
923
|
+
logger.debug("Could not determine source map path for bundle: ".concat(bundlePath));
|
|
924
|
+
return _context5.abrupt("return", undefined);
|
|
925
|
+
case 19:
|
|
926
|
+
case "end":
|
|
927
|
+
return _context5.stop();
|
|
928
|
+
}
|
|
929
|
+
}, _callee5, null, [[8, 15]]);
|
|
930
|
+
}));
|
|
931
|
+
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
1081
932
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
933
|
+
function prepareSourceMapForDebugIdUpload(_x12, _x13, _x14, _x15, _x16) {
|
|
934
|
+
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
935
|
+
}
|
|
936
|
+
function _prepareSourceMapForDebugIdUpload() {
|
|
937
|
+
_prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(sourceMapPath, targetPath, debugId, rewriteSourcesHook, logger) {
|
|
938
|
+
var sourceMapFileContent, map;
|
|
939
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
940
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
941
|
+
case 0:
|
|
942
|
+
_context6.prev = 0;
|
|
943
|
+
_context6.next = 3;
|
|
944
|
+
return util.promisify(fs__default.readFile)(sourceMapPath, {
|
|
945
|
+
encoding: "utf8"
|
|
946
|
+
});
|
|
947
|
+
case 3:
|
|
948
|
+
sourceMapFileContent = _context6.sent;
|
|
949
|
+
_context6.next = 10;
|
|
950
|
+
break;
|
|
951
|
+
case 6:
|
|
952
|
+
_context6.prev = 6;
|
|
953
|
+
_context6.t0 = _context6["catch"](0);
|
|
954
|
+
logger.error("Failed to read source map for debug ID upload: ".concat(sourceMapPath), _context6.t0);
|
|
955
|
+
return _context6.abrupt("return");
|
|
956
|
+
case 10:
|
|
957
|
+
_context6.prev = 10;
|
|
958
|
+
map = JSON.parse(sourceMapFileContent);
|
|
959
|
+
// For now we write both fields until we know what will become the standard - if ever.
|
|
960
|
+
map["debug_id"] = debugId;
|
|
961
|
+
map["debugId"] = debugId;
|
|
962
|
+
_context6.next = 20;
|
|
963
|
+
break;
|
|
964
|
+
case 16:
|
|
965
|
+
_context6.prev = 16;
|
|
966
|
+
_context6.t1 = _context6["catch"](10);
|
|
967
|
+
logger.error("Failed to parse source map for debug ID upload: ".concat(sourceMapPath));
|
|
968
|
+
return _context6.abrupt("return");
|
|
969
|
+
case 20:
|
|
970
|
+
if (map["sources"] && Array.isArray(map["sources"])) {
|
|
971
|
+
map["sources"].map(function (source) {
|
|
972
|
+
return rewriteSourcesHook(source, map);
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
_context6.prev = 21;
|
|
976
|
+
_context6.next = 24;
|
|
977
|
+
return util.promisify(fs__default.writeFile)(targetPath, JSON.stringify(map), {
|
|
978
|
+
encoding: "utf8"
|
|
979
|
+
});
|
|
980
|
+
case 24:
|
|
981
|
+
_context6.next = 30;
|
|
982
|
+
break;
|
|
983
|
+
case 26:
|
|
984
|
+
_context6.prev = 26;
|
|
985
|
+
_context6.t2 = _context6["catch"](21);
|
|
986
|
+
logger.error("Failed to prepare source map for debug ID upload: ".concat(sourceMapPath), _context6.t2);
|
|
987
|
+
return _context6.abrupt("return");
|
|
988
|
+
case 30:
|
|
989
|
+
case "end":
|
|
990
|
+
return _context6.stop();
|
|
991
|
+
}
|
|
992
|
+
}, _callee6, null, [[0, 6], [10, 16], [21, 26]]);
|
|
993
|
+
}));
|
|
994
|
+
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
995
|
+
}
|
|
996
|
+
var PROTOCOL_REGEX = /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//;
|
|
997
|
+
function defaultRewriteSourcesHook(source) {
|
|
998
|
+
if (source.match(PROTOCOL_REGEX)) {
|
|
999
|
+
return source.replace(PROTOCOL_REGEX, "");
|
|
1000
|
+
} else {
|
|
1001
|
+
return path__default.relative(process.cwd(), path__default.normalize(source));
|
|
1002
|
+
}
|
|
1098
1003
|
}
|
|
1099
1004
|
|
|
1100
1005
|
function releaseManagementPlugin(_ref) {
|
|
1101
1006
|
var releaseName = _ref.releaseName,
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1007
|
+
include = _ref.include,
|
|
1008
|
+
dist = _ref.dist,
|
|
1009
|
+
setCommitsOption = _ref.setCommitsOption,
|
|
1010
|
+
shouldCreateRelease = _ref.shouldCreateRelease,
|
|
1011
|
+
shouldCleanArtifacts = _ref.shouldCleanArtifacts,
|
|
1012
|
+
shouldFinalizeRelease = _ref.shouldFinalizeRelease,
|
|
1013
|
+
deployOptions = _ref.deployOptions,
|
|
1014
|
+
handleRecoverableError = _ref.handleRecoverableError,
|
|
1015
|
+
sentryHub = _ref.sentryHub,
|
|
1016
|
+
sentryClient = _ref.sentryClient,
|
|
1017
|
+
sentryCliOptions = _ref.sentryCliOptions;
|
|
1113
1018
|
return {
|
|
1114
1019
|
name: "sentry-debug-id-upload-plugin",
|
|
1115
1020
|
writeBundle: function writeBundle() {
|
|
1116
1021
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1117
1022
|
var cliInstance, normalizedInclude;
|
|
1118
1023
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1119
|
-
while (1) {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
if (!shouldCreateRelease) {
|
|
1126
|
-
_context.next = 5;
|
|
1127
|
-
break;
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1024
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1025
|
+
case 0:
|
|
1026
|
+
_context.prev = 0;
|
|
1027
|
+
cliInstance = new SentryCli(null, sentryCliOptions);
|
|
1028
|
+
if (!shouldCreateRelease) {
|
|
1130
1029
|
_context.next = 5;
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1030
|
+
break;
|
|
1031
|
+
}
|
|
1032
|
+
_context.next = 5;
|
|
1033
|
+
return cliInstance.releases["new"](releaseName);
|
|
1034
|
+
case 5:
|
|
1035
|
+
if (!shouldCleanArtifacts) {
|
|
1139
1036
|
_context.next = 8;
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
normalizedInclude = arrayify(include).map(function (includeItem) {
|
|
1149
|
-
return typeof includeItem === "string" ? {
|
|
1150
|
-
paths: [includeItem]
|
|
1151
|
-
} : includeItem;
|
|
1152
|
-
}).map(function (includeEntry) {
|
|
1153
|
-
var _includeEntry$validat;
|
|
1154
|
-
|
|
1155
|
-
return _objectSpread2(_objectSpread2({}, includeEntry), {}, {
|
|
1156
|
-
validate: (_includeEntry$validat = includeEntry.validate) !== null && _includeEntry$validat !== void 0 ? _includeEntry$validat : false,
|
|
1157
|
-
ext: includeEntry.ext ? includeEntry.ext.map(function (extension) {
|
|
1158
|
-
return ".".concat(extension.replace(/^\./, ""));
|
|
1159
|
-
}) : [".js", ".map", ".jsbundle", ".bundle"],
|
|
1160
|
-
ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined
|
|
1161
|
-
});
|
|
1162
|
-
});
|
|
1037
|
+
break;
|
|
1038
|
+
}
|
|
1039
|
+
_context.next = 8;
|
|
1040
|
+
return cliInstance.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
|
|
1041
|
+
case 8:
|
|
1042
|
+
if (!include) {
|
|
1163
1043
|
_context.next = 12;
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1044
|
+
break;
|
|
1045
|
+
}
|
|
1046
|
+
normalizedInclude = arrayify(include).map(function (includeItem) {
|
|
1047
|
+
return typeof includeItem === "string" ? {
|
|
1048
|
+
paths: [includeItem]
|
|
1049
|
+
} : includeItem;
|
|
1050
|
+
}).map(function (includeEntry) {
|
|
1051
|
+
var _includeEntry$validat;
|
|
1052
|
+
return _objectSpread2(_objectSpread2({}, includeEntry), {}, {
|
|
1053
|
+
validate: (_includeEntry$validat = includeEntry.validate) !== null && _includeEntry$validat !== void 0 ? _includeEntry$validat : false,
|
|
1054
|
+
ext: includeEntry.ext ? includeEntry.ext.map(function (extension) {
|
|
1055
|
+
return ".".concat(extension.replace(/^\./, ""));
|
|
1056
|
+
}) : [".js", ".map", ".jsbundle", ".bundle"],
|
|
1057
|
+
ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined
|
|
1167
1058
|
});
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1059
|
+
});
|
|
1060
|
+
_context.next = 12;
|
|
1061
|
+
return cliInstance.releases.uploadSourceMaps(releaseName, {
|
|
1062
|
+
include: normalizedInclude,
|
|
1063
|
+
dist: dist
|
|
1064
|
+
});
|
|
1065
|
+
case 12:
|
|
1066
|
+
if (!setCommitsOption) {
|
|
1175
1067
|
_context.next = 15;
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1068
|
+
break;
|
|
1069
|
+
}
|
|
1070
|
+
_context.next = 15;
|
|
1071
|
+
return cliInstance.releases.setCommits(releaseName, setCommitsOption);
|
|
1072
|
+
case 15:
|
|
1073
|
+
if (!shouldFinalizeRelease) {
|
|
1184
1074
|
_context.next = 18;
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
_context.next = 18;
|
|
1078
|
+
return cliInstance.releases.finalize(releaseName);
|
|
1079
|
+
case 18:
|
|
1080
|
+
if (!deployOptions) {
|
|
1193
1081
|
_context.next = 21;
|
|
1194
|
-
return cliInstance.releases.newDeploy(releaseName, deployOptions);
|
|
1195
|
-
|
|
1196
|
-
case 21:
|
|
1197
|
-
_context.next = 29;
|
|
1198
1082
|
break;
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1083
|
+
}
|
|
1084
|
+
_context.next = 21;
|
|
1085
|
+
return cliInstance.releases.newDeploy(releaseName, deployOptions);
|
|
1086
|
+
case 21:
|
|
1087
|
+
_context.next = 29;
|
|
1088
|
+
break;
|
|
1089
|
+
case 23:
|
|
1090
|
+
_context.prev = 23;
|
|
1091
|
+
_context.t0 = _context["catch"](0);
|
|
1092
|
+
sentryHub.captureException('Error in "releaseManagementPlugin" writeBundle hook');
|
|
1093
|
+
_context.next = 28;
|
|
1094
|
+
return sentryClient.flush();
|
|
1095
|
+
case 28:
|
|
1096
|
+
handleRecoverableError(_context.t0);
|
|
1097
|
+
case 29:
|
|
1098
|
+
case "end":
|
|
1099
|
+
return _context.stop();
|
|
1214
1100
|
}
|
|
1215
1101
|
}, _callee, null, [[0, 23]]);
|
|
1216
1102
|
}))();
|
|
@@ -1219,32 +1105,33 @@ function releaseManagementPlugin(_ref) {
|
|
|
1219
1105
|
}
|
|
1220
1106
|
|
|
1221
1107
|
function telemetryPlugin(_ref) {
|
|
1222
|
-
var
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1108
|
+
var sentryHub = _ref.sentryHub,
|
|
1109
|
+
sentryClient = _ref.sentryClient,
|
|
1110
|
+
shouldSendTelemetry = _ref.shouldSendTelemetry,
|
|
1111
|
+
logger = _ref.logger;
|
|
1226
1112
|
return {
|
|
1227
1113
|
name: "sentry-telemetry-plugin",
|
|
1228
1114
|
buildStart: function buildStart() {
|
|
1229
|
-
void shouldSendTelemetry.then(function () {
|
|
1230
|
-
logger.info("Sending error and performance telemetry data to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
|
|
1231
|
-
});
|
|
1232
|
-
pluginExecutionTransaction.startTimestamp = Date.now() / 1000;
|
|
1233
|
-
},
|
|
1234
|
-
writeBundle: function writeBundle() {
|
|
1235
1115
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1236
1116
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1237
|
-
while (1) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1117
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1118
|
+
case 0:
|
|
1119
|
+
_context.next = 2;
|
|
1120
|
+
return shouldSendTelemetry;
|
|
1121
|
+
case 2:
|
|
1122
|
+
if (!_context.sent) {
|
|
1123
|
+
_context.next = 7;
|
|
1124
|
+
break;
|
|
1125
|
+
}
|
|
1126
|
+
logger.info("Sending error and performance telemetry data to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
|
|
1127
|
+
sentryHub.startTransaction({
|
|
1128
|
+
name: "Sentry Bundler Plugin execution"
|
|
1129
|
+
}).finish();
|
|
1130
|
+
_context.next = 7;
|
|
1131
|
+
return sentryClient.flush(3000);
|
|
1132
|
+
case 7:
|
|
1133
|
+
case "end":
|
|
1134
|
+
return _context.stop();
|
|
1248
1135
|
}
|
|
1249
1136
|
}, _callee);
|
|
1250
1137
|
}))();
|
|
@@ -1257,11 +1144,9 @@ function createLogger(options) {
|
|
|
1257
1144
|
info: function info(message) {
|
|
1258
1145
|
if (!options.silent) {
|
|
1259
1146
|
var _console;
|
|
1260
|
-
|
|
1261
1147
|
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1262
1148
|
params[_key - 1] = arguments[_key];
|
|
1263
1149
|
}
|
|
1264
|
-
|
|
1265
1150
|
// eslint-disable-next-line no-console
|
|
1266
1151
|
(_console = console).log.apply(_console, ["".concat(options.prefix, " Info: ").concat(message)].concat(params));
|
|
1267
1152
|
}
|
|
@@ -1269,11 +1154,9 @@ function createLogger(options) {
|
|
|
1269
1154
|
warn: function warn(message) {
|
|
1270
1155
|
if (!options.silent) {
|
|
1271
1156
|
var _console2;
|
|
1272
|
-
|
|
1273
1157
|
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1274
1158
|
params[_key2 - 1] = arguments[_key2];
|
|
1275
1159
|
}
|
|
1276
|
-
|
|
1277
1160
|
// eslint-disable-next-line no-console
|
|
1278
1161
|
(_console2 = console).log.apply(_console2, ["".concat(options.prefix, " Warning: ").concat(message)].concat(params));
|
|
1279
1162
|
}
|
|
@@ -1281,11 +1164,9 @@ function createLogger(options) {
|
|
|
1281
1164
|
error: function error(message) {
|
|
1282
1165
|
if (!options.silent) {
|
|
1283
1166
|
var _console3;
|
|
1284
|
-
|
|
1285
1167
|
for (var _len3 = arguments.length, params = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
1286
1168
|
params[_key3 - 1] = arguments[_key3];
|
|
1287
1169
|
}
|
|
1288
|
-
|
|
1289
1170
|
// eslint-disable-next-line no-console
|
|
1290
1171
|
(_console3 = console).log.apply(_console3, ["".concat(options.prefix, " Error: ").concat(message)].concat(params));
|
|
1291
1172
|
}
|
|
@@ -1293,11 +1174,9 @@ function createLogger(options) {
|
|
|
1293
1174
|
debug: function debug(message) {
|
|
1294
1175
|
if (!options.silent && options.debug) {
|
|
1295
1176
|
var _console4;
|
|
1296
|
-
|
|
1297
1177
|
for (var _len4 = arguments.length, params = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
1298
1178
|
params[_key4 - 1] = arguments[_key4];
|
|
1299
1179
|
}
|
|
1300
|
-
|
|
1301
1180
|
// eslint-disable-next-line no-console
|
|
1302
1181
|
(_console4 = console).log.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params));
|
|
1303
1182
|
}
|
|
@@ -1311,23 +1190,20 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
|
|
|
1311
1190
|
dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
1312
1191
|
tracesSampleRate: 1,
|
|
1313
1192
|
sampleRate: 1,
|
|
1314
|
-
release: "2.
|
|
1193
|
+
release: "2.2.0",
|
|
1315
1194
|
integrations: [],
|
|
1316
1195
|
tracePropagationTargets: ["sentry.io/api"],
|
|
1317
1196
|
stackParser: defaultStackParser,
|
|
1318
1197
|
beforeSend: function beforeSend(event) {
|
|
1319
1198
|
var _event$exception, _event$exception$valu;
|
|
1320
|
-
|
|
1321
1199
|
(_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) {
|
|
1322
1200
|
delete exception.stacktrace;
|
|
1323
1201
|
});
|
|
1324
1202
|
delete event.server_name; // Server name might contain PII
|
|
1325
|
-
|
|
1326
1203
|
return event;
|
|
1327
1204
|
},
|
|
1328
1205
|
beforeSendTransaction: function beforeSendTransaction(event) {
|
|
1329
1206
|
delete event.server_name; // Server name might contain PII
|
|
1330
|
-
|
|
1331
1207
|
return event;
|
|
1332
1208
|
},
|
|
1333
1209
|
// We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
|
|
@@ -1341,35 +1217,27 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
|
|
|
1341
1217
|
send: function () {
|
|
1342
1218
|
var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
|
1343
1219
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1344
|
-
while (1) {
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
return _context.abrupt("return", undefined);
|
|
1360
|
-
|
|
1361
|
-
case 7:
|
|
1362
|
-
case "end":
|
|
1363
|
-
return _context.stop();
|
|
1364
|
-
}
|
|
1220
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1221
|
+
case 0:
|
|
1222
|
+
_context.next = 2;
|
|
1223
|
+
return shouldSendTelemetry;
|
|
1224
|
+
case 2:
|
|
1225
|
+
if (!_context.sent) {
|
|
1226
|
+
_context.next = 6;
|
|
1227
|
+
break;
|
|
1228
|
+
}
|
|
1229
|
+
return _context.abrupt("return", nodeTransport.send(request));
|
|
1230
|
+
case 6:
|
|
1231
|
+
return _context.abrupt("return", undefined);
|
|
1232
|
+
case 7:
|
|
1233
|
+
case "end":
|
|
1234
|
+
return _context.stop();
|
|
1365
1235
|
}
|
|
1366
1236
|
}, _callee);
|
|
1367
1237
|
}));
|
|
1368
|
-
|
|
1369
1238
|
function send(_x) {
|
|
1370
1239
|
return _send.apply(this, arguments);
|
|
1371
1240
|
}
|
|
1372
|
-
|
|
1373
1241
|
return send;
|
|
1374
1242
|
}()
|
|
1375
1243
|
};
|
|
@@ -1384,45 +1252,29 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
|
|
|
1384
1252
|
}
|
|
1385
1253
|
function setTelemetryDataOnHub(options, hub, bundler) {
|
|
1386
1254
|
var org = options.org,
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1255
|
+
project = options.project,
|
|
1256
|
+
release = options.release,
|
|
1257
|
+
errorHandler = options.errorHandler,
|
|
1258
|
+
sourcemaps = options.sourcemaps;
|
|
1259
|
+
hub.setTag("upload-legacy-sourcemaps", !!release.uploadLegacySourcemaps);
|
|
1392
1260
|
if (release.uploadLegacySourcemaps) {
|
|
1393
1261
|
hub.setTag("uploadLegacySourcemapsEntries", Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1);
|
|
1394
|
-
} // Optional release pipeline steps
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
if (release.cleanArtifacts) {
|
|
1398
|
-
hub.setTag("clean-artifacts", true);
|
|
1399
1262
|
}
|
|
1400
1263
|
|
|
1264
|
+
// Optional release pipeline steps
|
|
1265
|
+
hub.setTag("clean-artifacts", release.cleanArtifacts);
|
|
1401
1266
|
if (release.setCommits) {
|
|
1402
1267
|
hub.setTag("set-commits", release.setCommits.auto === true ? "auto" : "manual");
|
|
1268
|
+
} else {
|
|
1269
|
+
hub.setTag("set-commits", "undefined");
|
|
1403
1270
|
}
|
|
1271
|
+
hub.setTag("finalize-release", release.finalize);
|
|
1272
|
+
hub.setTag("deploy-options", !!release.deploy);
|
|
1404
1273
|
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
if (release.deploy) {
|
|
1410
|
-
hub.setTag("add-deploy", true);
|
|
1411
|
-
} // Miscelaneous options
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
if (errorHandler) {
|
|
1415
|
-
hub.setTag("error-handler", "custom");
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
if (sourcemaps !== null && sourcemaps !== void 0 && sourcemaps.assets) {
|
|
1419
|
-
hub.setTag("debug-id-upload", true);
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
if (sourcemaps !== null && sourcemaps !== void 0 && sourcemaps.deleteFilesAfterUpload) {
|
|
1423
|
-
hub.setTag("delete-after-upload", true);
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1274
|
+
// Miscelaneous options
|
|
1275
|
+
hub.setTag("custom-error-handler", !!errorHandler);
|
|
1276
|
+
hub.setTag("sourcemaps-assets", !!(sourcemaps !== null && sourcemaps !== void 0 && sourcemaps.assets));
|
|
1277
|
+
hub.setTag("delete-after-upload", !!(sourcemaps !== null && sourcemaps !== void 0 && sourcemaps.deleteFilesAfterUpload));
|
|
1426
1278
|
hub.setTag("node", process.version);
|
|
1427
1279
|
hub.setTags({
|
|
1428
1280
|
organization: org,
|
|
@@ -1436,74 +1288,58 @@ function setTelemetryDataOnHub(options, hub, bundler) {
|
|
|
1436
1288
|
function allowedToSendTelemetry(_x2) {
|
|
1437
1289
|
return _allowedToSendTelemetry.apply(this, arguments);
|
|
1438
1290
|
}
|
|
1439
|
-
|
|
1440
1291
|
function _allowedToSendTelemetry() {
|
|
1441
1292
|
_allowedToSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1442
1293
|
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1443
|
-
|
|
1444
1294
|
var silent, org, project, authToken, url, headers, telemetry, release, cli, cliInfo, cliInfoUrl;
|
|
1445
1295
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1446
|
-
while (1) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
if (!(telemetry === false)) {
|
|
1452
|
-
_context2.next = 3;
|
|
1453
|
-
break;
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
return _context2.abrupt("return", false);
|
|
1457
|
-
|
|
1458
|
-
case 3:
|
|
1459
|
-
if (!(url === SENTRY_SAAS_URL)) {
|
|
1460
|
-
_context2.next = 5;
|
|
1461
|
-
break;
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
return _context2.abrupt("return", true);
|
|
1465
|
-
|
|
1466
|
-
case 5:
|
|
1467
|
-
cli = new SentryCli(null, {
|
|
1468
|
-
url: url,
|
|
1469
|
-
authToken: authToken,
|
|
1470
|
-
org: org,
|
|
1471
|
-
project: project,
|
|
1472
|
-
vcsRemote: release.vcsRemote,
|
|
1473
|
-
silent: silent,
|
|
1474
|
-
headers: headers
|
|
1475
|
-
});
|
|
1476
|
-
_context2.prev = 6;
|
|
1477
|
-
_context2.next = 9;
|
|
1478
|
-
return cli.execute(["info"], false);
|
|
1479
|
-
|
|
1480
|
-
case 9:
|
|
1481
|
-
cliInfo = _context2.sent;
|
|
1482
|
-
_context2.next = 15;
|
|
1296
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1297
|
+
case 0:
|
|
1298
|
+
silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, headers = options.headers, telemetry = options.telemetry, release = options.release; // `options.telemetry` defaults to true
|
|
1299
|
+
if (!(telemetry === false)) {
|
|
1300
|
+
_context2.next = 3;
|
|
1483
1301
|
break;
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1302
|
+
}
|
|
1303
|
+
return _context2.abrupt("return", false);
|
|
1304
|
+
case 3:
|
|
1305
|
+
if (!(url === SENTRY_SAAS_URL)) {
|
|
1306
|
+
_context2.next = 5;
|
|
1307
|
+
break;
|
|
1308
|
+
}
|
|
1309
|
+
return _context2.abrupt("return", true);
|
|
1310
|
+
case 5:
|
|
1311
|
+
cli = new SentryCli(null, {
|
|
1312
|
+
url: url,
|
|
1313
|
+
authToken: authToken,
|
|
1314
|
+
org: org,
|
|
1315
|
+
project: project,
|
|
1316
|
+
vcsRemote: release.vcsRemote,
|
|
1317
|
+
silent: silent,
|
|
1318
|
+
headers: headers
|
|
1319
|
+
});
|
|
1320
|
+
_context2.prev = 6;
|
|
1321
|
+
_context2.next = 9;
|
|
1322
|
+
return cli.execute(["info"], false);
|
|
1323
|
+
case 9:
|
|
1324
|
+
cliInfo = _context2.sent;
|
|
1325
|
+
_context2.next = 15;
|
|
1326
|
+
break;
|
|
1327
|
+
case 12:
|
|
1328
|
+
_context2.prev = 12;
|
|
1329
|
+
_context2.t0 = _context2["catch"](6);
|
|
1330
|
+
return _context2.abrupt("return", false);
|
|
1331
|
+
case 15:
|
|
1332
|
+
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();
|
|
1333
|
+
if (!(cliInfoUrl === undefined)) {
|
|
1334
|
+
_context2.next = 18;
|
|
1335
|
+
break;
|
|
1336
|
+
}
|
|
1337
|
+
return _context2.abrupt("return", false);
|
|
1338
|
+
case 18:
|
|
1339
|
+
return _context2.abrupt("return", new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME);
|
|
1340
|
+
case 19:
|
|
1341
|
+
case "end":
|
|
1342
|
+
return _context2.stop();
|
|
1507
1343
|
}
|
|
1508
1344
|
}, _callee2, null, [[6, 12]]);
|
|
1509
1345
|
}));
|
|
@@ -1539,64 +1375,69 @@ function _allowedToSendTelemetry() {
|
|
|
1539
1375
|
*/
|
|
1540
1376
|
function sentryUnpluginFactory(_ref) {
|
|
1541
1377
|
var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
|
|
1542
|
-
|
|
1378
|
+
debugIdInjectionPlugin = _ref.debugIdInjectionPlugin,
|
|
1379
|
+
debugIdUploadPlugin = _ref.debugIdUploadPlugin;
|
|
1543
1380
|
return createUnplugin(function (userOptions, unpluginMetaContext) {
|
|
1544
|
-
var _options$release$name;
|
|
1545
|
-
|
|
1546
1381
|
var options = normalizeUserOptions(userOptions);
|
|
1547
|
-
|
|
1548
1382
|
if (unpluginMetaContext.watchMode || options.disable) {
|
|
1549
1383
|
return [{
|
|
1550
1384
|
name: "sentry-noop-plugin"
|
|
1551
1385
|
}];
|
|
1552
1386
|
}
|
|
1553
|
-
|
|
1554
1387
|
var shouldSendTelemetry = allowedToSendTelemetry(options);
|
|
1555
|
-
|
|
1556
1388
|
var _createSentryInstance = createSentryInstance(options, shouldSendTelemetry, unpluginMetaContext.framework),
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1389
|
+
sentryHub = _createSentryInstance.sentryHub,
|
|
1390
|
+
sentryClient = _createSentryInstance.sentryClient;
|
|
1391
|
+
var sentrySession = sentryHub.startSession();
|
|
1392
|
+
sentryHub.captureSession();
|
|
1393
|
+
var sentEndSession = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out
|
|
1394
|
+
// We also need to manually end sesisons on errors because beforeExit is not called on crashes
|
|
1395
|
+
process.on("beforeExit", function () {
|
|
1396
|
+
if (!sentEndSession) {
|
|
1397
|
+
sentryHub.endSession();
|
|
1398
|
+
sentEndSession = true;
|
|
1399
|
+
}
|
|
1562
1400
|
});
|
|
1563
|
-
sentryHub.getScope().setSpan(pluginExecutionTransaction);
|
|
1564
1401
|
var logger = createLogger({
|
|
1565
1402
|
prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
|
|
1566
1403
|
silent: options.silent,
|
|
1567
1404
|
debug: options.debug
|
|
1568
1405
|
});
|
|
1569
|
-
|
|
1570
1406
|
function handleRecoverableError(unknownError) {
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1407
|
+
sentrySession.status = "abnormal";
|
|
1408
|
+
try {
|
|
1409
|
+
if (options.errorHandler) {
|
|
1410
|
+
try {
|
|
1411
|
+
if (unknownError instanceof Error) {
|
|
1412
|
+
options.errorHandler(unknownError);
|
|
1413
|
+
} else {
|
|
1414
|
+
options.errorHandler(new Error("An unknown error occured"));
|
|
1415
|
+
}
|
|
1416
|
+
} catch (e) {
|
|
1417
|
+
sentrySession.status = "crashed";
|
|
1418
|
+
throw e;
|
|
1419
|
+
}
|
|
1576
1420
|
} else {
|
|
1577
|
-
|
|
1421
|
+
sentrySession.status = "crashed";
|
|
1422
|
+
throw unknownError;
|
|
1578
1423
|
}
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1424
|
+
} finally {
|
|
1425
|
+
sentryHub.endSession();
|
|
1581
1426
|
}
|
|
1582
1427
|
}
|
|
1583
|
-
|
|
1584
1428
|
if (!validateOptions(options, logger)) {
|
|
1585
1429
|
handleRecoverableError(new Error("Options were not set correctly. See output above for more details."));
|
|
1586
1430
|
}
|
|
1587
|
-
|
|
1588
1431
|
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) {
|
|
1589
1432
|
logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
1590
1433
|
}
|
|
1591
|
-
|
|
1592
1434
|
var plugins = [];
|
|
1593
1435
|
plugins.push(telemetryPlugin({
|
|
1594
|
-
|
|
1436
|
+
sentryClient: sentryClient,
|
|
1437
|
+
sentryHub: sentryHub,
|
|
1595
1438
|
logger: logger,
|
|
1596
|
-
shouldSendTelemetry: shouldSendTelemetry
|
|
1597
|
-
sentryClient: sentryClient
|
|
1439
|
+
shouldSendTelemetry: shouldSendTelemetry
|
|
1598
1440
|
}));
|
|
1599
|
-
|
|
1600
1441
|
if (!options.release.inject) {
|
|
1601
1442
|
logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
1602
1443
|
} else if (!options.release.name) {
|
|
@@ -1606,13 +1447,9 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1606
1447
|
release: options.release.name,
|
|
1607
1448
|
injectBuildInformation: options._experiments.injectBuildInformation || false
|
|
1608
1449
|
});
|
|
1609
|
-
|
|
1610
1450
|
plugins.push(releaseInjectionPlugin(_injectionCode));
|
|
1611
1451
|
}
|
|
1612
|
-
|
|
1613
|
-
var releaseManagementPluginReleaseName = (_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : determineReleaseName();
|
|
1614
|
-
|
|
1615
|
-
if (!releaseManagementPluginReleaseName) {
|
|
1452
|
+
if (!options.release.name) {
|
|
1616
1453
|
logger.warn("No release name provided. Will not create release. Please set the `release.name` option to identifiy your release.");
|
|
1617
1454
|
} else if (!options.authToken) {
|
|
1618
1455
|
logger.warn("No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/");
|
|
@@ -1623,7 +1460,7 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1623
1460
|
} else {
|
|
1624
1461
|
plugins.push(releaseManagementPlugin({
|
|
1625
1462
|
logger: logger,
|
|
1626
|
-
releaseName:
|
|
1463
|
+
releaseName: options.release.name,
|
|
1627
1464
|
shouldCreateRelease: options.release.create,
|
|
1628
1465
|
shouldCleanArtifacts: options.release.cleanArtifacts,
|
|
1629
1466
|
shouldFinalizeRelease: options.release.finalize,
|
|
@@ -1645,67 +1482,60 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1645
1482
|
}
|
|
1646
1483
|
}));
|
|
1647
1484
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
headers: options.headers
|
|
1679
|
-
}
|
|
1680
|
-
}));
|
|
1681
|
-
}
|
|
1485
|
+
if (!options.authToken) {
|
|
1486
|
+
logger.warn("No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/");
|
|
1487
|
+
} else if (!options.org) {
|
|
1488
|
+
logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug.");
|
|
1489
|
+
} else if (!options.project) {
|
|
1490
|
+
logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug.");
|
|
1491
|
+
} else {
|
|
1492
|
+
var _options$sourcemaps, _options$sourcemaps2, _options$sourcemaps3, _options$sourcemaps4;
|
|
1493
|
+
plugins.push(debugIdInjectionPlugin());
|
|
1494
|
+
plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
|
|
1495
|
+
assets: (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets,
|
|
1496
|
+
ignore: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.ignore,
|
|
1497
|
+
deleteFilesAfterUpload: (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.deleteFilesAfterUpload,
|
|
1498
|
+
dist: options.release.dist,
|
|
1499
|
+
releaseName: options.release.name,
|
|
1500
|
+
logger: logger,
|
|
1501
|
+
handleRecoverableError: handleRecoverableError,
|
|
1502
|
+
rewriteSourcesHook: (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.rewriteSources,
|
|
1503
|
+
sentryHub: sentryHub,
|
|
1504
|
+
sentryClient: sentryClient,
|
|
1505
|
+
sentryCliOptions: {
|
|
1506
|
+
authToken: options.authToken,
|
|
1507
|
+
org: options.org,
|
|
1508
|
+
project: options.project,
|
|
1509
|
+
silent: options.silent,
|
|
1510
|
+
url: options.url,
|
|
1511
|
+
vcsRemote: options.release.vcsRemote,
|
|
1512
|
+
headers: options.headers
|
|
1513
|
+
}
|
|
1514
|
+
})));
|
|
1682
1515
|
}
|
|
1683
|
-
|
|
1684
1516
|
return plugins;
|
|
1685
1517
|
});
|
|
1686
1518
|
}
|
|
1687
1519
|
function getBuildInformation() {
|
|
1688
1520
|
var packageJson = getPackageJson();
|
|
1689
|
-
|
|
1690
1521
|
var _ref2 = packageJson ? getDependencies(packageJson) : {
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1522
|
+
deps: [],
|
|
1523
|
+
depsVersions: {}
|
|
1524
|
+
},
|
|
1525
|
+
deps = _ref2.deps,
|
|
1526
|
+
depsVersions = _ref2.depsVersions;
|
|
1697
1527
|
return {
|
|
1698
1528
|
deps: deps,
|
|
1699
1529
|
depsVersions: depsVersions,
|
|
1700
1530
|
nodeVersion: parseMajorVersion(process.version)
|
|
1701
1531
|
};
|
|
1702
1532
|
}
|
|
1533
|
+
|
|
1703
1534
|
/**
|
|
1704
1535
|
* Determines whether the Sentry CLI binary is in its expected location.
|
|
1705
1536
|
* This function is useful since `@sentry/cli` installs the binary via a post-install
|
|
1706
1537
|
* script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.
|
|
1707
1538
|
*/
|
|
1708
|
-
|
|
1709
1539
|
function sentryCliBinaryExists() {
|
|
1710
1540
|
return fs.existsSync(SentryCli.getPath());
|
|
1711
1541
|
}
|
|
@@ -1735,19 +1565,20 @@ function createRollupReleaseInjectionHooks(injectionCode) {
|
|
|
1735
1565
|
return null;
|
|
1736
1566
|
}
|
|
1737
1567
|
|
|
1738
|
-
|
|
1568
|
+
// id may contain query and hash which will trip up our file extension logic below
|
|
1569
|
+
var idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
|
|
1570
|
+
if (idWithoutQueryAndHash.match(/\\node_modules\\|\/node_modules\//)) {
|
|
1739
1571
|
return null;
|
|
1740
1572
|
}
|
|
1741
|
-
|
|
1742
1573
|
if (![".js", ".ts", ".jsx", ".tsx", ".mjs"].some(function (ending) {
|
|
1743
|
-
return
|
|
1574
|
+
return idWithoutQueryAndHash.endsWith(ending);
|
|
1744
1575
|
})) {
|
|
1745
1576
|
return null;
|
|
1746
1577
|
}
|
|
1578
|
+
var ms = new MagicString(code);
|
|
1747
1579
|
|
|
1748
|
-
|
|
1580
|
+
// Appending instead of prepending has less probability of mucking with user's source maps.
|
|
1749
1581
|
// Luckily import statements get hoisted to the top anyways.
|
|
1750
|
-
|
|
1751
1582
|
ms.append("\n\n;import \"".concat(virtualReleaseInjectionFileId, "\";"));
|
|
1752
1583
|
return {
|
|
1753
1584
|
code: ms.toString(),
|
|
@@ -1764,18 +1595,17 @@ function createRollupDebugIdInjectionHooks() {
|
|
|
1764
1595
|
}) // chunks could be any file (html, md, ...)
|
|
1765
1596
|
) {
|
|
1766
1597
|
var _code$match;
|
|
1767
|
-
|
|
1768
1598
|
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
1769
|
-
|
|
1770
1599
|
var codeToInject = getDebugIdSnippet(debugId);
|
|
1771
1600
|
var ms = new MagicString(code, {
|
|
1772
1601
|
filename: chunk.fileName
|
|
1773
|
-
});
|
|
1774
|
-
// As an additional complication `"use strict";`s may come after any number of comments.
|
|
1602
|
+
});
|
|
1775
1603
|
|
|
1776
|
-
|
|
1604
|
+
// We need to be careful not to inject the snippet before any `"use strict";`s.
|
|
1605
|
+
// As an additional complication `"use strict";`s may come after any number of comments.
|
|
1606
|
+
var commentUseStrictRegex =
|
|
1607
|
+
// Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
|
|
1777
1608
|
/^(?:\s*|\/\*(?:.|\r|\n)*\*\/|\/\/.*[\n\r])*(?:"[^"]*";|'[^']*';)?/;
|
|
1778
|
-
|
|
1779
1609
|
if ((_code$match = code.match(commentUseStrictRegex)) !== null && _code$match !== void 0 && _code$match[0]) {
|
|
1780
1610
|
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
1781
1611
|
ms.replace(commentUseStrictRegex, function (match) {
|
|
@@ -1787,7 +1617,6 @@ function createRollupDebugIdInjectionHooks() {
|
|
|
1787
1617
|
// need this special case here.
|
|
1788
1618
|
ms.prepend(codeToInject);
|
|
1789
1619
|
}
|
|
1790
|
-
|
|
1791
1620
|
return {
|
|
1792
1621
|
code: ms.toString(),
|
|
1793
1622
|
map: ms.generateMap({
|
|
@@ -1800,9 +1629,56 @@ function createRollupDebugIdInjectionHooks() {
|
|
|
1800
1629
|
}
|
|
1801
1630
|
};
|
|
1802
1631
|
}
|
|
1632
|
+
|
|
1633
|
+
function createRollupDebugIdUploadHooks(upload) {
|
|
1634
|
+
return {
|
|
1635
|
+
writeBundle: function writeBundle(outputOptions, bundle) {
|
|
1636
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1637
|
+
var outputDir, _buildArtifacts, _buildArtifacts2;
|
|
1638
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1639
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1640
|
+
case 0:
|
|
1641
|
+
if (!outputOptions.dir) {
|
|
1642
|
+
_context.next = 7;
|
|
1643
|
+
break;
|
|
1644
|
+
}
|
|
1645
|
+
outputDir = outputOptions.dir;
|
|
1646
|
+
_buildArtifacts = Object.keys(bundle).map(function (asset) {
|
|
1647
|
+
return path.join(outputDir, asset);
|
|
1648
|
+
});
|
|
1649
|
+
_context.next = 5;
|
|
1650
|
+
return upload(_buildArtifacts);
|
|
1651
|
+
case 5:
|
|
1652
|
+
_context.next = 15;
|
|
1653
|
+
break;
|
|
1654
|
+
case 7:
|
|
1655
|
+
if (!outputOptions.file) {
|
|
1656
|
+
_context.next = 12;
|
|
1657
|
+
break;
|
|
1658
|
+
}
|
|
1659
|
+
_context.next = 10;
|
|
1660
|
+
return upload([outputOptions.file]);
|
|
1661
|
+
case 10:
|
|
1662
|
+
_context.next = 15;
|
|
1663
|
+
break;
|
|
1664
|
+
case 12:
|
|
1665
|
+
_buildArtifacts2 = Object.keys(bundle).map(function (asset) {
|
|
1666
|
+
return path.join(path.resolve(), asset);
|
|
1667
|
+
});
|
|
1668
|
+
_context.next = 15;
|
|
1669
|
+
return upload(_buildArtifacts2);
|
|
1670
|
+
case 15:
|
|
1671
|
+
case "end":
|
|
1672
|
+
return _context.stop();
|
|
1673
|
+
}
|
|
1674
|
+
}, _callee);
|
|
1675
|
+
}))();
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1803
1679
|
function getDebugIdSnippet(debugId) {
|
|
1804
1680
|
return ";!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]=\"".concat(debugId, "\",e._sentryDebugIdIdentifier=\"sentry-dbid-").concat(debugId, "\")}catch(e){}}();");
|
|
1805
1681
|
}
|
|
1806
1682
|
|
|
1807
|
-
export { createRollupDebugIdInjectionHooks, createRollupReleaseInjectionHooks, getBuildInformation, getDebugIdSnippet, sentryCliBinaryExists, sentryUnpluginFactory };
|
|
1683
|
+
export { createRollupDebugIdInjectionHooks, createRollupDebugIdUploadHooks, createRollupReleaseInjectionHooks, getBuildInformation, getDebugIdSnippet, sentryCliBinaryExists, sentryUnpluginFactory };
|
|
1808
1684
|
//# sourceMappingURL=index.mjs.map
|