@sentio/cli 3.5.1-rc.2 → 3.5.1-rc.3
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/lib/index.js +52 -20
- package/package.json +1 -1
- package/src/commands/upload.ts +32 -2
- package/src/uploader.ts +29 -22
package/lib/index.js
CHANGED
|
@@ -112339,12 +112339,14 @@ var DefaultBatchUploader = class extends BatchUploader {
|
|
|
112339
112339
|
constructor(options, auth) {
|
|
112340
112340
|
super(0 /* DEFAULT */, options, auth);
|
|
112341
112341
|
}
|
|
112342
|
-
async upload(files, commitSha, gitUrl, debug, continueFrom, networkOverrides, rollback) {
|
|
112343
|
-
|
|
112344
|
-
|
|
112345
|
-
|
|
112346
|
-
|
|
112347
|
-
|
|
112342
|
+
async upload(files, commitSha, gitUrl, debug, continueFrom, networkOverrides, rollback, initResponse) {
|
|
112343
|
+
if (!initResponse) {
|
|
112344
|
+
const fileTypes = {
|
|
112345
|
+
source: 1 /* SOURCE */,
|
|
112346
|
+
code: 0 /* PROCESSOR */
|
|
112347
|
+
};
|
|
112348
|
+
initResponse = await this.initUpload(fileTypes);
|
|
112349
|
+
}
|
|
112348
112350
|
for (const [fileKey, payload] of Object.entries(initResponse.payloads)) {
|
|
112349
112351
|
if (!payload?.object?.putUrl) {
|
|
112350
112352
|
throw new Error(`No S3 put URL found for file: ${fileKey}`);
|
|
@@ -112380,14 +112382,16 @@ var DefaultBatchUploader = class extends BatchUploader {
|
|
|
112380
112382
|
};
|
|
112381
112383
|
var IPFSBatchUploader = class extends BatchUploader {
|
|
112382
112384
|
constructor(options, auth) {
|
|
112383
|
-
super(
|
|
112385
|
+
super(5 /* IPFS */, options, auth);
|
|
112384
112386
|
}
|
|
112385
|
-
async upload(files, commitSha, gitUrl, debug, continueFrom, networkOverrides, rollback) {
|
|
112386
|
-
|
|
112387
|
-
|
|
112388
|
-
|
|
112389
|
-
|
|
112390
|
-
|
|
112387
|
+
async upload(files, commitSha, gitUrl, debug, continueFrom, networkOverrides, rollback, initResponse) {
|
|
112388
|
+
if (!initResponse) {
|
|
112389
|
+
const fileTypes = {
|
|
112390
|
+
source: 1 /* SOURCE */,
|
|
112391
|
+
code: 0 /* PROCESSOR */
|
|
112392
|
+
};
|
|
112393
|
+
initResponse = await this.initUpload(fileTypes);
|
|
112394
|
+
}
|
|
112391
112395
|
for (const [fileKey, payload] of Object.entries(initResponse.payloads)) {
|
|
112392
112396
|
const putUrl = payload.object?.putUrl || payload.ipfs?.putUrl;
|
|
112393
112397
|
if (!putUrl) {
|
|
@@ -112448,12 +112452,14 @@ var WalrusBatchUploader = class extends BatchUploader {
|
|
|
112448
112452
|
form.append("_metadata", JSON.stringify(metadata));
|
|
112449
112453
|
return form;
|
|
112450
112454
|
}
|
|
112451
|
-
async upload(files, commitSha, gitUrl, debug, continueFrom, networkOverrides, rollback) {
|
|
112452
|
-
|
|
112453
|
-
|
|
112454
|
-
|
|
112455
|
-
|
|
112456
|
-
|
|
112455
|
+
async upload(files, commitSha, gitUrl, debug, continueFrom, networkOverrides, rollback, initResponse) {
|
|
112456
|
+
if (!initResponse) {
|
|
112457
|
+
const fileTypes = {
|
|
112458
|
+
source: 1 /* SOURCE */,
|
|
112459
|
+
code: 0 /* PROCESSOR */
|
|
112460
|
+
};
|
|
112461
|
+
initResponse = await this.initUpload(fileTypes);
|
|
112462
|
+
}
|
|
112457
112463
|
const formData = this.createQuiltMultipartFormData(files);
|
|
112458
112464
|
const firstPayload = Object.values(initResponse.payloads)[0];
|
|
112459
112465
|
if (!firstPayload?.walrus?.putUrl || !firstPayload.walrus.jwtToken) {
|
|
@@ -112775,6 +112781,15 @@ async function checkOrCreateProject(options, auth) {
|
|
|
112775
112781
|
);
|
|
112776
112782
|
process.exit(1);
|
|
112777
112783
|
}
|
|
112784
|
+
if (!options.sentioNetwork && project.sentioNetwork === true) {
|
|
112785
|
+
console.error(
|
|
112786
|
+
source_default.red(
|
|
112787
|
+
`Project ${project?.slug} is a Sentio Network project. Please add the --sentio-network flag when uploading.
|
|
112788
|
+
Example: sentio upload --sentio-network testnet`
|
|
112789
|
+
)
|
|
112790
|
+
);
|
|
112791
|
+
process.exit(1);
|
|
112792
|
+
}
|
|
112778
112793
|
return project?.id;
|
|
112779
112794
|
}
|
|
112780
112795
|
async function uploadFile(config, auth, options) {
|
|
@@ -112841,6 +112856,22 @@ async function uploadFile(config, auth, options) {
|
|
|
112841
112856
|
const sourceBuffer = await createSourceZip();
|
|
112842
112857
|
const codeBuffer = fs16.readFileSync(processorFile);
|
|
112843
112858
|
const uploader = options.walrus ? new WalrusBatchUploader(config, auth) : options.sentioNetwork ? new IPFSBatchUploader(config, auth) : new DefaultBatchUploader(config, auth);
|
|
112859
|
+
const fileTypes = {
|
|
112860
|
+
source: 1 /* SOURCE */,
|
|
112861
|
+
code: 0 /* PROCESSOR */
|
|
112862
|
+
};
|
|
112863
|
+
const initResponse = await uploader.initUpload(fileTypes);
|
|
112864
|
+
if (initResponse.warning) {
|
|
112865
|
+
console.log(source_default.yellow(initResponse.warning));
|
|
112866
|
+
}
|
|
112867
|
+
if (initResponse.replacing_version && !config.silentOverwrite) {
|
|
112868
|
+
const confirmed = await confirm(
|
|
112869
|
+
`This will replace processor version ${initResponse.replacing_version}. Continue?`
|
|
112870
|
+
);
|
|
112871
|
+
if (!confirmed) {
|
|
112872
|
+
process.exit(0);
|
|
112873
|
+
}
|
|
112874
|
+
}
|
|
112844
112875
|
if (config.variables && config.variables.length > 0) {
|
|
112845
112876
|
const ret = await updateVariables(projectId, config, auth);
|
|
112846
112877
|
if (!ret.ok) {
|
|
@@ -112856,7 +112887,8 @@ async function uploadFile(config, auth, options) {
|
|
|
112856
112887
|
config.debug || options.debug,
|
|
112857
112888
|
continueFrom,
|
|
112858
112889
|
config.networkOverrides,
|
|
112859
|
-
rollbackMap
|
|
112890
|
+
rollbackMap,
|
|
112891
|
+
initResponse
|
|
112860
112892
|
);
|
|
112861
112893
|
console.log(source_default.green("Upload success: "));
|
|
112862
112894
|
const codeHash = createHash3("sha256").update(codeBuffer).digest("hex");
|
package/package.json
CHANGED
package/src/commands/upload.ts
CHANGED
|
@@ -13,7 +13,7 @@ import readline from 'readline'
|
|
|
13
13
|
import JSZip from 'jszip'
|
|
14
14
|
import { UserInfo } from '../../../protos/lib/service/common/protos/common.js'
|
|
15
15
|
import { CommandOptionsType } from './types.js'
|
|
16
|
-
import { Auth, DefaultBatchUploader, IPFSBatchUploader, WalrusBatchUploader } from '../uploader.js'
|
|
16
|
+
import { Auth, DefaultBatchUploader, FileType, IPFSBatchUploader, WalrusBatchUploader } from '../uploader.js'
|
|
17
17
|
export { type Auth } from '../uploader.js'
|
|
18
18
|
|
|
19
19
|
function myParseInt(value: string, dummyPrevious: number): number {
|
|
@@ -322,6 +322,15 @@ async function checkOrCreateProject(options: YamlProjectConfig, auth: Auth) {
|
|
|
322
322
|
)
|
|
323
323
|
process.exit(1)
|
|
324
324
|
}
|
|
325
|
+
if (!options.sentioNetwork && project.sentioNetwork === true) {
|
|
326
|
+
console.error(
|
|
327
|
+
chalk.red(
|
|
328
|
+
`Project ${project?.slug} is a Sentio Network project. Please add the --sentio-network flag when uploading.\n` +
|
|
329
|
+
`Example: sentio upload --sentio-network testnet`
|
|
330
|
+
)
|
|
331
|
+
)
|
|
332
|
+
process.exit(1)
|
|
333
|
+
}
|
|
325
334
|
return project?.id
|
|
326
335
|
}
|
|
327
336
|
|
|
@@ -421,6 +430,26 @@ export async function uploadFile(
|
|
|
421
430
|
? new IPFSBatchUploader(config, auth)
|
|
422
431
|
: new DefaultBatchUploader(config, auth)
|
|
423
432
|
|
|
433
|
+
// Initialize upload and handle confirmation
|
|
434
|
+
const fileTypes: Record<string, number> = {
|
|
435
|
+
source: FileType.SOURCE,
|
|
436
|
+
code: FileType.PROCESSOR
|
|
437
|
+
}
|
|
438
|
+
const initResponse = await uploader.initUpload(fileTypes)
|
|
439
|
+
|
|
440
|
+
if (initResponse.warning) {
|
|
441
|
+
console.log(chalk.yellow(initResponse.warning))
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (initResponse.replacing_version && !config.silentOverwrite) {
|
|
445
|
+
const confirmed = await confirm(
|
|
446
|
+
`This will replace processor version ${initResponse.replacing_version}. Continue?`
|
|
447
|
+
)
|
|
448
|
+
if (!confirmed) {
|
|
449
|
+
process.exit(0)
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
424
453
|
// Handle variables update if needed
|
|
425
454
|
if (config.variables && config.variables.length > 0) {
|
|
426
455
|
const ret = await updateVariables(projectId, config, auth)
|
|
@@ -439,7 +468,8 @@ export async function uploadFile(
|
|
|
439
468
|
config.debug || options.debug,
|
|
440
469
|
continueFrom,
|
|
441
470
|
config.networkOverrides,
|
|
442
|
-
rollbackMap
|
|
471
|
+
rollbackMap,
|
|
472
|
+
initResponse
|
|
443
473
|
)
|
|
444
474
|
|
|
445
475
|
console.log(chalk.green('Upload success: '))
|
package/src/uploader.ts
CHANGED
|
@@ -89,7 +89,8 @@ export abstract class BatchUploader {
|
|
|
89
89
|
debug?: boolean,
|
|
90
90
|
continueFrom?: number,
|
|
91
91
|
networkOverrides?: NetworkOverride[],
|
|
92
|
-
rollback?: Record<string, number
|
|
92
|
+
rollback?: Record<string, number>,
|
|
93
|
+
initResponse?: InitBatchUploadResponse
|
|
93
94
|
): Promise<FinishBatchUploadResponse>
|
|
94
95
|
|
|
95
96
|
async initUpload(fileTypes?: Record<string, FileType>): Promise<InitBatchUploadResponse> {
|
|
@@ -184,16 +185,18 @@ export class DefaultBatchUploader extends BatchUploader {
|
|
|
184
185
|
debug?: boolean,
|
|
185
186
|
continueFrom?: number,
|
|
186
187
|
networkOverrides?: NetworkOverride[],
|
|
187
|
-
rollback?: Record<string, number
|
|
188
|
+
rollback?: Record<string, number>,
|
|
189
|
+
initResponse?: InitBatchUploadResponse
|
|
188
190
|
): Promise<FinishBatchUploadResponse> {
|
|
189
|
-
// Step 1: Initialize upload with file types
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
// Step 1: Initialize upload with file types (if not already done)
|
|
192
|
+
if (!initResponse) {
|
|
193
|
+
const fileTypes: Record<string, FileType> = {
|
|
194
|
+
source: FileType.SOURCE,
|
|
195
|
+
code: FileType.PROCESSOR
|
|
196
|
+
}
|
|
197
|
+
initResponse = await this.initUpload(fileTypes)
|
|
193
198
|
}
|
|
194
199
|
|
|
195
|
-
const initResponse = await this.initUpload(fileTypes)
|
|
196
|
-
|
|
197
200
|
// Step 3: Upload files to S3 using presigned URLs
|
|
198
201
|
for (const [fileKey, payload] of Object.entries(initResponse.payloads)) {
|
|
199
202
|
if (!payload?.object?.putUrl) {
|
|
@@ -235,7 +238,7 @@ export class DefaultBatchUploader extends BatchUploader {
|
|
|
235
238
|
|
|
236
239
|
export class IPFSBatchUploader extends BatchUploader {
|
|
237
240
|
constructor(options: YamlProjectConfig, auth: Auth) {
|
|
238
|
-
super(StorageEngine.
|
|
241
|
+
super(StorageEngine.IPFS, options, auth)
|
|
239
242
|
}
|
|
240
243
|
|
|
241
244
|
async upload(
|
|
@@ -245,15 +248,17 @@ export class IPFSBatchUploader extends BatchUploader {
|
|
|
245
248
|
debug?: boolean,
|
|
246
249
|
continueFrom?: number,
|
|
247
250
|
networkOverrides?: NetworkOverride[],
|
|
248
|
-
rollback?: Record<string, number
|
|
251
|
+
rollback?: Record<string, number>,
|
|
252
|
+
initResponse?: InitBatchUploadResponse
|
|
249
253
|
): Promise<FinishBatchUploadResponse> {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
254
|
+
if (!initResponse) {
|
|
255
|
+
const fileTypes: Record<string, FileType> = {
|
|
256
|
+
source: FileType.SOURCE,
|
|
257
|
+
code: FileType.PROCESSOR
|
|
258
|
+
}
|
|
259
|
+
initResponse = await this.initUpload(fileTypes)
|
|
253
260
|
}
|
|
254
261
|
|
|
255
|
-
const initResponse = await this.initUpload(fileTypes)
|
|
256
|
-
|
|
257
262
|
for (const [fileKey, payload] of Object.entries(initResponse.payloads)) {
|
|
258
263
|
const putUrl = payload.object?.putUrl || payload.ipfs?.putUrl
|
|
259
264
|
if (!putUrl) {
|
|
@@ -334,16 +339,18 @@ export class WalrusBatchUploader extends BatchUploader {
|
|
|
334
339
|
debug?: boolean,
|
|
335
340
|
continueFrom?: number,
|
|
336
341
|
networkOverrides?: NetworkOverride[],
|
|
337
|
-
rollback?: Record<string, number
|
|
342
|
+
rollback?: Record<string, number>,
|
|
343
|
+
initResponse?: InitBatchUploadResponse
|
|
338
344
|
): Promise<FinishBatchUploadResponse> {
|
|
339
|
-
// Step 1: Initialize upload with file types
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
345
|
+
// Step 1: Initialize upload with file types (if not already done)
|
|
346
|
+
if (!initResponse) {
|
|
347
|
+
const fileTypes: Record<string, FileType> = {
|
|
348
|
+
source: FileType.SOURCE,
|
|
349
|
+
code: FileType.PROCESSOR
|
|
350
|
+
}
|
|
351
|
+
initResponse = await this.initUpload(fileTypes)
|
|
343
352
|
}
|
|
344
353
|
|
|
345
|
-
const initResponse = await this.initUpload(fileTypes)
|
|
346
|
-
|
|
347
354
|
// Step 2: Create quilt multipart form data for all files
|
|
348
355
|
const formData = this.createQuiltMultipartFormData(files)
|
|
349
356
|
|