(args)
| 45 | describe: 'Initialize Tailchat with docker configuration', |
| 46 | builder: undefined, |
| 47 | async handler(args) { |
| 48 | const spinner = ora(); |
| 49 | try { |
| 50 | console.log(initWelcome); |
| 51 | const { dir, secret, apiUrl, fileLimit } = await inquirer.prompt([ |
| 52 | { |
| 53 | name: 'dir', |
| 54 | type: 'input', |
| 55 | default: './tailchat', |
| 56 | message: 'Configurate storage directory', |
| 57 | }, |
| 58 | { |
| 59 | name: 'secret', |
| 60 | type: 'input', |
| 61 | default: randomString({ length: 16 }), |
| 62 | message: |
| 63 | '(SECRET)Please enter any string, which will be used as the secret key for Tailchat to sign the user identity. Leaking this string will cause the risk of identity forgery. By default, a 16-digit string is randomly generated', |
| 64 | }, |
| 65 | { |
| 66 | name: 'apiUrl', |
| 67 | type: 'input', |
| 68 | message: |
| 69 | '(API_URL)Please configure an address that can be accessed by the external network, which will affect the storage path and access address of the file, example: https://tailchat.example.com', |
| 70 | }, |
| 71 | { |
| 72 | name: 'fileLimit', |
| 73 | type: 'number', |
| 74 | default: 1048576, |
| 75 | message: |
| 76 | '(FILE_LIMIT)File upload volume limit, the default is 1048576(1m)', |
| 77 | }, |
| 78 | ]); |
| 79 | |
| 80 | spinner.start('Start downloading the latest configuration file'); |
| 81 | // eslint-disable-next-line prefer-const |
| 82 | let [rawEnv, rawConfig] = await Promise.all([ |
| 83 | got(envUrl).then((res) => res.body), |
| 84 | got(configUrl).then((res) => res.body), |
| 85 | ]); |
| 86 | spinner.info('The configuration file is downloaded'); |
| 87 | |
| 88 | if (secret) { |
| 89 | rawEnv = setEnvValue(rawEnv, 'SECRET', secret); |
| 90 | } |
| 91 | |
| 92 | if (apiUrl) { |
| 93 | rawEnv = setEnvValue(rawEnv, 'API_URL', apiUrl); |
| 94 | } |
| 95 | |
| 96 | if (fileLimit) { |
| 97 | rawEnv = setEnvValue(rawEnv, 'FILE_LIMIT', fileLimit); |
| 98 | } |
| 99 | |
| 100 | if ( |
| 101 | await promptConfirm( |
| 102 | 'Do you need to configure the email service? The email service can be used for functions such as password retrieval and email notification.' |
| 103 | ) |
| 104 | ) { |
nothing calls this directly
no test coverage detected