(args)
| 40 | type: 'boolean', |
| 41 | }), |
| 42 | async handler(args) { |
| 43 | const url = args.url as string; |
| 44 | const file = args.file as string; |
| 45 | const count = args.count as number; |
| 46 | const concurrency = args.concurrency as number; |
| 47 | const invite = args.invite as string | undefined; |
| 48 | const append = (args.append ?? false) as boolean; |
| 49 | const tokens: string[] = []; |
| 50 | const start = Date.now(); |
| 51 | |
| 52 | const spinner = ora().info(`Register temporary account`).start(); |
| 53 | |
| 54 | let i = 0; |
| 55 | spinner.text = `Progress: ${i}/${count}`; |
| 56 | await pMap( |
| 57 | Array.from({ length: count }), |
| 58 | async () => { |
| 59 | const token = await registerTemporaryAccount(url, `benchUser-${i}`); |
| 60 | if (invite) { |
| 61 | // Apply group invite |
| 62 | await applyGroupInviteCode(url, token, invite); |
| 63 | } |
| 64 | if (append) { |
| 65 | await fs.appendFile(file, `\n${token}`); |
| 66 | } |
| 67 | |
| 68 | spinner.text = `Progress: ${++i}/${count}`; |
| 69 | tokens.push(token); |
| 70 | }, |
| 71 | { |
| 72 | concurrency, |
| 73 | } |
| 74 | ); |
| 75 | |
| 76 | if (!append) { |
| 77 | spinner.info(`Writing tokens into path: ${file}`); |
| 78 | |
| 79 | await fs.writeFile(file, tokens.join('\n')); |
| 80 | } |
| 81 | |
| 82 | spinner.succeed(`Register completed! Usage: ${Date.now() - start}ms`); |
| 83 | }, |
| 84 | }; |
| 85 | |
| 86 | async function registerTemporaryAccount( |
nothing calls this directly
no test coverage detected