@front10/danger-plugins 2.0.0-alpha.6 → 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1089 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var fs = require('fs');
8
- var fs__default = _interopDefault(fs);
9
- var undici = require('undici');
10
- var path = _interopDefault(require('path'));
11
- var zlib = _interopDefault(require('zlib'));
12
- var util = require('util');
13
-
14
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
15
- try {
16
- var info = gen[key](arg);
17
- var value = info.value;
18
- } catch (error) {
19
- reject(error);
20
- return;
21
- }
22
-
23
- if (info.done) {
24
- resolve(value);
25
- } else {
26
- Promise.resolve(value).then(_next, _throw);
27
- }
28
- }
29
-
30
- function _asyncToGenerator(fn) {
31
- return function () {
32
- var self = this,
33
- args = arguments;
34
- return new Promise(function (resolve, reject) {
35
- var gen = fn.apply(self, args);
36
-
37
- function _next(value) {
38
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
39
- }
40
-
41
- function _throw(err) {
42
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
43
- }
44
-
45
- _next(undefined);
46
- });
47
- };
48
- }
49
-
50
- function createCommonjsModule(fn, module) {
51
- return module = { exports: {} }, fn(module, module.exports), module.exports;
52
- }
53
-
54
- var runtime_1 = createCommonjsModule(function (module) {
55
- /**
56
- * Copyright (c) 2014-present, Facebook, Inc.
57
- *
58
- * This source code is licensed under the MIT license found in the
59
- * LICENSE file in the root directory of this source tree.
60
- */
61
-
62
- var runtime = (function (exports) {
63
-
64
- var Op = Object.prototype;
65
- var hasOwn = Op.hasOwnProperty;
66
- var undefined$1; // More compressible than void 0.
67
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
68
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
69
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
70
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
71
-
72
- function wrap(innerFn, outerFn, self, tryLocsList) {
73
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
74
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
75
- var generator = Object.create(protoGenerator.prototype);
76
- var context = new Context(tryLocsList || []);
77
-
78
- // The ._invoke method unifies the implementations of the .next,
79
- // .throw, and .return methods.
80
- generator._invoke = makeInvokeMethod(innerFn, self, context);
81
-
82
- return generator;
83
- }
84
- exports.wrap = wrap;
85
-
86
- // Try/catch helper to minimize deoptimizations. Returns a completion
87
- // record like context.tryEntries[i].completion. This interface could
88
- // have been (and was previously) designed to take a closure to be
89
- // invoked without arguments, but in all the cases we care about we
90
- // already have an existing method we want to call, so there's no need
91
- // to create a new function object. We can even get away with assuming
92
- // the method takes exactly one argument, since that happens to be true
93
- // in every case, so we don't have to touch the arguments object. The
94
- // only additional allocation required is the completion record, which
95
- // has a stable shape and so hopefully should be cheap to allocate.
96
- function tryCatch(fn, obj, arg) {
97
- try {
98
- return { type: "normal", arg: fn.call(obj, arg) };
99
- } catch (err) {
100
- return { type: "throw", arg: err };
101
- }
102
- }
103
-
104
- var GenStateSuspendedStart = "suspendedStart";
105
- var GenStateSuspendedYield = "suspendedYield";
106
- var GenStateExecuting = "executing";
107
- var GenStateCompleted = "completed";
108
-
109
- // Returning this object from the innerFn has the same effect as
110
- // breaking out of the dispatch switch statement.
111
- var ContinueSentinel = {};
112
-
113
- // Dummy constructor functions that we use as the .constructor and
114
- // .constructor.prototype properties for functions that return Generator
115
- // objects. For full spec compliance, you may wish to configure your
116
- // minifier not to mangle the names of these two functions.
117
- function Generator() {}
118
- function GeneratorFunction() {}
119
- function GeneratorFunctionPrototype() {}
120
-
121
- // This is a polyfill for %IteratorPrototype% for environments that
122
- // don't natively support it.
123
- var IteratorPrototype = {};
124
- IteratorPrototype[iteratorSymbol] = function () {
125
- return this;
126
- };
127
-
128
- var getProto = Object.getPrototypeOf;
129
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
130
- if (NativeIteratorPrototype &&
131
- NativeIteratorPrototype !== Op &&
132
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
133
- // This environment has a native %IteratorPrototype%; use it instead
134
- // of the polyfill.
135
- IteratorPrototype = NativeIteratorPrototype;
136
- }
137
-
138
- var Gp = GeneratorFunctionPrototype.prototype =
139
- Generator.prototype = Object.create(IteratorPrototype);
140
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
141
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
142
- GeneratorFunctionPrototype[toStringTagSymbol] =
143
- GeneratorFunction.displayName = "GeneratorFunction";
144
-
145
- // Helper for defining the .next, .throw, and .return methods of the
146
- // Iterator interface in terms of a single ._invoke method.
147
- function defineIteratorMethods(prototype) {
148
- ["next", "throw", "return"].forEach(function(method) {
149
- prototype[method] = function(arg) {
150
- return this._invoke(method, arg);
151
- };
152
- });
153
- }
154
-
155
- exports.isGeneratorFunction = function(genFun) {
156
- var ctor = typeof genFun === "function" && genFun.constructor;
157
- return ctor
158
- ? ctor === GeneratorFunction ||
159
- // For the native GeneratorFunction constructor, the best we can
160
- // do is to check its .name property.
161
- (ctor.displayName || ctor.name) === "GeneratorFunction"
162
- : false;
163
- };
164
-
165
- exports.mark = function(genFun) {
166
- if (Object.setPrototypeOf) {
167
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
168
- } else {
169
- genFun.__proto__ = GeneratorFunctionPrototype;
170
- if (!(toStringTagSymbol in genFun)) {
171
- genFun[toStringTagSymbol] = "GeneratorFunction";
172
- }
173
- }
174
- genFun.prototype = Object.create(Gp);
175
- return genFun;
176
- };
177
-
178
- // Within the body of any async function, `await x` is transformed to
179
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
180
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
181
- // meant to be awaited.
182
- exports.awrap = function(arg) {
183
- return { __await: arg };
184
- };
185
-
186
- function AsyncIterator(generator, PromiseImpl) {
187
- function invoke(method, arg, resolve, reject) {
188
- var record = tryCatch(generator[method], generator, arg);
189
- if (record.type === "throw") {
190
- reject(record.arg);
191
- } else {
192
- var result = record.arg;
193
- var value = result.value;
194
- if (value &&
195
- typeof value === "object" &&
196
- hasOwn.call(value, "__await")) {
197
- return PromiseImpl.resolve(value.__await).then(function(value) {
198
- invoke("next", value, resolve, reject);
199
- }, function(err) {
200
- invoke("throw", err, resolve, reject);
201
- });
202
- }
203
-
204
- return PromiseImpl.resolve(value).then(function(unwrapped) {
205
- // When a yielded Promise is resolved, its final value becomes
206
- // the .value of the Promise<{value,done}> result for the
207
- // current iteration.
208
- result.value = unwrapped;
209
- resolve(result);
210
- }, function(error) {
211
- // If a rejected Promise was yielded, throw the rejection back
212
- // into the async generator function so it can be handled there.
213
- return invoke("throw", error, resolve, reject);
214
- });
215
- }
216
- }
217
-
218
- var previousPromise;
219
-
220
- function enqueue(method, arg) {
221
- function callInvokeWithMethodAndArg() {
222
- return new PromiseImpl(function(resolve, reject) {
223
- invoke(method, arg, resolve, reject);
224
- });
225
- }
226
-
227
- return previousPromise =
228
- // If enqueue has been called before, then we want to wait until
229
- // all previous Promises have been resolved before calling invoke,
230
- // so that results are always delivered in the correct order. If
231
- // enqueue has not been called before, then it is important to
232
- // call invoke immediately, without waiting on a callback to fire,
233
- // so that the async generator function has the opportunity to do
234
- // any necessary setup in a predictable way. This predictability
235
- // is why the Promise constructor synchronously invokes its
236
- // executor callback, and why async functions synchronously
237
- // execute code before the first await. Since we implement simple
238
- // async functions in terms of async generators, it is especially
239
- // important to get this right, even though it requires care.
240
- previousPromise ? previousPromise.then(
241
- callInvokeWithMethodAndArg,
242
- // Avoid propagating failures to Promises returned by later
243
- // invocations of the iterator.
244
- callInvokeWithMethodAndArg
245
- ) : callInvokeWithMethodAndArg();
246
- }
247
-
248
- // Define the unified helper method that is used to implement .next,
249
- // .throw, and .return (see defineIteratorMethods).
250
- this._invoke = enqueue;
251
- }
252
-
253
- defineIteratorMethods(AsyncIterator.prototype);
254
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
255
- return this;
256
- };
257
- exports.AsyncIterator = AsyncIterator;
258
-
259
- // Note that simple async functions are implemented on top of
260
- // AsyncIterator objects; they just return a Promise for the value of
261
- // the final result produced by the iterator.
262
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
263
- if (PromiseImpl === void 0) PromiseImpl = Promise;
264
-
265
- var iter = new AsyncIterator(
266
- wrap(innerFn, outerFn, self, tryLocsList),
267
- PromiseImpl
268
- );
269
-
270
- return exports.isGeneratorFunction(outerFn)
271
- ? iter // If outerFn is a generator, return the full iterator.
272
- : iter.next().then(function(result) {
273
- return result.done ? result.value : iter.next();
274
- });
275
- };
276
-
277
- function makeInvokeMethod(innerFn, self, context) {
278
- var state = GenStateSuspendedStart;
279
-
280
- return function invoke(method, arg) {
281
- if (state === GenStateExecuting) {
282
- throw new Error("Generator is already running");
283
- }
284
-
285
- if (state === GenStateCompleted) {
286
- if (method === "throw") {
287
- throw arg;
288
- }
289
-
290
- // Be forgiving, per 25.3.3.3.3 of the spec:
291
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
292
- return doneResult();
293
- }
294
-
295
- context.method = method;
296
- context.arg = arg;
297
-
298
- while (true) {
299
- var delegate = context.delegate;
300
- if (delegate) {
301
- var delegateResult = maybeInvokeDelegate(delegate, context);
302
- if (delegateResult) {
303
- if (delegateResult === ContinueSentinel) continue;
304
- return delegateResult;
305
- }
306
- }
307
-
308
- if (context.method === "next") {
309
- // Setting context._sent for legacy support of Babel's
310
- // function.sent implementation.
311
- context.sent = context._sent = context.arg;
312
-
313
- } else if (context.method === "throw") {
314
- if (state === GenStateSuspendedStart) {
315
- state = GenStateCompleted;
316
- throw context.arg;
317
- }
318
-
319
- context.dispatchException(context.arg);
320
-
321
- } else if (context.method === "return") {
322
- context.abrupt("return", context.arg);
323
- }
324
-
325
- state = GenStateExecuting;
326
-
327
- var record = tryCatch(innerFn, self, context);
328
- if (record.type === "normal") {
329
- // If an exception is thrown from innerFn, we leave state ===
330
- // GenStateExecuting and loop back for another invocation.
331
- state = context.done
332
- ? GenStateCompleted
333
- : GenStateSuspendedYield;
334
-
335
- if (record.arg === ContinueSentinel) {
336
- continue;
337
- }
338
-
339
- return {
340
- value: record.arg,
341
- done: context.done
342
- };
343
-
344
- } else if (record.type === "throw") {
345
- state = GenStateCompleted;
346
- // Dispatch the exception by looping back around to the
347
- // context.dispatchException(context.arg) call above.
348
- context.method = "throw";
349
- context.arg = record.arg;
350
- }
351
- }
352
- };
353
- }
354
-
355
- // Call delegate.iterator[context.method](context.arg) and handle the
356
- // result, either by returning a { value, done } result from the
357
- // delegate iterator, or by modifying context.method and context.arg,
358
- // setting context.delegate to null, and returning the ContinueSentinel.
359
- function maybeInvokeDelegate(delegate, context) {
360
- var method = delegate.iterator[context.method];
361
- if (method === undefined$1) {
362
- // A .throw or .return when the delegate iterator has no .throw
363
- // method always terminates the yield* loop.
364
- context.delegate = null;
365
-
366
- if (context.method === "throw") {
367
- // Note: ["return"] must be used for ES3 parsing compatibility.
368
- if (delegate.iterator["return"]) {
369
- // If the delegate iterator has a return method, give it a
370
- // chance to clean up.
371
- context.method = "return";
372
- context.arg = undefined$1;
373
- maybeInvokeDelegate(delegate, context);
374
-
375
- if (context.method === "throw") {
376
- // If maybeInvokeDelegate(context) changed context.method from
377
- // "return" to "throw", let that override the TypeError below.
378
- return ContinueSentinel;
379
- }
380
- }
381
-
382
- context.method = "throw";
383
- context.arg = new TypeError(
384
- "The iterator does not provide a 'throw' method");
385
- }
386
-
387
- return ContinueSentinel;
388
- }
389
-
390
- var record = tryCatch(method, delegate.iterator, context.arg);
391
-
392
- if (record.type === "throw") {
393
- context.method = "throw";
394
- context.arg = record.arg;
395
- context.delegate = null;
396
- return ContinueSentinel;
397
- }
398
-
399
- var info = record.arg;
400
-
401
- if (! info) {
402
- context.method = "throw";
403
- context.arg = new TypeError("iterator result is not an object");
404
- context.delegate = null;
405
- return ContinueSentinel;
406
- }
407
-
408
- if (info.done) {
409
- // Assign the result of the finished delegate to the temporary
410
- // variable specified by delegate.resultName (see delegateYield).
411
- context[delegate.resultName] = info.value;
412
-
413
- // Resume execution at the desired location (see delegateYield).
414
- context.next = delegate.nextLoc;
415
-
416
- // If context.method was "throw" but the delegate handled the
417
- // exception, let the outer generator proceed normally. If
418
- // context.method was "next", forget context.arg since it has been
419
- // "consumed" by the delegate iterator. If context.method was
420
- // "return", allow the original .return call to continue in the
421
- // outer generator.
422
- if (context.method !== "return") {
423
- context.method = "next";
424
- context.arg = undefined$1;
425
- }
426
-
427
- } else {
428
- // Re-yield the result returned by the delegate method.
429
- return info;
430
- }
431
-
432
- // The delegate iterator is finished, so forget it and continue with
433
- // the outer generator.
434
- context.delegate = null;
435
- return ContinueSentinel;
436
- }
437
-
438
- // Define Generator.prototype.{next,throw,return} in terms of the
439
- // unified ._invoke helper method.
440
- defineIteratorMethods(Gp);
441
-
442
- Gp[toStringTagSymbol] = "Generator";
443
-
444
- // A Generator should always return itself as the iterator object when the
445
- // @@iterator function is called on it. Some browsers' implementations of the
446
- // iterator prototype chain incorrectly implement this, causing the Generator
447
- // object to not be returned from this call. This ensures that doesn't happen.
448
- // See https://github.com/facebook/regenerator/issues/274 for more details.
449
- Gp[iteratorSymbol] = function() {
450
- return this;
451
- };
452
-
453
- Gp.toString = function() {
454
- return "[object Generator]";
455
- };
456
-
457
- function pushTryEntry(locs) {
458
- var entry = { tryLoc: locs[0] };
459
-
460
- if (1 in locs) {
461
- entry.catchLoc = locs[1];
462
- }
463
-
464
- if (2 in locs) {
465
- entry.finallyLoc = locs[2];
466
- entry.afterLoc = locs[3];
467
- }
468
-
469
- this.tryEntries.push(entry);
470
- }
471
-
472
- function resetTryEntry(entry) {
473
- var record = entry.completion || {};
474
- record.type = "normal";
475
- delete record.arg;
476
- entry.completion = record;
477
- }
478
-
479
- function Context(tryLocsList) {
480
- // The root entry object (effectively a try statement without a catch
481
- // or a finally block) gives us a place to store values thrown from
482
- // locations where there is no enclosing try statement.
483
- this.tryEntries = [{ tryLoc: "root" }];
484
- tryLocsList.forEach(pushTryEntry, this);
485
- this.reset(true);
486
- }
487
-
488
- exports.keys = function(object) {
489
- var keys = [];
490
- for (var key in object) {
491
- keys.push(key);
492
- }
493
- keys.reverse();
494
-
495
- // Rather than returning an object with a next method, we keep
496
- // things simple and return the next function itself.
497
- return function next() {
498
- while (keys.length) {
499
- var key = keys.pop();
500
- if (key in object) {
501
- next.value = key;
502
- next.done = false;
503
- return next;
504
- }
505
- }
506
-
507
- // To avoid creating an additional object, we just hang the .value
508
- // and .done properties off the next function object itself. This
509
- // also ensures that the minifier will not anonymize the function.
510
- next.done = true;
511
- return next;
512
- };
513
- };
514
-
515
- function values(iterable) {
516
- if (iterable) {
517
- var iteratorMethod = iterable[iteratorSymbol];
518
- if (iteratorMethod) {
519
- return iteratorMethod.call(iterable);
520
- }
521
-
522
- if (typeof iterable.next === "function") {
523
- return iterable;
524
- }
525
-
526
- if (!isNaN(iterable.length)) {
527
- var i = -1, next = function next() {
528
- while (++i < iterable.length) {
529
- if (hasOwn.call(iterable, i)) {
530
- next.value = iterable[i];
531
- next.done = false;
532
- return next;
533
- }
534
- }
535
-
536
- next.value = undefined$1;
537
- next.done = true;
538
-
539
- return next;
540
- };
541
-
542
- return next.next = next;
543
- }
544
- }
545
-
546
- // Return an iterator with no values.
547
- return { next: doneResult };
548
- }
549
- exports.values = values;
550
-
551
- function doneResult() {
552
- return { value: undefined$1, done: true };
553
- }
554
-
555
- Context.prototype = {
556
- constructor: Context,
557
-
558
- reset: function(skipTempReset) {
559
- this.prev = 0;
560
- this.next = 0;
561
- // Resetting context._sent for legacy support of Babel's
562
- // function.sent implementation.
563
- this.sent = this._sent = undefined$1;
564
- this.done = false;
565
- this.delegate = null;
566
-
567
- this.method = "next";
568
- this.arg = undefined$1;
569
-
570
- this.tryEntries.forEach(resetTryEntry);
571
-
572
- if (!skipTempReset) {
573
- for (var name in this) {
574
- // Not sure about the optimal order of these conditions:
575
- if (name.charAt(0) === "t" &&
576
- hasOwn.call(this, name) &&
577
- !isNaN(+name.slice(1))) {
578
- this[name] = undefined$1;
579
- }
580
- }
581
- }
582
- },
583
-
584
- stop: function() {
585
- this.done = true;
586
-
587
- var rootEntry = this.tryEntries[0];
588
- var rootRecord = rootEntry.completion;
589
- if (rootRecord.type === "throw") {
590
- throw rootRecord.arg;
591
- }
592
-
593
- return this.rval;
594
- },
595
-
596
- dispatchException: function(exception) {
597
- if (this.done) {
598
- throw exception;
599
- }
600
-
601
- var context = this;
602
- function handle(loc, caught) {
603
- record.type = "throw";
604
- record.arg = exception;
605
- context.next = loc;
606
-
607
- if (caught) {
608
- // If the dispatched exception was caught by a catch block,
609
- // then let that catch block handle the exception normally.
610
- context.method = "next";
611
- context.arg = undefined$1;
612
- }
613
-
614
- return !! caught;
615
- }
616
-
617
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
618
- var entry = this.tryEntries[i];
619
- var record = entry.completion;
620
-
621
- if (entry.tryLoc === "root") {
622
- // Exception thrown outside of any try block that could handle
623
- // it, so set the completion value of the entire function to
624
- // throw the exception.
625
- return handle("end");
626
- }
627
-
628
- if (entry.tryLoc <= this.prev) {
629
- var hasCatch = hasOwn.call(entry, "catchLoc");
630
- var hasFinally = hasOwn.call(entry, "finallyLoc");
631
-
632
- if (hasCatch && hasFinally) {
633
- if (this.prev < entry.catchLoc) {
634
- return handle(entry.catchLoc, true);
635
- } else if (this.prev < entry.finallyLoc) {
636
- return handle(entry.finallyLoc);
637
- }
638
-
639
- } else if (hasCatch) {
640
- if (this.prev < entry.catchLoc) {
641
- return handle(entry.catchLoc, true);
642
- }
643
-
644
- } else if (hasFinally) {
645
- if (this.prev < entry.finallyLoc) {
646
- return handle(entry.finallyLoc);
647
- }
648
-
649
- } else {
650
- throw new Error("try statement without catch or finally");
651
- }
652
- }
653
- }
654
- },
655
-
656
- abrupt: function(type, arg) {
657
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
658
- var entry = this.tryEntries[i];
659
- if (entry.tryLoc <= this.prev &&
660
- hasOwn.call(entry, "finallyLoc") &&
661
- this.prev < entry.finallyLoc) {
662
- var finallyEntry = entry;
663
- break;
664
- }
665
- }
666
-
667
- if (finallyEntry &&
668
- (type === "break" ||
669
- type === "continue") &&
670
- finallyEntry.tryLoc <= arg &&
671
- arg <= finallyEntry.finallyLoc) {
672
- // Ignore the finally entry if control is not jumping to a
673
- // location outside the try/catch block.
674
- finallyEntry = null;
675
- }
676
-
677
- var record = finallyEntry ? finallyEntry.completion : {};
678
- record.type = type;
679
- record.arg = arg;
680
-
681
- if (finallyEntry) {
682
- this.method = "next";
683
- this.next = finallyEntry.finallyLoc;
684
- return ContinueSentinel;
685
- }
686
-
687
- return this.complete(record);
688
- },
689
-
690
- complete: function(record, afterLoc) {
691
- if (record.type === "throw") {
692
- throw record.arg;
693
- }
694
-
695
- if (record.type === "break" ||
696
- record.type === "continue") {
697
- this.next = record.arg;
698
- } else if (record.type === "return") {
699
- this.rval = this.arg = record.arg;
700
- this.method = "return";
701
- this.next = "end";
702
- } else if (record.type === "normal" && afterLoc) {
703
- this.next = afterLoc;
704
- }
705
-
706
- return ContinueSentinel;
707
- },
708
-
709
- finish: function(finallyLoc) {
710
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
711
- var entry = this.tryEntries[i];
712
- if (entry.finallyLoc === finallyLoc) {
713
- this.complete(entry.completion, entry.afterLoc);
714
- resetTryEntry(entry);
715
- return ContinueSentinel;
716
- }
717
- }
718
- },
719
-
720
- "catch": function(tryLoc) {
721
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
722
- var entry = this.tryEntries[i];
723
- if (entry.tryLoc === tryLoc) {
724
- var record = entry.completion;
725
- if (record.type === "throw") {
726
- var thrown = record.arg;
727
- resetTryEntry(entry);
728
- }
729
- return thrown;
730
- }
731
- }
732
-
733
- // The context.catch method must only be called with a location
734
- // argument that corresponds to a known catch block.
735
- throw new Error("illegal catch attempt");
736
- },
737
-
738
- delegateYield: function(iterable, resultName, nextLoc) {
739
- this.delegate = {
740
- iterator: values(iterable),
741
- resultName: resultName,
742
- nextLoc: nextLoc
743
- };
744
-
745
- if (this.method === "next") {
746
- // Deliberately forget the last sent value so that we don't
747
- // accidentally pass it on to the delegate.
748
- this.arg = undefined$1;
749
- }
750
-
751
- return ContinueSentinel;
752
- }
753
- };
754
-
755
- // Regardless of whether this script is executing as a CommonJS module
756
- // or not, return the runtime object so that we can declare the variable
757
- // regeneratorRuntime in the outer scope, which allows this module to be
758
- // injected easily by `bin/regenerator --include-runtime script.js`.
759
- return exports;
760
-
761
- }(
762
- // If this script is executing as a CommonJS module, use module.exports
763
- // as the regeneratorRuntime namespace. Otherwise create a new empty
764
- // object. Either way, the resulting object will be used to initialize
765
- // the regeneratorRuntime variable at the top of this file.
766
- module.exports
767
- ));
768
-
769
- try {
770
- regeneratorRuntime = runtime;
771
- } catch (accidentalStrictMode) {
772
- // This module should not be running in strict mode, so the above
773
- // assignment should always work unless something is misconfigured. Just
774
- // in case runtime.js accidentally runs in strict mode, we can escape
775
- // strict mode using a global Function call. This could conceivably fail
776
- // if a Content Security Policy forbids using Function, but in that case
777
- // the proper solution is to fix the accidental strict mode problem. If
778
- // you've misconfigured your bundler to force strict mode and applied a
779
- // CSP to forbid Function, and you're not willing to fix either of those
780
- // problems, please detail your unique predicament in a GitHub issue.
781
- Function("r", "regeneratorRuntime = r")(runtime);
782
- }
783
- });
784
-
785
- function deployment(_x) {
786
- return _deployment.apply(this, arguments);
787
- }
788
-
789
- function _deployment() {
790
- _deployment = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(configs) {
791
- var authToken, lastCommit;
792
- return runtime_1.wrap(function _callee$(_context) {
793
- while (1) {
794
- switch (_context.prev = _context.next) {
795
- case 0:
796
- authToken = process.env.NETLIFY_AUTH_TOKEN;
797
-
798
- if (!authToken) {
799
- fail("Couldn't get deploy information. You need to set up an authentication \n token in your environment variables. \n See: https://gitlab.com/help/ci/variables/README#variables");
800
- }
801
-
802
- try {
803
- lastCommit = danger.git.commits[0];
804
- markdown(["## Deploy preview", "The deploy preview is ready!", "Built with commit " + lastCommit.sha].concat(configs.map(function (result) {
805
- return result.label + ": " + result.deploy_url;
806
- })).join("\n\n"));
807
- } catch (e) {
808
- console.error(e);
809
- fail("Couldn't get deploy information.");
810
- }
811
-
812
- case 3:
813
- case "end":
814
- return _context.stop();
815
- }
816
- }
817
- }, _callee);
818
- }));
819
- return _deployment.apply(this, arguments);
820
- }
821
-
822
- var pluginNetlify = {
823
- __proto__: null,
824
- deployment: deployment
825
- };
826
-
827
- /**
828
- * Generates a Markdown table
829
- * @param {string[]} headers
830
- * @param {string[][]} body
831
- */
832
-
833
- function generateMDTable(headers, body) {
834
- var tableHeaders = [headers.join(" | "), headers.map(function () {
835
- return " --- ";
836
- }).join(" | ")];
837
- var tableBody = body.map(function (r) {
838
- return r.join(" | ");
839
- });
840
- return tableHeaders.join("\n") + "\n" + tableBody.join("\n");
841
- }
842
-
843
- function getWidgetsGetBundlesFn(bundlePrefix) {
844
- return function defaultGetBundlesFn(bundlesDir) {
845
- return fs.readdirSync(bundlesDir).map(function (name) {
846
- return path.join(bundlesDir, name);
847
- }).filter(function (dirName) {
848
- return fs.lstatSync(dirName).isDirectory();
849
- }).map(function (dirName) {
850
- return path.join(dirName, path.basename(dirName).replace(bundlePrefix, "") + ".bundle.js");
851
- });
852
- };
853
- }
854
-
855
- function defaultGetBundlesFn(bundlesDir) {
856
- return fs.readdirSync(bundlesDir).filter(function (file) {
857
- return file.endsWith(".js");
858
- }).map(function (file) {
859
- return path.join(bundlesDir, file);
860
- });
861
- }
862
-
863
- function widgetsRenameFn(filename) {
864
- return filename.split(".bundle.js")[0].replace(/--/g, "-").split("-").map(function (e) {
865
- return e[0].toUpperCase() + e.slice(1);
866
- }).join(" ").replace("Mobile", "(mobile)");
867
- }
868
-
869
- function defaultRenameFn(filename) {
870
- return filename.replace(".min.js", "").replace(".js", "");
871
- }
872
-
873
- function bundleSizeResults(_ref) {
874
- var _ref$formats = _ref.formats,
875
- formats = _ref$formats === void 0 ? ["gzip"] : _ref$formats,
876
- bundlesDir = _ref.bundlesDir,
877
- _ref$renameFn = _ref.renameFn,
878
- renameFn = _ref$renameFn === void 0 ? defaultRenameFn : _ref$renameFn,
879
- _ref$getBundlesFn = _ref.getBundlesFn,
880
- getBundlesFn = _ref$getBundlesFn === void 0 ? defaultGetBundlesFn : _ref$getBundlesFn,
881
- _ref$bundlePrefix = _ref.bundlePrefix,
882
- bundlePrefix = _ref$bundlePrefix === void 0 ? "cmp-mc-" : _ref$bundlePrefix,
883
- reportPath = _ref.reportPath,
884
- preset = _ref.preset;
885
- var getBundles = getBundlesFn;
886
- var rename = renameFn;
887
-
888
- if (preset === "widgets") {
889
- getBundles = getWidgetsGetBundlesFn(bundlePrefix);
890
- rename = widgetsRenameFn;
891
- }
892
-
893
- var files = getBundles(bundlesDir).filter(fs.existsSync);
894
- var formatFilter = new Set(formats);
895
- var gzip = formatFilter.has("gzip");
896
- var brotli = formatFilter.has("brotli");
897
- var results = {
898
- gzip: gzip,
899
- brotli: brotli,
900
- bundles: files.map(function (filePath) {
901
- var jsFile = fs.readFileSync(filePath);
902
- var fileSizes = [jsFile].concat(gzip ? [zlib.gzipSync(jsFile)] : [], brotli ? [zlib.brotliCompressSync(jsFile)] : []);
903
- return {
904
- filename: rename(path.basename(filePath)),
905
- sizes: fileSizes.map(function (file) {
906
- return file.length;
907
- })
908
- };
909
- })
910
- };
911
-
912
- if (reportPath) {
913
- fs__default.writeFileSync(reportPath, JSON.stringify(results, null, 2));
914
- }
915
-
916
- return results;
917
- }
918
-
919
- function formatDiff(value) {
920
- var sizeString = (value / 1000).toFixed(1);
921
-
922
- if (sizeString === "-0.0") {
923
- sizeString = "0.0";
924
- }
925
-
926
- var size = Number(sizeString);
927
- var icon = "";
928
-
929
- if (size > 0) {
930
- icon = "🔺+";
931
- } else if (size < 0) {
932
- icon = "🔻";
933
- }
934
-
935
- return "" + icon + sizeString + "k";
936
- }
937
-
938
- function bundleSize(_x) {
939
- return _bundleSize.apply(this, arguments);
940
- }
941
-
942
- function _bundleSize() {
943
- _bundleSize = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(options) {
944
- var _ref2;
945
-
946
- var results, reportPath, _options$baseBundleJo, baseBundleJob, baseResults, projectId, authToken, targetBranch, baseBundlesUrl, _headers, baseBundlesResponse, baseBundles, diffHeaders, _baseResults, bundles, brotli, gzip, headers, body;
947
-
948
- return runtime_1.wrap(function _callee$(_context) {
949
- while (1) {
950
- switch (_context.prev = _context.next) {
951
- case 0:
952
- results = bundleSizeResults(options);
953
- reportPath = options.reportPath, _options$baseBundleJo = options.baseBundleJob, baseBundleJob = _options$baseBundleJo === void 0 ? "publish" : _options$baseBundleJo;
954
-
955
- if (!reportPath) {
956
- _context.next = 16;
957
- break;
958
- }
959
-
960
- projectId = process.env.CI_MERGE_REQUEST_PROJECT_ID;
961
- authToken = process.env.DANGER_GITLAB_API_TOKEN;
962
- targetBranch = process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME || "main";
963
- baseBundlesUrl = "https://gitlab.com/api/v4/projects/" + projectId + "/jobs/artifacts/" + targetBranch + "/raw/" + reportPath + "?job=" + baseBundleJob;
964
- _headers = new undici.Headers();
965
-
966
- if (authToken) {
967
- _headers.set("PRIVATE-TOKEN", authToken);
968
- }
969
-
970
- _context.next = 11;
971
- return undici.fetch(baseBundlesUrl, {
972
- headers: _headers
973
- });
974
-
975
- case 11:
976
- baseBundlesResponse = _context.sent;
977
-
978
- if (!baseBundlesResponse.ok) {
979
- _context.next = 16;
980
- break;
981
- }
982
-
983
- _context.next = 15;
984
- return baseBundlesResponse.json();
985
-
986
- case 15:
987
- baseResults = _context.sent;
988
-
989
- case 16:
990
- baseBundles = new Map();
991
- diffHeaders = [];
992
-
993
- if (baseResults) {
994
- _baseResults = baseResults, bundles = _baseResults.bundles, brotli = _baseResults.brotli, gzip = _baseResults.gzip;
995
-
996
- if (bundles) {
997
- bundles.forEach(function (bundle) {
998
- baseBundles.set(bundle.filename, bundle.sizes);
999
- });
1000
- }
1001
-
1002
- diffHeaders = ["Filesize diff"].concat(gzip ? ["Gzip diff"] : [], brotli ? ["Brotli diff"] : []);
1003
- }
1004
-
1005
- headers = ["Module", "Filesize"].concat(results.gzip ? ["Gzip size"] : [], results.brotli ? ["Brotli size"] : [], diffHeaders);
1006
- body = results.bundles.map(function (bundle) {
1007
- var diff = [];
1008
-
1009
- if (baseResults) {
1010
- var _baseResults2 = baseResults,
1011
- _brotli = _baseResults2.brotli,
1012
- _gzip = _baseResults2.gzip;
1013
- var baseBrotliIndex = _brotli && !_gzip ? 1 : 2;
1014
- var brotliIndex = results.brotli && !results.gzip ? 1 : 2;
1015
-
1016
- if (baseBundles.has(bundle.filename)) {
1017
- var baseBundle = baseBundles.get(bundle.filename);
1018
- diff = [bundle.sizes[0] - baseBundle[0]].concat(_gzip && results.gzip ? [bundle.sizes[1] - baseBundle[1]] : [], _brotli && results.brotli ? [bundle.sizes[brotliIndex] - baseBundle[baseBrotliIndex]] : []);
1019
- }
1020
- }
1021
-
1022
- return [bundle.filename].concat(bundle.sizes.map(function (size) {
1023
- return (size / 1000).toFixed(1) + "k";
1024
- }), diff.map(function (size) {
1025
- return formatDiff(size);
1026
- }));
1027
- });
1028
- markdown([(_ref2 = "## " + options.title) != null ? _ref2 : "Bundle size", generateMDTable(headers, body)].join("\n\n"));
1029
-
1030
- case 22:
1031
- case "end":
1032
- return _context.stop();
1033
- }
1034
- }
1035
- }, _callee);
1036
- }));
1037
- return _bundleSize.apply(this, arguments);
1038
- }
1039
-
1040
- var readFile = /*#__PURE__*/util.promisify(fs.readFile);
1041
- function lighthouse() {
1042
- return _lighthouse.apply(this, arguments);
1043
- }
1044
-
1045
- function _lighthouse() {
1046
- _lighthouse = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1047
- var content, links, urlsToCheck;
1048
- return runtime_1.wrap(function _callee$(_context) {
1049
- while (1) {
1050
- switch (_context.prev = _context.next) {
1051
- case 0:
1052
- _context.next = 2;
1053
- return readFile(".lighthouseci/links.json");
1054
-
1055
- case 2:
1056
- content = _context.sent;
1057
- links = JSON.parse(content.toString());
1058
- urlsToCheck = Object.entries(links);
1059
-
1060
- if (!(urlsToCheck.length === 0)) {
1061
- _context.next = 7;
1062
- break;
1063
- }
1064
-
1065
- return _context.abrupt("return");
1066
-
1067
- case 7:
1068
- markdown(["## Lighthouse report", urlsToCheck.map(function (_ref) {
1069
- var pageUrl = _ref[0],
1070
- reportUrl = _ref[1];
1071
- var pageDisplay = pageUrl.replace(/http:\/\/localhost:[0-9]*\//, "");
1072
- return "- [" + pageDisplay + "](" + reportUrl + ")";
1073
- }).join("\n")].join("\n\n"));
1074
-
1075
- case 8:
1076
- case "end":
1077
- return _context.stop();
1078
- }
1079
- }
1080
- }, _callee);
1081
- }));
1082
- return _lighthouse.apply(this, arguments);
1083
- }
1084
-
1085
- exports.bundleSize = bundleSize;
1086
- exports.bundleSizeResults = bundleSizeResults;
1087
- exports.lighthouse = lighthouse;
1088
- exports.netlify = pluginNetlify;
1089
- //# sourceMappingURL=danger-plugins.cjs.development.js.map