permaweb-deploy 2.0.1 → 2.0.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/turbo/index.js +71 -87
- package/package.json +1 -1
- package/src/turbo/index.js +4 -3
package/dist/turbo/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -10,49 +11,35 @@ var _mimeTypes = _interopRequireDefault(require("mime-types"));
|
|
|
10
11
|
var _path = _interopRequireDefault(require("path"));
|
|
11
12
|
var _stream = require("stream");
|
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
-
function
|
|
14
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
14
15
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
15
16
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
16
17
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
18
18
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
19
19
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
20
20
|
// Gets MIME types for each file to tag the upload
|
|
21
|
-
function getContentType(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function _getContentType() {
|
|
25
|
-
_getContentType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(filePath) {
|
|
26
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
27
|
-
while (1) switch (_context.prev = _context.next) {
|
|
28
|
-
case 0:
|
|
29
|
-
return _context.abrupt("return", _mimeTypes["default"].lookup(filePath));
|
|
30
|
-
case 1:
|
|
31
|
-
case "end":
|
|
32
|
-
return _context.stop();
|
|
33
|
-
}
|
|
34
|
-
}, _callee);
|
|
35
|
-
}));
|
|
36
|
-
return _getContentType.apply(this, arguments);
|
|
21
|
+
function getContentType(filePath) {
|
|
22
|
+
var res = _mimeTypes["default"].lookup(filePath);
|
|
23
|
+
return res || 'application/octet-stream';
|
|
37
24
|
}
|
|
38
|
-
function TurboDeploy(
|
|
25
|
+
function TurboDeploy(_x, _x2) {
|
|
39
26
|
return _TurboDeploy.apply(this, arguments);
|
|
40
27
|
}
|
|
41
28
|
function _TurboDeploy() {
|
|
42
|
-
_TurboDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
29
|
+
_TurboDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(argv, jwk) {
|
|
43
30
|
var turbo, deployFolder, newManifest, processFiles, _processFiles, uploadManifest, _uploadManifest, manifestId;
|
|
44
|
-
return _regeneratorRuntime().wrap(function
|
|
45
|
-
while (1) switch (
|
|
31
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
32
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
46
33
|
case 0:
|
|
47
34
|
_uploadManifest = function _uploadManifest3() {
|
|
48
|
-
_uploadManifest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
35
|
+
_uploadManifest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(manifest) {
|
|
49
36
|
var manifestString, uploadResult;
|
|
50
|
-
return _regeneratorRuntime().wrap(function
|
|
51
|
-
while (1) switch (
|
|
37
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
38
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
52
39
|
case 0:
|
|
53
|
-
|
|
40
|
+
_context3.prev = 0;
|
|
54
41
|
manifestString = JSON.stringify(manifest);
|
|
55
|
-
|
|
42
|
+
_context3.next = 4;
|
|
56
43
|
return turbo.uploadFile({
|
|
57
44
|
fileStreamFactory: function fileStreamFactory() {
|
|
58
45
|
return _stream.Readable.from(Buffer.from(manifestString));
|
|
@@ -72,60 +59,57 @@ function _TurboDeploy() {
|
|
|
72
59
|
}
|
|
73
60
|
});
|
|
74
61
|
case 4:
|
|
75
|
-
uploadResult =
|
|
76
|
-
return
|
|
62
|
+
uploadResult = _context3.sent;
|
|
63
|
+
return _context3.abrupt("return", uploadResult.id);
|
|
77
64
|
case 8:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.error('Error uploading manifest:',
|
|
81
|
-
return
|
|
65
|
+
_context3.prev = 8;
|
|
66
|
+
_context3.t0 = _context3["catch"](0);
|
|
67
|
+
console.error('Error uploading manifest:', _context3.t0);
|
|
68
|
+
return _context3.abrupt("return", null);
|
|
82
69
|
case 12:
|
|
83
70
|
case "end":
|
|
84
|
-
return
|
|
71
|
+
return _context3.stop();
|
|
85
72
|
}
|
|
86
|
-
},
|
|
73
|
+
}, _callee2, null, [[0, 8]]);
|
|
87
74
|
}));
|
|
88
75
|
return _uploadManifest.apply(this, arguments);
|
|
89
76
|
};
|
|
90
|
-
uploadManifest = function _uploadManifest2(
|
|
77
|
+
uploadManifest = function _uploadManifest2(_x4) {
|
|
91
78
|
return _uploadManifest.apply(this, arguments);
|
|
92
79
|
};
|
|
93
80
|
_processFiles = function _processFiles3() {
|
|
94
|
-
_processFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
81
|
+
_processFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dir) {
|
|
95
82
|
var files, _iterator, _step, _loop;
|
|
96
|
-
return _regeneratorRuntime().wrap(function
|
|
97
|
-
while (1) switch (
|
|
83
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
84
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
98
85
|
case 0:
|
|
99
86
|
files = _fs["default"].readdirSync(dir);
|
|
100
87
|
_iterator = _createForOfIteratorHelper(files);
|
|
101
|
-
|
|
88
|
+
_context2.prev = 2;
|
|
102
89
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
103
90
|
var file, filePath, relativePath, fileSize, contentType, uploadResult;
|
|
104
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
105
|
-
while (1) switch (
|
|
91
|
+
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
92
|
+
while (1) switch (_context.prev = _context.next) {
|
|
106
93
|
case 0:
|
|
107
94
|
file = _step.value;
|
|
108
|
-
|
|
95
|
+
_context.prev = 1;
|
|
109
96
|
filePath = _path["default"].join(dir, file);
|
|
110
97
|
relativePath = _path["default"].relative(deployFolder, filePath);
|
|
111
98
|
if (!_fs["default"].statSync(filePath).isDirectory()) {
|
|
112
|
-
|
|
99
|
+
_context.next = 9;
|
|
113
100
|
break;
|
|
114
101
|
}
|
|
115
|
-
|
|
102
|
+
_context.next = 7;
|
|
116
103
|
return processFiles(filePath);
|
|
117
104
|
case 7:
|
|
118
|
-
|
|
105
|
+
_context.next = 24;
|
|
119
106
|
break;
|
|
120
107
|
case 9:
|
|
121
108
|
console.log("Uploading file: ".concat(relativePath));
|
|
122
|
-
|
|
109
|
+
_context.prev = 10;
|
|
123
110
|
fileSize = _fs["default"].statSync(filePath).size;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
case 14:
|
|
127
|
-
contentType = _context2.sent;
|
|
128
|
-
_context2.next = 17;
|
|
111
|
+
contentType = getContentType(filePath);
|
|
112
|
+
_context.next = 15;
|
|
129
113
|
return turbo.uploadFile({
|
|
130
114
|
fileStreamFactory: function fileStreamFactory() {
|
|
131
115
|
return _fs["default"].createReadStream(filePath);
|
|
@@ -145,8 +129,8 @@ function _TurboDeploy() {
|
|
|
145
129
|
}]
|
|
146
130
|
}
|
|
147
131
|
});
|
|
148
|
-
case
|
|
149
|
-
uploadResult =
|
|
132
|
+
case 15:
|
|
133
|
+
uploadResult = _context.sent;
|
|
150
134
|
console.log("Uploaded ".concat(relativePath, " with id:"), uploadResult.id);
|
|
151
135
|
// adds uploaded file txId to the new manifest json
|
|
152
136
|
newManifest.paths[relativePath] = {
|
|
@@ -156,55 +140,55 @@ function _TurboDeploy() {
|
|
|
156
140
|
// sets manifest fallback to 404.html if found
|
|
157
141
|
newManifest.fallback.id = uploadResult.id;
|
|
158
142
|
}
|
|
159
|
-
|
|
143
|
+
_context.next = 24;
|
|
160
144
|
break;
|
|
161
|
-
case
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
console.error("Error uploading file ".concat(relativePath, ":"),
|
|
165
|
-
case
|
|
166
|
-
|
|
145
|
+
case 21:
|
|
146
|
+
_context.prev = 21;
|
|
147
|
+
_context.t0 = _context["catch"](10);
|
|
148
|
+
console.error("Error uploading file ".concat(relativePath, ":"), _context.t0);
|
|
149
|
+
case 24:
|
|
150
|
+
_context.next = 29;
|
|
167
151
|
break;
|
|
168
|
-
case
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
console.error('ERROR:',
|
|
172
|
-
case
|
|
152
|
+
case 26:
|
|
153
|
+
_context.prev = 26;
|
|
154
|
+
_context.t1 = _context["catch"](1);
|
|
155
|
+
console.error('ERROR:', _context.t1);
|
|
156
|
+
case 29:
|
|
173
157
|
case "end":
|
|
174
|
-
return
|
|
158
|
+
return _context.stop();
|
|
175
159
|
}
|
|
176
|
-
}, _loop, null, [[1,
|
|
160
|
+
}, _loop, null, [[1, 26], [10, 21]]);
|
|
177
161
|
});
|
|
178
162
|
_iterator.s();
|
|
179
163
|
case 5:
|
|
180
164
|
if ((_step = _iterator.n()).done) {
|
|
181
|
-
|
|
165
|
+
_context2.next = 9;
|
|
182
166
|
break;
|
|
183
167
|
}
|
|
184
|
-
return
|
|
168
|
+
return _context2.delegateYield(_loop(), "t0", 7);
|
|
185
169
|
case 7:
|
|
186
|
-
|
|
170
|
+
_context2.next = 5;
|
|
187
171
|
break;
|
|
188
172
|
case 9:
|
|
189
|
-
|
|
173
|
+
_context2.next = 14;
|
|
190
174
|
break;
|
|
191
175
|
case 11:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
_iterator.e(
|
|
176
|
+
_context2.prev = 11;
|
|
177
|
+
_context2.t1 = _context2["catch"](2);
|
|
178
|
+
_iterator.e(_context2.t1);
|
|
195
179
|
case 14:
|
|
196
|
-
|
|
180
|
+
_context2.prev = 14;
|
|
197
181
|
_iterator.f();
|
|
198
|
-
return
|
|
182
|
+
return _context2.finish(14);
|
|
199
183
|
case 17:
|
|
200
184
|
case "end":
|
|
201
|
-
return
|
|
185
|
+
return _context2.stop();
|
|
202
186
|
}
|
|
203
|
-
},
|
|
187
|
+
}, _callee, null, [[2, 11, 14, 17]]);
|
|
204
188
|
}));
|
|
205
189
|
return _processFiles.apply(this, arguments);
|
|
206
190
|
};
|
|
207
|
-
processFiles = function _processFiles2(
|
|
191
|
+
processFiles = function _processFiles2(_x3) {
|
|
208
192
|
return _processFiles.apply(this, arguments);
|
|
209
193
|
};
|
|
210
194
|
turbo = _turboSdk.TurboFactory.authenticated({
|
|
@@ -220,28 +204,28 @@ function _TurboDeploy() {
|
|
|
220
204
|
fallback: {},
|
|
221
205
|
paths: {}
|
|
222
206
|
}; // starts processing files in the selected directory
|
|
223
|
-
|
|
207
|
+
_context4.next = 9;
|
|
224
208
|
return processFiles(deployFolder);
|
|
225
209
|
case 9:
|
|
226
210
|
if (!newManifest.fallback.id) {
|
|
227
211
|
// if no 404.html file is found, manifest fallback is set to the txId of index.html
|
|
228
212
|
newManifest.fallback.id = newManifest.paths['index.html'].id;
|
|
229
213
|
}
|
|
230
|
-
|
|
214
|
+
_context4.next = 12;
|
|
231
215
|
return uploadManifest(newManifest);
|
|
232
216
|
case 12:
|
|
233
|
-
manifestId =
|
|
217
|
+
manifestId = _context4.sent;
|
|
234
218
|
if (!manifestId) {
|
|
235
|
-
|
|
219
|
+
_context4.next = 16;
|
|
236
220
|
break;
|
|
237
221
|
}
|
|
238
222
|
console.log("Manifest uploaded with Id: ".concat(manifestId));
|
|
239
|
-
return
|
|
223
|
+
return _context4.abrupt("return", manifestId);
|
|
240
224
|
case 16:
|
|
241
225
|
case "end":
|
|
242
|
-
return
|
|
226
|
+
return _context4.stop();
|
|
243
227
|
}
|
|
244
|
-
},
|
|
228
|
+
}, _callee3);
|
|
245
229
|
}));
|
|
246
230
|
return _TurboDeploy.apply(this, arguments);
|
|
247
231
|
}
|
package/package.json
CHANGED
package/src/turbo/index.js
CHANGED
|
@@ -5,8 +5,9 @@ import path from 'path';
|
|
|
5
5
|
import { Readable } from 'stream';
|
|
6
6
|
|
|
7
7
|
// Gets MIME types for each file to tag the upload
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
function getContentType(filePath) {
|
|
9
|
+
const res = mime.lookup(filePath);
|
|
10
|
+
return res || 'application/octet-stream';
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export default async function TurboDeploy(argv, jwk) {
|
|
@@ -37,7 +38,7 @@ export default async function TurboDeploy(argv, jwk) {
|
|
|
37
38
|
console.log(`Uploading file: ${relativePath}`);
|
|
38
39
|
try {
|
|
39
40
|
const fileSize = fs.statSync(filePath).size;
|
|
40
|
-
const contentType =
|
|
41
|
+
const contentType = getContentType(filePath);
|
|
41
42
|
const uploadResult = await turbo.uploadFile({
|
|
42
43
|
fileStreamFactory: () => fs.createReadStream(filePath),
|
|
43
44
|
fileSizeFactory: () => fileSize,
|