Skip to content

Commit 60e4ad0

Browse files
authored
Merge pull request #198 from thepower/fix/clI_container_upload_fix
container upload fix
2 parents e1163d0 + 09d8681 commit 60e4ad0

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

.changeset/cyan-goats-hunt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@thepowereco/cli': patch
3+
---
4+
5+
container upload fix

packages/cli/src/commands/container/upload.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import abis from '../../abis/index.js'
1111
import { scanDir } from '../../helpers/upload.helper.js'
1212
import { BaseCommand } from '../../baseCommand.js'
1313
import { importContainerKey } from '../../helpers/container.helper.js'
14+
import { ParamsParser } from '../../helpers/params-parser.helper.js'
1415

1516
async function uploadFile({
1617
url,
@@ -99,6 +100,10 @@ export default class ContainerUpload extends BaseCommand {
99100
char: 'n',
100101
description: 'Chain ID'
101102
}),
103+
ignoreUploadList: Flags.string({
104+
char: 'g',
105+
description: 'Ignore upload list'
106+
}),
102107
isEth: Flags.boolean({
103108
char: 'e',
104109
description: 'Use an ethereum address',
@@ -119,6 +124,7 @@ export default class ContainerUpload extends BaseCommand {
119124
ordersScAddress,
120125
providerScAddress,
121126
chain,
127+
ignoreUploadList,
122128
isEth
123129
} = flags
124130

@@ -128,6 +134,10 @@ export default class ContainerUpload extends BaseCommand {
128134
throw new Error('No wallet found.')
129135
}
130136

137+
const paramsParser = new ParamsParser()
138+
139+
const parsedIgnoreUploadList = ignoreUploadList && paramsParser.parse(ignoreUploadList)
140+
131141
// Initialize network API
132142
const networkApi = await initializeNetworkApi({
133143
address: importedWallet.address,
@@ -227,17 +237,30 @@ export default class ContainerUpload extends BaseCommand {
227237

228238
const ignoreList = ['.git']
229239

240+
if (parsedIgnoreUploadList) {
241+
for (const ignore of parsedIgnoreUploadList) {
242+
if (typeof ignore === 'string') {
243+
ignoreList.push(ignore)
244+
}
245+
}
246+
}
247+
248+
const filteredFiles = files.filter(
249+
file =>
250+
!ignoreList.some(ignore =>
251+
`${file.path !== '.' ? file.path : ''}${file.name}`.startsWith(ignore)
252+
)
253+
)
254+
230255
const uploadTasks = new Listr(
231-
files.map(file => ({
256+
filteredFiles.map(file => ({
232257
async task() {
233-
if (!ignoreList.some(ignore => file.path.startsWith(ignore))) {
234-
await uploadFile({
235-
url: `${activeProviderUrl}/files/${containerId}`,
236-
dir: filesPath,
237-
jwt,
238-
file
239-
})
240-
}
258+
await uploadFile({
259+
url: `${activeProviderUrl}/files/${containerId}`,
260+
dir: filesPath,
261+
jwt,
262+
file
263+
})
241264
},
242265
title: color.whiteBright(`Uploading ${file.name}, size: ${file.size} bytes`)
243266
}))

0 commit comments

Comments
 (0)