Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
*.js
*.js.map
*.log
src/*.d.ts
!src/index.d.ts
!src/references.d.ts
!src/scripts/*.js
!seed-tests/*.js
seed-tests/seed-copy/**/*.*
seed-tests/seed-copy-new-git-repo/**/*.*
demo/app/*.js
!demo/karma.conf.js
!demo/app/tests/*.js
demo/*.d.ts
!demo/references.d.ts
demo/lib
demo/platforms
demo/node_modules
node_modules
publish/src
publish/package
publish/package
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Develop a NativeScript plugin [![Build Status](https://travis-ci.org/NativeScript/nativescript-plugin-seed.svg?branch=master)](https://travis-ci.org/NativeScript/nativescript-plugin-seed)

> This repo is heavily based on [@NathanWalker](https://github.com/NathanWalker)'s [Plugin Seed](https://github.com/NathanWalker/nativescript-plugin-seed). Thanks Nathan!
> This repo is heavily based on [@NathanWalker](https://github.com/NathanWalker)'s [Plugin Seed](https://github.com/NathanWalker/nativescript-plugin-seed). Thanks, Nathan!

<!-- vscode-markdown-toc -->
* [TL;DR](#TLDR)
Expand Down Expand Up @@ -28,7 +28,7 @@ The NativeScript plugin seed is built to be used as a starting point by NativeSc
2. `cd nativescript-yourplugin/src`
3. `npm run postclone`
4. `npm run demo.ios` or `npm run demo.android` to run the demo.
5. In another command prompt/terminal `npm run plugin.tscwatch` to watch to typescript changes in the plugin and to autmatically apply them in the demo.
5. In another command prompt/terminal `npm run plugin.tscwatch` to watch typescript changes in the plugin and to automatically apply them in the demo.

## <a name='LongDescription'></a>Long Description

Expand Down Expand Up @@ -69,7 +69,7 @@ What does the seed give you out of the box?
* configure your plugin name - all files and classes in the seed will be renamed for you
* stub your plugin README.md file
* create a new repository for your plugin
* npm link your plugin the demo app - this will install the plugin dependencies and will add a sym link to the plugin code in the demo project allowing you to do changes and review them in the demo without adding/removing the plugin every time you make a change. [Read more about npm link](https://docs.npmjs.com/cli/link). If you encounter an "EACCES" permission denied error, please fix you global npm permissions, which is perfectly explained [here](https://docs.npmjs.com/getting-started/fixing-npm-permissions).
* npm link your plugin the demo app - this will install the plugin dependencies and will add a symbolic link to the plugin code in the demo project allowing you to do changes and review them in the demo without adding/removing the plugin every time you make a change. [Read more about npm link](https://docs.npmjs.com/cli/link). If you encounter an "EACCES" permission denied error, please fix you global npm permissions, which is perfectly explained [here](https://docs.npmjs.com/getting-started/fixing-npm-permissions).

Now you can continue with the development of your plugin by using the [Development setup](#Developmentsetup) described below.

Expand All @@ -81,7 +81,7 @@ For easier development and debugging purposes continue with the following steps:

Now go and make a change to your plugin. It will be automatically applied to the demo project.

NOTE: If you need to use a native library in your plugin or do some changes in Info.plist/AndroidManifest.xml, these cannot be applied to the demo project only by npm link. In such scenario you need to use `tns plugin add ../src` from the `demo` so that the native libraries and changes in the above mentioned files are applied in the demo. Then you can link again the code of your plugin in the demo by using `npm run plugin.link` from the `src`.
NOTE: If you need to use a native library in your plugin or do some changes in Info.plist/AndroidManifest.xml, these cannot be applied to the demo project only by npm link. In such scenario, you need to use `tns plugin add ../src` from the `demo` so that the native libraries and changes in the above-mentioned files are applied in the demo. Then you can link again the code of your plugin in the demo by using `npm run plugin.link` from the `src`.

### <a name='LinkingtoCocoaPodorAndroidArsenalplugins'></a>Linking to CocoaPod or Android Arsenal plugins

Expand Down Expand Up @@ -116,7 +116,6 @@ Sometimes you may need to ensure plugin files are updated in the demo:

* Run `npm run plugin.prepare` will do a fresh build of the plugin then remove itself from the demo and add it back for assurance.


### <a name='Unittesting'></a>Unittesting
The plugin seed automatically adds Jasmine-based unittest support to your plugin.
Open `demo/app/tests/tests.js` and adjust its contents so the tests become meaningful in the context of your plugin and its features.
Expand All @@ -143,7 +142,7 @@ If you just want to create a package, go to `publish` folder and execute `pack.s

### <a name='TravisCI'></a>TravisCI

The plugin structure comes with fully functional .travis.yml file that deploys the testing app on Android emulator and iOS simulator and as a subsequent step runs the tests from [UnitTesting section](#Unittesting). All you have to do, after cloning the repo and implementing your plugin and tests, is to sign up at [https://travis-ci.org/](https://travis-ci.org/). Then enable your plugin's repo on "https://travis-ci.org/profile/<your github user\>" and that's it. Next time a PR is opened or change is commited to a branch TravisCI will trigger a build testing the code.
The plugin structure comes with a fully functional .travis.yml file that deploys the testing app on Android emulator and iOS simulator and as a subsequent step runs the tests from [UnitTesting section](#Unittesting). All you have to do, after cloning the repo and implementing your plugin and tests, is to sign up at [https://travis-ci.org/](https://travis-ci.org/). Then enable your plugin's repo on "https://travis-ci.org/profile/<your github user\>" and that's it. Next time a PR is opened or change is committed to a branch TravisCI will trigger a build testing the code.

To properly show current build status you will have to edit the badge at the start of the README.md file so it matches your repo, user and branch.

Expand Down Expand Up @@ -178,4 +177,3 @@ import * as app from 'application';
````
import * as app from 'tns-core-modules/application';
````

2 changes: 1 addition & 1 deletion demo/app/main-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export function pageLoaded(args: observable.EventData) {
// Get the event sender
let page = <pages.Page>args.object;
page.bindingContext = new HelloWorldModel();
}
}
2 changes: 1 addition & 1 deletion demo/app/main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export class HelloWorldModel extends Observable {
this.yourPlugin = new YourPlugin();
this.message = this.yourPlugin.message;
}
}
}
2 changes: 1 addition & 1 deletion demo/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
'app/**/*.js',
'app/**/*.js'
],


