permaweb-deploy 2.5.0 → 3.0.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.
- package/README.md +311 -83
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/commands/deploy.js +227 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/constants/flags.js +190 -0
- package/dist/constants/flags.js.map +1 -0
- package/dist/index.js +2 -299
- package/dist/index.js.map +1 -0
- package/dist/prompts/arns.js +89 -0
- package/dist/prompts/arns.js.map +1 -0
- package/dist/prompts/deployment.js +27 -0
- package/dist/prompts/deployment.js.map +1 -0
- package/dist/prompts/wallet.js +51 -0
- package/dist/prompts/wallet.js.map +1 -0
- package/dist/src/commands/deploy.d.ts +9 -0
- package/dist/src/commands/deploy.d.ts.map +1 -0
- package/dist/src/constants/flags.d.ts +84 -0
- package/dist/src/constants/flags.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/prompts/arns.d.ts +13 -0
- package/dist/src/prompts/arns.d.ts.map +1 -0
- package/dist/src/prompts/deployment.d.ts +6 -0
- package/dist/src/prompts/deployment.d.ts.map +1 -0
- package/dist/src/prompts/wallet.d.ts +11 -0
- package/dist/src/prompts/wallet.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +31 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/utils/__tests__/constants.test.d.ts +2 -0
- package/dist/src/utils/__tests__/constants.test.d.ts.map +1 -0
- package/dist/src/utils/config-resolver.d.ts +72 -0
- package/dist/src/utils/config-resolver.d.ts.map +1 -0
- package/dist/src/utils/constants.d.ts +4 -0
- package/dist/src/utils/constants.d.ts.map +1 -0
- package/dist/src/utils/path.d.ts +5 -0
- package/dist/src/utils/path.d.ts.map +1 -0
- package/dist/src/utils/signer.d.ts +17 -0
- package/dist/src/utils/signer.d.ts.map +1 -0
- package/dist/src/utils/uploader.d.ts +8 -0
- package/dist/src/utils/uploader.d.ts.map +1 -0
- package/dist/src/utils/validators.d.ts +29 -0
- package/dist/src/utils/validators.d.ts.map +1 -0
- package/dist/tests/constants.d.ts +11 -0
- package/dist/tests/constants.d.ts.map +1 -0
- package/dist/tests/e2e/deploy-command.test.d.ts +2 -0
- package/dist/tests/e2e/deploy-command.test.d.ts.map +1 -0
- package/dist/tests/global-setup.d.ts +6 -0
- package/dist/tests/global-setup.d.ts.map +1 -0
- package/dist/tests/mocks/turbo-handlers.d.ts +105 -0
- package/dist/tests/mocks/turbo-handlers.d.ts.map +1 -0
- package/dist/tests/setup.d.ts +11 -0
- package/dist/tests/setup.d.ts.map +1 -0
- package/dist/tests/types/payment-service.d.ts +218 -0
- package/dist/tests/types/payment-service.d.ts.map +1 -0
- package/dist/tests/types/upload-service.d.ts +168 -0
- package/dist/tests/types/upload-service.d.ts.map +1 -0
- package/dist/tests/unit/validators.test.d.ts +2 -0
- package/dist/tests/unit/validators.test.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/config-resolver.js +39 -0
- package/dist/utils/config-resolver.js.map +1 -0
- package/dist/utils/constants.js +6 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/path.js +15 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/signer.js +40 -0
- package/dist/utils/signer.js.map +1 -0
- package/dist/utils/uploader.js +78 -0
- package/dist/utils/uploader.js.map +1 -0
- package/dist/utils/validators.js +62 -0
- package/dist/utils/validators.js.map +1 -0
- package/package.json +107 -37
- package/.babelrc +0 -3
- package/.editorconfig +0 -4
- package/.eslintrc.js +0 -35
- package/dist/turbo/index.js +0 -234
- package/src/index.js +0 -287
package/.eslintrc.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
parser: '@babel/eslint-parser',
|
|
3
|
-
parserOptions: {
|
|
4
|
-
requireConfigFile: false,
|
|
5
|
-
babelOptions: {
|
|
6
|
-
presets: ['@babel/preset-env'],
|
|
7
|
-
},
|
|
8
|
-
},
|
|
9
|
-
plugins: ['import', 'simple-import-sort'],
|
|
10
|
-
extends: [],
|
|
11
|
-
rules: {
|
|
12
|
-
'import/no-duplicates': 'error',
|
|
13
|
-
'simple-import-sort/imports': 'error',
|
|
14
|
-
'simple-import-sort/exports': 'error',
|
|
15
|
-
},
|
|
16
|
-
overrides: [
|
|
17
|
-
{
|
|
18
|
-
files: ['*.js'],
|
|
19
|
-
rules: {
|
|
20
|
-
'simple-import-sort/imports': [
|
|
21
|
-
'error',
|
|
22
|
-
{
|
|
23
|
-
groups: [
|
|
24
|
-
['^react', '^@?\\w'],
|
|
25
|
-
['^arweave', '@ar.io/sdk', '@ardrive/turbo-sdk', '@permaweb/aoconnect', '^@?\\w'],
|
|
26
|
-
['^\\u0000'],
|
|
27
|
-
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
|
|
28
|
-
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
};
|
package/dist/turbo/index.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.uploadDirectory = uploadDirectory;
|
|
7
|
-
exports.uploadFile = uploadFile;
|
|
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
|
-
var _turboSdk = require("@ardrive/turbo-sdk");
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
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 _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
18
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
|
|
19
|
-
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); }
|
|
20
|
-
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); }); }; }
|
|
21
|
-
// Gets MIME types for each file to tag the upload
|
|
22
|
-
function getContentType(filePath) {
|
|
23
|
-
var res = _mimeTypes["default"].lookup(filePath);
|
|
24
|
-
return res || 'application/octet-stream';
|
|
25
|
-
}
|
|
26
|
-
function uploadFile(_x, _x2) {
|
|
27
|
-
return _uploadFile.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
function _uploadFile() {
|
|
30
|
-
_uploadFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(path, turbo) {
|
|
31
|
-
var fileSize, contentType, uploadResult, _t;
|
|
32
|
-
return _regenerator().w(function (_context) {
|
|
33
|
-
while (1) switch (_context.n) {
|
|
34
|
-
case 0:
|
|
35
|
-
console.log("Uploading file: ".concat(path, "..."));
|
|
36
|
-
_context.p = 1;
|
|
37
|
-
fileSize = _fs["default"].statSync(path).size;
|
|
38
|
-
contentType = getContentType(path);
|
|
39
|
-
_context.n = 2;
|
|
40
|
-
return turbo.uploadFile({
|
|
41
|
-
fileStreamFactory: function fileStreamFactory() {
|
|
42
|
-
return _fs["default"].createReadStream(path);
|
|
43
|
-
},
|
|
44
|
-
fileSizeFactory: function fileSizeFactory() {
|
|
45
|
-
return fileSize;
|
|
46
|
-
},
|
|
47
|
-
signal: AbortSignal.timeout(10000),
|
|
48
|
-
// Cancel the upload after 10 seconds
|
|
49
|
-
dataItemOpts: {
|
|
50
|
-
tags: [{
|
|
51
|
-
name: 'Content-Type',
|
|
52
|
-
value: contentType
|
|
53
|
-
}, {
|
|
54
|
-
name: 'App-Name',
|
|
55
|
-
value: 'Permaweb-Deploy'
|
|
56
|
-
}]
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
case 2:
|
|
60
|
-
uploadResult = _context.v;
|
|
61
|
-
console.log("Uploaded ".concat(path, " with id:"), uploadResult.id);
|
|
62
|
-
return _context.a(2, uploadResult);
|
|
63
|
-
case 3:
|
|
64
|
-
_context.p = 3;
|
|
65
|
-
_t = _context.v;
|
|
66
|
-
console.error("Error uploading file ".concat(path, ":"), _t);
|
|
67
|
-
case 4:
|
|
68
|
-
return _context.a(2);
|
|
69
|
-
}
|
|
70
|
-
}, _callee, null, [[1, 3]]);
|
|
71
|
-
}));
|
|
72
|
-
return _uploadFile.apply(this, arguments);
|
|
73
|
-
}
|
|
74
|
-
function uploadDirectory(_x3, _x4) {
|
|
75
|
-
return _uploadDirectory.apply(this, arguments);
|
|
76
|
-
}
|
|
77
|
-
function _uploadDirectory() {
|
|
78
|
-
_uploadDirectory = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(argv, jwk) {
|
|
79
|
-
var turbo, deployFolder, newManifest, processFiles, _processFiles, uploadManifest, _uploadManifest, manifestId;
|
|
80
|
-
return _regenerator().w(function (_context4) {
|
|
81
|
-
while (1) switch (_context4.n) {
|
|
82
|
-
case 0:
|
|
83
|
-
_uploadManifest = function _uploadManifest3() {
|
|
84
|
-
_uploadManifest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(manifest) {
|
|
85
|
-
var manifestString, uploadResult, _t4;
|
|
86
|
-
return _regenerator().w(function (_context3) {
|
|
87
|
-
while (1) switch (_context3.n) {
|
|
88
|
-
case 0:
|
|
89
|
-
_context3.p = 0;
|
|
90
|
-
manifestString = JSON.stringify(manifest);
|
|
91
|
-
_context3.n = 1;
|
|
92
|
-
return turbo.uploadFile({
|
|
93
|
-
fileStreamFactory: function fileStreamFactory() {
|
|
94
|
-
return _stream.Readable.from(Buffer.from(manifestString));
|
|
95
|
-
},
|
|
96
|
-
fileSizeFactory: function fileSizeFactory() {
|
|
97
|
-
return Buffer.byteLength(manifestString);
|
|
98
|
-
},
|
|
99
|
-
signal: AbortSignal.timeout(10000),
|
|
100
|
-
dataItemOpts: {
|
|
101
|
-
tags: [{
|
|
102
|
-
name: 'Content-Type',
|
|
103
|
-
value: 'application/x.arweave-manifest+json'
|
|
104
|
-
}, {
|
|
105
|
-
name: 'App-Name',
|
|
106
|
-
value: 'Permaweb-Deploy'
|
|
107
|
-
}]
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
case 1:
|
|
111
|
-
uploadResult = _context3.v;
|
|
112
|
-
return _context3.a(2, uploadResult.id);
|
|
113
|
-
case 2:
|
|
114
|
-
_context3.p = 2;
|
|
115
|
-
_t4 = _context3.v;
|
|
116
|
-
console.error('Error uploading manifest:', _t4);
|
|
117
|
-
return _context3.a(2, null);
|
|
118
|
-
}
|
|
119
|
-
}, _callee3, null, [[0, 2]]);
|
|
120
|
-
}));
|
|
121
|
-
return _uploadManifest.apply(this, arguments);
|
|
122
|
-
};
|
|
123
|
-
uploadManifest = function _uploadManifest2(_x6) {
|
|
124
|
-
return _uploadManifest.apply(this, arguments);
|
|
125
|
-
};
|
|
126
|
-
_processFiles = function _processFiles3() {
|
|
127
|
-
_processFiles = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dir) {
|
|
128
|
-
var files, _iterator, _step, file, filePath, relativePath, uploadResult, _t2, _t3;
|
|
129
|
-
return _regenerator().w(function (_context2) {
|
|
130
|
-
while (1) switch (_context2.n) {
|
|
131
|
-
case 0:
|
|
132
|
-
files = _fs["default"].readdirSync(dir);
|
|
133
|
-
_iterator = _createForOfIteratorHelper(files);
|
|
134
|
-
_context2.p = 1;
|
|
135
|
-
_iterator.s();
|
|
136
|
-
case 2:
|
|
137
|
-
if ((_step = _iterator.n()).done) {
|
|
138
|
-
_context2.n = 10;
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
file = _step.value;
|
|
142
|
-
_context2.p = 3;
|
|
143
|
-
filePath = _path["default"].join(dir, file);
|
|
144
|
-
relativePath = _path["default"].relative(deployFolder, filePath);
|
|
145
|
-
if (!_fs["default"].statSync(filePath).isDirectory()) {
|
|
146
|
-
_context2.n = 5;
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
_context2.n = 4;
|
|
150
|
-
return processFiles(filePath);
|
|
151
|
-
case 4:
|
|
152
|
-
_context2.n = 7;
|
|
153
|
-
break;
|
|
154
|
-
case 5:
|
|
155
|
-
_context2.n = 6;
|
|
156
|
-
return uploadFile(filePath, turbo);
|
|
157
|
-
case 6:
|
|
158
|
-
uploadResult = _context2.v;
|
|
159
|
-
// Adds uploaded file txId to the new manifest json
|
|
160
|
-
newManifest.paths[relativePath] = {
|
|
161
|
-
id: uploadResult.id
|
|
162
|
-
};
|
|
163
|
-
if (file === '404.html') {
|
|
164
|
-
// Sets manifest fallback to 404.html if found
|
|
165
|
-
newManifest.fallback.id = uploadResult.id;
|
|
166
|
-
}
|
|
167
|
-
case 7:
|
|
168
|
-
_context2.n = 9;
|
|
169
|
-
break;
|
|
170
|
-
case 8:
|
|
171
|
-
_context2.p = 8;
|
|
172
|
-
_t2 = _context2.v;
|
|
173
|
-
console.error('ERROR:', _t2);
|
|
174
|
-
case 9:
|
|
175
|
-
_context2.n = 2;
|
|
176
|
-
break;
|
|
177
|
-
case 10:
|
|
178
|
-
_context2.n = 12;
|
|
179
|
-
break;
|
|
180
|
-
case 11:
|
|
181
|
-
_context2.p = 11;
|
|
182
|
-
_t3 = _context2.v;
|
|
183
|
-
_iterator.e(_t3);
|
|
184
|
-
case 12:
|
|
185
|
-
_context2.p = 12;
|
|
186
|
-
_iterator.f();
|
|
187
|
-
return _context2.f(12);
|
|
188
|
-
case 13:
|
|
189
|
-
return _context2.a(2);
|
|
190
|
-
}
|
|
191
|
-
}, _callee2, null, [[3, 8], [1, 11, 12, 13]]);
|
|
192
|
-
}));
|
|
193
|
-
return _processFiles.apply(this, arguments);
|
|
194
|
-
};
|
|
195
|
-
processFiles = function _processFiles2(_x5) {
|
|
196
|
-
return _processFiles.apply(this, arguments);
|
|
197
|
-
};
|
|
198
|
-
turbo = _turboSdk.TurboFactory.authenticated({
|
|
199
|
-
privateKey: jwk
|
|
200
|
-
});
|
|
201
|
-
deployFolder = argv.deployFolder; // Uses Arweave manifest version 0.2.0, which supports fallbacks
|
|
202
|
-
newManifest = {
|
|
203
|
-
manifest: 'arweave/paths',
|
|
204
|
-
version: '0.2.0',
|
|
205
|
-
index: {
|
|
206
|
-
path: 'index.html'
|
|
207
|
-
},
|
|
208
|
-
fallback: {},
|
|
209
|
-
paths: {}
|
|
210
|
-
}; // Starts processing files in the selected directory
|
|
211
|
-
_context4.n = 1;
|
|
212
|
-
return processFiles(deployFolder);
|
|
213
|
-
case 1:
|
|
214
|
-
if (!newManifest.fallback.id) {
|
|
215
|
-
// If no 404.html file is found, manifest fallback is set to the txId of index.html
|
|
216
|
-
newManifest.fallback.id = newManifest.paths['index.html'].id;
|
|
217
|
-
}
|
|
218
|
-
_context4.n = 2;
|
|
219
|
-
return uploadManifest(newManifest);
|
|
220
|
-
case 2:
|
|
221
|
-
manifestId = _context4.v;
|
|
222
|
-
if (!manifestId) {
|
|
223
|
-
_context4.n = 3;
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
console.log("Manifest uploaded with Id: ".concat(manifestId));
|
|
227
|
-
return _context4.a(2, manifestId);
|
|
228
|
-
case 3:
|
|
229
|
-
return _context4.a(2);
|
|
230
|
-
}
|
|
231
|
-
}, _callee4);
|
|
232
|
-
}));
|
|
233
|
-
return _uploadDirectory.apply(this, arguments);
|
|
234
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { EthereumSigner, TurboFactory } from '@ardrive/turbo-sdk';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import yargs from 'yargs';
|
|
5
|
-
import { hideBin } from 'yargs/helpers';
|
|
6
|
-
import mime from 'mime-types';
|
|
7
|
-
|
|
8
|
-
import { ANT, AOProcess, ARIO, ARIO_MAINNET_PROCESS_ID, ARIO_TESTNET_PROCESS_ID, ArweaveSigner } from '@ar.io/sdk';
|
|
9
|
-
import { connect } from '@permaweb/aoconnect';
|
|
10
|
-
import { Readable } from 'node:stream';
|
|
11
|
-
|
|
12
|
-
const arweaveTxIdRegex = /^[a-zA-Z0-9-_]{43}$/;
|
|
13
|
-
|
|
14
|
-
const argv = yargs(hideBin(process.argv))
|
|
15
|
-
.version('2.1.0')
|
|
16
|
-
.help()
|
|
17
|
-
.usage('Usage: $0 --arns-name <name> [options]')
|
|
18
|
-
.example('$0 --arns-name my-app', 'Deploy to my-app.arweave.dev')
|
|
19
|
-
.example('$0 --arns-name my-app --undername staging', 'Deploy to staging.my-app.arweave.dev')
|
|
20
|
-
.option('ario-process', {
|
|
21
|
-
alias: 'p',
|
|
22
|
-
type: 'string',
|
|
23
|
-
description: 'The ARIO process to use',
|
|
24
|
-
demandOption: true,
|
|
25
|
-
default: ARIO_MAINNET_PROCESS_ID,
|
|
26
|
-
})
|
|
27
|
-
.option('arns-name', {
|
|
28
|
-
alias: 'n',
|
|
29
|
-
type: 'string',
|
|
30
|
-
description: 'The ARNS name',
|
|
31
|
-
demandOption: true,
|
|
32
|
-
})
|
|
33
|
-
.option('deploy-folder', {
|
|
34
|
-
alias: 'd',
|
|
35
|
-
type: 'string',
|
|
36
|
-
description: 'Folder to deploy.',
|
|
37
|
-
default: './dist',
|
|
38
|
-
})
|
|
39
|
-
.option('deploy-file', {
|
|
40
|
-
alias: 'f',
|
|
41
|
-
type: 'string',
|
|
42
|
-
description: 'File to deploy.',
|
|
43
|
-
})
|
|
44
|
-
.option('ttl-seconds', {
|
|
45
|
-
alias: 't',
|
|
46
|
-
type: 'number',
|
|
47
|
-
description: 'ArNS TTL Seconds',
|
|
48
|
-
default: 3600,
|
|
49
|
-
})
|
|
50
|
-
.option('undername', {
|
|
51
|
-
alias: 'u',
|
|
52
|
-
type: 'string',
|
|
53
|
-
description: 'ANT undername to update.',
|
|
54
|
-
default: '@',
|
|
55
|
-
})
|
|
56
|
-
.option('sig-type', {
|
|
57
|
-
alias: 's',
|
|
58
|
-
type: 'string',
|
|
59
|
-
description: 'The type of signer to be used for deployment.',
|
|
60
|
-
choices: [
|
|
61
|
-
'arweave',
|
|
62
|
-
'ethereum',
|
|
63
|
-
'polygon',
|
|
64
|
-
// 'solana',
|
|
65
|
-
'kyve',
|
|
66
|
-
],
|
|
67
|
-
default: 'arweave',
|
|
68
|
-
})
|
|
69
|
-
.check((argv) => {
|
|
70
|
-
if (argv.ttl < 60 || argv.ttl > 86400) {
|
|
71
|
-
throw new Error('TTL must be between 60 seconds (1 minute) and 86400 seconds (1 day)');
|
|
72
|
-
}
|
|
73
|
-
return true;
|
|
74
|
-
}).argv;
|
|
75
|
-
|
|
76
|
-
const DEPLOY_KEY = process.env.DEPLOY_KEY;
|
|
77
|
-
const ARNS_NAME = argv['arns-name'];
|
|
78
|
-
let ARIO_PROCESS = argv['ario-process'];
|
|
79
|
-
const TTL_SECONDS = argv['ttl-seconds'];
|
|
80
|
-
|
|
81
|
-
if (ARIO_PROCESS === 'mainnet') {
|
|
82
|
-
ARIO_PROCESS = ARIO_MAINNET_PROCESS_ID;
|
|
83
|
-
} else if (ARIO_PROCESS === 'testnet') {
|
|
84
|
-
ARIO_PROCESS = ARIO_TESTNET_PROCESS_ID;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
(async () => {
|
|
88
|
-
if (!ARIO_PROCESS || !arweaveTxIdRegex.test(ARIO_PROCESS)) {
|
|
89
|
-
console.error('ARIO_PROCESS must be a valid Arweave transaction ID, or "mainnet" or "testnet"');
|
|
90
|
-
process.exit(1);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!DEPLOY_KEY) {
|
|
94
|
-
console.error('DEPLOY_KEY not configured');
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (!ARNS_NAME) {
|
|
99
|
-
console.error('ARNS_NAME not configured');
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (!Number.isFinite(TTL_SECONDS) || TTL_SECONDS < 60 || TTL_SECONDS > 86400) {
|
|
104
|
-
console.error('TTL_SECONDS must be a number between 60 and 86400 seconds');
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (argv.deployFile && !fs.existsSync(argv.deployFile)) {
|
|
109
|
-
console.error(`deploy-file [${argv.deployFolder}] does not exist`);
|
|
110
|
-
process.exit(1);
|
|
111
|
-
} else {
|
|
112
|
-
if (!fs.existsSync(argv.deployFolder)) {
|
|
113
|
-
console.error(`deploy-folder [${argv.deployFolder}] does not exist`);
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (argv.undername.length === 0) {
|
|
119
|
-
console.error('undername must be set');
|
|
120
|
-
process.exit(1);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const ario = ARIO.init({
|
|
124
|
-
process: new AOProcess({
|
|
125
|
-
processId: ARIO_PROCESS,
|
|
126
|
-
ao: connect({
|
|
127
|
-
MODE: 'legacy',
|
|
128
|
-
CU_URL: 'https://cu.ardrive.io',
|
|
129
|
-
}),
|
|
130
|
-
}),
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const arnsNameRecord = await ario.getArNSRecord({ name: ARNS_NAME }).catch((e) => {
|
|
134
|
-
console.error(`ARNS name [${ARNS_NAME}] does not exist`);
|
|
135
|
-
process.exit(1);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
let signer;
|
|
140
|
-
let token;
|
|
141
|
-
|
|
142
|
-
// Creates the proper signer based on the sig-type value
|
|
143
|
-
switch (argv['sig-type']) {
|
|
144
|
-
case 'ethereum':
|
|
145
|
-
signer = new EthereumSigner(DEPLOY_KEY);
|
|
146
|
-
token = 'ethereum';
|
|
147
|
-
break;
|
|
148
|
-
case 'polygon':
|
|
149
|
-
signer = new EthereumSigner(DEPLOY_KEY);
|
|
150
|
-
token = 'pol';
|
|
151
|
-
break;
|
|
152
|
-
case 'arweave':
|
|
153
|
-
const jwk = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8'));
|
|
154
|
-
signer = new ArweaveSigner(jwk);
|
|
155
|
-
token = 'arweave';
|
|
156
|
-
break;
|
|
157
|
-
case 'kyve':
|
|
158
|
-
signer = new EthereumSigner(DEPLOY_KEY);
|
|
159
|
-
token = 'kyve';
|
|
160
|
-
break;
|
|
161
|
-
default:
|
|
162
|
-
throw new Error(
|
|
163
|
-
`Invalid sig-type provided: ${argv['sig-type']}. Allowed values are 'arweave', 'ethereum', 'polygon', or 'kyve'.`
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const turbo = TurboFactory.authenticated({
|
|
168
|
-
signer: signer,
|
|
169
|
-
token: token,
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
let uploadResult;
|
|
173
|
-
let txOrManifestId;
|
|
174
|
-
if (argv['deploy-file']) {
|
|
175
|
-
// Detect MIME type for the file
|
|
176
|
-
const mimeType = mime.lookup(argv['deploy-file']) || 'application/octet-stream';
|
|
177
|
-
|
|
178
|
-
uploadResult = await turbo.uploadFile({
|
|
179
|
-
file: argv['deploy-file'],
|
|
180
|
-
dataItemOpts: {
|
|
181
|
-
tags: [
|
|
182
|
-
{
|
|
183
|
-
name: 'App-Name',
|
|
184
|
-
value: 'Permaweb-Deploy',
|
|
185
|
-
},
|
|
186
|
-
// prevents identical transaction Ids from eth wallets
|
|
187
|
-
{
|
|
188
|
-
name: 'anchor',
|
|
189
|
-
value: new Date().toISOString(),
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
name: 'Content-Type',
|
|
193
|
-
value: mimeType,
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
txOrManifestId = uploadResult.id;
|
|
199
|
-
} else {
|
|
200
|
-
uploadResult = await turbo.uploadFolder({
|
|
201
|
-
folderPath: argv['deploy-folder'],
|
|
202
|
-
dataItemOpts: {
|
|
203
|
-
tags: [
|
|
204
|
-
{
|
|
205
|
-
name: 'App-Name',
|
|
206
|
-
value: 'Permaweb-Deploy',
|
|
207
|
-
},
|
|
208
|
-
// prevents identical transaction Ids from eth wallets
|
|
209
|
-
{
|
|
210
|
-
name: 'anchor',
|
|
211
|
-
value: new Date().toISOString(),
|
|
212
|
-
},
|
|
213
|
-
],
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
txOrManifestId = uploadResult.manifestResponse.id; //might replace now
|
|
217
|
-
|
|
218
|
-
// Make default folder paths work by adding extra path entries
|
|
219
|
-
const origPaths = uploadResult.manifest.paths;
|
|
220
|
-
const newPaths = {};
|
|
221
|
-
let replaceManifest = false;
|
|
222
|
-
for (const [key, value] of Object.entries(origPaths)) {
|
|
223
|
-
newPaths[key] = value;
|
|
224
|
-
if (key.endsWith('/index.html')) {
|
|
225
|
-
const newKey = key.replace(/\/index\.html$/, '');
|
|
226
|
-
newPaths[newKey] = value;
|
|
227
|
-
replaceManifest = true;
|
|
228
|
-
};
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
if (replaceManifest) {
|
|
232
|
-
console.info('replacing manifest');
|
|
233
|
-
const newManifest = { ...uploadResult.manifest, paths: newPaths };
|
|
234
|
-
const buffer = Buffer.from(JSON.stringify(newManifest));
|
|
235
|
-
const { id } = await turbo.uploadFile({
|
|
236
|
-
fileStreamFactory: () => Readable.from(buffer),
|
|
237
|
-
fileSizeFactory: () => buffer.length,
|
|
238
|
-
dataItemOpts: { tags: [{ name: 'Content-Type', value: 'application/x.arweave-manifest+json' }] },
|
|
239
|
-
});
|
|
240
|
-
txOrManifestId = id;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
console.log('-------------------- DEPLOY DETAILS --------------------');
|
|
245
|
-
console.log(`Tx ID: ${txOrManifestId}`);
|
|
246
|
-
console.log(`ArNS Name: ${ARNS_NAME}`);
|
|
247
|
-
console.log(`Undername: ${argv.undername}`);
|
|
248
|
-
console.log(`ANT: ${arnsNameRecord.processId}`);
|
|
249
|
-
console.log(`AR IO Process: ${ARIO_PROCESS}`);
|
|
250
|
-
console.log(`TTL Seconds: ${TTL_SECONDS}`);
|
|
251
|
-
console.log('--------------------------------------------------------');
|
|
252
|
-
|
|
253
|
-
const ant = ANT.init({ processId: arnsNameRecord.processId, signer });
|
|
254
|
-
|
|
255
|
-
// Update the ANT record (assumes the JWK is a controller or owner)
|
|
256
|
-
await ant.setRecord(
|
|
257
|
-
{
|
|
258
|
-
undername: argv.undername,
|
|
259
|
-
transactionId: txOrManifestId,
|
|
260
|
-
ttlSeconds: argv['ttl-seconds'],
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
tags: [
|
|
264
|
-
{
|
|
265
|
-
name: 'App-Name',
|
|
266
|
-
value: 'Permaweb-Deploy',
|
|
267
|
-
},
|
|
268
|
-
...(process.env.GITHUB_SHA
|
|
269
|
-
? [
|
|
270
|
-
{
|
|
271
|
-
name: 'GIT-HASH',
|
|
272
|
-
value: process.env.GITHUB_SHA,
|
|
273
|
-
},
|
|
274
|
-
]
|
|
275
|
-
: []),
|
|
276
|
-
],
|
|
277
|
-
}
|
|
278
|
-
);
|
|
279
|
-
|
|
280
|
-
console.log(
|
|
281
|
-
`Deployed TxId [${txOrManifestId}] to name [${ARNS_NAME}] for ANT [${arnsNameRecord.processId}] using undername [${argv.undername}]`
|
|
282
|
-
);
|
|
283
|
-
} catch (e) {
|
|
284
|
-
console.error('Deployment failed:', e);
|
|
285
|
-
process.exit(1); // Exit with error code
|
|
286
|
-
}
|
|
287
|
-
})();
|