Skip to content

Commit 778cf6b

Browse files
authored
feat: jit install command (#265)
* feat: add jit install command * chore: simplify implementation
1 parent 4870c62 commit 778cf6b

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ package-lock.json
1010
npm-error.log
1111
yarn-error.log
1212
lerna-debug.log
13+
*.tsbuildinfo
1314

1415
# compile source
1516
lib

messages/jit.install.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# summary
2+
3+
Install all JIT plugins.
4+
5+
# examples
6+
7+
- <%= config.bin %> <%= command.id %>
8+
9+
# flags.dry-run.summary
10+
11+
List the plugins that would be installed.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
"commandreference": {
7272
"description": "generate the Salesforce CLI command reference guide.",
7373
"longDescription": "xx"
74+
},
75+
"jit": {
76+
"description": "description for jit"
7477
}
7578
},
7679
"devPlugins": [
@@ -101,4 +104,4 @@
101104
"access": "public"
102105
},
103106
"main": "lib/index.js"
104-
}
107+
}

src/commands/jit/install.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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

Comments
 (0)