permaweb-deploy 2.5.1 → 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.
Files changed (78) hide show
  1. package/README.md +311 -83
  2. package/bin/dev.js +5 -0
  3. package/bin/run.js +5 -0
  4. package/dist/commands/deploy.js +227 -0
  5. package/dist/commands/deploy.js.map +1 -0
  6. package/dist/constants/flags.js +190 -0
  7. package/dist/constants/flags.js.map +1 -0
  8. package/dist/index.js +2 -299
  9. package/dist/index.js.map +1 -0
  10. package/dist/prompts/arns.js +89 -0
  11. package/dist/prompts/arns.js.map +1 -0
  12. package/dist/prompts/deployment.js +27 -0
  13. package/dist/prompts/deployment.js.map +1 -0
  14. package/dist/prompts/wallet.js +51 -0
  15. package/dist/prompts/wallet.js.map +1 -0
  16. package/dist/src/commands/deploy.d.ts +9 -0
  17. package/dist/src/commands/deploy.d.ts.map +1 -0
  18. package/dist/src/constants/flags.d.ts +84 -0
  19. package/dist/src/constants/flags.d.ts.map +1 -0
  20. package/dist/src/index.d.ts +2 -0
  21. package/dist/src/index.d.ts.map +1 -0
  22. package/dist/src/prompts/arns.d.ts +13 -0
  23. package/dist/src/prompts/arns.d.ts.map +1 -0
  24. package/dist/src/prompts/deployment.d.ts +6 -0
  25. package/dist/src/prompts/deployment.d.ts.map +1 -0
  26. package/dist/src/prompts/wallet.d.ts +11 -0
  27. package/dist/src/prompts/wallet.d.ts.map +1 -0
  28. package/dist/src/types/index.d.ts +31 -0
  29. package/dist/src/types/index.d.ts.map +1 -0
  30. package/dist/src/utils/__tests__/constants.test.d.ts +2 -0
  31. package/dist/src/utils/__tests__/constants.test.d.ts.map +1 -0
  32. package/dist/src/utils/config-resolver.d.ts +72 -0
  33. package/dist/src/utils/config-resolver.d.ts.map +1 -0
  34. package/dist/src/utils/constants.d.ts +4 -0
  35. package/dist/src/utils/constants.d.ts.map +1 -0
  36. package/dist/src/utils/path.d.ts +5 -0
  37. package/dist/src/utils/path.d.ts.map +1 -0
  38. package/dist/src/utils/signer.d.ts +17 -0
  39. package/dist/src/utils/signer.d.ts.map +1 -0
  40. package/dist/src/utils/uploader.d.ts +8 -0
  41. package/dist/src/utils/uploader.d.ts.map +1 -0
  42. package/dist/src/utils/validators.d.ts +29 -0
  43. package/dist/src/utils/validators.d.ts.map +1 -0
  44. package/dist/tests/constants.d.ts +11 -0
  45. package/dist/tests/constants.d.ts.map +1 -0
  46. package/dist/tests/e2e/deploy-command.test.d.ts +2 -0
  47. package/dist/tests/e2e/deploy-command.test.d.ts.map +1 -0
  48. package/dist/tests/global-setup.d.ts +6 -0
  49. package/dist/tests/global-setup.d.ts.map +1 -0
  50. package/dist/tests/mocks/turbo-handlers.d.ts +105 -0
  51. package/dist/tests/mocks/turbo-handlers.d.ts.map +1 -0
  52. package/dist/tests/setup.d.ts +11 -0
  53. package/dist/tests/setup.d.ts.map +1 -0
  54. package/dist/tests/types/payment-service.d.ts +218 -0
  55. package/dist/tests/types/payment-service.d.ts.map +1 -0
  56. package/dist/tests/types/upload-service.d.ts +168 -0
  57. package/dist/tests/types/upload-service.d.ts.map +1 -0
  58. package/dist/tests/unit/validators.test.d.ts +2 -0
  59. package/dist/tests/unit/validators.test.d.ts.map +1 -0
  60. package/dist/types/index.js +2 -0
  61. package/dist/types/index.js.map +1 -0
  62. package/dist/utils/config-resolver.js +39 -0
  63. package/dist/utils/config-resolver.js.map +1 -0
  64. package/dist/utils/constants.js +6 -0
  65. package/dist/utils/constants.js.map +1 -0
  66. package/dist/utils/path.js +15 -0
  67. package/dist/utils/path.js.map +1 -0
  68. package/dist/utils/signer.js +40 -0
  69. package/dist/utils/signer.js.map +1 -0
  70. package/dist/utils/uploader.js +78 -0
  71. package/dist/utils/uploader.js.map +1 -0
  72. package/dist/utils/validators.js +62 -0
  73. package/dist/utils/validators.js.map +1 -0
  74. package/package.json +107 -37
  75. package/.babelrc +0 -3
  76. package/.editorconfig +0 -4
  77. package/.eslintrc.js +0 -35
  78. 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/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: 60,
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
- })();