permaweb-deploy 1.1.9 → 2.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.
Files changed (3) hide show
  1. package/dist/index.js +45 -49
  2. package/package.json +2 -2
  3. package/src/index.js +25 -16
package/dist/index.js CHANGED
@@ -21,10 +21,10 @@ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(
21
21
  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; }
22
22
  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); }
23
23
  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); }); }; }
24
- var argv = (0, _yargs["default"])((0, _helpers.hideBin)(process.argv)).option('ant-process', {
25
- alias: 'a',
24
+ var argv = (0, _yargs["default"])((0, _helpers.hideBin)(process.argv)).option('arns-name', {
25
+ alias: 'n',
26
26
  type: 'string',
27
- description: 'The ANT process',
27
+ description: 'The ARNS name',
28
28
  demandOption: true
29
29
  }).option('deploy-folder', {
30
30
  alias: 'd',
@@ -38,7 +38,7 @@ var argv = (0, _yargs["default"])((0, _helpers.hideBin)(process.argv)).option('a
38
38
  "default": '@'
39
39
  }).argv;
40
40
  var DEPLOY_KEY = process.env.DEPLOY_KEY;
41
- var ANT_PROCESS = argv.antProcess;
41
+ var ARNS_NAME = argv.arnsName;
42
42
  function getTagValue(list, name) {
43
43
  for (var i = 0; i < list.length; i++) {
44
44
  if (list[i]) {
@@ -50,57 +50,52 @@ function getTagValue(list, name) {
50
50
  return STORAGE.none;
51
51
  }
52
52
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
53
- var jwk, manifestId, signer, ant;
53
+ var jwk, ario, arnsNameRecord, manifestId, signer, ant;
54
54
  return _regeneratorRuntime().wrap(function _callee$(_context) {
55
55
  while (1) switch (_context.prev = _context.next) {
56
56
  case 0:
57
- if (DEPLOY_KEY) {
58
- _context.next = 3;
59
- break;
57
+ if (!DEPLOY_KEY) {
58
+ console.error('DEPLOY_KEY not configured');
59
+ process.exit(1);
60
60
  }
61
- console.error('DEPLOY_KEY not configured');
62
- return _context.abrupt("return");
63
- case 3:
64
- if (ANT_PROCESS) {
65
- _context.next = 6;
66
- break;
61
+ if (!ARNS_NAME) {
62
+ console.error('ARNS_NAME not configured');
63
+ process.exit(1);
67
64
  }
68
- console.error('ANT_PROCESS not configured');
69
- return _context.abrupt("return");
70
- case 6:
71
- if (!(argv.deployFolder.length == 0)) {
72
- _context.next = 9;
73
- break;
65
+ if (argv.deployFolder.length == 0) {
66
+ console.error('deploy folder must not be empty');
67
+ process.exit(1);
74
68
  }
75
- console.error('deploy folder must not be empty');
76
- return _context.abrupt("return");
77
- case 9:
78
- if (!(argv.undername.length == 0)) {
79
- _context.next = 12;
80
- break;
69
+ if (argv.undername.length == 0) {
70
+ console.error('undername must not be empty');
71
+ process.exit(1);
81
72
  }
82
- console.error('undername must not be empty');
83
- return _context.abrupt("return");
84
- case 12:
85
- if (_fs["default"].existsSync(argv.deployFolder)) {
86
- _context.next = 15;
87
- break;
73
+ if (!_fs["default"].existsSync(argv.deployFolder)) {
74
+ console.error("deploy folder [".concat(argv.deployFolder, "] does not exist"));
75
+ process.exit(1);
88
76
  }
89
- console.error("deploy folder [".concat(argv.deployFolder, "] does not exist"));
90
- return _context.abrupt("return");
91
- case 15:
92
77
  jwk = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8'));
93
- _context.prev = 16;
94
- _context.next = 19;
78
+ ario = _sdk.ARIO.init();
79
+ _context.next = 9;
80
+ return ario.getArNSRecord({
81
+ name: ARNS_NAME
82
+ })["catch"](function (e) {
83
+ console.error("ARNS name [".concat(ARNS_NAME, "] does not exist"));
84
+ process.exit(1);
85
+ });
86
+ case 9:
87
+ arnsNameRecord = _context.sent;
88
+ _context.prev = 10;
89
+ _context.next = 13;
95
90
  return (0, _turbo["default"])(argv, jwk);
96
- case 19:
91
+ case 13:
97
92
  manifestId = _context.sent;
98
93
  signer = new _sdk.ArweaveSigner(jwk);
99
94
  ant = _sdk.ANT.init({
100
- processId: ANT_PROCESS,
95
+ processId: arnsNameRecord.processId,
101
96
  signer: signer
102
97
  }); // Update the ANT record (assumes the JWK is a controller or owner)
103
- _context.next = 24;
98
+ _context.next = 18;
104
99
  return ant.setRecord({
105
100
  undername: argv.undername,
106
101
  transactionId: manifestId,
@@ -114,17 +109,18 @@ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
114
109
  value: process.env.GITHUB_SHA
115
110
  }] : []))
116
111
  });
117
- case 24:
118
- console.log("Deployed TxId [".concat(manifestId, "] to ANT [").concat(ANT_PROCESS, "] using undername [").concat(argv.undername, "]"));
119
- _context.next = 30;
112
+ case 18:
113
+ console.log("Deployed TxId [".concat(manifestId, "] to name [").concat(ARNS_NAME, "] for ANT [").concat(arnsNameRecord.processId, "] using undername [").concat(argv.undername, "]"));
114
+ _context.next = 25;
120
115
  break;
121
- case 27:
122
- _context.prev = 27;
123
- _context.t0 = _context["catch"](16);
124
- throw new Error(_context.t0);
125
- case 30:
116
+ case 21:
117
+ _context.prev = 21;
118
+ _context.t0 = _context["catch"](10);
119
+ console.error('Deployment failed:', _context.t0);
120
+ process.exit(1); // Exit with error code
121
+ case 25:
126
122
  case "end":
127
123
  return _context.stop();
128
124
  }
129
- }, _callee, null, [[16, 27]]);
125
+ }, _callee, null, [[10, 21]]);
130
126
  }))();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "permaweb-deploy",
3
- "version": "1.1.9",
3
+ "version": "2.0.0",
4
4
  "description": "Permaweb app deployment package",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  "permaweb-deploy": "./dist/index.js"
11
11
  },
12
12
  "dependencies": {
13
- "@ar.io/sdk": "^2.2.5",
13
+ "@ar.io/sdk": "^3.10.1",
14
14
  "@ardrive/turbo-sdk": "^1.17.0",
15
15
  "mime-types": "^2.1.35",
16
16
  "yargs": "17.7.2"
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { ANT, ArweaveSigner } from '@ar.io/sdk';
3
+ import { ANT, ARIO, ArweaveSigner } from '@ar.io/sdk';
4
4
  import fs from 'fs';
5
5
  import yargs from 'yargs';
6
6
  import { hideBin } from 'yargs/helpers';
@@ -8,10 +8,10 @@ import { hideBin } from 'yargs/helpers';
8
8
  import TurboDeploy from './turbo';
9
9
 
10
10
  const argv = yargs(hideBin(process.argv))
11
- .option('ant-process', {
12
- alias: 'a',
11
+ .option('arns-name', {
12
+ alias: 'n',
13
13
  type: 'string',
14
- description: 'The ANT process',
14
+ description: 'The ARNS name',
15
15
  demandOption: true,
16
16
  })
17
17
  .option('deploy-folder', {
@@ -28,7 +28,7 @@ const argv = yargs(hideBin(process.argv))
28
28
  }).argv;
29
29
 
30
30
  const DEPLOY_KEY = process.env.DEPLOY_KEY;
31
- const ANT_PROCESS = argv.antProcess;
31
+ const ARNS_NAME = argv.arnsName;
32
32
 
33
33
  export function getTagValue(list, name) {
34
34
  for (let i = 0; i < list.length; i++) {
@@ -44,34 +44,42 @@ export function getTagValue(list, name) {
44
44
  (async () => {
45
45
  if (!DEPLOY_KEY) {
46
46
  console.error('DEPLOY_KEY not configured');
47
- return;
47
+ process.exit(1);
48
48
  }
49
49
 
50
- if (!ANT_PROCESS) {
51
- console.error('ANT_PROCESS not configured');
52
- return;
50
+ if (!ARNS_NAME) {
51
+ console.error('ARNS_NAME not configured');
52
+ process.exit(1);
53
53
  }
54
54
 
55
+
55
56
  if (argv.deployFolder.length == 0) {
56
57
  console.error('deploy folder must not be empty');
57
- return;
58
+ process.exit(1);
58
59
  }
59
60
 
60
61
  if (argv.undername.length == 0) {
61
62
  console.error('undername must not be empty');
62
- return;
63
+ process.exit(1);
63
64
  }
64
65
 
65
66
  if (!fs.existsSync(argv.deployFolder)) {
66
67
  console.error(`deploy folder [${argv.deployFolder}] does not exist`);
67
- return;
68
+ process.exit(1);
68
69
  }
69
70
 
70
- let jwk = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8'));
71
+ const jwk = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8'));
72
+ const ario = ARIO.init()
73
+ const arnsNameRecord = await ario.getArNSRecord({name: ARNS_NAME}).catch((e) => {
74
+ console.error(`ARNS name [${ARNS_NAME}] does not exist`);
75
+ process.exit(1);
76
+ });
77
+
78
+
71
79
  try {
72
80
  const manifestId = await TurboDeploy(argv, jwk);
73
81
  const signer = new ArweaveSigner(jwk);
74
- const ant = ANT.init({ processId: ANT_PROCESS, signer });
82
+ const ant = ANT.init({ processId: arnsNameRecord.processId, signer });
75
83
 
76
84
  // Update the ANT record (assumes the JWK is a controller or owner)
77
85
  await ant.setRecord(
@@ -93,8 +101,9 @@ export function getTagValue(list, name) {
93
101
  }
94
102
  );
95
103
 
96
- console.log(`Deployed TxId [${manifestId}] to ANT [${ANT_PROCESS}] using undername [${argv.undername}]`);
104
+ console.log(`Deployed TxId [${manifestId}] to name [${ARNS_NAME}] for ANT [${arnsNameRecord.processId}] using undername [${argv.undername}]`);
97
105
  } catch (e) {
98
- throw new Error(e);
106
+ console.error('Deployment failed:', e);
107
+ process.exit(1); // Exit with error code
99
108
  }
100
109
  })();