permaweb-deploy 1.1.6 → 1.1.7
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/index.js +20 -31
- package/dist/turbo/index.js +247 -0
- package/package.json +4 -3
- package/src/index.js +8 -17
- package/src/turbo/index.js +111 -0
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var _sdk = require("@ar.io/sdk");
|
|
|
10
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
11
|
var _yargs = _interopRequireDefault(require("yargs"));
|
|
12
12
|
var _helpers = require("yargs/helpers");
|
|
13
|
-
var
|
|
13
|
+
var _turbo = _interopRequireDefault(require("./turbo"));
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
15
|
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; }
|
|
16
16
|
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); }
|
|
@@ -44,7 +44,7 @@ function getTagValue(list, name) {
|
|
|
44
44
|
return STORAGE.none;
|
|
45
45
|
}
|
|
46
46
|
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
47
|
-
var jwk,
|
|
47
|
+
var jwk, manifestId, signer, ant;
|
|
48
48
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
49
49
|
while (1) switch (_context.prev = _context.next) {
|
|
50
50
|
case 0:
|
|
@@ -84,50 +84,39 @@ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
|
84
84
|
return _context.abrupt("return");
|
|
85
85
|
case 15:
|
|
86
86
|
jwk = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8'));
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
irys.uploader.useChunking = false;
|
|
93
|
-
_context.prev = 18;
|
|
94
|
-
console.log("Deploying ".concat(argv.deployFolder, " folder"));
|
|
95
|
-
_context.next = 22;
|
|
96
|
-
return irys.uploadFolder(argv.deployFolder, {
|
|
97
|
-
indexFile: 'index.html',
|
|
98
|
-
interactivePreflight: false,
|
|
99
|
-
logFunction: function logFunction(log) {
|
|
100
|
-
return console.log(log);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
case 22:
|
|
104
|
-
txResult = _context.sent;
|
|
105
|
-
console.log("Bundle TxId [".concat(txResult.id, "]"));
|
|
87
|
+
_context.prev = 16;
|
|
88
|
+
_context.next = 19;
|
|
89
|
+
return (0, _turbo["default"])(argv, jwk);
|
|
90
|
+
case 19:
|
|
91
|
+
manifestId = _context.sent;
|
|
106
92
|
signer = new _sdk.ArweaveSigner(jwk);
|
|
107
93
|
ant = _sdk.ANT.init({
|
|
108
94
|
processId: ANT_PROCESS,
|
|
109
95
|
signer: signer
|
|
110
96
|
}); // Update the ANT record (assumes the JWK is a controller or owner)
|
|
111
|
-
_context.next =
|
|
97
|
+
_context.next = 24;
|
|
112
98
|
return ant.setRecord({
|
|
113
99
|
undername: argv.undername,
|
|
114
|
-
transactionId:
|
|
100
|
+
transactionId: manifestId,
|
|
115
101
|
ttlSeconds: 3600
|
|
116
102
|
}, {
|
|
117
103
|
name: 'GIT-HASH',
|
|
118
104
|
value: process.env.GITHUB_SHA
|
|
105
|
+
}, {
|
|
106
|
+
name: 'App-Name',
|
|
107
|
+
value: 'Permaweb-Deploy'
|
|
119
108
|
});
|
|
120
|
-
case
|
|
121
|
-
console.log("Deployed TxId [".concat(
|
|
122
|
-
_context.next =
|
|
109
|
+
case 24:
|
|
110
|
+
console.log("Deployed TxId [".concat(manifestId, "] to ANT [").concat(ANT_PROCESS, "] using undername [").concat(argv.undername, "]"));
|
|
111
|
+
_context.next = 30;
|
|
123
112
|
break;
|
|
124
|
-
case
|
|
125
|
-
_context.prev =
|
|
126
|
-
_context.t0 = _context["catch"](
|
|
113
|
+
case 27:
|
|
114
|
+
_context.prev = 27;
|
|
115
|
+
_context.t0 = _context["catch"](16);
|
|
127
116
|
console.error(_context.t0);
|
|
128
|
-
case
|
|
117
|
+
case 30:
|
|
129
118
|
case "end":
|
|
130
119
|
return _context.stop();
|
|
131
120
|
}
|
|
132
|
-
}, _callee, null, [[
|
|
121
|
+
}, _callee, null, [[16, 27]]);
|
|
133
122
|
}))();
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = TurboDeploy;
|
|
7
|
+
var _turboSdk = require("@ardrive/turbo-sdk");
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
var _mimeTypes = _interopRequireDefault(require("mime-types"));
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _stream = require("stream");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
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); }
|
|
14
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
// Gets MIME types for each file to tag the upload
|
|
21
|
+
function getContentType(_x) {
|
|
22
|
+
return _getContentType.apply(this, arguments);
|
|
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);
|
|
37
|
+
}
|
|
38
|
+
function TurboDeploy(_x2, _x3) {
|
|
39
|
+
return _TurboDeploy.apply(this, arguments);
|
|
40
|
+
}
|
|
41
|
+
function _TurboDeploy() {
|
|
42
|
+
_TurboDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(argv, jwk) {
|
|
43
|
+
var turbo, deployFolder, newManifest, processFiles, _processFiles, uploadManifest, _uploadManifest, manifestId;
|
|
44
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
45
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
_uploadManifest = function _uploadManifest3() {
|
|
48
|
+
_uploadManifest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(manifest) {
|
|
49
|
+
var manifestString, uploadResult;
|
|
50
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
51
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
_context4.prev = 0;
|
|
54
|
+
manifestString = JSON.stringify(manifest);
|
|
55
|
+
_context4.next = 4;
|
|
56
|
+
return turbo.uploadFile({
|
|
57
|
+
fileStreamFactory: function fileStreamFactory() {
|
|
58
|
+
return _stream.Readable.from(Buffer.from(manifestString));
|
|
59
|
+
},
|
|
60
|
+
fileSizeFactory: function fileSizeFactory() {
|
|
61
|
+
return Buffer.byteLength(manifestString);
|
|
62
|
+
},
|
|
63
|
+
signal: AbortSignal.timeout(10000),
|
|
64
|
+
dataItemOpts: {
|
|
65
|
+
tags: [{
|
|
66
|
+
name: 'Content-Type',
|
|
67
|
+
value: 'application/x.arweave-manifest+json'
|
|
68
|
+
}, {
|
|
69
|
+
name: 'App-Name',
|
|
70
|
+
value: 'Permaweb-Deploy'
|
|
71
|
+
}]
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
case 4:
|
|
75
|
+
uploadResult = _context4.sent;
|
|
76
|
+
return _context4.abrupt("return", uploadResult.id);
|
|
77
|
+
case 8:
|
|
78
|
+
_context4.prev = 8;
|
|
79
|
+
_context4.t0 = _context4["catch"](0);
|
|
80
|
+
console.error('Error uploading manifest:', _context4.t0);
|
|
81
|
+
return _context4.abrupt("return", null);
|
|
82
|
+
case 12:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context4.stop();
|
|
85
|
+
}
|
|
86
|
+
}, _callee3, null, [[0, 8]]);
|
|
87
|
+
}));
|
|
88
|
+
return _uploadManifest.apply(this, arguments);
|
|
89
|
+
};
|
|
90
|
+
uploadManifest = function _uploadManifest2(_x5) {
|
|
91
|
+
return _uploadManifest.apply(this, arguments);
|
|
92
|
+
};
|
|
93
|
+
_processFiles = function _processFiles3() {
|
|
94
|
+
_processFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(dir) {
|
|
95
|
+
var files, _iterator, _step, _loop;
|
|
96
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
97
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
98
|
+
case 0:
|
|
99
|
+
files = _fs["default"].readdirSync(dir);
|
|
100
|
+
_iterator = _createForOfIteratorHelper(files);
|
|
101
|
+
_context3.prev = 2;
|
|
102
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
103
|
+
var file, filePath, relativePath, fileSize, contentType, uploadResult;
|
|
104
|
+
return _regeneratorRuntime().wrap(function _loop$(_context2) {
|
|
105
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
file = _step.value;
|
|
108
|
+
_context2.prev = 1;
|
|
109
|
+
filePath = _path["default"].join(dir, file);
|
|
110
|
+
relativePath = _path["default"].relative(deployFolder, filePath);
|
|
111
|
+
if (!_fs["default"].statSync(filePath).isDirectory()) {
|
|
112
|
+
_context2.next = 9;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
_context2.next = 7;
|
|
116
|
+
return processFiles(filePath);
|
|
117
|
+
case 7:
|
|
118
|
+
_context2.next = 26;
|
|
119
|
+
break;
|
|
120
|
+
case 9:
|
|
121
|
+
console.log("Uploading file: ".concat(relativePath));
|
|
122
|
+
_context2.prev = 10;
|
|
123
|
+
fileSize = _fs["default"].statSync(filePath).size;
|
|
124
|
+
_context2.next = 14;
|
|
125
|
+
return getContentType(filePath);
|
|
126
|
+
case 14:
|
|
127
|
+
contentType = _context2.sent;
|
|
128
|
+
_context2.next = 17;
|
|
129
|
+
return turbo.uploadFile({
|
|
130
|
+
fileStreamFactory: function fileStreamFactory() {
|
|
131
|
+
return _fs["default"].createReadStream(filePath);
|
|
132
|
+
},
|
|
133
|
+
fileSizeFactory: function fileSizeFactory() {
|
|
134
|
+
return fileSize;
|
|
135
|
+
},
|
|
136
|
+
signal: AbortSignal.timeout(10000),
|
|
137
|
+
// cancel the upload after 10 seconds
|
|
138
|
+
dataItemOpts: {
|
|
139
|
+
tags: [{
|
|
140
|
+
name: 'Content-Type',
|
|
141
|
+
value: contentType
|
|
142
|
+
}, {
|
|
143
|
+
name: 'App-Name',
|
|
144
|
+
value: 'Permaweb-Deploy'
|
|
145
|
+
}]
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
case 17:
|
|
149
|
+
uploadResult = _context2.sent;
|
|
150
|
+
console.log("Uploaded ".concat(relativePath, " with id:"), uploadResult.id);
|
|
151
|
+
// adds uploaded file txId to the new manifest json
|
|
152
|
+
newManifest.paths[relativePath] = {
|
|
153
|
+
id: uploadResult.id
|
|
154
|
+
};
|
|
155
|
+
if (file === '404.html') {
|
|
156
|
+
// sets manifest fallback to 404.html if found
|
|
157
|
+
newManifest.fallback.id = uploadResult.id;
|
|
158
|
+
}
|
|
159
|
+
_context2.next = 26;
|
|
160
|
+
break;
|
|
161
|
+
case 23:
|
|
162
|
+
_context2.prev = 23;
|
|
163
|
+
_context2.t0 = _context2["catch"](10);
|
|
164
|
+
console.error("Error uploading file ".concat(relativePath, ":"), _context2.t0);
|
|
165
|
+
case 26:
|
|
166
|
+
_context2.next = 31;
|
|
167
|
+
break;
|
|
168
|
+
case 28:
|
|
169
|
+
_context2.prev = 28;
|
|
170
|
+
_context2.t1 = _context2["catch"](1);
|
|
171
|
+
console.error('ERROR:', _context2.t1);
|
|
172
|
+
case 31:
|
|
173
|
+
case "end":
|
|
174
|
+
return _context2.stop();
|
|
175
|
+
}
|
|
176
|
+
}, _loop, null, [[1, 28], [10, 23]]);
|
|
177
|
+
});
|
|
178
|
+
_iterator.s();
|
|
179
|
+
case 5:
|
|
180
|
+
if ((_step = _iterator.n()).done) {
|
|
181
|
+
_context3.next = 9;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
return _context3.delegateYield(_loop(), "t0", 7);
|
|
185
|
+
case 7:
|
|
186
|
+
_context3.next = 5;
|
|
187
|
+
break;
|
|
188
|
+
case 9:
|
|
189
|
+
_context3.next = 14;
|
|
190
|
+
break;
|
|
191
|
+
case 11:
|
|
192
|
+
_context3.prev = 11;
|
|
193
|
+
_context3.t1 = _context3["catch"](2);
|
|
194
|
+
_iterator.e(_context3.t1);
|
|
195
|
+
case 14:
|
|
196
|
+
_context3.prev = 14;
|
|
197
|
+
_iterator.f();
|
|
198
|
+
return _context3.finish(14);
|
|
199
|
+
case 17:
|
|
200
|
+
case "end":
|
|
201
|
+
return _context3.stop();
|
|
202
|
+
}
|
|
203
|
+
}, _callee2, null, [[2, 11, 14, 17]]);
|
|
204
|
+
}));
|
|
205
|
+
return _processFiles.apply(this, arguments);
|
|
206
|
+
};
|
|
207
|
+
processFiles = function _processFiles2(_x4) {
|
|
208
|
+
return _processFiles.apply(this, arguments);
|
|
209
|
+
};
|
|
210
|
+
turbo = _turboSdk.TurboFactory.authenticated({
|
|
211
|
+
privateKey: jwk
|
|
212
|
+
});
|
|
213
|
+
deployFolder = argv.deployFolder; //Uses Arweave manifest version 0.2.0, which supports fallbacks
|
|
214
|
+
newManifest = {
|
|
215
|
+
manifest: 'arweave/paths',
|
|
216
|
+
version: '0.2.0',
|
|
217
|
+
index: {
|
|
218
|
+
path: 'index.html'
|
|
219
|
+
},
|
|
220
|
+
fallback: {},
|
|
221
|
+
paths: {}
|
|
222
|
+
}; // starts processing files in the selected directory
|
|
223
|
+
_context5.next = 9;
|
|
224
|
+
return processFiles(deployFolder);
|
|
225
|
+
case 9:
|
|
226
|
+
if (!newManifest.fallback.id) {
|
|
227
|
+
// if no 404.html file is found, manifest fallback is set to the txId of index.html
|
|
228
|
+
newManifest.fallback.id = newManifest.paths['index.html'].id;
|
|
229
|
+
}
|
|
230
|
+
_context5.next = 12;
|
|
231
|
+
return uploadManifest(newManifest);
|
|
232
|
+
case 12:
|
|
233
|
+
manifestId = _context5.sent;
|
|
234
|
+
if (!manifestId) {
|
|
235
|
+
_context5.next = 16;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
console.log("Manifest uploaded with Id: ".concat(manifestId));
|
|
239
|
+
return _context5.abrupt("return", manifestId);
|
|
240
|
+
case 16:
|
|
241
|
+
case "end":
|
|
242
|
+
return _context5.stop();
|
|
243
|
+
}
|
|
244
|
+
}, _callee4);
|
|
245
|
+
}));
|
|
246
|
+
return _TurboDeploy.apply(this, arguments);
|
|
247
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "permaweb-deploy",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "Permaweb app deployment package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
"permaweb-deploy": "./dist/index.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ar.io/sdk": "1.2.
|
|
14
|
-
"@
|
|
13
|
+
"@ar.io/sdk": "^1.2.2",
|
|
14
|
+
"@ardrive/turbo-sdk": "^1.9.0",
|
|
15
|
+
"mime-types": "^2.1.35",
|
|
15
16
|
"yargs": "17.7.2"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import fs from 'fs';
|
|
|
5
5
|
import yargs from 'yargs';
|
|
6
6
|
import { hideBin } from 'yargs/helpers';
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import TurboDeploy from './turbo';
|
|
9
9
|
|
|
10
10
|
const argv = yargs(hideBin(process.argv))
|
|
11
11
|
.option('ant-process', {
|
|
@@ -68,21 +68,8 @@ export function getTagValue(list, name) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
let jwk = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8'));
|
|
71
|
-
|
|
72
|
-
const irys = new Irys({ url: 'https://turbo.ardrive.io', token: 'arweave', key: jwk });
|
|
73
|
-
irys.uploader.useChunking = false;
|
|
74
|
-
|
|
75
71
|
try {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const txResult = await irys.uploadFolder(argv.deployFolder, {
|
|
79
|
-
indexFile: 'index.html',
|
|
80
|
-
interactivePreflight: false,
|
|
81
|
-
logFunction: (log) => console.log(log),
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
console.log(`Bundle TxId [${txResult.id}]`);
|
|
85
|
-
|
|
72
|
+
const manifestId = await TurboDeploy(argv, jwk);
|
|
86
73
|
const signer = new ArweaveSigner(jwk);
|
|
87
74
|
const ant = ANT.init({ processId: ANT_PROCESS, signer });
|
|
88
75
|
|
|
@@ -90,16 +77,20 @@ export function getTagValue(list, name) {
|
|
|
90
77
|
await ant.setRecord(
|
|
91
78
|
{
|
|
92
79
|
undername: argv.undername,
|
|
93
|
-
transactionId:
|
|
80
|
+
transactionId: manifestId,
|
|
94
81
|
ttlSeconds: 3600,
|
|
95
82
|
},
|
|
96
83
|
{
|
|
97
84
|
name: 'GIT-HASH',
|
|
98
85
|
value: process.env.GITHUB_SHA,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'App-Name',
|
|
89
|
+
value: 'Permaweb-Deploy',
|
|
99
90
|
}
|
|
100
91
|
);
|
|
101
92
|
|
|
102
|
-
console.log(`Deployed TxId [${
|
|
93
|
+
console.log(`Deployed TxId [${manifestId}] to ANT [${ANT_PROCESS}] using undername [${argv.undername}]`);
|
|
103
94
|
} catch (e) {
|
|
104
95
|
console.error(e);
|
|
105
96
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { TurboFactory } from '@ardrive/turbo-sdk';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import mime from 'mime-types';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { Readable } from 'stream';
|
|
6
|
+
|
|
7
|
+
// Gets MIME types for each file to tag the upload
|
|
8
|
+
async function getContentType(filePath) {
|
|
9
|
+
return mime.lookup(filePath);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default async function TurboDeploy(argv, jwk) {
|
|
13
|
+
const turbo = TurboFactory.authenticated({ privateKey: jwk });
|
|
14
|
+
|
|
15
|
+
const deployFolder = argv.deployFolder;
|
|
16
|
+
//Uses Arweave manifest version 0.2.0, which supports fallbacks
|
|
17
|
+
let newManifest = {
|
|
18
|
+
manifest: 'arweave/paths',
|
|
19
|
+
version: '0.2.0',
|
|
20
|
+
index: { path: 'index.html' },
|
|
21
|
+
fallback: {},
|
|
22
|
+
paths: {},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
async function processFiles(dir) {
|
|
26
|
+
const files = fs.readdirSync(dir);
|
|
27
|
+
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
try {
|
|
30
|
+
const filePath = path.join(dir, file);
|
|
31
|
+
const relativePath = path.relative(deployFolder, filePath);
|
|
32
|
+
|
|
33
|
+
if (fs.statSync(filePath).isDirectory()) {
|
|
34
|
+
// recursively process all files in a directory
|
|
35
|
+
await processFiles(filePath);
|
|
36
|
+
} else {
|
|
37
|
+
console.log(`Uploading file: ${relativePath}`);
|
|
38
|
+
try {
|
|
39
|
+
const fileSize = fs.statSync(filePath).size;
|
|
40
|
+
const contentType = await getContentType(filePath);
|
|
41
|
+
const uploadResult = await turbo.uploadFile({
|
|
42
|
+
fileStreamFactory: () => fs.createReadStream(filePath),
|
|
43
|
+
fileSizeFactory: () => fileSize,
|
|
44
|
+
signal: AbortSignal.timeout(10_000), // cancel the upload after 10 seconds
|
|
45
|
+
dataItemOpts: {
|
|
46
|
+
tags: [
|
|
47
|
+
{ name: 'Content-Type', value: contentType },
|
|
48
|
+
{ name: 'App-Name', value: 'Permaweb-Deploy' },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
console.log(`Uploaded ${relativePath} with id:`, uploadResult.id);
|
|
54
|
+
// adds uploaded file txId to the new manifest json
|
|
55
|
+
newManifest.paths[relativePath] = { id: uploadResult.id };
|
|
56
|
+
|
|
57
|
+
if (file === '404.html') {
|
|
58
|
+
// sets manifest fallback to 404.html if found
|
|
59
|
+
newManifest.fallback.id = uploadResult.id;
|
|
60
|
+
}
|
|
61
|
+
} catch (err) {
|
|
62
|
+
console.error(`Error uploading file ${relativePath}:`, err);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} catch (err) {
|
|
66
|
+
console.error('ERROR:', err);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function uploadManifest(manifest) {
|
|
72
|
+
try {
|
|
73
|
+
const manifestString = JSON.stringify(manifest);
|
|
74
|
+
const uploadResult = await turbo.uploadFile({
|
|
75
|
+
fileStreamFactory: () => Readable.from(Buffer.from(manifestString)),
|
|
76
|
+
fileSizeFactory: () => Buffer.byteLength(manifestString),
|
|
77
|
+
signal: AbortSignal.timeout(10_000),
|
|
78
|
+
dataItemOpts: {
|
|
79
|
+
tags: [
|
|
80
|
+
{
|
|
81
|
+
name: 'Content-Type',
|
|
82
|
+
value: 'application/x.arweave-manifest+json',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'App-Name',
|
|
86
|
+
value: 'Permaweb-Deploy',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
return uploadResult.id;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error('Error uploading manifest:', error);
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// starts processing files in the selected directory
|
|
99
|
+
await processFiles(deployFolder);
|
|
100
|
+
|
|
101
|
+
if (!newManifest.fallback.id) {
|
|
102
|
+
// if no 404.html file is found, manifest fallback is set to the txId of index.html
|
|
103
|
+
newManifest.fallback.id = newManifest.paths['index.html'].id;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const manifestId = await uploadManifest(newManifest);
|
|
107
|
+
if (manifestId) {
|
|
108
|
+
console.log(`Manifest uploaded with Id: ${manifestId}`);
|
|
109
|
+
return manifestId;
|
|
110
|
+
}
|
|
111
|
+
}
|