* Check the LoopBack project dependencies and versions * @param generator - Yeoman generator instance
(generator)
| 222 | * @param generator - Yeoman generator instance |
| 223 | */ |
| 224 | async function checkLoopBackProject(generator) { |
| 225 | if (generator.shouldExit()) return false; |
| 226 | |
| 227 | const incompatibleDeps = await checkDependencies(generator); |
| 228 | if (incompatibleDeps == null) return false; |
| 229 | if ( |
| 230 | Object.keys({ |
| 231 | ...incompatibleDeps.dependencies, |
| 232 | ...incompatibleDeps.devDependencies, |
| 233 | ...incompatibleDeps.peerDependencies, |
| 234 | }) === 0 |
| 235 | ) |
| 236 | return false; |
| 237 | |
| 238 | const choices = [ |
| 239 | { |
| 240 | name: g.f('Upgrade project dependencies'), |
| 241 | value: 'upgrade', |
| 242 | }, |
| 243 | { |
| 244 | name: g.f('Skip upgrading project dependencies'), |
| 245 | value: 'continue', |
| 246 | }, |
| 247 | ]; |
| 248 | if (generator.command !== 'update') { |
| 249 | choices.unshift({ |
| 250 | name: g.f('Abort now'), |
| 251 | value: 'abort', |
| 252 | }); |
| 253 | } |
| 254 | const prompts = [ |
| 255 | { |
| 256 | name: 'decision', |
| 257 | message: g.f('How do you want to proceed?'), |
| 258 | type: 'list', |
| 259 | choices, |
| 260 | default: 0, |
| 261 | }, |
| 262 | ]; |
| 263 | const answers = await generator.prompt(prompts); |
| 264 | if (answers && answers.decision === 'continue') { |
| 265 | return false; |
| 266 | } |
| 267 | if (answers && answers.decision === 'upgrade') { |
| 268 | updateDependencies(generator); |
| 269 | return true; |
| 270 | } |
| 271 | generator.exit(new Error('Incompatible dependencies')); |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Check if the current cli is out of date |
no test coverage detected