()
| 202 | } |
| 203 | |
| 204 | function run() { |
| 205 | const cli = meow( |
| 206 | { |
| 207 | description: 'Codemods for updating React APIs.', |
| 208 | help: ` |
| 209 | Usage |
| 210 | $ npx react-codemod <transform> <path> <...options> |
| 211 | |
| 212 | transform One of the choices from https://github.com/reactjs/react-codemod |
| 213 | path Files or directory to transform. Can be a glob like src/**.test.js |
| 214 | |
| 215 | Options |
| 216 | --force Bypass Git safety checks and forcibly run codemods |
| 217 | --dry Dry run (no changes are made to files) |
| 218 | --print Print transformed files to your terminal |
| 219 | |
| 220 | --jscodeshift (Advanced) Pass options directly to jscodeshift |
| 221 | ` |
| 222 | }, |
| 223 | { |
| 224 | boolean: ['force', 'dry', 'print', 'explicit-require', 'help'], |
| 225 | string: ['_'], |
| 226 | alias: { |
| 227 | h: 'help' |
| 228 | } |
| 229 | } |
| 230 | ); |
| 231 | |
| 232 | if (!cli.flags.dry) { |
| 233 | checkGitStatus(cli.flags.force); |
| 234 | } |
| 235 | |
| 236 | if ( |
| 237 | cli.input[0] && |
| 238 | !TRANSFORMER_INQUIRER_CHOICES.find(x => x.value === cli.input[0]) |
| 239 | ) { |
| 240 | console.error('Invalid transform choice, pick one of:'); |
| 241 | console.error( |
| 242 | TRANSFORMER_INQUIRER_CHOICES.map(x => '- ' + x.value).join('\n') |
| 243 | ); |
| 244 | process.exit(1); |
| 245 | } |
| 246 | |
| 247 | inquirer |
| 248 | .prompt([ |
| 249 | { |
| 250 | type: 'input', |
| 251 | name: 'files', |
| 252 | message: 'On which files or directory should the codemods be applied?', |
| 253 | when: !cli.input[1], |
| 254 | default: '.', |
| 255 | // validate: () => |
| 256 | filter: files => files.trim() |
| 257 | }, |
| 258 | { |
| 259 | type: 'list', |
| 260 | name: 'parser', |
| 261 | message: 'Which dialect of JavaScript do you use?', |
nothing calls this directly
no test coverage detected