@front10/danger-plugins 2.0.0-alpha.2 → 2.0.0-alpha.5

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.
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
- var NetlifyAPI = _interopDefault(require('netlify'));
8
7
  var fs = require('fs');
9
8
  var fs__default = _interopDefault(fs);
10
9
  var undici = require('undici');
@@ -48,81 +47,6 @@ function _asyncToGenerator(fn) {
48
47
  };
49
48
  }
50
49
 
51
- function _extends() {
52
- _extends = Object.assign || function (target) {
53
- for (var i = 1; i < arguments.length; i++) {
54
- var source = arguments[i];
55
-
56
- for (var key in source) {
57
- if (Object.prototype.hasOwnProperty.call(source, key)) {
58
- target[key] = source[key];
59
- }
60
- }
61
- }
62
-
63
- return target;
64
- };
65
-
66
- return _extends.apply(this, arguments);
67
- }
68
-
69
- function _objectWithoutPropertiesLoose(source, excluded) {
70
- if (source == null) return {};
71
- var target = {};
72
- var sourceKeys = Object.keys(source);
73
- var key, i;
74
-
75
- for (i = 0; i < sourceKeys.length; i++) {
76
- key = sourceKeys[i];
77
- if (excluded.indexOf(key) >= 0) continue;
78
- target[key] = source[key];
79
- }
80
-
81
- return target;
82
- }
83
-
84
- function _unsupportedIterableToArray(o, minLen) {
85
- if (!o) return;
86
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
87
- var n = Object.prototype.toString.call(o).slice(8, -1);
88
- if (n === "Object" && o.constructor) n = o.constructor.name;
89
- if (n === "Map" || n === "Set") return Array.from(o);
90
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
91
- }
92
-
93
- function _arrayLikeToArray(arr, len) {
94
- if (len == null || len > arr.length) len = arr.length;
95
-
96
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
97
-
98
- return arr2;
99
- }
100
-
101
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
102
- var it;
103
-
104
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
105
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
106
- if (it) o = it;
107
- var i = 0;
108
- return function () {
109
- if (i >= o.length) return {
110
- done: true
111
- };
112
- return {
113
- done: false,
114
- value: o[i++]
115
- };
116
- };
117
- }
118
-
119
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
120
- }
121
-
122
- it = o[Symbol.iterator]();
123
- return it.next.bind(it);
124
- }
125
-
126
50
  function createCommonjsModule(fn, module) {
127
51
  return module = { exports: {} }, fn(module, module.exports), module.exports;
128
52
  }
