Skip to content

Commit f0f3185

Browse files
authored
feat: support more git/ssh url's (#82)
1 parent 0486fc8 commit f0f3185

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

src/commands/plugins/install.ts

+27-13
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,34 @@ Can be installed from npm or a git url.
1111
Installation of a user-installed plugin will override a core plugin.
1212
1313
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in the CLI without the need to patch and update the whole CLI.
14-
`
14+
`;
1515

16-
static usage = 'plugins:install PLUGIN...'
16+
static usage = 'plugins:install PLUGIN...';
1717

1818
static examples = [
1919
'$ <%= config.bin %> plugins:install <%- config.pjson.oclif.examplePlugin || "myplugin" %> ',
2020
'$ <%= config.bin %> plugins:install https://github.com/someuser/someplugin',
2121
'$ <%= config.bin %> plugins:install someuser/someplugin',
22-
]
22+
];
2323

24-
static strict = false
24+
static strict = false;
2525

26-
static args = [{name: 'plugin', description: 'plugin to install', required: true}]
26+
static args = [
27+
{name: 'plugin', description: 'plugin to install', required: true},
28+
];
2729

2830
static flags = {
2931
help: flags.help({char: 'h'}),
3032
verbose: flags.boolean({char: 'v'}),
31-
force: flags.boolean({char: 'f', description: 'yarn install with force flag'}),
32-
}
33+
force: flags.boolean({
34+
char: 'f',
35+
description: 'yarn install with force flag',
36+
}),
37+
};
3338

34-
static aliases = ['plugins:add']
39+
static aliases = ['plugins:add'];
3540

36-
plugins = new Plugins(this.config)
41+
plugins = new Plugins(this.config);
3742

3843
// In this case we want these operations to happen
3944
// sequentially so the `no-await-in-loop` rule is ugnored
@@ -51,8 +56,13 @@ e.g. If you have a core plugin that has a 'hello' command, installing a user-ins
5156
plugin: p,
5257
})
5358
if (p.type === 'npm') {
54-
cli.action.start(`Installing plugin ${chalk.cyan(this.plugins.friendlyName(p.name))}`)
55-
plugin = await this.plugins.install(p.name, {tag: p.tag, force: flags.force})
59+
cli.action.start(
60+
`Installing plugin ${chalk.cyan(this.plugins.friendlyName(p.name))}`,
61+
)
62+
plugin = await this.plugins.install(p.name, {
63+
tag: p.tag,
64+
force: flags.force,
65+
})
5666
} else {
5767
cli.action.start(`Installing plugin ${chalk.cyan(p.url)}`)
5868
plugin = await this.plugins.install(p.url, {force: flags.force})
@@ -62,8 +72,12 @@ e.g. If you have a core plugin that has a 'hello' command, installing a user-ins
6272
}
6373
/* eslint-enable no-await-in-loop */
6474

65-
async parsePlugin(input: string): Promise<{name: string; tag: string; type: 'npm'} | {url: string; type: 'repo'}> {
66-
if (input.startsWith('git+ssh://')) {
75+
async parsePlugin(
76+
input: string,
77+
): Promise<
78+
{ name: string; tag: string; type: 'npm' } | { url: string; type: 'repo' }
79+
> {
80+
if (input.startsWith('git+ssh://') || input.endsWith('.git')) {
6781
return {url: input, type: 'repo'}
6882
}
6983
if (input.includes('@') && input.includes('/')) {

0 commit comments

Comments
 (0)