|
| 1 | +/* |
| 2 | + * Copyright (c) 2020, salesforce.com, inc. |
| 3 | + * All rights reserved. |
| 4 | + * Licensed under the BSD 3-Clause license. |
| 5 | + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause |
| 6 | + */ |
| 7 | +import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; |
| 8 | +import { Messages } from '@salesforce/core'; |
| 9 | +import * as chalk from 'chalk'; |
| 10 | + |
| 11 | +Messages.importMessagesDirectory(__dirname); |
| 12 | +const messages = Messages.load('@salesforce/plugin-command-reference', 'jit.install', [ |
| 13 | + 'summary', |
| 14 | + 'examples', |
| 15 | + 'flags.dry-run.summary', |
| 16 | +]); |
| 17 | + |
| 18 | +export default class JitInstall extends SfCommand<void> { |
| 19 | + public static readonly summary = messages.getMessage('summary'); |
| 20 | + public static readonly examples = messages.getMessages('examples'); |
| 21 | + |
| 22 | + public static readonly flags = { |
| 23 | + 'dry-run': Flags.boolean({ |
| 24 | + char: 'd', |
| 25 | + summary: messages.getMessage('flags.dry-run.summary'), |
| 26 | + }), |
| 27 | + }; |
| 28 | + |
| 29 | + public async run(): Promise<void> { |
| 30 | + const { flags } = await this.parse(JitInstall); |
| 31 | + |
| 32 | + this.styledHeader(`Install all JIT Plugins${flags['dry-run'] ? ' (dry-run)' : ''}`); |
| 33 | + for (const [plugin, version] of Object.entries(this.config.pjson.oclif.jitPlugins)) { |
| 34 | + this.log(`• ${plugin} ${chalk.dim(version)}`); |
| 35 | + if (flags['dry-run']) continue; |
| 36 | + try { |
| 37 | + await this.config.runCommand(`plugins:install ${plugin}@${version}`); |
| 38 | + } catch { |
| 39 | + this.log(`Failed to install ${plugin} ${chalk.dim(version)}.`); |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | +} |
0 commit comments