@sentry/bundler-plugin-core 2.0.0-alpha.0 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1085 -1361
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +1067 -1368
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +65 -5
- package/dist/types/options-mapping.d.ts +55 -16
- package/dist/types/plugins/debug-id-upload.d.ts +25 -0
- package/dist/types/plugins/release-management.d.ts +30 -0
- package/dist/types/plugins/telemetry.d.ts +11 -0
- package/dist/types/sentry/telemetry.d.ts +5 -10
- package/dist/types/types.d.ts +137 -108
- package/dist/types/utils.d.ts +33 -0
- package/package.json +25 -10
- package/sentry-esbuild-debugid-injection-file.js +18 -0
- package/sentry-release-injection-file.js +4 -0
- package/dist/types/sentry/cli.d.ts +0 -16
- package/dist/types/sentry/releasePipeline.d.ts +0 -8
package/dist/esm/index.mjs
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
|
-
import { createUnplugin } from 'unplugin';
|
|
2
|
-
import MagicString from 'magic-string';
|
|
3
1
|
import SentryCli from '@sentry/cli';
|
|
4
|
-
import
|
|
5
|
-
import '
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import MagicString from 'magic-string';
|
|
4
|
+
import { createUnplugin } from 'unplugin';
|
|
5
|
+
import findUp from 'find-up';
|
|
6
6
|
import path from 'path';
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import crypto from 'crypto';
|
|
9
|
+
import childProcess from 'child_process';
|
|
10
|
+
import { glob } from 'glob';
|
|
11
|
+
import * as util from 'util';
|
|
12
|
+
import { promisify } from 'util';
|
|
13
|
+
import { NodeClient, defaultStackParser, makeNodeTransport, Hub } from '@sentry/node';
|
|
14
|
+
|
|
15
|
+
function ownKeys(object, enumerableOnly) {
|
|
16
|
+
var keys = Object.keys(object);
|
|
17
|
+
|
|
18
|
+
if (Object.getOwnPropertySymbols) {
|
|
19
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
20
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
21
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
22
|
+
})), keys.push.apply(keys, symbols);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return keys;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _objectSpread2(target) {
|
|
29
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
30
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
31
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
32
|
+
_defineProperty(target, key, source[key]);
|
|
33
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
34
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return target;
|
|
39
|
+
}
|
|
7
40
|
|
|
8
41
|
function _regeneratorRuntime() {
|
|
9
42
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -386,502 +419,260 @@ function _asyncToGenerator(fn) {
|
|
|
386
419
|
};
|
|
387
420
|
}
|
|
388
421
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
401
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
402
|
-
// furnished to do so, subject to the following conditions:
|
|
403
|
-
//
|
|
404
|
-
// The above copyright notice and this permission notice shall be included in
|
|
405
|
-
// all copies or substantial portions of the Software.
|
|
406
|
-
//
|
|
407
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
408
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
409
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
410
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
411
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
412
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
413
|
-
// THE SOFTWARE.
|
|
414
|
-
|
|
415
|
-
/** Returns 'obj' if it's the global object, otherwise returns undefined */
|
|
416
|
-
function isGlobalObj(obj) {
|
|
417
|
-
return obj && obj.Math == Math ? obj : undefined;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/** Get's the global object for the current JavaScript runtime */
|
|
421
|
-
const GLOBAL_OBJ =
|
|
422
|
-
(typeof globalThis == 'object' && isGlobalObj(globalThis)) ||
|
|
423
|
-
// eslint-disable-next-line no-restricted-globals
|
|
424
|
-
(typeof window == 'object' && isGlobalObj(window)) ||
|
|
425
|
-
(typeof self == 'object' && isGlobalObj(self)) ||
|
|
426
|
-
(typeof global == 'object' && isGlobalObj(global)) ||
|
|
427
|
-
(function () {
|
|
428
|
-
return this;
|
|
429
|
-
})() ||
|
|
430
|
-
{};
|
|
422
|
+
function _defineProperty(obj, key, value) {
|
|
423
|
+
if (key in obj) {
|
|
424
|
+
Object.defineProperty(obj, key, {
|
|
425
|
+
value: value,
|
|
426
|
+
enumerable: true,
|
|
427
|
+
configurable: true,
|
|
428
|
+
writable: true
|
|
429
|
+
});
|
|
430
|
+
} else {
|
|
431
|
+
obj[key] = value;
|
|
432
|
+
}
|
|
431
433
|
|
|
432
|
-
|
|
433
|
-
* @deprecated Use GLOBAL_OBJ instead or WINDOW from @sentry/browser. This will be removed in v8
|
|
434
|
-
*/
|
|
435
|
-
function getGlobalObject() {
|
|
436
|
-
return GLOBAL_OBJ ;
|
|
434
|
+
return obj;
|
|
437
435
|
}
|
|
438
436
|
|
|
439
437
|
/**
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
* If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory
|
|
443
|
-
* function and added to the `__SENTRY__` object.
|
|
438
|
+
* Checks whether the given input is already an array, and if it isn't, wraps it in one.
|
|
444
439
|
*
|
|
445
|
-
* @param
|
|
446
|
-
* @
|
|
447
|
-
* @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value
|
|
448
|
-
* @returns the singleton
|
|
440
|
+
* @param maybeArray Input to turn into an array, if necessary
|
|
441
|
+
* @returns The input, if already an array, or an array with the input as the only element, if not
|
|
449
442
|
*/
|
|
450
|
-
function getGlobalSingleton(name, creator, obj) {
|
|
451
|
-
const gbl = (obj || GLOBAL_OBJ) ;
|
|
452
|
-
const __SENTRY__ = (gbl.__SENTRY__ = gbl.__SENTRY__ || {});
|
|
453
|
-
const singleton = __SENTRY__[name] || (__SENTRY__[name] = creator());
|
|
454
|
-
return singleton;
|
|
455
|
-
}
|
|
456
443
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace'] ;
|
|
444
|
+
function arrayify(maybeArray) {
|
|
445
|
+
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
446
|
+
}
|
|
461
447
|
|
|
462
448
|
/**
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
*
|
|
449
|
+
* Get the closes package.json from a given starting point upwards.
|
|
450
|
+
* This handles a few edge cases:
|
|
451
|
+
* * Check if a given file package.json appears to be an actual NPM package.json file
|
|
452
|
+
* * Stop at the home dir, to avoid looking too deeply
|
|
467
453
|
*/
|
|
468
|
-
function
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
454
|
+
function getPackageJson() {
|
|
455
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
456
|
+
cwd = _ref.cwd,
|
|
457
|
+
stopAt = _ref.stopAt;
|
|
472
458
|
|
|
473
|
-
|
|
474
|
-
const wrappedLevels = {};
|
|
475
|
-
|
|
476
|
-
// Restore all wrapped console methods
|
|
477
|
-
CONSOLE_LEVELS.forEach(level => {
|
|
478
|
-
// TODO(v7): Remove this check as it's only needed for Node 6
|
|
479
|
-
const originalWrappedFunc =
|
|
480
|
-
originalConsole[level] && (originalConsole[level] ).__sentry_original__;
|
|
481
|
-
if (level in originalConsole && originalWrappedFunc) {
|
|
482
|
-
wrappedLevels[level] = originalConsole[level] ;
|
|
483
|
-
originalConsole[level] = originalWrappedFunc ;
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
try {
|
|
488
|
-
return callback();
|
|
489
|
-
} finally {
|
|
490
|
-
// Revert restoration to wrapped state
|
|
491
|
-
Object.keys(wrappedLevels).forEach(level => {
|
|
492
|
-
originalConsole[level] = wrappedLevels[level ];
|
|
493
|
-
});
|
|
494
|
-
}
|
|
459
|
+
return lookupPackageJson(cwd !== null && cwd !== void 0 ? cwd : process.cwd(), path.normalize(stopAt !== null && stopAt !== void 0 ? stopAt : os.homedir()));
|
|
495
460
|
}
|
|
461
|
+
function parseMajorVersion(version) {
|
|
462
|
+
// if it has a `v` prefix, remove it
|
|
463
|
+
if (version.startsWith("v")) {
|
|
464
|
+
version = version.slice(1);
|
|
465
|
+
} // First, try simple lookup of exact, ~ and ^ versions
|
|
496
466
|
|
|
497
|
-
function makeLogger() {
|
|
498
|
-
let enabled = false;
|
|
499
|
-
const logger = {
|
|
500
|
-
enable: () => {
|
|
501
|
-
enabled = true;
|
|
502
|
-
},
|
|
503
|
-
disable: () => {
|
|
504
|
-
enabled = false;
|
|
505
|
-
},
|
|
506
|
-
};
|
|
507
467
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
511
|
-
logger[name] = (...args) => {
|
|
512
|
-
if (enabled) {
|
|
513
|
-
consoleSandbox(() => {
|
|
514
|
-
GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
});
|
|
519
|
-
} else {
|
|
520
|
-
CONSOLE_LEVELS.forEach(name => {
|
|
521
|
-
logger[name] = () => undefined;
|
|
522
|
-
});
|
|
523
|
-
}
|
|
468
|
+
var regex = /^[\^~]?(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
469
|
+
var match = version.match(regex);
|
|
524
470
|
|
|
525
|
-
|
|
526
|
-
|
|
471
|
+
if (match) {
|
|
472
|
+
return parseInt(match[1], 10);
|
|
473
|
+
} // Try to parse e.g. 1.x
|
|
527
474
|
|
|
528
|
-
// Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
|
|
529
|
-
let logger;
|
|
530
|
-
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
|
|
531
|
-
logger = getGlobalSingleton('logger', makeLogger);
|
|
532
|
-
} else {
|
|
533
|
-
logger = makeLogger();
|
|
534
|
-
}
|
|
535
475
|
|
|
536
|
-
|
|
537
|
-
* This module exists for optimizations in the build process through rollup and terser. We define some global
|
|
538
|
-
* constants, which can be overridden during build. By guarding certain pieces of code with functions that return these
|
|
539
|
-
* constants, we can control whether or not they appear in the final bundle. (Any code guarded by a false condition will
|
|
540
|
-
* never run, and will hence be dropped during treeshaking.) The two primary uses for this are stripping out calls to
|
|
541
|
-
* `logger` and preventing node-related code from appearing in browser bundles.
|
|
542
|
-
*
|
|
543
|
-
* Attention:
|
|
544
|
-
* This file should not be used to define constants/flags that are intended to be used for tree-shaking conducted by
|
|
545
|
-
* users. These fags should live in their respective packages, as we identified user tooling (specifically webpack)
|
|
546
|
-
* having issues tree-shaking these constants across package boundaries.
|
|
547
|
-
* An example for this is the __SENTRY_DEBUG__ constant. It is declared in each package individually because we want
|
|
548
|
-
* users to be able to shake away expressions that it guards.
|
|
549
|
-
*/
|
|
476
|
+
var coerced = parseInt(version, 10);
|
|
550
477
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
* @returns true if this is a browser bundle build.
|
|
555
|
-
*/
|
|
556
|
-
function isBrowserBundle() {
|
|
557
|
-
return typeof __SENTRY_BROWSER_BUNDLE__ !== 'undefined' && !!__SENTRY_BROWSER_BUNDLE__;
|
|
558
|
-
}
|
|
478
|
+
if (!Number.isNaN(coerced)) {
|
|
479
|
+
return coerced;
|
|
480
|
+
} // Match <= and >= ranges.
|
|
559
481
|
|
|
560
|
-
/**
|
|
561
|
-
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
|
|
562
|
-
* you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
|
|
563
|
-
*/
|
|
564
482
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
*
|
|
568
|
-
* @returns Answer to given question
|
|
569
|
-
*/
|
|
570
|
-
function isNodeEnv() {
|
|
571
|
-
// explicitly check for browser bundles as those can be optimized statically
|
|
572
|
-
// by terser/rollup.
|
|
573
|
-
return (
|
|
574
|
-
!isBrowserBundle() &&
|
|
575
|
-
Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'
|
|
576
|
-
);
|
|
577
|
-
}
|
|
483
|
+
var gteLteRegex = /^[<>]=\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
484
|
+
var gteLteMatch = version.match(gteLteRegex);
|
|
578
485
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
* @param request The module path to resolve
|
|
583
|
-
*/
|
|
584
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
585
|
-
function dynamicRequire(mod, request) {
|
|
586
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
587
|
-
return mod.require(request);
|
|
588
|
-
}
|
|
486
|
+
if (gteLteMatch) {
|
|
487
|
+
return parseInt(gteLteMatch[1], 10);
|
|
488
|
+
} // match < ranges
|
|
589
489
|
|
|
590
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
591
490
|
|
|
592
|
-
|
|
593
|
-
var
|
|
594
|
-
/** Pending */
|
|
595
|
-
const PENDING = 0; States[States["PENDING"] = PENDING] = "PENDING";
|
|
596
|
-
/** Resolved / OK */
|
|
597
|
-
const RESOLVED = 1; States[States["RESOLVED"] = RESOLVED] = "RESOLVED";
|
|
598
|
-
/** Rejected / Error */
|
|
599
|
-
const REJECTED = 2; States[States["REJECTED"] = REJECTED] = "REJECTED";
|
|
600
|
-
})(States || (States = {}));
|
|
491
|
+
var ltRegex = /^<\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
492
|
+
var ltMatch = version.match(ltRegex);
|
|
601
493
|
|
|
602
|
-
|
|
603
|
-
|
|
494
|
+
if (ltMatch) {
|
|
495
|
+
// Two scenarios:
|
|
496
|
+
// a) < 2.0.0 --> return 1
|
|
497
|
+
// b) < 2.1.0 --> return 2
|
|
498
|
+
var major = parseInt(ltMatch[1], 10);
|
|
604
499
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
500
|
+
if ( // minor version > 0
|
|
501
|
+
typeof ltMatch[2] === "string" && parseInt(ltMatch[2].slice(1), 10) > 0 || // patch version > 0
|
|
502
|
+
typeof ltMatch[3] === "string" && parseInt(ltMatch[3].slice(1), 10) > 0) {
|
|
503
|
+
return major;
|
|
504
|
+
}
|
|
608
505
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
*
|
|
612
|
-
* Note that this TimestampSource does not use a monotonic clock. A call to `nowSeconds` may return a timestamp earlier
|
|
613
|
-
* than a previously returned value. We do not try to emulate a monotonic behavior in order to facilitate debugging. It
|
|
614
|
-
* is more obvious to explain "why does my span have negative duration" than "why my spans have zero duration".
|
|
615
|
-
*/
|
|
616
|
-
const dateTimestampSource = {
|
|
617
|
-
nowSeconds: () => Date.now() / 1000,
|
|
618
|
-
};
|
|
506
|
+
return major - 1;
|
|
507
|
+
} // match > ranges
|
|
619
508
|
|
|
620
|
-
/**
|
|
621
|
-
* A partial definition of the [Performance Web API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Performance}
|
|
622
|
-
* for accessing a high-resolution monotonic clock.
|
|
623
|
-
*/
|
|
624
509
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
if (!performance || !performance.now) {
|
|
634
|
-
return undefined;
|
|
510
|
+
var gtRegex = /^>\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
511
|
+
var gtMatch = version.match(gtRegex);
|
|
512
|
+
|
|
513
|
+
if (gtMatch) {
|
|
514
|
+
// We always return the version here, even though it _may_ be incorrect
|
|
515
|
+
// E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3
|
|
516
|
+
// Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists
|
|
517
|
+
return parseInt(gtMatch[1], 10);
|
|
635
518
|
}
|
|
636
519
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
// This is a partial workaround for browsers reporting performance.timeOrigin such that performance.timeOrigin +
|
|
640
|
-
// performance.now() gives a date arbitrarily in the past.
|
|
641
|
-
//
|
|
642
|
-
// Additionally, computing timeOrigin in this way fills the gap for browsers where performance.timeOrigin is
|
|
643
|
-
// undefined.
|
|
644
|
-
//
|
|
645
|
-
// The assumption that performance.timeOrigin + performance.now() ~= Date.now() is flawed, but we depend on it to
|
|
646
|
-
// interact with data coming out of performance entries.
|
|
647
|
-
//
|
|
648
|
-
// Note that despite recommendations against it in the spec, browsers implement the Performance API with a clock that
|
|
649
|
-
// might stop when the computer is asleep (and perhaps under other circumstances). Such behavior causes
|
|
650
|
-
// performance.timeOrigin + performance.now() to have an arbitrary skew over Date.now(). In laptop computers, we have
|
|
651
|
-
// observed skews that can be as long as days, weeks or months.
|
|
652
|
-
//
|
|
653
|
-
// See https://github.com/getsentry/sentry-javascript/issues/2590.
|
|
654
|
-
//
|
|
655
|
-
// BUG: despite our best intentions, this workaround has its limitations. It mostly addresses timings of pageload
|
|
656
|
-
// transactions, but ignores the skew built up over time that can aversely affect timestamps of navigation
|
|
657
|
-
// transactions of long-lived web pages.
|
|
658
|
-
const timeOrigin = Date.now() - performance.now();
|
|
520
|
+
return undefined;
|
|
521
|
+
} // This is an explicit list of packages where we want to include the (major) version number.
|
|
659
522
|
|
|
523
|
+
var PACKAGES_TO_INCLUDE_VERSION = ["react", "@angular/core", "vue", "ember-source", "svelte", "@sveltejs/kit", "webpack", "vite", "gatsby", "next", "remix", "rollup", "esbuild"];
|
|
524
|
+
function getDependencies(packageJson) {
|
|
525
|
+
var _packageJson$devDepen, _packageJson$dependen;
|
|
526
|
+
|
|
527
|
+
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 : {});
|
|
528
|
+
var deps = Object.keys(dependencies).sort();
|
|
529
|
+
var depsVersions = deps.reduce(function (depsVersions, depName) {
|
|
530
|
+
if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {
|
|
531
|
+
var version = dependencies[depName];
|
|
532
|
+
var majorVersion = parseMajorVersion(version);
|
|
533
|
+
|
|
534
|
+
if (majorVersion) {
|
|
535
|
+
depsVersions[depName] = majorVersion;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return depsVersions;
|
|
540
|
+
}, {});
|
|
660
541
|
return {
|
|
661
|
-
|
|
662
|
-
|
|
542
|
+
deps: deps,
|
|
543
|
+
depsVersions: depsVersions
|
|
663
544
|
};
|
|
664
545
|
}
|
|
665
546
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
return
|
|
674
|
-
}
|
|
547
|
+
function lookupPackageJson(cwd, stopAt) {
|
|
548
|
+
var jsonPath = findUp.sync(function (dirName) {
|
|
549
|
+
// Stop if we reach this dir
|
|
550
|
+
if (path.normalize(dirName) === stopAt) {
|
|
551
|
+
return findUp.stop;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return findUp.sync.exists(dirName + "/package.json") ? "package.json" : undefined;
|
|
555
|
+
}, {
|
|
556
|
+
cwd: cwd
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
if (!jsonPath) {
|
|
675
560
|
return undefined;
|
|
676
561
|
}
|
|
677
|
-
}
|
|
678
562
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
563
|
+
try {
|
|
564
|
+
var jsonStr = fs.readFileSync(jsonPath, "utf8");
|
|
565
|
+
var json = JSON.parse(jsonStr); // Ensure it is an actual package.json
|
|
566
|
+
// This is very much not bulletproof, but should be good enough
|
|
683
567
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
};
|
|
568
|
+
if ("name" in json || "private" in json) {
|
|
569
|
+
return json;
|
|
570
|
+
}
|
|
571
|
+
} catch (error) {// Ignore and walk up
|
|
572
|
+
} // Continue up the tree, if we find a fitting package.json
|
|
690
573
|
|
|
691
|
-
/**
|
|
692
|
-
* Returns a timestamp in seconds since the UNIX epoch using the Date API.
|
|
693
|
-
*/
|
|
694
|
-
dateTimestampSource.nowSeconds.bind(dateTimestampSource);
|
|
695
574
|
|
|
575
|
+
var newCwd = path.dirname(path.resolve(jsonPath + "/.."));
|
|
576
|
+
return lookupPackageJson(newCwd, stopAt);
|
|
577
|
+
}
|
|
696
578
|
/**
|
|
697
|
-
*
|
|
698
|
-
* availability of the Performance API.
|
|
699
|
-
*
|
|
700
|
-
* See `usingPerformanceAPI` to test whether the Performance API is used.
|
|
701
|
-
*
|
|
702
|
-
* BUG: Note that because of how browsers implement the Performance API, the clock might stop when the computer is
|
|
703
|
-
* asleep. This creates a skew between `dateTimestampInSeconds` and `timestampInSeconds`. The
|
|
704
|
-
* skew can grow to arbitrary amounts like days, weeks or months.
|
|
705
|
-
* See https://github.com/getsentry/sentry-javascript/issues/2590.
|
|
579
|
+
* Deterministically hashes a string and turns the hash into a uuid.
|
|
706
580
|
*/
|
|
707
|
-
timestampSource.nowSeconds.bind(timestampSource);
|
|
708
581
|
|
|
582
|
+
|
|
583
|
+
function stringToUUID(str) {
|
|
584
|
+
var md5sum = crypto.createHash("md5");
|
|
585
|
+
md5sum.update(str);
|
|
586
|
+
var md5Hash = md5sum.digest("hex");
|
|
587
|
+
return (md5Hash.substring(0, 8) + "-" + md5Hash.substring(8, 12) + "-4" + md5Hash.substring(13, 16) + "-" + md5Hash.substring(16, 20) + "-" + md5Hash.substring(20)).toLowerCase();
|
|
588
|
+
}
|
|
709
589
|
/**
|
|
710
|
-
*
|
|
711
|
-
* performance API is available.
|
|
590
|
+
* Tries to guess a release name based on environmental data.
|
|
712
591
|
*/
|
|
713
|
-
(() => {
|
|
714
|
-
// Unfortunately browsers may report an inaccurate time origin data, through either performance.timeOrigin or
|
|
715
|
-
// performance.timing.navigationStart, which results in poor results in performance data. We only treat time origin
|
|
716
|
-
// data as reliable if they are within a reasonable threshold of the current time.
|
|
717
592
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
return undefined;
|
|
721
|
-
}
|
|
593
|
+
function determineReleaseName() {
|
|
594
|
+
var gitRevision;
|
|
722
595
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
// if timeOrigin isn't available set delta to threshold so it isn't used
|
|
728
|
-
const timeOriginDelta = performance.timeOrigin
|
|
729
|
-
? Math.abs(performance.timeOrigin + performanceNow - dateNow)
|
|
730
|
-
: threshold;
|
|
731
|
-
const timeOriginIsReliable = timeOriginDelta < threshold;
|
|
732
|
-
|
|
733
|
-
// While performance.timing.navigationStart is deprecated in favor of performance.timeOrigin, performance.timeOrigin
|
|
734
|
-
// is not as widely supported. Namely, performance.timeOrigin is undefined in Safari as of writing.
|
|
735
|
-
// Also as of writing, performance.timing is not available in Web Workers in mainstream browsers, so it is not always
|
|
736
|
-
// a valid fallback. In the absence of an initial time provided by the browser, fallback to the current time from the
|
|
737
|
-
// Date API.
|
|
738
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
739
|
-
const navigationStart = performance.timing && performance.timing.navigationStart;
|
|
740
|
-
const hasNavigationStart = typeof navigationStart === 'number';
|
|
741
|
-
// if navigationStart isn't available set delta to threshold so it isn't used
|
|
742
|
-
const navigationStartDelta = hasNavigationStart ? Math.abs(navigationStart + performanceNow - dateNow) : threshold;
|
|
743
|
-
const navigationStartIsReliable = navigationStartDelta < threshold;
|
|
744
|
-
|
|
745
|
-
if (timeOriginIsReliable || navigationStartIsReliable) {
|
|
746
|
-
// Use the more reliable time origin
|
|
747
|
-
if (timeOriginDelta <= navigationStartDelta) {
|
|
748
|
-
return performance.timeOrigin;
|
|
749
|
-
} else {
|
|
750
|
-
return navigationStart;
|
|
751
|
-
}
|
|
596
|
+
try {
|
|
597
|
+
gitRevision = childProcess.execSync("git rev-parse --short HEAD").toString().trim();
|
|
598
|
+
} catch (e) {// noop
|
|
752
599
|
}
|
|
753
|
-
return dateNow;
|
|
754
|
-
})();
|
|
755
600
|
|
|
601
|
+
return (// GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
602
|
+
process.env["GITHUB_SHA"] || // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
|
|
603
|
+
process.env["COMMIT_REF"] || // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
|
|
604
|
+
process.env["CF_PAGES_COMMIT_SHA"] || // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
|
605
|
+
process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] || // CircleCI - https://circleci.com/docs/2.0/env-vars/
|
|
606
|
+
process.env["CIRCLE_SHA1"] || // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
|
|
607
|
+
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)
|
|
608
|
+
process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] || gitRevision
|
|
609
|
+
);
|
|
610
|
+
}
|
|
756
611
|
/**
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
* @param maybeArray Input to turn into an array, if necessary
|
|
760
|
-
* @returns The input, if already an array, or an array with the input as the only element, if not
|
|
612
|
+
* Generates code for the global injector which is responsible for setting the global
|
|
613
|
+
* `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
|
|
761
614
|
*/
|
|
762
|
-
|
|
763
|
-
|
|
615
|
+
|
|
616
|
+
function generateGlobalInjectorCode(_ref2) {
|
|
617
|
+
var release = _ref2.release,
|
|
618
|
+
injectBuildInformation = _ref2.injectBuildInformation;
|
|
619
|
+
// The code below is mostly ternary operators because it saves bundle size.
|
|
620
|
+
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
621
|
+
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, "\"};");
|
|
622
|
+
|
|
623
|
+
if (injectBuildInformation) {
|
|
624
|
+
var buildInfo = getBuildInformation$1();
|
|
625
|
+
code += "\n _global.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return code;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function getBuildInformation$1() {
|
|
632
|
+
var packageJson = getPackageJson();
|
|
633
|
+
|
|
634
|
+
var _ref3 = packageJson ? getDependencies(packageJson) : {
|
|
635
|
+
deps: [],
|
|
636
|
+
depsVersions: {}
|
|
637
|
+
},
|
|
638
|
+
deps = _ref3.deps,
|
|
639
|
+
depsVersions = _ref3.depsVersions;
|
|
640
|
+
|
|
641
|
+
return {
|
|
642
|
+
deps: deps,
|
|
643
|
+
depsVersions: depsVersions,
|
|
644
|
+
nodeVersion: parseMajorVersion(process.version)
|
|
645
|
+
};
|
|
764
646
|
}
|
|
765
647
|
|
|
766
648
|
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
767
649
|
function normalizeUserOptions(userOptions) {
|
|
768
|
-
var _userOptions$org, _userOptions$project,
|
|
650
|
+
var _userOptions$org, _userOptions$project, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _process$env$SENTRY_V, _userOptions$_experim;
|
|
769
651
|
|
|
770
652
|
var options = {
|
|
771
|
-
// include is the only strictly required option
|
|
772
|
-
// (normalizeInclude needs all userOptions to access top-level include options)
|
|
773
|
-
include: normalizeInclude(userOptions),
|
|
774
|
-
// These options must be set b/c we need them for release injection.
|
|
775
|
-
// They can also be set as environment variables. Technically, they
|
|
776
|
-
// could be set in the config file but this would be too late for
|
|
777
|
-
// release injection because we only pass the config file path
|
|
778
|
-
// to the CLI
|
|
779
653
|
org: (_userOptions$org = userOptions.org) !== null && _userOptions$org !== void 0 ? _userOptions$org : process.env["SENTRY_ORG"],
|
|
780
654
|
project: (_userOptions$project = userOptions.project) !== null && _userOptions$project !== void 0 ? _userOptions$project : process.env["SENTRY_PROJECT"],
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
release: (_ref = (_userOptions$release = userOptions.release) !== null && _userOptions$release !== void 0 ? _userOptions$release : process.env["SENTRY_RELEASE"]) !== null && _ref !== void 0 ? _ref : "",
|
|
785
|
-
// We technically don't need the URL for anything release-specific
|
|
786
|
-
// but we want to make sure that we're only sending Sentry data
|
|
787
|
-
// of SaaS customers. Hence we want to read it anyway.
|
|
788
|
-
url: (_ref2 = (_userOptions$url = userOptions.url) !== null && _userOptions$url !== void 0 ? _userOptions$url : process.env["SENTRY_URL"]) !== null && _ref2 !== void 0 ? _ref2 : SENTRY_SAAS_URL,
|
|
789
|
-
// Options with default values
|
|
790
|
-
finalize: (_userOptions$finalize = userOptions.finalize) !== null && _userOptions$finalize !== void 0 ? _userOptions$finalize : true,
|
|
791
|
-
cleanArtifacts: (_userOptions$cleanArt = userOptions.cleanArtifacts) !== null && _userOptions$cleanArt !== void 0 ? _userOptions$cleanArt : false,
|
|
792
|
-
dryRun: (_userOptions$dryRun = userOptions.dryRun) !== null && _userOptions$dryRun !== void 0 ? _userOptions$dryRun : false,
|
|
655
|
+
authToken: (_userOptions$authToke = userOptions.authToken) !== null && _userOptions$authToke !== void 0 ? _userOptions$authToke : process.env["SENTRY_AUTH_TOKEN"],
|
|
656
|
+
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,
|
|
657
|
+
headers: userOptions.headers,
|
|
793
658
|
debug: (_userOptions$debug = userOptions.debug) !== null && _userOptions$debug !== void 0 ? _userOptions$debug : false,
|
|
794
659
|
silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
|
|
795
|
-
telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
|
|
796
|
-
injectReleasesMap: (_userOptions$injectRe = userOptions.injectReleasesMap) !== null && _userOptions$injectRe !== void 0 ? _userOptions$injectRe : false,
|
|
797
|
-
// These options and can also be set via env variables or the config file.
|
|
798
|
-
// If they're set in the options, we simply pass them to the CLI constructor.
|
|
799
|
-
// Sentry CLI will internally query env variables and read its config file if
|
|
800
|
-
// the passed options are undefined.
|
|
801
|
-
authToken: userOptions.authToken,
|
|
802
|
-
// env var: `SENTRY_AUTH_TOKEN`
|
|
803
|
-
headers: userOptions.headers,
|
|
804
|
-
vcsRemote: userOptions.vcsRemote,
|
|
805
|
-
// env var: `SENTRY_VSC_REMOTE`
|
|
806
|
-
// Optional options
|
|
807
|
-
setCommits: userOptions.setCommits,
|
|
808
|
-
deploy: userOptions.deploy,
|
|
809
|
-
releaseInjectionTargets: normalizeReleaseInjectionTargets(userOptions.releaseInjectionTargets),
|
|
810
|
-
dist: userOptions.dist,
|
|
811
660
|
errorHandler: userOptions.errorHandler,
|
|
812
|
-
|
|
661
|
+
telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
|
|
662
|
+
disable: (_userOptions$disable = userOptions.disable) !== null && _userOptions$disable !== void 0 ? _userOptions$disable : false,
|
|
663
|
+
sourcemaps: userOptions.sourcemaps,
|
|
664
|
+
release: _objectSpread2({
|
|
665
|
+
name: determineReleaseName(),
|
|
666
|
+
inject: true,
|
|
667
|
+
create: true,
|
|
668
|
+
finalize: true,
|
|
669
|
+
vcsRemote: (_process$env$SENTRY_V = process.env["SENTRY_VSC_REMOTE"]) !== null && _process$env$SENTRY_V !== void 0 ? _process$env$SENTRY_V : "origin",
|
|
670
|
+
cleanArtifacts: false
|
|
671
|
+
}, userOptions.release),
|
|
672
|
+
_experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
|
|
813
673
|
};
|
|
814
674
|
return options;
|
|
815
675
|
}
|
|
816
|
-
/**
|
|
817
|
-
* Converts the user-facing `releaseInjectionTargets` option to the internal
|
|
818
|
-
* `releaseInjectionTargets` option
|
|
819
|
-
*/
|
|
820
|
-
|
|
821
|
-
function normalizeReleaseInjectionTargets(userReleaseInjectionTargets) {
|
|
822
|
-
if (userReleaseInjectionTargets === undefined) {
|
|
823
|
-
return undefined;
|
|
824
|
-
} else if (typeof userReleaseInjectionTargets === "function") {
|
|
825
|
-
return userReleaseInjectionTargets;
|
|
826
|
-
} else {
|
|
827
|
-
return arrayify(userReleaseInjectionTargets);
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
/**
|
|
831
|
-
* Converts the user-facing `include` option to the internal `include` option,
|
|
832
|
-
* resulting in an array of `InternalIncludeEntry` objects. This later on lets us
|
|
833
|
-
* work with only one type of include data structure instead of multiple.
|
|
834
|
-
*
|
|
835
|
-
* During the process, we hoist top-level include options (e.g. urlPrefix) into each
|
|
836
|
-
* object if they were not alrady specified in an `IncludeEntry`, making every object
|
|
837
|
-
* fully self-contained. This is also the reason why we pass the entire options
|
|
838
|
-
* object and not just `include`.
|
|
839
|
-
*
|
|
840
|
-
* @param userOptions the entire user-facing `options` object
|
|
841
|
-
*
|
|
842
|
-
* @return an array of `InternalIncludeEntry` objects.
|
|
843
|
-
*/
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
function normalizeInclude(userOptions) {
|
|
847
|
-
return arrayify(userOptions.include).map(function (includeItem) {
|
|
848
|
-
return typeof includeItem === "string" ? {
|
|
849
|
-
paths: [includeItem]
|
|
850
|
-
} : includeItem;
|
|
851
|
-
}).map(function (userIncludeEntry) {
|
|
852
|
-
return normalizeIncludeEntry(userOptions, userIncludeEntry);
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
|
-
/**
|
|
856
|
-
* Besides array-ifying the `ignore` option, this function hoists top level options into the items of the `include`
|
|
857
|
-
* option. This is to simplify the handling of of the `include` items later on.
|
|
858
|
-
*/
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
862
|
-
var _ref3, _includeEntry$ignore, _ref4, _includeEntry$ext, _includeEntry$ignoreF, _includeEntry$urlPref, _includeEntry$urlSuff, _includeEntry$stripPr, _ref5, _includeEntry$stripCo, _ref6, _includeEntry$sourceM, _ref7, _includeEntry$rewrite, _ref8, _includeEntry$validat;
|
|
863
|
-
|
|
864
|
-
var ignoreOption = (_ref3 = (_includeEntry$ignore = includeEntry.ignore) !== null && _includeEntry$ignore !== void 0 ? _includeEntry$ignore : userOptions.ignore) !== null && _ref3 !== void 0 ? _ref3 : ["node_modules"];
|
|
865
|
-
var ignore = Array.isArray(ignoreOption) ? ignoreOption : [ignoreOption]; // We're prefixing all entries in the `ext` option with a `.` (if it isn't already) to align with Node.js' `path.extname()`
|
|
866
|
-
|
|
867
|
-
var ext = (_ref4 = (_includeEntry$ext = includeEntry.ext) !== null && _includeEntry$ext !== void 0 ? _includeEntry$ext : userOptions.ext) !== null && _ref4 !== void 0 ? _ref4 : ["js", "map", "jsbundle", "bundle"];
|
|
868
|
-
var dotPrefixedExt = ext.map(function (extension) {
|
|
869
|
-
return ".".concat(extension.replace(/^\./, ""));
|
|
870
|
-
});
|
|
871
|
-
return {
|
|
872
|
-
paths: includeEntry.paths,
|
|
873
|
-
ignore: ignore,
|
|
874
|
-
ignoreFile: (_includeEntry$ignoreF = includeEntry.ignoreFile) !== null && _includeEntry$ignoreF !== void 0 ? _includeEntry$ignoreF : userOptions.ignoreFile,
|
|
875
|
-
ext: dotPrefixedExt,
|
|
876
|
-
urlPrefix: (_includeEntry$urlPref = includeEntry.urlPrefix) !== null && _includeEntry$urlPref !== void 0 ? _includeEntry$urlPref : userOptions.urlPrefix,
|
|
877
|
-
urlSuffix: (_includeEntry$urlSuff = includeEntry.urlSuffix) !== null && _includeEntry$urlSuff !== void 0 ? _includeEntry$urlSuff : userOptions.urlSuffix,
|
|
878
|
-
stripPrefix: (_includeEntry$stripPr = includeEntry.stripPrefix) !== null && _includeEntry$stripPr !== void 0 ? _includeEntry$stripPr : userOptions.stripPrefix,
|
|
879
|
-
stripCommonPrefix: (_ref5 = (_includeEntry$stripCo = includeEntry.stripCommonPrefix) !== null && _includeEntry$stripCo !== void 0 ? _includeEntry$stripCo : userOptions.stripCommonPrefix) !== null && _ref5 !== void 0 ? _ref5 : false,
|
|
880
|
-
sourceMapReference: (_ref6 = (_includeEntry$sourceM = includeEntry.sourceMapReference) !== null && _includeEntry$sourceM !== void 0 ? _includeEntry$sourceM : userOptions.sourceMapReference) !== null && _ref6 !== void 0 ? _ref6 : true,
|
|
881
|
-
rewrite: (_ref7 = (_includeEntry$rewrite = includeEntry.rewrite) !== null && _includeEntry$rewrite !== void 0 ? _includeEntry$rewrite : userOptions.rewrite) !== null && _ref7 !== void 0 ? _ref7 : true,
|
|
882
|
-
validate: (_ref8 = (_includeEntry$validat = includeEntry.validate) !== null && _includeEntry$validat !== void 0 ? _includeEntry$validat : userOptions.validate) !== null && _ref8 !== void 0 ? _ref8 : false
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
676
|
/**
|
|
886
677
|
* Validates a few combinations of options that are not checked by Sentry CLI.
|
|
887
678
|
*
|
|
@@ -895,14 +686,10 @@ function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
|
895
686
|
* @returns `true` if the options are valid, `false` otherwise
|
|
896
687
|
*/
|
|
897
688
|
|
|
898
|
-
|
|
899
689
|
function validateOptions(options, logger) {
|
|
900
|
-
|
|
901
|
-
logger.error("The `injectReleasesMap` option was set but it is only supported when the `org` option is also specified.", "Please set the `org` option (you can also set the SENTRY_ORG environment variable) or disable the `injectReleasesMap` option.");
|
|
902
|
-
return false;
|
|
903
|
-
}
|
|
690
|
+
var _options$release, _options$release2, _options$release3;
|
|
904
691
|
|
|
905
|
-
var setCommits = options.setCommits;
|
|
692
|
+
var setCommits = (_options$release = options.release) === null || _options$release === void 0 ? void 0 : _options$release.setCommits;
|
|
906
693
|
|
|
907
694
|
if (setCommits) {
|
|
908
695
|
if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {
|
|
@@ -915,7 +702,7 @@ function validateOptions(options, logger) {
|
|
|
915
702
|
}
|
|
916
703
|
}
|
|
917
704
|
|
|
918
|
-
if (options.deploy && !options.deploy.env) {
|
|
705
|
+
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)) {
|
|
919
706
|
logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
|
|
920
707
|
return false;
|
|
921
708
|
}
|
|
@@ -923,606 +710,513 @@ function validateOptions(options, logger) {
|
|
|
923
710
|
return true;
|
|
924
711
|
}
|
|
925
712
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
713
|
+
function debugIdUploadPlugin(_ref) {
|
|
714
|
+
var assets = _ref.assets,
|
|
715
|
+
ignore = _ref.ignore,
|
|
716
|
+
logger = _ref.logger,
|
|
717
|
+
releaseName = _ref.releaseName,
|
|
718
|
+
dist = _ref.dist,
|
|
719
|
+
handleRecoverableError = _ref.handleRecoverableError,
|
|
720
|
+
sentryHub = _ref.sentryHub,
|
|
721
|
+
sentryClient = _ref.sentryClient,
|
|
722
|
+
sentryCliOptions = _ref.sentryCliOptions;
|
|
723
|
+
return {
|
|
724
|
+
name: "sentry-debug-id-upload-plugin",
|
|
725
|
+
writeBundle: function writeBundle() {
|
|
726
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
727
|
+
var folderToCleanUp, cliInstance, tmpUploadFolder, debugIdChunkFilePaths;
|
|
728
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
729
|
+
while (1) {
|
|
730
|
+
switch (_context2.prev = _context2.next) {
|
|
731
|
+
case 0:
|
|
732
|
+
cliInstance = new SentryCli(null, sentryCliOptions);
|
|
733
|
+
_context2.prev = 1;
|
|
734
|
+
_context2.next = 4;
|
|
735
|
+
return fs.promises.mkdtemp(path.join(os.tmpdir(), "sentry-bundler-plugin-upload-"));
|
|
736
|
+
|
|
737
|
+
case 4:
|
|
738
|
+
tmpUploadFolder = _context2.sent;
|
|
739
|
+
folderToCleanUp = tmpUploadFolder;
|
|
740
|
+
_context2.next = 8;
|
|
741
|
+
return glob(assets, {
|
|
742
|
+
absolute: true,
|
|
743
|
+
nodir: true,
|
|
744
|
+
ignore: ignore
|
|
745
|
+
});
|
|
947
746
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
747
|
+
case 8:
|
|
748
|
+
debugIdChunkFilePaths = _context2.sent.filter(function (debugIdChunkFilePath) {
|
|
749
|
+
return debugIdChunkFilePath.endsWith(".js") || debugIdChunkFilePath.endsWith(".mjs") || debugIdChunkFilePath.endsWith(".cjs");
|
|
750
|
+
});
|
|
751
|
+
_context2.next = 11;
|
|
752
|
+
return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
|
|
753
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(chunkFilePath, chunkIndex) {
|
|
754
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
755
|
+
while (1) {
|
|
756
|
+
switch (_context.prev = _context.next) {
|
|
757
|
+
case 0:
|
|
758
|
+
_context.next = 2;
|
|
759
|
+
return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, String(chunkIndex), logger);
|
|
760
|
+
|
|
761
|
+
case 2:
|
|
762
|
+
case "end":
|
|
763
|
+
return _context.stop();
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}, _callee);
|
|
767
|
+
}));
|
|
768
|
+
|
|
769
|
+
return function (_x, _x2) {
|
|
770
|
+
return _ref2.apply(this, arguments);
|
|
771
|
+
};
|
|
772
|
+
}()));
|
|
952
773
|
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
send: function () {
|
|
964
|
-
var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
|
965
|
-
var isAllowedToSend;
|
|
966
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
967
|
-
while (1) {
|
|
968
|
-
switch (_context.prev = _context.next) {
|
|
969
|
-
case 0:
|
|
970
|
-
_context.next = 2;
|
|
971
|
-
return allowedToSendTelemetryPromise;
|
|
774
|
+
case 11:
|
|
775
|
+
_context2.next = 13;
|
|
776
|
+
return cliInstance.releases.uploadSourceMaps(releaseName !== null && releaseName !== void 0 ? releaseName : "", {
|
|
777
|
+
include: [{
|
|
778
|
+
paths: [tmpUploadFolder],
|
|
779
|
+
rewrite: false,
|
|
780
|
+
dist: dist
|
|
781
|
+
}],
|
|
782
|
+
useArtifactBundle: true
|
|
783
|
+
});
|
|
972
784
|
|
|
973
|
-
|
|
974
|
-
|
|
785
|
+
case 13:
|
|
786
|
+
_context2.next = 21;
|
|
787
|
+
break;
|
|
975
788
|
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
789
|
+
case 15:
|
|
790
|
+
_context2.prev = 15;
|
|
791
|
+
_context2.t0 = _context2["catch"](1);
|
|
792
|
+
sentryHub.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
|
|
793
|
+
_context2.next = 20;
|
|
794
|
+
return sentryClient.flush();
|
|
980
795
|
|
|
981
|
-
|
|
796
|
+
case 20:
|
|
797
|
+
handleRecoverableError(_context2.t0);
|
|
982
798
|
|
|
983
|
-
|
|
984
|
-
|
|
799
|
+
case 21:
|
|
800
|
+
_context2.prev = 21;
|
|
985
801
|
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
802
|
+
if (folderToCleanUp) {
|
|
803
|
+
void fs.promises.rm(folderToCleanUp, {
|
|
804
|
+
recursive: true,
|
|
805
|
+
force: true
|
|
806
|
+
});
|
|
989
807
|
}
|
|
990
|
-
}
|
|
991
|
-
}, _callee);
|
|
992
|
-
}));
|
|
993
808
|
|
|
994
|
-
|
|
995
|
-
return _send.apply(this, arguments);
|
|
996
|
-
}
|
|
809
|
+
return _context2.finish(21);
|
|
997
810
|
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
811
|
+
case 24:
|
|
812
|
+
case "end":
|
|
813
|
+
return _context2.stop();
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}, _callee2, null, [[1, 15, 21, 24]]);
|
|
817
|
+
}))();
|
|
1001
818
|
}
|
|
1002
|
-
});
|
|
1003
|
-
var hub = new Hub(client);
|
|
1004
|
-
return {
|
|
1005
|
-
sentryClient: client,
|
|
1006
|
-
sentryHub: hub
|
|
1007
819
|
};
|
|
1008
820
|
}
|
|
821
|
+
function prepareBundleForDebugIdUpload(_x3, _x4, _x5, _x6) {
|
|
822
|
+
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
823
|
+
}
|
|
1009
824
|
/**
|
|
1010
|
-
*
|
|
825
|
+
* Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle
|
|
826
|
+
* source and extracts the bundle's debug ID from it.
|
|
827
|
+
*
|
|
828
|
+
* The string pattern is injected via the debug ID injection snipped.
|
|
1011
829
|
*/
|
|
1012
830
|
|
|
1013
|
-
function
|
|
1014
|
-
|
|
831
|
+
function _prepareBundleForDebugIdUpload() {
|
|
832
|
+
_prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(bundleFilePath, uploadFolder, uniqueUploadName, logger) {
|
|
833
|
+
var bundleContent, debugId, writeSourceFilePromise, writeSourceMapFilePromise;
|
|
834
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
835
|
+
while (1) {
|
|
836
|
+
switch (_context4.prev = _context4.next) {
|
|
837
|
+
case 0:
|
|
838
|
+
_context4.prev = 0;
|
|
839
|
+
_context4.next = 3;
|
|
840
|
+
return promisify(fs.readFile)(bundleFilePath, "utf8");
|
|
1015
841
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
op: op,
|
|
1021
|
-
description: description
|
|
1022
|
-
});
|
|
1023
|
-
hub.configureScope(function (scope) {
|
|
1024
|
-
return scope.setSpan(span);
|
|
1025
|
-
});
|
|
1026
|
-
return span;
|
|
1027
|
-
}
|
|
1028
|
-
function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
1029
|
-
var org = options.org,
|
|
1030
|
-
project = options.project,
|
|
1031
|
-
cleanArtifacts = options.cleanArtifacts,
|
|
1032
|
-
finalize = options.finalize,
|
|
1033
|
-
setCommits = options.setCommits,
|
|
1034
|
-
injectReleasesMap = options.injectReleasesMap,
|
|
1035
|
-
dryRun = options.dryRun,
|
|
1036
|
-
errorHandler = options.errorHandler,
|
|
1037
|
-
deploy = options.deploy,
|
|
1038
|
-
include = options.include;
|
|
1039
|
-
hub.setTag("include", include.length > 1 ? "multiple-entries" : "single-entry"); // Optional release pipeline steps
|
|
842
|
+
case 3:
|
|
843
|
+
bundleContent = _context4.sent;
|
|
844
|
+
_context4.next = 10;
|
|
845
|
+
break;
|
|
1040
846
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
847
|
+
case 6:
|
|
848
|
+
_context4.prev = 6;
|
|
849
|
+
_context4.t0 = _context4["catch"](0);
|
|
850
|
+
logger.error("Could not read bundle to determine debug ID and source map: ".concat(bundleFilePath), _context4.t0);
|
|
851
|
+
return _context4.abrupt("return");
|
|
1044
852
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
}
|
|
853
|
+
case 10:
|
|
854
|
+
debugId = determineDebugIdFromBundleSource(bundleContent);
|
|
1048
855
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
856
|
+
if (!(debugId === undefined)) {
|
|
857
|
+
_context4.next = 14;
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
1052
860
|
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
} // Miscelaneous options
|
|
861
|
+
logger.warn("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));
|
|
862
|
+
return _context4.abrupt("return");
|
|
1056
863
|
|
|
864
|
+
case 14:
|
|
865
|
+
bundleContent += "\n//# debugId=".concat(debugId);
|
|
866
|
+
writeSourceFilePromise = fs.promises.writeFile(path.join(uploadFolder, "".concat(uniqueUploadName, ".js")), bundleContent, "utf-8");
|
|
867
|
+
writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger).then( /*#__PURE__*/function () {
|
|
868
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sourceMapPath) {
|
|
869
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
870
|
+
while (1) {
|
|
871
|
+
switch (_context3.prev = _context3.next) {
|
|
872
|
+
case 0:
|
|
873
|
+
if (!sourceMapPath) {
|
|
874
|
+
_context3.next = 4;
|
|
875
|
+
break;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
_context3.next = 3;
|
|
879
|
+
return prepareSourceMapForDebugIdUpload(sourceMapPath, path.join(uploadFolder, "".concat(uniqueUploadName, ".js.map")), debugId, logger);
|
|
880
|
+
|
|
881
|
+
case 3:
|
|
882
|
+
return _context3.abrupt("return", _context3.sent);
|
|
883
|
+
|
|
884
|
+
case 4:
|
|
885
|
+
case "end":
|
|
886
|
+
return _context3.stop();
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}, _callee3);
|
|
890
|
+
}));
|
|
1057
891
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
892
|
+
return function (_x14) {
|
|
893
|
+
return _ref3.apply(this, arguments);
|
|
894
|
+
};
|
|
895
|
+
}());
|
|
896
|
+
return _context4.abrupt("return", Promise.all([writeSourceFilePromise, writeSourceMapFilePromise]));
|
|
1061
897
|
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
898
|
+
case 18:
|
|
899
|
+
case "end":
|
|
900
|
+
return _context4.stop();
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}, _callee4, null, [[0, 6]]);
|
|
904
|
+
}));
|
|
905
|
+
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
906
|
+
}
|
|
1065
907
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
}
|
|
908
|
+
function determineDebugIdFromBundleSource(code) {
|
|
909
|
+
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})/);
|
|
1069
910
|
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
});
|
|
1076
|
-
hub.setUser({
|
|
1077
|
-
id: org
|
|
1078
|
-
});
|
|
911
|
+
if (match) {
|
|
912
|
+
return match[1];
|
|
913
|
+
} else {
|
|
914
|
+
return undefined;
|
|
915
|
+
}
|
|
1079
916
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
917
|
+
/**
|
|
918
|
+
* Applies a set of heuristics to find the source map for a particular bundle.
|
|
919
|
+
*
|
|
920
|
+
* @returns the path to the bundle's source map or `undefined` if none could be found.
|
|
921
|
+
*/
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
function determineSourceMapPathFromBundle(_x7, _x8, _x9) {
|
|
925
|
+
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
1082
926
|
}
|
|
927
|
+
/**
|
|
928
|
+
* Reads a source map, injects debug ID fields, and writes the source map to the target path.
|
|
929
|
+
*/
|
|
1083
930
|
|
|
1084
|
-
function _shouldSendTelemetry() {
|
|
1085
|
-
_shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1086
|
-
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1087
931
|
|
|
1088
|
-
|
|
1089
|
-
|
|
932
|
+
function _determineSourceMapPathFromBundle() {
|
|
933
|
+
_determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(bundlePath, bundleSource, logger) {
|
|
934
|
+
var sourceMappingUrlMatch, sourceMappingUrl, adjacentSourceMapFilePath;
|
|
935
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1090
936
|
while (1) {
|
|
1091
|
-
switch (
|
|
937
|
+
switch (_context5.prev = _context5.next) {
|
|
1092
938
|
case 0:
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
if (!(telemetry === false)) {
|
|
1096
|
-
_context2.next = 3;
|
|
1097
|
-
break;
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
return _context2.abrupt("return", false);
|
|
939
|
+
// 1. try to find source map at `sourceMappingURL` location
|
|
940
|
+
sourceMappingUrlMatch = bundleSource.match(/^\/\/# sourceMappingURL=(.*)$/);
|
|
1101
941
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
_context2.next = 5;
|
|
942
|
+
if (!sourceMappingUrlMatch) {
|
|
943
|
+
_context5.next = 8;
|
|
1105
944
|
break;
|
|
1106
945
|
}
|
|
1107
946
|
|
|
1108
|
-
|
|
947
|
+
sourceMappingUrl = path.normalize(sourceMappingUrlMatch[1]);
|
|
1109
948
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
_context2.next = 7;
|
|
949
|
+
if (!path.isAbsolute(sourceMappingUrl)) {
|
|
950
|
+
_context5.next = 7;
|
|
1113
951
|
break;
|
|
1114
952
|
}
|
|
1115
953
|
|
|
1116
|
-
return
|
|
954
|
+
return _context5.abrupt("return", sourceMappingUrl);
|
|
1117
955
|
|
|
1118
956
|
case 7:
|
|
1119
|
-
|
|
1120
|
-
url: url,
|
|
1121
|
-
authToken: authToken,
|
|
1122
|
-
org: org,
|
|
1123
|
-
project: project,
|
|
1124
|
-
vcsRemote: vcsRemote,
|
|
1125
|
-
silent: silent,
|
|
1126
|
-
headers: headers
|
|
1127
|
-
});
|
|
1128
|
-
_context2.prev = 8;
|
|
1129
|
-
_context2.next = 11;
|
|
1130
|
-
return cli.execute(["info"], false);
|
|
1131
|
-
|
|
1132
|
-
case 11:
|
|
1133
|
-
cliInfo = _context2.sent;
|
|
1134
|
-
_context2.next = 17;
|
|
1135
|
-
break;
|
|
1136
|
-
|
|
1137
|
-
case 14:
|
|
1138
|
-
_context2.prev = 14;
|
|
1139
|
-
_context2.t0 = _context2["catch"](8);
|
|
1140
|
-
throw new Error('Sentry CLI "info" command failed, make sure you have an auth token configured, and your `url` option is correct.');
|
|
957
|
+
return _context5.abrupt("return", path.join(path.dirname(bundlePath), sourceMappingUrl));
|
|
1141
958
|
|
|
1142
|
-
case
|
|
1143
|
-
|
|
959
|
+
case 8:
|
|
960
|
+
_context5.prev = 8;
|
|
961
|
+
adjacentSourceMapFilePath = bundlePath + ".map";
|
|
962
|
+
_context5.next = 12;
|
|
963
|
+
return util.promisify(fs.access)(adjacentSourceMapFilePath);
|
|
1144
964
|
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
break;
|
|
1148
|
-
}
|
|
965
|
+
case 12:
|
|
966
|
+
return _context5.abrupt("return", adjacentSourceMapFilePath);
|
|
1149
967
|
|
|
1150
|
-
|
|
968
|
+
case 15:
|
|
969
|
+
_context5.prev = 15;
|
|
970
|
+
_context5.t0 = _context5["catch"](8);
|
|
1151
971
|
|
|
1152
|
-
case
|
|
1153
|
-
|
|
972
|
+
case 17:
|
|
973
|
+
logger.warn("Could not determine source map path for bundle: ".concat(bundlePath));
|
|
974
|
+
return _context5.abrupt("return", undefined);
|
|
1154
975
|
|
|
1155
|
-
case
|
|
976
|
+
case 19:
|
|
1156
977
|
case "end":
|
|
1157
|
-
return
|
|
978
|
+
return _context5.stop();
|
|
1158
979
|
}
|
|
1159
980
|
}
|
|
1160
|
-
},
|
|
981
|
+
}, _callee5, null, [[8, 15]]);
|
|
1161
982
|
}));
|
|
1162
|
-
return
|
|
983
|
+
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
1163
984
|
}
|
|
1164
985
|
|
|
1165
|
-
function
|
|
1166
|
-
return
|
|
986
|
+
function prepareSourceMapForDebugIdUpload(_x10, _x11, _x12, _x13) {
|
|
987
|
+
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
1167
988
|
}
|
|
1168
989
|
|
|
1169
|
-
function
|
|
1170
|
-
|
|
1171
|
-
var
|
|
1172
|
-
return _regeneratorRuntime().wrap(function
|
|
990
|
+
function _prepareSourceMapForDebugIdUpload() {
|
|
991
|
+
_prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(sourceMapPath, targetPath, debugId, logger) {
|
|
992
|
+
var sourceMapFileContent, map;
|
|
993
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1173
994
|
while (1) {
|
|
1174
|
-
switch (
|
|
995
|
+
switch (_context6.prev = _context6.next) {
|
|
1175
996
|
case 0:
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
997
|
+
_context6.prev = 0;
|
|
998
|
+
_context6.next = 3;
|
|
999
|
+
return util.promisify(fs.readFile)(sourceMapPath, {
|
|
1000
|
+
encoding: "utf8"
|
|
1001
|
+
});
|
|
1180
1002
|
|
|
1181
|
-
case
|
|
1182
|
-
|
|
1003
|
+
case 3:
|
|
1004
|
+
sourceMapFileContent = _context6.sent;
|
|
1005
|
+
_context6.next = 10;
|
|
1183
1006
|
break;
|
|
1184
1007
|
|
|
1185
1008
|
case 6:
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1009
|
+
_context6.prev = 6;
|
|
1010
|
+
_context6.t0 = _context6["catch"](0);
|
|
1011
|
+
logger.error("Failed to read source map for debug ID upload: ".concat(sourceMapPath), _context6.t0);
|
|
1012
|
+
return _context6.abrupt("return");
|
|
1190
1013
|
|
|
1191
1014
|
case 10:
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
return _context.finish(10);
|
|
1195
|
-
|
|
1196
|
-
case 13:
|
|
1197
|
-
ctx.hub.addBreadcrumb({
|
|
1198
|
-
level: "info",
|
|
1199
|
-
message: "Successfully created release."
|
|
1200
|
-
});
|
|
1201
|
-
ctx.logger.info("Successfully created release.");
|
|
1202
|
-
|
|
1203
|
-
case 15:
|
|
1204
|
-
case "end":
|
|
1205
|
-
return _context.stop();
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
}, _callee, null, [[1, 6, 10, 13]]);
|
|
1209
|
-
}));
|
|
1210
|
-
return _createNewRelease.apply(this, arguments);
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
function cleanArtifacts(_x4, _x5, _x6) {
|
|
1214
|
-
return _cleanArtifacts.apply(this, arguments);
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
function _cleanArtifacts() {
|
|
1218
|
-
_cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx, releaseName) {
|
|
1219
|
-
var span;
|
|
1220
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1221
|
-
while (1) {
|
|
1222
|
-
switch (_context2.prev = _context2.next) {
|
|
1223
|
-
case 0:
|
|
1224
|
-
if (options.cleanArtifacts) {
|
|
1225
|
-
_context2.next = 3;
|
|
1226
|
-
break;
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
logger.debug("Skipping artifact cleanup.");
|
|
1230
|
-
return _context2.abrupt("return");
|
|
1231
|
-
|
|
1232
|
-
case 3:
|
|
1233
|
-
span = addSpanToTransaction(ctx, "function.plugin.clean_artifacts");
|
|
1234
|
-
_context2.prev = 4;
|
|
1235
|
-
_context2.next = 7;
|
|
1236
|
-
return ctx.cli.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
|
|
1015
|
+
_context6.prev = 10;
|
|
1016
|
+
map = JSON.parse(sourceMapFileContent); // For now we write both fields until we know what will become the standard - if ever.
|
|
1237
1017
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1018
|
+
map["debug_id"] = debugId;
|
|
1019
|
+
map["debugId"] = debugId;
|
|
1020
|
+
_context6.next = 20;
|
|
1240
1021
|
break;
|
|
1241
1022
|
|
|
1242
|
-
case 9:
|
|
1243
|
-
_context2.prev = 9;
|
|
1244
|
-
_context2.t0 = _context2["catch"](4);
|
|
1245
|
-
ctx.hub.captureException(new Error("CLI Error: Deleting release files failed"));
|
|
1246
|
-
throw _context2.t0;
|
|
1247
|
-
|
|
1248
|
-
case 13:
|
|
1249
|
-
_context2.prev = 13;
|
|
1250
|
-
span === null || span === void 0 ? void 0 : span.finish();
|
|
1251
|
-
return _context2.finish(13);
|
|
1252
|
-
|
|
1253
1023
|
case 16:
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
ctx.logger.info("Successfully cleaned previous artifacts.");
|
|
1259
|
-
|
|
1260
|
-
case 18:
|
|
1261
|
-
case "end":
|
|
1262
|
-
return _context2.stop();
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
}, _callee2, null, [[4, 9, 13, 16]]);
|
|
1266
|
-
}));
|
|
1267
|
-
return _cleanArtifacts.apply(this, arguments);
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
function uploadSourceMaps(_x7, _x8, _x9) {
|
|
1271
|
-
return _uploadSourceMaps.apply(this, arguments);
|
|
1272
|
-
}
|
|
1024
|
+
_context6.prev = 16;
|
|
1025
|
+
_context6.t1 = _context6["catch"](10);
|
|
1026
|
+
logger.error("Failed to parse source map for debug ID upload: ".concat(sourceMapPath));
|
|
1027
|
+
return _context6.abrupt("return");
|
|
1273
1028
|
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
switch (_context3.prev = _context3.next) {
|
|
1280
|
-
case 0:
|
|
1281
|
-
span = addSpanToTransaction(ctx, "function.plugin.upload_sourcemaps");
|
|
1282
|
-
ctx.logger.info("Uploading Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
|
|
1283
|
-
// we only need to pass the include option here.
|
|
1284
|
-
|
|
1285
|
-
_context3.prev = 2;
|
|
1286
|
-
_context3.next = 5;
|
|
1287
|
-
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1288
|
-
include: options.include,
|
|
1289
|
-
dist: options.dist
|
|
1029
|
+
case 20:
|
|
1030
|
+
_context6.prev = 20;
|
|
1031
|
+
_context6.next = 23;
|
|
1032
|
+
return util.promisify(fs.writeFile)(targetPath, JSON.stringify(map), {
|
|
1033
|
+
encoding: "utf8"
|
|
1290
1034
|
});
|
|
1291
1035
|
|
|
1292
|
-
case
|
|
1293
|
-
|
|
1036
|
+
case 23:
|
|
1037
|
+
_context6.next = 29;
|
|
1294
1038
|
break;
|
|
1295
1039
|
|
|
1296
|
-
case
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
case 11:
|
|
1303
|
-
_context3.prev = 11;
|
|
1304
|
-
span === null || span === void 0 ? void 0 : span.finish();
|
|
1305
|
-
return _context3.finish(11);
|
|
1306
|
-
|
|
1307
|
-
case 14:
|
|
1308
|
-
ctx.hub.addBreadcrumb({
|
|
1309
|
-
level: "info",
|
|
1310
|
-
message: "Successfully uploaded source maps."
|
|
1311
|
-
});
|
|
1312
|
-
ctx.logger.info("Successfully uploaded source maps.");
|
|
1040
|
+
case 25:
|
|
1041
|
+
_context6.prev = 25;
|
|
1042
|
+
_context6.t2 = _context6["catch"](20);
|
|
1043
|
+
logger.error("Failed to prepare source map for debug ID upload: ".concat(sourceMapPath), _context6.t2);
|
|
1044
|
+
return _context6.abrupt("return");
|
|
1313
1045
|
|
|
1314
|
-
case
|
|
1046
|
+
case 29:
|
|
1315
1047
|
case "end":
|
|
1316
|
-
return
|
|
1048
|
+
return _context6.stop();
|
|
1317
1049
|
}
|
|
1318
1050
|
}
|
|
1319
|
-
},
|
|
1051
|
+
}, _callee6, null, [[0, 6], [10, 16], [20, 25]]);
|
|
1320
1052
|
}));
|
|
1321
|
-
return
|
|
1053
|
+
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
1322
1054
|
}
|
|
1323
1055
|
|
|
1324
|
-
function
|
|
1325
|
-
|
|
1326
|
-
|
|
1056
|
+
function releaseManagementPlugin(_ref) {
|
|
1057
|
+
var releaseName = _ref.releaseName,
|
|
1058
|
+
include = _ref.include,
|
|
1059
|
+
dist = _ref.dist,
|
|
1060
|
+
setCommitsOption = _ref.setCommitsOption,
|
|
1061
|
+
shouldCreateRelease = _ref.shouldCreateRelease,
|
|
1062
|
+
shouldCleanArtifacts = _ref.shouldCleanArtifacts,
|
|
1063
|
+
shouldFinalizeRelease = _ref.shouldFinalizeRelease,
|
|
1064
|
+
deployOptions = _ref.deployOptions,
|
|
1065
|
+
handleRecoverableError = _ref.handleRecoverableError,
|
|
1066
|
+
sentryHub = _ref.sentryHub,
|
|
1067
|
+
sentryClient = _ref.sentryClient,
|
|
1068
|
+
sentryCliOptions = _ref.sentryCliOptions;
|
|
1069
|
+
return {
|
|
1070
|
+
name: "sentry-debug-id-upload-plugin",
|
|
1071
|
+
writeBundle: function writeBundle() {
|
|
1072
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1073
|
+
var cliInstance, normalizedInclude;
|
|
1074
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1075
|
+
while (1) {
|
|
1076
|
+
switch (_context.prev = _context.next) {
|
|
1077
|
+
case 0:
|
|
1078
|
+
_context.prev = 0;
|
|
1079
|
+
cliInstance = new SentryCli(null, sentryCliOptions);
|
|
1327
1080
|
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1081
|
+
if (!shouldCreateRelease) {
|
|
1082
|
+
_context.next = 5;
|
|
1083
|
+
break;
|
|
1084
|
+
}
|
|
1331
1085
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
switch (_context4.prev = _context4.next) {
|
|
1335
|
-
case 0:
|
|
1336
|
-
if (options.setCommits) {
|
|
1337
|
-
_context4.next = 3;
|
|
1338
|
-
break;
|
|
1339
|
-
}
|
|
1086
|
+
_context.next = 5;
|
|
1087
|
+
return cliInstance.releases["new"](releaseName);
|
|
1340
1088
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1089
|
+
case 5:
|
|
1090
|
+
if (!shouldCleanArtifacts) {
|
|
1091
|
+
_context.next = 8;
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1343
1094
|
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
_options$setCommits = options.setCommits, auto = _options$setCommits.auto, repo = _options$setCommits.repo, commit = _options$setCommits.commit, previousCommit = _options$setCommits.previousCommit, ignoreMissing = _options$setCommits.ignoreMissing, ignoreEmpty = _options$setCommits.ignoreEmpty;
|
|
1347
|
-
_context4.prev = 5;
|
|
1348
|
-
_context4.next = 8;
|
|
1349
|
-
return ctx.cli.releases.setCommits(releaseName, {
|
|
1350
|
-
commit: commit,
|
|
1351
|
-
previousCommit: previousCommit,
|
|
1352
|
-
repo: repo,
|
|
1353
|
-
auto: auto,
|
|
1354
|
-
ignoreMissing: ignoreMissing,
|
|
1355
|
-
ignoreEmpty: ignoreEmpty
|
|
1356
|
-
});
|
|
1095
|
+
_context.next = 8;
|
|
1096
|
+
return cliInstance.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
|
|
1357
1097
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1098
|
+
case 8:
|
|
1099
|
+
if (!include) {
|
|
1100
|
+
_context.next = 12;
|
|
1101
|
+
break;
|
|
1102
|
+
}
|
|
1361
1103
|
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1104
|
+
normalizedInclude = arrayify(include).map(function (includeItem) {
|
|
1105
|
+
return typeof includeItem === "string" ? {
|
|
1106
|
+
paths: [includeItem]
|
|
1107
|
+
} : includeItem;
|
|
1108
|
+
}).map(function (includeEntry) {
|
|
1109
|
+
var _includeEntry$validat;
|
|
1110
|
+
|
|
1111
|
+
return _objectSpread2(_objectSpread2({}, includeEntry), {}, {
|
|
1112
|
+
validate: (_includeEntry$validat = includeEntry.validate) !== null && _includeEntry$validat !== void 0 ? _includeEntry$validat : false,
|
|
1113
|
+
ext: includeEntry.ext ? includeEntry.ext.map(function (extension) {
|
|
1114
|
+
return ".".concat(extension.replace(/^\./, ""));
|
|
1115
|
+
}) : [".js", ".map", ".jsbundle", ".bundle"],
|
|
1116
|
+
ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined
|
|
1117
|
+
});
|
|
1118
|
+
});
|
|
1119
|
+
_context.next = 12;
|
|
1120
|
+
return cliInstance.releases.uploadSourceMaps(releaseName, {
|
|
1121
|
+
include: normalizedInclude,
|
|
1122
|
+
dist: dist
|
|
1123
|
+
});
|
|
1367
1124
|
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1125
|
+
case 12:
|
|
1126
|
+
if (!setCommitsOption) {
|
|
1127
|
+
_context.next = 15;
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1372
1130
|
|
|
1373
|
-
|
|
1374
|
-
|
|
1131
|
+
_context.next = 15;
|
|
1132
|
+
return cliInstance.releases.setCommits(releaseName, setCommitsOption);
|
|
1375
1133
|
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
}, _callee4, null, [[5, 10, 14, 17]]);
|
|
1382
|
-
}));
|
|
1383
|
-
return _setCommits.apply(this, arguments);
|
|
1384
|
-
}
|
|
1134
|
+
case 15:
|
|
1135
|
+
if (!shouldFinalizeRelease) {
|
|
1136
|
+
_context.next = 18;
|
|
1137
|
+
break;
|
|
1138
|
+
}
|
|
1385
1139
|
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
}
|
|
1140
|
+
_context.next = 18;
|
|
1141
|
+
return cliInstance.releases.finalize(releaseName);
|
|
1389
1142
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
switch (_context5.prev = _context5.next) {
|
|
1396
|
-
case 0:
|
|
1397
|
-
if (options.finalize) {
|
|
1398
|
-
_context5.next = 4;
|
|
1399
|
-
break;
|
|
1400
|
-
}
|
|
1143
|
+
case 18:
|
|
1144
|
+
if (!deployOptions) {
|
|
1145
|
+
_context.next = 21;
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1401
1148
|
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
message: "Skipping release finalization."
|
|
1405
|
-
});
|
|
1406
|
-
logger.debug("Skipping release finalization.");
|
|
1407
|
-
return _context5.abrupt("return");
|
|
1149
|
+
_context.next = 21;
|
|
1150
|
+
return cliInstance.releases.newDeploy(releaseName, deployOptions);
|
|
1408
1151
|
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
_context5.next = 8;
|
|
1413
|
-
return ctx.cli.releases.finalize(releaseName);
|
|
1152
|
+
case 21:
|
|
1153
|
+
_context.next = 29;
|
|
1154
|
+
break;
|
|
1414
1155
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1156
|
+
case 23:
|
|
1157
|
+
_context.prev = 23;
|
|
1158
|
+
_context.t0 = _context["catch"](0);
|
|
1159
|
+
sentryHub.captureException('Error in "releaseManagementPlugin" writeBundle hook');
|
|
1160
|
+
_context.next = 28;
|
|
1161
|
+
return sentryClient.flush();
|
|
1418
1162
|
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
_context5.t0 = _context5["catch"](5);
|
|
1422
|
-
ctx.hub.captureException(new Error("CLI Error: Finalizing release failed"));
|
|
1423
|
-
throw _context5.t0;
|
|
1163
|
+
case 28:
|
|
1164
|
+
handleRecoverableError(_context.t0);
|
|
1424
1165
|
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1166
|
+
case 29:
|
|
1167
|
+
case "end":
|
|
1168
|
+
return _context.stop();
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}, _callee, null, [[0, 23]]);
|
|
1172
|
+
}))();
|
|
1173
|
+
}
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1429
1176
|
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1177
|
+
function telemetryPlugin(_ref) {
|
|
1178
|
+
var sentryClient = _ref.sentryClient,
|
|
1179
|
+
pluginExecutionTransaction = _ref.pluginExecutionTransaction,
|
|
1180
|
+
shouldSendTelemetry = _ref.shouldSendTelemetry,
|
|
1181
|
+
logger = _ref.logger;
|
|
1182
|
+
return {
|
|
1183
|
+
name: "sentry-telemetry-plugin",
|
|
1184
|
+
buildStart: function buildStart() {
|
|
1185
|
+
void shouldSendTelemetry.then(function () {
|
|
1186
|
+
logger.info("Sending error and performance telemetry data to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
|
|
1187
|
+
});
|
|
1188
|
+
pluginExecutionTransaction.startTimestamp = Date.now() / 1000;
|
|
1189
|
+
},
|
|
1190
|
+
writeBundle: function writeBundle() {
|
|
1191
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1192
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1193
|
+
while (1) {
|
|
1194
|
+
switch (_context.prev = _context.next) {
|
|
1195
|
+
case 0:
|
|
1196
|
+
pluginExecutionTransaction.finish();
|
|
1197
|
+
_context.next = 3;
|
|
1198
|
+
return sentryClient.flush();
|
|
1436
1199
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1200
|
+
case 3:
|
|
1201
|
+
case "end":
|
|
1202
|
+
return _context.stop();
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}, _callee);
|
|
1206
|
+
}))();
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1445
1209
|
}
|
|
1446
1210
|
|
|
1447
|
-
function
|
|
1448
|
-
return
|
|
1449
|
-
|
|
1211
|
+
function createLogger(options) {
|
|
1212
|
+
return {
|
|
1213
|
+
info: function info(message) {
|
|
1214
|
+
if (!options.silent) {
|
|
1215
|
+
var _console;
|
|
1450
1216
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1456
|
-
while (1) {
|
|
1457
|
-
switch (_context6.prev = _context6.next) {
|
|
1458
|
-
case 0:
|
|
1459
|
-
if (options.deploy) {
|
|
1460
|
-
_context6.next = 4;
|
|
1461
|
-
break;
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
ctx.hub.addBreadcrumb({
|
|
1465
|
-
level: "info",
|
|
1466
|
-
message: "Skipping adding deploy info to release."
|
|
1467
|
-
});
|
|
1468
|
-
logger.debug("Skipping adding deploy info to release.");
|
|
1469
|
-
return _context6.abrupt("return");
|
|
1470
|
-
|
|
1471
|
-
case 4:
|
|
1472
|
-
span = addSpanToTransaction(ctx, "function.plugin.deploy");
|
|
1473
|
-
_options$deploy = options.deploy, env = _options$deploy.env, started = _options$deploy.started, finished = _options$deploy.finished, time = _options$deploy.time, name = _options$deploy.name, url = _options$deploy.url;
|
|
1474
|
-
_context6.prev = 6;
|
|
1475
|
-
_context6.next = 9;
|
|
1476
|
-
return ctx.cli.releases.newDeploy(releaseName, {
|
|
1477
|
-
env: env,
|
|
1478
|
-
started: started,
|
|
1479
|
-
finished: finished,
|
|
1480
|
-
time: time,
|
|
1481
|
-
name: name,
|
|
1482
|
-
url: url
|
|
1483
|
-
});
|
|
1484
|
-
|
|
1485
|
-
case 9:
|
|
1486
|
-
_context6.next = 15;
|
|
1487
|
-
break;
|
|
1488
|
-
|
|
1489
|
-
case 11:
|
|
1490
|
-
_context6.prev = 11;
|
|
1491
|
-
_context6.t0 = _context6["catch"](6);
|
|
1492
|
-
ctx.hub.captureException(new Error("CLI Error: Adding deploy info failed"));
|
|
1493
|
-
throw _context6.t0;
|
|
1494
|
-
|
|
1495
|
-
case 15:
|
|
1496
|
-
_context6.prev = 15;
|
|
1497
|
-
span === null || span === void 0 ? void 0 : span.finish();
|
|
1498
|
-
return _context6.finish(15);
|
|
1499
|
-
|
|
1500
|
-
case 18:
|
|
1501
|
-
ctx.hub.addBreadcrumb({
|
|
1502
|
-
level: "info",
|
|
1503
|
-
message: "Successfully added deploy."
|
|
1504
|
-
});
|
|
1505
|
-
ctx.logger.info("Successfully added deploy.");
|
|
1506
|
-
|
|
1507
|
-
case 20:
|
|
1508
|
-
case "end":
|
|
1509
|
-
return _context6.stop();
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
}, _callee6, null, [[6, 11, 15, 18]]);
|
|
1513
|
-
}));
|
|
1514
|
-
return _addDeploy.apply(this, arguments);
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
function createLogger(options) {
|
|
1518
|
-
return {
|
|
1519
|
-
info: function info(message) {
|
|
1520
|
-
if (!options.silent) {
|
|
1521
|
-
var _console;
|
|
1522
|
-
|
|
1523
|
-
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1524
|
-
params[_key - 1] = arguments[_key];
|
|
1525
|
-
}
|
|
1217
|
+
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1218
|
+
params[_key - 1] = arguments[_key];
|
|
1219
|
+
}
|
|
1526
1220
|
|
|
1527
1221
|
// eslint-disable-next-line no-console
|
|
1528
1222
|
(_console = console).log.apply(_console, ["".concat(options.prefix, " Info: ").concat(message)].concat(params));
|
|
@@ -1567,91 +1261,222 @@ function createLogger(options) {
|
|
|
1567
1261
|
};
|
|
1568
1262
|
}
|
|
1569
1263
|
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1264
|
+
var SENTRY_SAAS_HOSTNAME = "sentry.io";
|
|
1265
|
+
function createSentryInstance(options, shouldSendTelemetry, bundler) {
|
|
1266
|
+
var client = new NodeClient({
|
|
1267
|
+
dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
1268
|
+
tracesSampleRate: 1,
|
|
1269
|
+
sampleRate: 1,
|
|
1270
|
+
release: "2.0.0-alpha.2",
|
|
1271
|
+
integrations: [],
|
|
1272
|
+
tracePropagationTargets: ["sentry.io/api"],
|
|
1273
|
+
stackParser: defaultStackParser,
|
|
1274
|
+
beforeSend: function beforeSend(event) {
|
|
1275
|
+
var _event$exception, _event$exception$valu;
|
|
1276
|
+
|
|
1277
|
+
(_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) {
|
|
1278
|
+
delete exception.stacktrace;
|
|
1279
|
+
});
|
|
1280
|
+
delete event.server_name; // Server name might contain PII
|
|
1281
|
+
|
|
1282
|
+
return event;
|
|
1283
|
+
},
|
|
1284
|
+
beforeSendTransaction: function beforeSendTransaction(event) {
|
|
1285
|
+
delete event.server_name; // Server name might contain PII
|
|
1286
|
+
|
|
1287
|
+
return event;
|
|
1288
|
+
},
|
|
1289
|
+
// We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
|
|
1290
|
+
// us that the upload URL is the Sentry SaaS URL)
|
|
1291
|
+
transport: function transport(nodeTransportOptions) {
|
|
1292
|
+
var nodeTransport = makeNodeTransport(nodeTransportOptions);
|
|
1293
|
+
return {
|
|
1294
|
+
flush: function flush(timeout) {
|
|
1295
|
+
return nodeTransport.flush(timeout);
|
|
1296
|
+
},
|
|
1297
|
+
send: function () {
|
|
1298
|
+
var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
|
1299
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1300
|
+
while (1) {
|
|
1301
|
+
switch (_context.prev = _context.next) {
|
|
1302
|
+
case 0:
|
|
1303
|
+
_context.next = 2;
|
|
1304
|
+
return shouldSendTelemetry;
|
|
1305
|
+
|
|
1306
|
+
case 2:
|
|
1307
|
+
if (!_context.sent) {
|
|
1308
|
+
_context.next = 6;
|
|
1309
|
+
break;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
return _context.abrupt("return", nodeTransport.send(request));
|
|
1313
|
+
|
|
1314
|
+
case 6:
|
|
1315
|
+
return _context.abrupt("return", undefined);
|
|
1316
|
+
|
|
1317
|
+
case 7:
|
|
1318
|
+
case "end":
|
|
1319
|
+
return _context.stop();
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
}, _callee);
|
|
1323
|
+
}));
|
|
1324
|
+
|
|
1325
|
+
function send(_x) {
|
|
1326
|
+
return _send.apply(this, arguments);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
return send;
|
|
1330
|
+
}()
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1592
1333
|
});
|
|
1334
|
+
var hub = new Hub(client);
|
|
1335
|
+
setTelemetryDataOnHub(options, hub, bundler);
|
|
1336
|
+
return {
|
|
1337
|
+
sentryHub: hub,
|
|
1338
|
+
sentryClient: client
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
function setTelemetryDataOnHub(options, hub, bundler) {
|
|
1342
|
+
var org = options.org,
|
|
1343
|
+
project = options.project,
|
|
1344
|
+
release = options.release,
|
|
1345
|
+
errorHandler = options.errorHandler,
|
|
1346
|
+
sourcemaps = options.sourcemaps;
|
|
1347
|
+
|
|
1348
|
+
if (release.uploadLegacySourcemaps) {
|
|
1349
|
+
hub.setTag("uploadLegacySourcemapsEntries", Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1);
|
|
1350
|
+
} // Optional release pipeline steps
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
if (release.cleanArtifacts) {
|
|
1354
|
+
hub.setTag("clean-artifacts", true);
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
if (release.setCommits) {
|
|
1358
|
+
hub.setTag("set-commits", release.setCommits.auto === true ? "auto" : "manual");
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
if (release.finalize) {
|
|
1362
|
+
hub.setTag("finalize-release", true);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
if (release.deploy) {
|
|
1366
|
+
hub.setTag("add-deploy", true);
|
|
1367
|
+
} // Miscelaneous options
|
|
1368
|
+
|
|
1369
|
+
|
|
1370
|
+
if (errorHandler) {
|
|
1371
|
+
hub.setTag("error-handler", "custom");
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
if (sourcemaps !== null && sourcemaps !== void 0 && sourcemaps.assets) {
|
|
1375
|
+
hub.setTag("debug-id-upload", true);
|
|
1376
|
+
}
|
|
1593
1377
|
|
|
1594
|
-
if (
|
|
1595
|
-
|
|
1596
|
-
return getDryRunCLI(cli, logger);
|
|
1378
|
+
if (sourcemaps !== null && sourcemaps !== void 0 && sourcemaps.deleteAfterUpload) {
|
|
1379
|
+
hub.setTag("delete-after-upload", true);
|
|
1597
1380
|
}
|
|
1598
1381
|
|
|
1599
|
-
|
|
1382
|
+
hub.setTag("node", process.version);
|
|
1383
|
+
hub.setTags({
|
|
1384
|
+
organization: org,
|
|
1385
|
+
project: project,
|
|
1386
|
+
bundler: bundler
|
|
1387
|
+
});
|
|
1388
|
+
hub.setUser({
|
|
1389
|
+
id: org
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
function allowedToSendTelemetry(_x2) {
|
|
1393
|
+
return _allowedToSendTelemetry.apply(this, arguments);
|
|
1600
1394
|
}
|
|
1601
1395
|
|
|
1602
|
-
function
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1396
|
+
function _allowedToSendTelemetry() {
|
|
1397
|
+
_allowedToSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1398
|
+
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1399
|
+
|
|
1400
|
+
var silent, org, project, authToken, url, headers, telemetry, release, cli, cliInfo, cliInfoUrl;
|
|
1401
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1402
|
+
while (1) {
|
|
1403
|
+
switch (_context2.prev = _context2.next) {
|
|
1404
|
+
case 0:
|
|
1405
|
+
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
|
|
1406
|
+
|
|
1407
|
+
if (!(telemetry === false)) {
|
|
1408
|
+
_context2.next = 3;
|
|
1409
|
+
break;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
return _context2.abrupt("return", false);
|
|
1413
|
+
|
|
1414
|
+
case 3:
|
|
1415
|
+
if (!(url === SENTRY_SAAS_URL)) {
|
|
1416
|
+
_context2.next = 5;
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
return _context2.abrupt("return", true);
|
|
1421
|
+
|
|
1422
|
+
case 5:
|
|
1423
|
+
cli = new SentryCli(null, {
|
|
1424
|
+
url: url,
|
|
1425
|
+
authToken: authToken,
|
|
1426
|
+
org: org,
|
|
1427
|
+
project: project,
|
|
1428
|
+
vcsRemote: release.vcsRemote,
|
|
1429
|
+
silent: silent,
|
|
1430
|
+
headers: headers
|
|
1431
|
+
});
|
|
1432
|
+
_context2.prev = 6;
|
|
1433
|
+
_context2.next = 9;
|
|
1434
|
+
return cli.execute(["info"], false);
|
|
1435
|
+
|
|
1436
|
+
case 9:
|
|
1437
|
+
cliInfo = _context2.sent;
|
|
1438
|
+
_context2.next = 15;
|
|
1439
|
+
break;
|
|
1440
|
+
|
|
1441
|
+
case 12:
|
|
1442
|
+
_context2.prev = 12;
|
|
1443
|
+
_context2.t0 = _context2["catch"](6);
|
|
1444
|
+
return _context2.abrupt("return", false);
|
|
1445
|
+
|
|
1446
|
+
case 15:
|
|
1447
|
+
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();
|
|
1448
|
+
|
|
1449
|
+
if (!(cliInfoUrl === undefined)) {
|
|
1450
|
+
_context2.next = 18;
|
|
1451
|
+
break;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
return _context2.abrupt("return", false);
|
|
1455
|
+
|
|
1456
|
+
case 18:
|
|
1457
|
+
return _context2.abrupt("return", new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME);
|
|
1458
|
+
|
|
1459
|
+
case 19:
|
|
1460
|
+
case "end":
|
|
1461
|
+
return _context2.stop();
|
|
1462
|
+
}
|
|
1634
1463
|
}
|
|
1635
|
-
},
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
return Promise.resolve("Executed");
|
|
1639
|
-
}
|
|
1640
|
-
};
|
|
1464
|
+
}, _callee2, null, [[6, 12]]);
|
|
1465
|
+
}));
|
|
1466
|
+
return _allowedToSendTelemetry.apply(this, arguments);
|
|
1641
1467
|
}
|
|
1642
1468
|
|
|
1643
|
-
var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"];
|
|
1644
1469
|
/**
|
|
1645
1470
|
* The sentry bundler plugin concerns itself with two things:
|
|
1646
1471
|
* - Release injection
|
|
1647
1472
|
* - Sourcemaps upload
|
|
1648
1473
|
*
|
|
1649
1474
|
* Release injection:
|
|
1650
|
-
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into
|
|
1651
|
-
*
|
|
1652
|
-
*
|
|
1653
|
-
*
|
|
1654
|
-
* they can use the `releaseInjectionTargets` option.
|
|
1475
|
+
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into each JavaScript/TypeScript module
|
|
1476
|
+
* that is part of the bundle. On a technical level this is done by appending an import (`import "sentry-release-injector;"`)
|
|
1477
|
+
* to all entrypoint files of the user code (see `transformInclude` and `transform` hooks). This import is then resolved
|
|
1478
|
+
* by the sentry plugin to a virtual module that sets the global variable (see `resolveId` and `load` hooks).
|
|
1479
|
+
* If a user wants to inject the release into a particular set of modules they can use the `releaseInjectionTargets` option.
|
|
1655
1480
|
*
|
|
1656
1481
|
* Source maps upload:
|
|
1657
1482
|
*
|
|
@@ -1668,392 +1493,266 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"]
|
|
|
1668
1493
|
*
|
|
1669
1494
|
* This release creation pipeline relies on Sentry CLI to execute the different steps.
|
|
1670
1495
|
*/
|
|
1671
|
-
|
|
1672
|
-
var
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
// we might interfere with other plugins that use Sentry. However, for now, we'll
|
|
1682
|
-
// leave it in because without it, we can't get distributed traces (which are pretty nice)
|
|
1683
|
-
// Let's keep it until someone complains about interference.
|
|
1684
|
-
// The ideal solution would be a code change in the JS SDK but it's not a straight-forward fix.
|
|
1685
|
-
|
|
1686
|
-
makeMain(sentryHub);
|
|
1687
|
-
var logger = createLogger({
|
|
1688
|
-
prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
|
|
1689
|
-
silent: internalOptions.silent,
|
|
1690
|
-
debug: internalOptions.debug
|
|
1691
|
-
});
|
|
1692
|
-
|
|
1693
|
-
if (!validateOptions(internalOptions, logger)) {
|
|
1694
|
-
handleError(new Error("Options were not set correctly. See output above for more details."), logger, internalOptions.errorHandler);
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
var cli = getSentryCli(internalOptions, logger);
|
|
1698
|
-
var releaseNamePromise = new Promise(function (resolve) {
|
|
1699
|
-
if (options.release) {
|
|
1700
|
-
resolve(options.release);
|
|
1701
|
-
} else {
|
|
1702
|
-
resolve(cli.releases.proposeVersion());
|
|
1496
|
+
function sentryUnpluginFactory(_ref) {
|
|
1497
|
+
var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
|
|
1498
|
+
debugIdInjectionPlugin = _ref.debugIdInjectionPlugin;
|
|
1499
|
+
return createUnplugin(function (userOptions, unpluginMetaContext) {
|
|
1500
|
+
var options = normalizeUserOptions(userOptions);
|
|
1501
|
+
|
|
1502
|
+
if (unpluginMetaContext.watchMode || options.disable) {
|
|
1503
|
+
return [{
|
|
1504
|
+
name: "sentry-noop-plugin"
|
|
1505
|
+
}];
|
|
1703
1506
|
}
|
|
1704
|
-
});
|
|
1705
|
-
var transaction;
|
|
1706
|
-
var releaseInjectionSpan;
|
|
1707
|
-
var absolueEntrypointPaths = new Set();
|
|
1708
|
-
return {
|
|
1709
|
-
name: "sentry-plugin",
|
|
1710
|
-
enforce: "pre",
|
|
1711
|
-
// needed for Vite to call resolveId hook
|
|
1712
1507
|
|
|
1713
|
-
|
|
1714
|
-
* Responsible for starting the plugin execution transaction and the release injection span
|
|
1715
|
-
*/
|
|
1716
|
-
buildStart: function buildStart() {
|
|
1717
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1718
|
-
var isAllowedToSendToSendTelemetry, releaseName;
|
|
1719
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1720
|
-
while (1) {
|
|
1721
|
-
switch (_context.prev = _context.next) {
|
|
1722
|
-
case 0:
|
|
1723
|
-
logger.debug("Called 'buildStart'");
|
|
1724
|
-
_context.next = 3;
|
|
1725
|
-
return allowedToSendTelemetryPromise;
|
|
1508
|
+
var shouldSendTelemetry = allowedToSendTelemetry(options);
|
|
1726
1509
|
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
if (isAllowedToSendToSendTelemetry) {
|
|
1731
|
-
logger.info("Sending error and performance telemetry data to Sentry.");
|
|
1732
|
-
logger.info("To disable telemetry, set `options.telemetry` to `false`.");
|
|
1733
|
-
sentryHub.addBreadcrumb({
|
|
1734
|
-
level: "info",
|
|
1735
|
-
message: "Telemetry enabled."
|
|
1736
|
-
});
|
|
1737
|
-
} else {
|
|
1738
|
-
sentryHub.addBreadcrumb({
|
|
1739
|
-
level: "info",
|
|
1740
|
-
message: "Telemetry disabled. This should never show up in a Sentry event."
|
|
1741
|
-
});
|
|
1742
|
-
}
|
|
1510
|
+
var _createSentryInstance = createSentryInstance(options, shouldSendTelemetry, unpluginMetaContext.framework),
|
|
1511
|
+
sentryHub = _createSentryInstance.sentryHub,
|
|
1512
|
+
sentryClient = _createSentryInstance.sentryClient;
|
|
1743
1513
|
|
|
1744
|
-
|
|
1745
|
-
|
|
1514
|
+
var pluginExecutionTransaction = sentryHub.startTransaction({
|
|
1515
|
+
name: "Sentry Bundler Plugin execution"
|
|
1516
|
+
});
|
|
1517
|
+
sentryHub.getScope().setSpan(pluginExecutionTransaction);
|
|
1518
|
+
var logger = createLogger({
|
|
1519
|
+
prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
|
|
1520
|
+
silent: options.silent,
|
|
1521
|
+
debug: options.debug
|
|
1522
|
+
});
|
|
1746
1523
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1524
|
+
function handleRecoverableError(unknownError) {
|
|
1525
|
+
pluginExecutionTransaction.setStatus("internal_error");
|
|
1749
1526
|
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1527
|
+
if (options.errorHandler) {
|
|
1528
|
+
if (unknownError instanceof Error) {
|
|
1529
|
+
options.errorHandler(unknownError);
|
|
1530
|
+
} else {
|
|
1531
|
+
options.errorHandler(new Error("An unknown error occured"));
|
|
1532
|
+
}
|
|
1533
|
+
} else {
|
|
1534
|
+
throw unknownError;
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1754
1537
|
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
});
|
|
1759
|
-
releaseInjectionSpan = addSpanToTransaction({
|
|
1760
|
-
hub: sentryHub,
|
|
1761
|
-
parentSpan: transaction,
|
|
1762
|
-
logger: logger,
|
|
1763
|
-
cli: cli
|
|
1764
|
-
}, "function.plugin.inject_release", "Release injection");
|
|
1538
|
+
if (!validateOptions(options, logger)) {
|
|
1539
|
+
handleRecoverableError(new Error("Options were not set correctly. See output above for more details."));
|
|
1540
|
+
}
|
|
1765
1541
|
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
}, _callee);
|
|
1772
|
-
}))();
|
|
1773
|
-
},
|
|
1542
|
+
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) {
|
|
1543
|
+
logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
1544
|
+
}
|
|
1774
1545
|
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
isEntry: isEntry
|
|
1546
|
+
var plugins = [];
|
|
1547
|
+
plugins.push(telemetryPlugin({
|
|
1548
|
+
pluginExecutionTransaction: pluginExecutionTransaction,
|
|
1549
|
+
logger: logger,
|
|
1550
|
+
shouldSendTelemetry: shouldSendTelemetry,
|
|
1551
|
+
sentryClient: sentryClient
|
|
1552
|
+
}));
|
|
1553
|
+
|
|
1554
|
+
if (!options.release.inject) {
|
|
1555
|
+
logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
1556
|
+
} else if (!options.release.name) {
|
|
1557
|
+
logger.warn("No release name provided. Will not inject release. Please set the `release.name` option to identifiy your release.");
|
|
1558
|
+
} else {
|
|
1559
|
+
var _injectionCode = generateGlobalInjectorCode({
|
|
1560
|
+
release: options.release.name,
|
|
1561
|
+
injectBuildInformation: options._experiments.injectBuildInformation || false
|
|
1792
1562
|
});
|
|
1793
1563
|
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
return undefined;
|
|
1799
|
-
},
|
|
1564
|
+
plugins.push(releaseInjectionPlugin(_injectionCode));
|
|
1565
|
+
}
|
|
1800
1566
|
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1567
|
+
if (!options.release.name) {
|
|
1568
|
+
logger.warn("No release name provided. Will not create release. Please set the `release.name` option to identifiy your release.");
|
|
1569
|
+
} else if (!options.authToken) {
|
|
1570
|
+
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/");
|
|
1571
|
+
} else if (!options.org) {
|
|
1572
|
+
logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug.");
|
|
1573
|
+
} else if (!options.project) {
|
|
1574
|
+
logger.warn("No project provided. Will not create release. Please set the `project` option to your Sentry project slug.");
|
|
1575
|
+
} else {
|
|
1576
|
+
plugins.push(releaseManagementPlugin({
|
|
1577
|
+
logger: logger,
|
|
1578
|
+
releaseName: options.release.name,
|
|
1579
|
+
shouldCreateRelease: options.release.create,
|
|
1580
|
+
shouldCleanArtifacts: options.release.cleanArtifacts,
|
|
1581
|
+
shouldFinalizeRelease: options.release.finalize,
|
|
1582
|
+
include: options.release.uploadLegacySourcemaps,
|
|
1583
|
+
setCommitsOption: options.release.setCommits,
|
|
1584
|
+
deployOptions: options.release.deploy,
|
|
1585
|
+
dist: options.release.dist,
|
|
1586
|
+
handleRecoverableError: handleRecoverableError,
|
|
1587
|
+
sentryHub: sentryHub,
|
|
1588
|
+
sentryClient: sentryClient,
|
|
1589
|
+
sentryCliOptions: {
|
|
1590
|
+
authToken: options.authToken,
|
|
1591
|
+
org: options.org,
|
|
1592
|
+
project: options.project,
|
|
1593
|
+
silent: options.silent,
|
|
1594
|
+
url: options.url,
|
|
1595
|
+
vcsRemote: options.release.vcsRemote,
|
|
1596
|
+
headers: options.headers
|
|
1821
1597
|
}
|
|
1598
|
+
}));
|
|
1599
|
+
}
|
|
1822
1600
|
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
|
|
1833
|
-
var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
|
|
1834
|
-
return normalizedId.endsWith(allowedFileEnding);
|
|
1835
|
-
});
|
|
1836
|
-
return pathIsOrdinary && pathHasAllowedFileEnding;
|
|
1601
|
+
if (options.sourcemaps) {
|
|
1602
|
+
if (!options.authToken) {
|
|
1603
|
+
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/");
|
|
1604
|
+
} else if (!options.org) {
|
|
1605
|
+
logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug.");
|
|
1606
|
+
} else if (!options.project) {
|
|
1607
|
+
logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug.");
|
|
1608
|
+
} else if (!options.sourcemaps.assets) {
|
|
1609
|
+
logger.warn("No assets defined. Will not upload source maps. Please provide set the `assets` option to your build-output folder.");
|
|
1837
1610
|
} else {
|
|
1838
|
-
|
|
1611
|
+
plugins.push(debugIdInjectionPlugin());
|
|
1612
|
+
plugins.push(debugIdUploadPlugin({
|
|
1613
|
+
assets: options.sourcemaps.assets,
|
|
1614
|
+
ignore: options.sourcemaps.ignore,
|
|
1615
|
+
dist: options.release.dist,
|
|
1616
|
+
releaseName: options.release.name,
|
|
1617
|
+
logger: logger,
|
|
1618
|
+
handleRecoverableError: handleRecoverableError,
|
|
1619
|
+
sentryHub: sentryHub,
|
|
1620
|
+
sentryClient: sentryClient,
|
|
1621
|
+
sentryCliOptions: {
|
|
1622
|
+
authToken: options.authToken,
|
|
1623
|
+
org: options.org,
|
|
1624
|
+
project: options.project,
|
|
1625
|
+
silent: options.silent,
|
|
1626
|
+
url: options.url,
|
|
1627
|
+
vcsRemote: options.release.vcsRemote,
|
|
1628
|
+
headers: options.headers
|
|
1629
|
+
}
|
|
1630
|
+
}));
|
|
1839
1631
|
}
|
|
1840
|
-
}
|
|
1632
|
+
}
|
|
1841
1633
|
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
* @param id Always the absolute (fully resolved) path to the module.
|
|
1848
|
-
* @returns transformed code + source map
|
|
1849
|
-
*/
|
|
1850
|
-
transform: function transform(code, id) {
|
|
1851
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1852
|
-
var ms;
|
|
1853
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1854
|
-
while (1) {
|
|
1855
|
-
switch (_context2.prev = _context2.next) {
|
|
1856
|
-
case 0:
|
|
1857
|
-
logger.debug('Called "transform":', {
|
|
1858
|
-
id: id
|
|
1859
|
-
}); // The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
|
|
1860
|
-
|
|
1861
|
-
ms = new MagicString(code);
|
|
1862
|
-
_context2.t0 = ms;
|
|
1863
|
-
_context2.t1 = generateGlobalInjectorCode;
|
|
1864
|
-
_context2.next = 6;
|
|
1865
|
-
return releaseNamePromise;
|
|
1866
|
-
|
|
1867
|
-
case 6:
|
|
1868
|
-
_context2.t2 = _context2.sent;
|
|
1869
|
-
_context2.t3 = internalOptions.injectReleasesMap;
|
|
1870
|
-
_context2.t4 = internalOptions.org;
|
|
1871
|
-
_context2.t5 = internalOptions.project;
|
|
1872
|
-
_context2.t6 = {
|
|
1873
|
-
release: _context2.t2,
|
|
1874
|
-
injectReleasesMap: _context2.t3,
|
|
1875
|
-
org: _context2.t4,
|
|
1876
|
-
project: _context2.t5
|
|
1877
|
-
};
|
|
1878
|
-
_context2.t7 = (0, _context2.t1)(_context2.t6);
|
|
1879
|
-
|
|
1880
|
-
_context2.t0.prepend.call(_context2.t0, _context2.t7);
|
|
1881
|
-
|
|
1882
|
-
if (!(unpluginMetaContext.framework === "esbuild")) {
|
|
1883
|
-
_context2.next = 17;
|
|
1884
|
-
break;
|
|
1885
|
-
}
|
|
1634
|
+
return plugins;
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
function getBuildInformation() {
|
|
1638
|
+
var packageJson = getPackageJson();
|
|
1886
1639
|
|
|
1887
|
-
|
|
1640
|
+
var _ref2 = packageJson ? getDependencies(packageJson) : {
|
|
1641
|
+
deps: [],
|
|
1642
|
+
depsVersions: {}
|
|
1643
|
+
},
|
|
1644
|
+
deps = _ref2.deps,
|
|
1645
|
+
depsVersions = _ref2.depsVersions;
|
|
1888
1646
|
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1647
|
+
return {
|
|
1648
|
+
deps: deps,
|
|
1649
|
+
depsVersions: depsVersions,
|
|
1650
|
+
nodeVersion: parseMajorVersion(process.version)
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Determines whether the Sentry CLI binary is in its expected location.
|
|
1655
|
+
* This function is useful since `@sentry/cli` installs the binary via a post-install
|
|
1656
|
+
* script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.
|
|
1657
|
+
*/
|
|
1894
1658
|
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1659
|
+
function sentryCliBinaryExists() {
|
|
1660
|
+
return fs.existsSync(SentryCli.getPath());
|
|
1661
|
+
}
|
|
1662
|
+
function createRollupReleaseInjectionHooks(injectionCode) {
|
|
1663
|
+
var virtualReleaseInjectionFileId = "\0sentry-release-injection-file";
|
|
1664
|
+
return {
|
|
1665
|
+
resolveId: function resolveId(id) {
|
|
1666
|
+
if (id === virtualReleaseInjectionFileId) {
|
|
1667
|
+
return {
|
|
1668
|
+
id: virtualReleaseInjectionFileId,
|
|
1669
|
+
external: false,
|
|
1670
|
+
moduleSideEffects: true
|
|
1671
|
+
};
|
|
1672
|
+
} else {
|
|
1673
|
+
return null;
|
|
1674
|
+
}
|
|
1902
1675
|
},
|
|
1676
|
+
load: function load(id) {
|
|
1677
|
+
if (id === virtualReleaseInjectionFileId) {
|
|
1678
|
+
return injectionCode;
|
|
1679
|
+
} else {
|
|
1680
|
+
return null;
|
|
1681
|
+
}
|
|
1682
|
+
},
|
|
1683
|
+
transform: function transform(code, id) {
|
|
1684
|
+
if (id === virtualReleaseInjectionFileId) {
|
|
1685
|
+
return null;
|
|
1686
|
+
}
|
|
1903
1687
|
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
*/
|
|
1908
|
-
writeBundle: function writeBundle() {
|
|
1909
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1910
|
-
var _releaseInjectionSpan;
|
|
1911
|
-
|
|
1912
|
-
var releasePipelineSpan, ctx, releaseName, _transaction, _transaction2, _transaction3;
|
|
1913
|
-
|
|
1914
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1915
|
-
while (1) {
|
|
1916
|
-
switch (_context3.prev = _context3.next) {
|
|
1917
|
-
case 0:
|
|
1918
|
-
logger.debug('Called "writeBundle"');
|
|
1919
|
-
(_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
|
|
1920
|
-
releasePipelineSpan = transaction && addSpanToTransaction({
|
|
1921
|
-
hub: sentryHub,
|
|
1922
|
-
parentSpan: transaction,
|
|
1923
|
-
logger: logger,
|
|
1924
|
-
cli: cli
|
|
1925
|
-
}, "function.plugin.release", "Release pipeline");
|
|
1926
|
-
sentryHub.addBreadcrumb({
|
|
1927
|
-
category: "writeBundle:start",
|
|
1928
|
-
level: "info"
|
|
1929
|
-
});
|
|
1930
|
-
ctx = {
|
|
1931
|
-
hub: sentryHub,
|
|
1932
|
-
parentSpan: releasePipelineSpan,
|
|
1933
|
-
logger: logger,
|
|
1934
|
-
cli: cli
|
|
1935
|
-
};
|
|
1936
|
-
_context3.next = 7;
|
|
1937
|
-
return releaseNamePromise;
|
|
1938
|
-
|
|
1939
|
-
case 7:
|
|
1940
|
-
releaseName = _context3.sent;
|
|
1941
|
-
_context3.prev = 8;
|
|
1942
|
-
_context3.next = 11;
|
|
1943
|
-
return createNewRelease(internalOptions, ctx, releaseName);
|
|
1944
|
-
|
|
1945
|
-
case 11:
|
|
1946
|
-
_context3.next = 13;
|
|
1947
|
-
return cleanArtifacts(internalOptions, ctx, releaseName);
|
|
1948
|
-
|
|
1949
|
-
case 13:
|
|
1950
|
-
_context3.next = 15;
|
|
1951
|
-
return uploadSourceMaps(internalOptions, ctx, releaseName);
|
|
1952
|
-
|
|
1953
|
-
case 15:
|
|
1954
|
-
_context3.next = 17;
|
|
1955
|
-
return setCommits(internalOptions, ctx, releaseName);
|
|
1956
|
-
|
|
1957
|
-
case 17:
|
|
1958
|
-
_context3.next = 19;
|
|
1959
|
-
return finalizeRelease(internalOptions, ctx, releaseName);
|
|
1960
|
-
|
|
1961
|
-
case 19:
|
|
1962
|
-
_context3.next = 21;
|
|
1963
|
-
return addDeploy(internalOptions, ctx, releaseName);
|
|
1964
|
-
|
|
1965
|
-
case 21:
|
|
1966
|
-
(_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
|
|
1967
|
-
_context3.next = 29;
|
|
1968
|
-
break;
|
|
1969
|
-
|
|
1970
|
-
case 24:
|
|
1971
|
-
_context3.prev = 24;
|
|
1972
|
-
_context3.t0 = _context3["catch"](8);
|
|
1973
|
-
(_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
|
|
1974
|
-
sentryHub.addBreadcrumb({
|
|
1975
|
-
level: "error",
|
|
1976
|
-
message: "Error during writeBundle"
|
|
1977
|
-
});
|
|
1978
|
-
handleError(_context3.t0, logger, internalOptions.errorHandler);
|
|
1979
|
-
|
|
1980
|
-
case 29:
|
|
1981
|
-
_context3.prev = 29;
|
|
1982
|
-
releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
|
|
1983
|
-
(_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
|
|
1984
|
-
_context3.next = 34;
|
|
1985
|
-
return sentryClient.flush().then(null, function () {
|
|
1986
|
-
logger.warn("Sending of telemetry failed");
|
|
1987
|
-
});
|
|
1688
|
+
if (id.match(/\\node_modules\\|\/node_modules\//)) {
|
|
1689
|
+
return null;
|
|
1690
|
+
}
|
|
1988
1691
|
|
|
1989
|
-
|
|
1990
|
-
|
|
1692
|
+
if (![".js", ".ts", ".jsx", ".tsx", ".mjs"].some(function (ending) {
|
|
1693
|
+
return id.endsWith(ending);
|
|
1694
|
+
})) {
|
|
1695
|
+
return null;
|
|
1696
|
+
}
|
|
1991
1697
|
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
category: "writeBundle:finish",
|
|
1995
|
-
level: "info"
|
|
1996
|
-
});
|
|
1698
|
+
var ms = new MagicString(code); // Appending instead of prepending has less probability of mucking with user's source maps.
|
|
1699
|
+
// Luckily import statements get hoisted to the top anyways.
|
|
1997
1700
|
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
}, _callee3, null, [[8, 24, 29, 35]]);
|
|
2004
|
-
}))();
|
|
1701
|
+
ms.append("\n\n;import \"".concat(virtualReleaseInjectionFileId, "\";"));
|
|
1702
|
+
return {
|
|
1703
|
+
code: ms.toString(),
|
|
1704
|
+
map: ms.generateMap()
|
|
1705
|
+
};
|
|
2005
1706
|
}
|
|
2006
1707
|
};
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
1708
|
+
}
|
|
1709
|
+
function createRollupDebugIdInjectionHooks() {
|
|
1710
|
+
return {
|
|
1711
|
+
renderChunk: function renderChunk(code, chunk) {
|
|
1712
|
+
if ([".js", ".mjs", ".cjs"].some(function (ending) {
|
|
1713
|
+
return chunk.fileName.endsWith(ending);
|
|
1714
|
+
}) // chunks could be any file (html, md, ...)
|
|
1715
|
+
) {
|
|
1716
|
+
var _code$match;
|
|
1717
|
+
|
|
1718
|
+
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
1719
|
+
|
|
1720
|
+
var codeToInject = getDebugIdSnippet(debugId);
|
|
1721
|
+
var ms = new MagicString(code, {
|
|
1722
|
+
filename: chunk.fileName
|
|
1723
|
+
}); // We need to be careful not to inject the snippet before any `"use strict";`s.
|
|
1724
|
+
// As an additional complication `"use strict";`s may come after any number of comments.
|
|
1725
|
+
|
|
1726
|
+
var commentUseStrictRegex = // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
|
|
1727
|
+
/^(?:\s*|\/\*(?:.|\r|\n)*\*\/|\/\/.*[\n\r])*(?:"[^"]*";|'[^']*';)?/;
|
|
1728
|
+
|
|
1729
|
+
if ((_code$match = code.match(commentUseStrictRegex)) !== null && _code$match !== void 0 && _code$match[0]) {
|
|
1730
|
+
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
1731
|
+
ms.replace(commentUseStrictRegex, function (match) {
|
|
1732
|
+
return "".concat(match).concat(codeToInject);
|
|
1733
|
+
});
|
|
1734
|
+
} else {
|
|
1735
|
+
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
1736
|
+
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
1737
|
+
// need this special case here.
|
|
1738
|
+
ms.prepend(codeToInject);
|
|
1739
|
+
}
|
|
2015
1740
|
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
1741
|
+
return {
|
|
1742
|
+
code: ms.toString(),
|
|
1743
|
+
map: ms.generateMap({
|
|
1744
|
+
file: chunk.fileName
|
|
1745
|
+
})
|
|
1746
|
+
};
|
|
1747
|
+
} else {
|
|
1748
|
+
return null; // returning null means not modifying the chunk at all
|
|
1749
|
+
}
|
|
2021
1750
|
}
|
|
2022
|
-
}
|
|
2023
|
-
|
|
2024
|
-
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
function getDebugIdSnippet(debugId) {
|
|
1754
|
+
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){}}();");
|
|
2025
1755
|
}
|
|
2026
|
-
/**
|
|
2027
|
-
* Generates code for the "sentry-release-injector" which is responsible for setting the global `SENTRY_RELEASE`
|
|
2028
|
-
* variable.
|
|
2029
|
-
*/
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
function generateGlobalInjectorCode(_ref2) {
|
|
2033
|
-
var release = _ref2.release,
|
|
2034
|
-
injectReleasesMap = _ref2.injectReleasesMap,
|
|
2035
|
-
org = _ref2.org,
|
|
2036
|
-
project = _ref2.project;
|
|
2037
|
-
// The code below is mostly ternary operators because it saves bundle size.
|
|
2038
|
-
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
2039
|
-
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, "\"};");
|
|
2040
|
-
|
|
2041
|
-
if (injectReleasesMap && project) {
|
|
2042
|
-
var key = org ? "".concat(project, "@").concat(org) : project;
|
|
2043
|
-
code += "\n _global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};\n _global.SENTRY_RELEASES[\"".concat(key, "\"]={id:\"").concat(release, "\"};");
|
|
2044
|
-
}
|
|
2045
|
-
|
|
2046
|
-
return code;
|
|
2047
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
var sentryVitePlugin = unplugin.vite; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2051
|
-
|
|
2052
|
-
var sentryRollupPlugin = unplugin.rollup; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2053
|
-
|
|
2054
|
-
var sentryWebpackPlugin = unplugin.webpack; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2055
|
-
|
|
2056
|
-
var sentryEsbuildPlugin = unplugin.esbuild;
|
|
2057
1756
|
|
|
2058
|
-
export {
|
|
1757
|
+
export { createRollupDebugIdInjectionHooks, createRollupReleaseInjectionHooks, getBuildInformation, getDebugIdSnippet, sentryCliBinaryExists, sentryUnpluginFactory };
|
|
2059
1758
|
//# sourceMappingURL=index.mjs.map
|