@@ -145,24 +69,6 @@ var runtime = (function (exports) {
145
69
  var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
146
70
  var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
147
71
 
148
- function define(obj, key, value) {
149
- Object.defineProperty(obj, key, {
150
- value: value,
151
- enumerable: true,
152
- configurable: true,
153
- writable: true
154
- });
155
- return obj[key];
156
- }
157
- try {
158
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
159
- define({}, "");
160
- } catch (err) {
161
- define = function(obj, key, value) {
162
- return obj[key] = value;
163
- };
164
- }
165
-
166
72
  function wrap(innerFn, outerFn, self, tryLocsList) {
167
73
  // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
168
74
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
@@ -215,9 +121,9 @@ var runtime = (function (exports) {
215
121
  // This is a polyfill for %IteratorPrototype% for environments that
216
122
  // don't natively support it.
217
123
  var IteratorPrototype = {};
218
- define(IteratorPrototype, iteratorSymbol, function () {
124
+ IteratorPrototype[iteratorSymbol] = function () {
219
125
  return this;
220
- });
126
+ };
221
127
 
222
128
  var getProto = Object.getPrototypeOf;
223
129
  var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
@@ -231,22 +137,18 @@ var runtime = (function (exports) {
231
137
 
232
138
  var Gp = GeneratorFunctionPrototype.prototype =
233
139
  Generator.prototype = Object.create(IteratorPrototype);
234
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
235
- define(Gp, "constructor", GeneratorFunctionPrototype);
236
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
237
- GeneratorFunction.displayName = define(
238
- GeneratorFunctionPrototype,
239
- toStringTagSymbol,
240
- "GeneratorFunction"
241
- );
140
+ GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
141
+ GeneratorFunctionPrototype.constructor = GeneratorFunction;
142
+ GeneratorFunctionPrototype[toStringTagSymbol] =
143
+ GeneratorFunction.displayName = "GeneratorFunction";
242
144
 
243
145
  // Helper for defining the .next, .throw, and .return methods of the
244
146
  // Iterator interface in terms of a single ._invoke method.
245
147
  function defineIteratorMethods(prototype) {
246
148
  ["next", "throw", "return"].forEach(function(method) {
247
- define(prototype, method, function(arg) {
149
+ prototype[method] = function(arg) {
248
150
  return this._invoke(method, arg);
249
- });
151
+ };
250
152
  });
251
153
  }
252
154
 
@@ -265,7 +167,9 @@ var runtime = (function (exports) {
265
167
  Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
266
168
  } else {
267
169
  genFun.__proto__ = GeneratorFunctionPrototype;
268
- define(genFun, toStringTagSymbol, "GeneratorFunction");
170
+ if (!(toStringTagSymbol in genFun)) {
171
+ genFun[toStringTagSymbol] = "GeneratorFunction";
172
+ }
269
173
  }
270
174
  genFun.prototype = Object.create(Gp);
271
175
  return genFun;
@@ -347,9 +251,9 @@ var runtime = (function (exports) {
347
251
  }
348
252
 
349
253
  defineIteratorMethods(AsyncIterator.prototype);
350
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
254
+ AsyncIterator.prototype[asyncIteratorSymbol] = function () {
351
255
  return this;
352
- });
256
+ };
353
257
  exports.AsyncIterator = AsyncIterator;
354
258
 
355
259
  // Note that simple async functions are implemented on top of
@@ -535,20 +439,20 @@ var runtime = (function (exports) {
535
439
  // unified ._invoke helper method.
536
440
  defineIteratorMethods(Gp);
537
441
 
538
- define(Gp, toStringTagSymbol, "Generator");
442
+ Gp[toStringTagSymbol] = "Generator";
539
443
 
540
444
  // A Generator should always return itself as the iterator object when the
541
445
  // @@iterator function is called on it. Some browsers' implementations of the
542
446
  // iterator prototype chain incorrectly implement this, causing the Generator
543
447
  // object to not be returned from this call. This ensures that doesn't happen.
544
448
  // See https://github.com/facebook/regenerator/issues/274 for more details.
545
- define(Gp, iteratorSymbol, function() {
449
+ Gp[iteratorSymbol] = function() {
546
450
  return this;
547
- });
451
+ };
548
452
 
549
- define(Gp, "toString", function() {
453
+ Gp.toString = function() {
550
454
  return "[object Generator]";
551
- });
455
+ };
552
456
 
553
457
  function pushTryEntry(locs) {
554
458
  var entry = { tryLoc: locs[0] };
@@ -867,49 +771,24 @@ try {
867
771
  } catch (accidentalStrictMode) {
868
772
  // This module should not be running in strict mode, so the above
869
773
  // assignment should always work unless something is misconfigured. Just
870
- // in case runtime.js accidentally runs in strict mode, in modern engines
871
- // we can explicitly access globalThis. In older engines we can escape
774
+ // in case runtime.js accidentally runs in strict mode, we can escape
872
775
  // strict mode using a global Function call. This could conceivably fail
873
776
  // if a Content Security Policy forbids using Function, but in that case
874
777
  // the proper solution is to fix the accidental strict mode problem. If
875
778
  // you've misconfigured your bundler to force strict mode and applied a
876
779
  // CSP to forbid Function, and you're not willing to fix either of those
877
780
  // problems, please detail your unique predicament in a GitHub issue.
878
- if (typeof globalThis === "object") {
879
- globalThis.regeneratorRuntime = runtime;
880
- } else {
881
- Function("r", "regeneratorRuntime = r")(runtime);
882
- }
781
+ Function("r", "regeneratorRuntime = r")(runtime);
883
782
  }
884
783
  });
885
784
 
886
- function deploySite(_ref) {
887
- var siteId = _ref.siteId,
888
- buildDir = _ref.buildDir,
889
- customClient = _ref.client,
890
- configRest = _objectWithoutPropertiesLoose(_ref, ["siteId", "buildDir", "client"]);
891
-
892
- var client = customClient;
893
-
894
- if (!client) {
895
- var authToken = process.env.NETLIFY_AUTH_TOKEN;
896
- client = new NetlifyAPI(authToken);
897
- }
898
-
899
- return client.deploy(siteId, buildDir, _extends({
900
- statusCb: function statusCb(statusObj) {
901
- console.log(statusObj.msg);
902
- }
903
- }, configRest));
785
+ function deployment(_x) {
786
+ return _deployment.apply(this, arguments);
904
787
  }
905
- function deploy(_x) {
906
- return _deploy.apply(this, arguments);
907
- }
908
-
909
- function _deploy() {
910
- _deploy = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(configs) {
911
- var authToken, client, message, deployResults, _iterator, _step, config, result, lastCommit;
912
788
 
789
+ function _deployment() {
790
+ _deployment = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(configs) {
791
+ var authToken, lastCommit;
913
792
  return runtime_1.wrap(function _callee$(_context) {
914
793
  while (1) {
915
794
  switch (_context.prev = _context.next) {
@@ -920,66 +799,29 @@ function _deploy() {
920
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");
921
800
  }
922
801
 
923
- _context.prev = 2;
924
- client = new NetlifyAPI(authToken);
925
-
926
- if (danger.gitlab) {
927
- message = danger.gitlab.mr.title;
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.");
928
810
  }
929
811
 
930
- deployResults = [];
931
- _iterator = _createForOfIteratorHelperLoose(configs);
932
-
933
- case 7:
934
- if ((_step = _iterator()).done) {
935
- _context.next = 15;
936
- break;
937
- }
938
-
939
- config = _step.value;
940
- _context.next = 11;
941
- return deploySite(_extends({
942
- client: client,
943
- message: message,
944
- draft: true
945
- }, config));
946
-
947
- case 11:
948
- result = _context.sent;
949
- deployResults.push(result);
950
-
951
- case 13:
952
- _context.next = 7;
953
- break;
954
-
955
- case 15:
956
- lastCommit = danger.git.commits[0];
957
- markdown(["## Deploy preview", "Deploy preview for *front10-ui* ready!", "Built with commit " + lastCommit.sha].concat(deployResults.map(function (result, index) {
958
- return configs[index].label + ": " + result.deploy.deploy_ssl_url;
959
- })).join("\n\n"));
960
- _context.next = 23;
961
- break;
962
-
963
- case 19:
964
- _context.prev = 19;
965
- _context.t0 = _context["catch"](2);
966
- console.error(_context.t0);
967
- fail("Couldn't get deploy information.");
968
-
969
- case 23:
812
+ case 3:
970
813
  case "end":
971
814
  return _context.stop();
972
815
  }
973
816
  }
974
- }, _callee, null, [[2, 19]]);
817
+ }, _callee);
975
818
  }));
976
- return _deploy.apply(this, arguments);
819
+ return _deployment.apply(this, arguments);
977
820
  }
978
821
 
979
822
  var pluginNetlify = {
980
823
  __proto__: null,
981
- deploySite: deploySite,
982
- deploy: deploy
824
+ deployment: deployment
983
825
  };
984
826
 
985
827
  /**
@@ -1099,7 +941,7 @@ function bundleSize(_x) {
1099
941
 
1100
942
  function _bundleSize() {
1101
943
  _bundleSize = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(options) {
1102
- var results, reportPath, _options$baseBundleJo, baseBundleJob, baseResults, projectId, authToken, targetBranch, baseBundlesUrl, baseResultsResponse, baseBundles, diffHeaders, _baseResults, bundles, brotli, gzip, headers, body;
944
+ var results, reportPath, _options$baseBundleJo, baseBundleJob, baseResults, projectId, authToken, targetBranch, baseBundlesUrl, _headers, baseBundlesResponse, baseBundles, diffHeaders, _baseResults, bundles, brotli, gzip, headers, body;
1103
945
 
1104
946
  return runtime_1.wrap(function _callee$(_context) {
1105
947
  while (1) {
@@ -1109,36 +951,40 @@ function _bundleSize() {
1109
951
  reportPath = options.reportPath, _options$baseBundleJo = options.baseBundleJob, baseBundleJob = _options$baseBundleJo === void 0 ? "publish" : _options$baseBundleJo;
1110
952
 
1111
953
  if (!reportPath) {
1112
- _context.next = 14;
954
+ _context.next = 16;
1113
955
  break;
1114
956
  }
1115
957
 
1116
958
  projectId = process.env.CI_MERGE_REQUEST_PROJECT_ID;
1117
959
  authToken = process.env.DANGER_GITLAB_API_TOKEN;
1118
- targetBranch = process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME || "master";
960
+ targetBranch = process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME || "main";
1119
961
  baseBundlesUrl = "https://gitlab.com/api/v4/projects/" + projectId + "/jobs/artifacts/" + targetBranch + "/raw/" + reportPath + "?job=" + baseBundleJob;
1120
- _context.next = 9;
962
+ _headers = new undici.Headers();
963
+
964
+ if (authToken) {
965
+ _headers.set("PRIVATE-TOKEN", authToken);
966
+ }
967
+
968
+ _context.next = 11;
1121
969
  return undici.fetch(baseBundlesUrl, {
1122
- headers: {
1123
- "PRIVATE-TOKEN": authToken
1124
- }
970
+ headers: _headers
1125
971
  });
1126
972
 
1127
- case 9:
1128
- baseResultsResponse = _context.sent;
973
+ case 11:
974
+ baseBundlesResponse = _context.sent;
1129
975
 
1130
- if (!baseResultsResponse.ok) {
1131
- _context.next = 14;
976
+ if (!baseBundlesResponse.ok) {
977
+ _context.next = 16;
1132
978
  break;
1133
979
  }
1134
980
 
1135
- _context.next = 13;
1136
- return baseResultsResponse.json();
981
+ _context.next = 15;
982
+ return baseBundlesResponse.json();
1137
983
 
1138
- case 13:
984
+ case 15:
1139
985
  baseResults = _context.sent;
1140
986
 
1141
- case 14:
987
+ case 16:
1142
988
  baseBundles = new Map();
1143
989
  diffHeaders = [];
1144
990
 
@@ -1179,7 +1025,7 @@ function _bundleSize() {
1179
1025
  });
1180
1026
  markdown(["## Bundle size", generateMDTable(headers, body)].join("\n\n"));
1181
1027
 
1182
- case 20:
1028
+ case 22:
1183
1029
  case "end":
1184
1030
  return _context.stop();
1185
1031
  }