* @param {{port: (number), normalStoreUrl: (string), accessToken: (string)}} defaultAnswers * @param {{port: (number), normalStoreUrl: (string), accessToken: (string)}} cliOptions * @returns {{object[]}}
(defaultAnswers, cliOptions)
| 87 | * @returns {{object[]}} |
| 88 | */ |
| 89 | getQuestions(defaultAnswers, cliOptions) { |
| 90 | const prompts = []; |
| 91 | if (!cliOptions.normalStoreUrl) { |
| 92 | prompts.push({ |
| 93 | type: 'input', |
| 94 | name: 'normalStoreUrl', |
| 95 | message: "What is the URL of your store's home page?", |
| 96 | validate: (val) => /^https?:\/\//.test(val) || 'You must enter a URL', |
| 97 | default: defaultAnswers.normalStoreUrl, |
| 98 | }); |
| 99 | } |
| 100 | if (!cliOptions.accessToken) { |
| 101 | prompts.push({ |
| 102 | type: 'input', |
| 103 | name: 'accessToken', |
| 104 | message: 'What is your Stencil OAuth Access Token?', |
| 105 | default: defaultAnswers.accessToken, |
| 106 | filter: (val) => val.trim(), |
| 107 | }); |
| 108 | } |
| 109 | if (!cliOptions.port) { |
| 110 | prompts.push({ |
| 111 | type: 'input', |
| 112 | name: 'port', |
| 113 | message: 'What port would you like to run the server on?', |
| 114 | default: defaultAnswers.port, |
| 115 | validate: (val) => { |
| 116 | if (Number.isNaN(val)) { |
| 117 | return 'You must enter an integer'; |
| 118 | } |
| 119 | if (val < 1024 || val > 65535) { |
| 120 | return 'The port number must be between 1025 and 65535'; |
| 121 | } |
| 122 | return true; |
| 123 | }, |
| 124 | }); |
| 125 | } |
| 126 | if (!cliOptions.packageManager) { |
| 127 | prompts.push({ |
| 128 | type: 'list', |
| 129 | name: 'packageManager', |
| 130 | message: 'What is your favourite Package Manager?', |
| 131 | choices: ['npm', 'yarn', 'pnpm'], |
| 132 | default: this.getPackageManager(), |
| 133 | }); |
| 134 | } |
| 135 | return prompts; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * @param {{object[]}} questions |
no test coverage detected