permaweb-deploy 1.1.4 → 1.1.6
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 +48 -18
- package/package.json +1 -1
- package/src/index.js +44 -16
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.getTagValue = getTagValue;
|
|
9
9
|
var _sdk = require("@ar.io/sdk");
|
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
10
11
|
var _yargs = _interopRequireDefault(require("yargs"));
|
|
11
12
|
var _helpers = require("yargs/helpers");
|
|
12
13
|
var _sdk2 = _interopRequireDefault(require("@irys/sdk"));
|
|
@@ -19,8 +20,17 @@ var argv = (0, _yargs["default"])((0, _helpers.hideBin)(process.argv)).option('a
|
|
|
19
20
|
type: 'string',
|
|
20
21
|
description: 'The ANT process',
|
|
21
22
|
demandOption: true
|
|
23
|
+
}).option('deploy-folder', {
|
|
24
|
+
alias: 'd',
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'Folder to deploy.',
|
|
27
|
+
"default": './dist'
|
|
28
|
+
}).option('undername', {
|
|
29
|
+
alias: 'u',
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'ANT undername to update.',
|
|
32
|
+
"default": '@'
|
|
22
33
|
}).argv;
|
|
23
|
-
var DEPLOY_FOLDER = './dist';
|
|
24
34
|
var DEPLOY_KEY = process.env.DEPLOY_KEY;
|
|
25
35
|
var ANT_PROCESS = argv.antProcess;
|
|
26
36
|
function getTagValue(list, name) {
|
|
@@ -52,25 +62,45 @@ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
|
52
62
|
console.error('ANT_PROCESS not configured');
|
|
53
63
|
return _context.abrupt("return");
|
|
54
64
|
case 6:
|
|
55
|
-
|
|
65
|
+
if (!(argv.deployFolder.length == 0)) {
|
|
66
|
+
_context.next = 9;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
console.error('deploy folder must not be empty');
|
|
70
|
+
return _context.abrupt("return");
|
|
71
|
+
case 9:
|
|
72
|
+
if (!(argv.undername.length == 0)) {
|
|
73
|
+
_context.next = 12;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
console.error('undername must not be empty');
|
|
77
|
+
return _context.abrupt("return");
|
|
78
|
+
case 12:
|
|
79
|
+
if (_fs["default"].existsSync(argv.deployFolder)) {
|
|
80
|
+
_context.next = 15;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
console.error("deploy folder [".concat(argv.deployFolder, "] does not exist"));
|
|
84
|
+
return _context.abrupt("return");
|
|
85
|
+
case 15:
|
|
56
86
|
jwk = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8'));
|
|
57
87
|
irys = new _sdk2["default"]({
|
|
58
|
-
url: 'https://
|
|
88
|
+
url: 'https://turbo.ardrive.io',
|
|
59
89
|
token: 'arweave',
|
|
60
90
|
key: jwk
|
|
61
91
|
});
|
|
62
92
|
irys.uploader.useChunking = false;
|
|
63
|
-
_context.prev =
|
|
64
|
-
console.log("Deploying ".concat(
|
|
65
|
-
_context.next =
|
|
66
|
-
return irys.uploadFolder(
|
|
93
|
+
_context.prev = 18;
|
|
94
|
+
console.log("Deploying ".concat(argv.deployFolder, " folder"));
|
|
95
|
+
_context.next = 22;
|
|
96
|
+
return irys.uploadFolder(argv.deployFolder, {
|
|
67
97
|
indexFile: 'index.html',
|
|
68
98
|
interactivePreflight: false,
|
|
69
99
|
logFunction: function logFunction(log) {
|
|
70
100
|
return console.log(log);
|
|
71
101
|
}
|
|
72
102
|
});
|
|
73
|
-
case
|
|
103
|
+
case 22:
|
|
74
104
|
txResult = _context.sent;
|
|
75
105
|
console.log("Bundle TxId [".concat(txResult.id, "]"));
|
|
76
106
|
signer = new _sdk.ArweaveSigner(jwk);
|
|
@@ -78,26 +108,26 @@ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
|
78
108
|
processId: ANT_PROCESS,
|
|
79
109
|
signer: signer
|
|
80
110
|
}); // Update the ANT record (assumes the JWK is a controller or owner)
|
|
81
|
-
_context.next =
|
|
111
|
+
_context.next = 28;
|
|
82
112
|
return ant.setRecord({
|
|
83
|
-
undername:
|
|
113
|
+
undername: argv.undername,
|
|
84
114
|
transactionId: txResult.id,
|
|
85
115
|
ttlSeconds: 3600
|
|
86
116
|
}, {
|
|
87
117
|
name: 'GIT-HASH',
|
|
88
118
|
value: process.env.GITHUB_SHA
|
|
89
119
|
});
|
|
90
|
-
case
|
|
91
|
-
console.log("Deployed TxId [".concat(txResult.id, "] to ANT [").concat(ANT_PROCESS, "]"));
|
|
92
|
-
_context.next =
|
|
120
|
+
case 28:
|
|
121
|
+
console.log("Deployed TxId [".concat(txResult.id, "] to ANT [").concat(ANT_PROCESS, "] using undername [").concat(argv.undername, "]"));
|
|
122
|
+
_context.next = 34;
|
|
93
123
|
break;
|
|
94
|
-
case
|
|
95
|
-
_context.prev =
|
|
96
|
-
_context.t0 = _context["catch"](
|
|
124
|
+
case 31:
|
|
125
|
+
_context.prev = 31;
|
|
126
|
+
_context.t0 = _context["catch"](18);
|
|
97
127
|
console.error(_context.t0);
|
|
98
|
-
case
|
|
128
|
+
case 34:
|
|
99
129
|
case "end":
|
|
100
130
|
return _context.stop();
|
|
101
131
|
}
|
|
102
|
-
}, _callee, null, [[
|
|
132
|
+
}, _callee, null, [[18, 31]]);
|
|
103
133
|
}))();
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { ANT, ArweaveSigner } from '@ar.io/sdk';
|
|
4
|
+
import fs from 'fs';
|
|
4
5
|
import yargs from 'yargs';
|
|
5
6
|
import { hideBin } from 'yargs/helpers';
|
|
6
7
|
|
|
@@ -13,9 +14,19 @@ const argv = yargs(hideBin(process.argv))
|
|
|
13
14
|
description: 'The ANT process',
|
|
14
15
|
demandOption: true,
|
|
15
16
|
})
|
|
16
|
-
.
|
|
17
|
+
.option('deploy-folder', {
|
|
18
|
+
alias: 'd',
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'Folder to deploy.',
|
|
21
|
+
default: './dist',
|
|
22
|
+
})
|
|
23
|
+
.option('undername', {
|
|
24
|
+
alias: 'u',
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'ANT undername to update.',
|
|
27
|
+
default: '@',
|
|
28
|
+
}).argv;
|
|
17
29
|
|
|
18
|
-
const DEPLOY_FOLDER = './dist';
|
|
19
30
|
const DEPLOY_KEY = process.env.DEPLOY_KEY;
|
|
20
31
|
const ANT_PROCESS = argv.antProcess;
|
|
21
32
|
|
|
@@ -41,17 +52,30 @@ export function getTagValue(list, name) {
|
|
|
41
52
|
return;
|
|
42
53
|
}
|
|
43
54
|
|
|
44
|
-
|
|
55
|
+
if (argv.deployFolder.length == 0) {
|
|
56
|
+
console.error('deploy folder must not be empty');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (argv.undername.length == 0) {
|
|
61
|
+
console.error('undername must not be empty');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!fs.existsSync(argv.deployFolder)) {
|
|
66
|
+
console.error(`deploy folder [${argv.deployFolder}] does not exist`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
45
69
|
|
|
46
70
|
let jwk = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8'));
|
|
47
|
-
|
|
48
|
-
const irys = new Irys({ url: 'https://
|
|
71
|
+
|
|
72
|
+
const irys = new Irys({ url: 'https://turbo.ardrive.io', token: 'arweave', key: jwk });
|
|
49
73
|
irys.uploader.useChunking = false;
|
|
50
74
|
|
|
51
75
|
try {
|
|
52
|
-
console.log(`Deploying ${
|
|
76
|
+
console.log(`Deploying ${argv.deployFolder} folder`);
|
|
53
77
|
|
|
54
|
-
const txResult = await irys.uploadFolder(
|
|
78
|
+
const txResult = await irys.uploadFolder(argv.deployFolder, {
|
|
55
79
|
indexFile: 'index.html',
|
|
56
80
|
interactivePreflight: false,
|
|
57
81
|
logFunction: (log) => console.log(log),
|
|
@@ -63,15 +87,19 @@ export function getTagValue(list, name) {
|
|
|
63
87
|
const ant = ANT.init({ processId: ANT_PROCESS, signer });
|
|
64
88
|
|
|
65
89
|
// Update the ANT record (assumes the JWK is a controller or owner)
|
|
66
|
-
await ant.setRecord(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
await ant.setRecord(
|
|
91
|
+
{
|
|
92
|
+
undername: argv.undername,
|
|
93
|
+
transactionId: txResult.id,
|
|
94
|
+
ttlSeconds: 3600,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'GIT-HASH',
|
|
98
|
+
value: process.env.GITHUB_SHA,
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
console.log(`Deployed TxId [${txResult.id}] to ANT [${ANT_PROCESS}] using undername [${argv.undername}]`);
|
|
75
103
|
} catch (e) {
|
|
76
104
|
console.error(e);
|
|
77
105
|
}
|