Expand Down
1 change: 1 addition & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"karma-nativescript-launcher": "^0.4.0",
"lazy": "1.0.11",
"nativescript-dev-typescript": "libs",
"tns-platform-declarations": "^3.1.0",
"typescript": "~2.3.0"
}
}
2 changes: 2 additions & 0 deletions demo/references.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
2 changes: 1 addition & 1 deletion demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"platforms"
],
"compileOnSave": false
}
}
8 changes: 4 additions & 4 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"plugin.tscwatch": "npm run tsc -- -w",
"demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios --syncAllFiles",
"demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles",
"demo.reset": "cd ../demo && rm -rf platforms && cd ../src",
"plugin.prepare": "npm run tsc && cd ../demo && tns plugin remove nativescript-yourplugin && tns plugin add ../src && cd ../src",
"clean": "rm -rf node_modules && cd ../demo && rm -rf hooks node_modules platforms && cd ../src && npm run plugin.link"
"demo.reset": "cd ../demo && rm -rf platforms",
"plugin.prepare": "npm run tsc && cd ../demo && tns plugin remove nativescript-yourplugin && tns plugin add ../src",
"clean": "rimraf node_modules && cd ../demo && rimraf hooks node_modules platforms && cd ../src && npm run plugin.link"
},
"keywords": [
"NativeScript",
Expand Down Expand Up @@ -53,4 +53,4 @@
},
"dependencies": {},
"bootstrapper": "nativescript-plugin-seed"
}
}
2 changes: 1 addition & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"node_modules"
],
"compileOnSave": false
}
}