Skip to content

Commit 9e48db9

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #534 from NativeScript/fatme/help-for-plugin-commands
Help for plugin commands
2 parents 6176a52 + 1246860 commit 9e48db9

File tree

5 files changed

+242
-0
lines changed

5 files changed

+242
-0
lines changed

PLUGINS.md

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
PLUGINS
2+
=========
3+
4+
NativeScript plugin is a npm package that consist of the following:
5+
6+
* Metadata about the package itself: name, version, supported runtime versions, etc.
7+
* CommonJS module(one or many) that expose the native API via a single JavaScript API.
8+
* Native libraries and resources.
9+
10+
A package json file has the following structure:
11+
```
12+
{
13+
"name": "myplugin",
14+
"version": "0.0.1",
15+
"nativescript": {
16+
"platforms": {
17+
"ios": "1.0.0",
18+
"android": "1.1.0"
19+
}
20+
}
21+
}
22+
```
23+
`nativescript` key is a mandatory section for a NativeScript plugin. `platforms` section describes the supported runtime versions for each platform.
24+
25+
A plugin directory has the following structure:
26+
```
27+
myPlugin/
28+
-- index.js
29+
-- package.json
30+
-- platforms
31+
-- Android
32+
-- myjar.jar
33+
-- Android.manifest
34+
-- iOS
35+
-- myFramework.framework
36+
-- Info.plist
37+
```
38+
39+
You can use `platforms` folder and place platform specific files in each platform directory.
40+
41+
Here is an example.
42+
43+
Let you say that you have the following `Android.manifest` file in `platforms\android\` folder in your plugin:
44+
```
45+
<?xml version="1.0" encoding="UTF-8"?>
46+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
47+
package="com.example.android.basiccontactables"
48+
android:versionCode="1"
49+
android:versionName="1.0" >
50+
51+
<uses-sdk
52+
android:minSdkVersion="19"
53+
android:targetSdkVersion="21" />
54+
55+
<uses-permission android:name="android.permission.READ_CONTACTS"/>
56+
<uses-permission android:name="android.permission.INTERNET" />
57+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
58+
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
59+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
60+
<uses-permission android:name="com.example.towntour.permission.MAPS_RECEIVE" />
61+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
62+
<uses-permission android:name="android.permission.CALL_PHONE" />
63+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
64+
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
65+
66+
<application
67+
android:name="com.tns.NativeScriptApplication"
68+
android:allowBackup="true"
69+
android:icon="@drawable/icon"
70+
android:label="@string/app_name"
71+
android:theme="@style/AppTheme" >
72+
<activity
73+
android:name="com.tns.NativeScriptActivity"
74+
android:label="@string/title_activity_kimera"
75+
android:configChanges="keyboardHidden|orientation|screenSize">
76+
77+
<intent-filter>
78+
<action android:name="android.intent.action.MAIN" />
79+
<action android:name="android.intent.action.EDIT" />
80+
<action android:name="android.intent.action.VIEW" />
81+
82+
<category android:name="android.intent.category.LAUNCHER" />
83+
</intent-filter>
84+
</activity>
85+
</application>
86+
87+
</manifest>
88+
```
89+
90+
and the default `Android.manifest` file in your app in `platforms\android\` folder.
91+
```
92+
<?xml version="1.0" encoding="utf-8"?>
93+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
94+
package="org.nativescript.test"
95+
android:versionCode="1"
96+
android:versionName="1.0" >
97+
98+
<uses-sdk
99+
android:minSdkVersion="17"
100+
android:targetSdkVersion="17" />
101+
102+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
103+
<uses-permission android:name="android.permission.INTERNET"/>
104+
105+
<application
106+
android:name="com.tns.NativeScriptApplication"
107+
android:allowBackup="true"
108+
android:icon="@drawable/icon"
109+
android:label="@string/app_name"
110+
android:theme="@style/AppTheme" >
111+
<activity
112+
android:name="com.tns.NativeScriptActivity"
113+
android:label="@string/title_activity_kimera"
114+
android:configChanges="keyboardHidden|orientation|screenSize">
115+
116+
<intent-filter>
117+
<action android:name="android.intent.action.MAIN" />
118+
119+
<category android:name="android.intent.category.LAUNCHER" />
120+
</intent-filter>
121+
</activity>
122+
</application>
123+
124+
</manifest>
125+
```
126+
127+
The produced result xml will be:
128+
```
129+
<?xml version="1.0" encoding="utf-8"?>
130+
<manifest
131+
xmlns:android="http://schemas.android.com/apk/res/android" package="org.nativescript.test" android:versionCode="1" android:versionName="1.0">
132+
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="21"/>
133+
<uses-permission android:name="android.permission.READ_CONTACTS"/>
134+
<uses-permission android:name="android.permission.INTERNET"/>
135+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
136+
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
137+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
138+
<uses-permission android:name="com.example.towntour.permission.MAPS_RECEIVE"/>
139+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
140+
<uses-permission android:name="android.permission.CALL_PHONE"/>
141+
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
142+
<!--
143+
Some comment here
144+
-->
145+
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
146+
<application android:name="com.tns.NativeScriptApplication" android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/AppTheme">
147+
<activity android:name="com.tns.NativeScriptActivity" android:label="@string/title_activity_kimera" android:configChanges="keyboardHidden|orientation|screenSize">
148+
<intent-filter>
149+
<action android:name="android.intent.action.MAIN"/>
150+
<action android:name="android.intent.action.EDIT"/>
151+
<action android:name="android.intent.action.VIEW"/>
152+
<category android:name="android.intent.category.LAUNCHER"/>
153+
</intent-filter>
154+
</activity>
155+
</application>
156+
</manifest>
157+
```
158+
159+

docs/man_pages/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Command | Description
2828
[emulate `<Platform>`](project/testing/emulate.html) | Deploys the project in the native emulator for the selected target platform.
2929
[run `<Platform>`](project/testing/run.html) | Runs your project on a connected device or in the native emulator, if configured.
3030
[debug `<Platform>`](project/testing/debug.html) | Debugs your project on a connected device.
31+
[plugin](plugin.html) | Lists all installed plugins for your project or lets you manage the plugins for your project.
3132

3233
## Device Commands
3334
Command | Description
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
plugin add
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns plugin add <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/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+
[library](library.html) | You must run the library command with a related command.
30+
[library add](library-add.html) | Adds a native library to the current project.
31+
[plugin](plugin.html) | Lets you manage the plugins for your project.
32+
[plugin remove](plugin-remove.html) | Uninstalls the specified plugin and its dependencies.
33+
<% } %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
plugin remove
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns plugin remove <Plugin>`
7+
8+
<% if(isConsole) { %>Uninstalls a plugin by its name.<% } %>
9+
<% if(isHtml) { %>Removes the specified plugin and its dependencies from the local `node_modules` folder and the `dependencies` section in `package.json`. This operation does not remove the plugin from the installed platforms and you need to run `$ tns prepare` to finish uninstalling the plugin. For more information about working with plugins, see [NativeScript Plugins](https://github.com/NativeScript/nativescript-cli/PLUGINS.md).<% } %>
10+
11+
### Attributes
12+
13+
* `<Plugin>` is the name of the plugin as listed in its `package.json` file.
14+
15+
<% if(isHtml) { %>
16+
### Related Commands
17+
18+
Command | Description
19+
----------|----------
20+
[library](library.html) | You must run the library command with a related command.
21+
[library add](library-add.html) | Adds a native library to the current project.
22+
[plugin](plugin.html) | Lets you manage the plugins for your project.
23+
[plugin add](plugin-add.html) | Installs the specified plugin and its dependencies.
24+
<% } %>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
plugin
2+
==========
3+
4+
Usage | Synopsis
5+
---|---
6+
List plugins | `$ tns plugin`
7+
Manage plugins | `$ tns plugin <Command>`
8+
9+
Lets you manage the plugins for your project.
10+
11+
### Attributes
12+
`<Command>` extends the `plugin` command. You can set the following values for this attribute.
13+
* `add` - Installs the specified plugin and its dependencies.
14+
* `remove` - Uninstalls the specified plugin and its dependencies.
15+
16+
<% if(isHtml) { %>
17+
### Related Commands
18+
19+
Command | Description
20+
----------|----------
21+
[library](library.html) | You must run the library command with a related command.
22+
[library add](library-add.html) | Adds a native library to the current project.
23+
[plugin add](plugin-add.html) | Installs the specified plugin and its dependencies.
24+
[plugin remove](plugin-remove.html) | Uninstalls the specified plugin and its dependencies.
25+
<% } %>

0 commit comments

Comments
 (0)