From 09d8681a87cabbc8d331a48deb1d7fad0c7a169e Mon Sep 17 00:00:00 2001 From: jackkru69 Date: Tue, 17 Dec 2024 21:00:06 +0700 Subject: [PATCH] container upload fix --- .changeset/cyan-goats-hunt.md | 5 +++ packages/cli/src/commands/container/upload.ts | 41 +++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 .changeset/cyan-goats-hunt.md diff --git a/.changeset/cyan-goats-hunt.md b/.changeset/cyan-goats-hunt.md new file mode 100644 index 0000000..04a1426 --- /dev/null +++ b/.changeset/cyan-goats-hunt.md @@ -0,0 +1,5 @@ +--- +'@thepowereco/cli': patch +--- + +container upload fix diff --git a/packages/cli/src/commands/container/upload.ts b/packages/cli/src/commands/container/upload.ts index c8731f8..4343f47 100644 --- a/packages/cli/src/commands/container/upload.ts +++ b/packages/cli/src/commands/container/upload.ts @@ -11,6 +11,7 @@ import abis from '../../abis/index.js' import { scanDir } from '../../helpers/upload.helper.js' import { BaseCommand } from '../../baseCommand.js' import { importContainerKey } from '../../helpers/container.helper.js' +import { ParamsParser } from '../../helpers/params-parser.helper.js' async function uploadFile({ url, @@ -99,6 +100,10 @@ export default class ContainerUpload extends BaseCommand { char: 'n', description: 'Chain ID' }), + ignoreUploadList: Flags.string({ + char: 'g', + description: 'Ignore upload list' + }), isEth: Flags.boolean({ char: 'e', description: 'Use an ethereum address', @@ -119,6 +124,7 @@ export default class ContainerUpload extends BaseCommand { ordersScAddress, providerScAddress, chain, + ignoreUploadList, isEth } = flags @@ -128,6 +134,10 @@ export default class ContainerUpload extends BaseCommand { throw new Error('No wallet found.') } + const paramsParser = new ParamsParser() + + const parsedIgnoreUploadList = ignoreUploadList && paramsParser.parse(ignoreUploadList) + // Initialize network API const networkApi = await initializeNetworkApi({ address: importedWallet.address, @@ -227,17 +237,30 @@ export default class ContainerUpload extends BaseCommand { const ignoreList = ['.git'] + if (parsedIgnoreUploadList) { + for (const ignore of parsedIgnoreUploadList) { + if (typeof ignore === 'string') { + ignoreList.push(ignore) + } + } + } + + const filteredFiles = files.filter( + file => + !ignoreList.some(ignore => + `${file.path !== '.' ? file.path : ''}${file.name}`.startsWith(ignore) + ) + ) + const uploadTasks = new Listr( - files.map(file => ({ + filteredFiles.map(file => ({ async task() { - if (!ignoreList.some(ignore => file.path.startsWith(ignore))) { - await uploadFile({ - url: `${activeProviderUrl}/files/${containerId}`, - dir: filesPath, - jwt, - file - }) - } + await uploadFile({ + url: `${activeProviderUrl}/files/${containerId}`, + dir: filesPath, + jwt, + file + }) }, title: color.whiteBright(`Uploading ${file.name}, size: ${file.size} bytes`) }))