Skip to content

Commit d55b51c

Browse files
authored
Merge pull request #1950 from NativeScript/plugin-install
plugin install alias added
2 parents 1960b0c + f973638 commit d55b51c

File tree

5 files changed

+315
-275
lines changed

5 files changed

+315
-275
lines changed

docs/man_pages/lib-management/plugin-add.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ General | `$ tns plugin add <Plugin>`
2727
Command | Description
2828
----------|----------
2929
[plugin](plugin.html) | Lets you manage the plugins for your project.
30+
[plugin install](plugin-install.html) | Installs the specified plugin and its dependencies.
3031
[plugin remove](plugin-remove.html) | Uninstalls the specified plugin and its dependencies.
3132
[plugin find](plugin-find.html) | Finds NativeScript plugins in npm.
3233
[plugin search](plugin-search.html) | Finds NativeScript plugins in npm.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugin install
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns plugin install <Plugin>`
7+
8+
<% if(isConsole) { %>Installs the specified plugin and any packages that it depends on.<% } %>
9+
<% if(isHtml) { %>Installs the specified plugin and its dependencies in the local `node_modules` folder, adds it to the `dependencies` section in `package.json`, and prepares the plugin for all installed platforms. If you have not configured any platforms for the project, the NativeScript CLI will prepare the plugin when you add a platform. For more information about working with plugins, see [NativeScript Plugins](https://github.com/NativeScript/nativescript-cli/blob/master/PLUGINS.md).<% } %>
10+
11+
### Attributes
12+
13+
* `<Plugin>` is a valid NativeScript plugin, specified by any of the following.
14+
* A `<Name>` or `<Name>@<Version>` where `<Name>` is the name of a plugin that is published in the npm registry and `<Version>` is a valid version of this plugin.
15+
* A `<Local Path>` to the directory which contains the plugin, including its `package.json` file.
16+
* A `<Local Path>` to a `.tar.gz` archive containing a directory with the plugin and its `package.json` file.
17+
* A `<URL>` which resolves to a `.tar.gz` archive containing a directory with the plugin and its `package.json` file.
18+
* A `<git Remote URL>` which resolves to a `.tar.gz` archive containing a directory with the plugin and its `package.json` file.
19+
20+
<% if(isHtml) { %>
21+
### Prerequisites
22+
23+
* Verify that the plugin that you want to add contains a valid `package.json` file. Valid `package.json` files contain a `nativescript` section.
24+
25+
### Related Commands
26+
27+
Command | Description
28+
----------|----------
29+
[plugin](plugin.html) | Lets you manage the plugins for your project.
30+
[plugin add](plugin-add.html) | Installs the specified plugin and its dependencies.
31+
[plugin remove](plugin-remove.html) | Uninstalls the specified plugin and its dependencies.
32+
[plugin find](plugin-find.html) | Finds NativeScript plugins in npm.
33+
[plugin search](plugin-search.html) | Finds NativeScript plugins in npm.
34+
<% } %>

lib/bootstrap.ts

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ $injector.requireCommand("plugin|*list", "./commands/plugin/list-plugins");
8484
$injector.requireCommand("plugin|find", "./commands/plugin/find-plugins");
8585
$injector.requireCommand("plugin|search", "./commands/plugin/find-plugins");
8686
$injector.requireCommand("plugin|add", "./commands/plugin/add-plugin");
87+
$injector.requireCommand("plugin|install", "./commands/plugin/add-plugin");
8788
$injector.requireCommand("plugin|remove", "./commands/plugin/remove-plugin");
8889

8990
$injector.require("doctorService", "./services/doctor-service");

lib/commands/plugin/add-plugin.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export class AddPluginCommand implements ICommand {
88

99
canExecute(args: string[]): IFuture<boolean> {
1010
return (() => {
11-
if(!args[0]) {
11+
if (!args[0]) {
1212
this.$errors.fail("You must specify plugin name.");
1313
}
1414

1515
let installedPlugins = this.$pluginsService.getAllInstalledPlugins().wait();
1616
let pluginName = args[0].toLowerCase();
17-
if(_.some(installedPlugins, (plugin: IPluginData) => plugin.name.toLowerCase() === pluginName)) {
17+
if (_.some(installedPlugins, (plugin: IPluginData) => plugin.name.toLowerCase() === pluginName)) {
1818
this.$errors.failWithoutHelp(`Plugin "${pluginName}" is already installed.`);
1919
return false;
2020
}
@@ -25,4 +25,4 @@ export class AddPluginCommand implements ICommand {
2525

2626
public allowedParameters: ICommandParameter[] = [];
2727
}
28-
$injector.registerCommand("plugin|add", AddPluginCommand);
28+
$injector.registerCommand(["plugin|add", "plugin|install"], AddPluginCommand);

0 commit comments

Comments
 (0)