From 5d88a46f8c3ebaac3592680d1ff7b1788fdceed7 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 09:46:54 +0200 Subject: [PATCH 01/16] removed a few redundant exclusions --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 026cd9c..67807d0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,14 +8,12 @@ !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 \ No newline at end of file +publish/package From b917c2c79a802baf622a1cb52867862bb7f3ace8 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 09:52:58 +0200 Subject: [PATCH 02/16] Fixed a bunch of typos --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c6e8dc7..bc796ca 100644 --- a/README.md +++ b/README.md @@ -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! * [TL;DR](#TLDR) @@ -27,7 +27,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. ## Long Description @@ -68,7 +68,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. @@ -80,7 +80,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`. ### Linking to CocoaPod or Android Arsenal plugins @@ -105,7 +105,7 @@ Take a look at these existing plugins for how that can be done very simply: Sometimes you may need to wipe away the `node_modules` and `demo/platforms` folders to reinstall them fresh. -1. Run `npm run clean` to wipe those clean then you can can run `npm i` to install fresh dependencies. +1. Run `npm run clean` to wipe those clean then you can run `npm i` to install fresh dependencies. ### Unittesting The plugin seed automatically adds Jasmine-based unittest support to your plugin. @@ -133,6 +133,6 @@ If you just want to create a package, go to `publish` folder and execute `pack.s ### 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/" 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/" 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. +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. From 58b0ca875eb58ba52063843b0e5a5ca851a24d41 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 10:22:23 +0200 Subject: [PATCH 03/16] Make IDEA/Webstorm internal TypeScript compiler happy IntelliJ IDEA couldn't find modules inside tns-core-modules - this fixes the issue (it was also in Nathan's original seed). --- src/tsconfig.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tsconfig.json b/src/tsconfig.json index 0e5c6fc..7c5a980 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -17,10 +17,17 @@ "noImplicitAny": false, "noImplicitReturns": true, "noImplicitUseStrict": false, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "skipLibCheck": true, + "baseUrl": ".", + "paths": { + "*": [ + "./node_modules/tns-core-modules/*" + ] + } }, "exclude": [ "node_modules" ], "compileOnSave": false -} \ No newline at end of file +} From 97d908c3d6c27827a9176f043b24b5decb5923cf Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 10:27:41 +0200 Subject: [PATCH 04/16] Removed a superfluous comma --- demo/karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/karma.conf.js b/demo/karma.conf.js index 91d9c28..5d2286a 100644 --- a/demo/karma.conf.js +++ b/demo/karma.conf.js @@ -12,7 +12,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'app/**/*.js', + 'app/**/*.js' ], From f04820877cced023de76ecdbcfba7c84712cdac7 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 10:55:29 +0200 Subject: [PATCH 05/16] Use rimraf for Windows compatibility --- src/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/package.json b/src/package.json index 3091a66..4a55add 100644 --- a/src/package.json +++ b/src/package.json @@ -20,7 +20,7 @@ "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", - "clean": "rm -rf node_modules && cd ../demo && rm -rf hooks node_modules platforms && cd ../src && npm run plugin.link" + "clean": "rimraf node_modules && cd ../demo && rimraf hooks node_modules platforms && cd ../src && npm run plugin.link" }, "keywords": [ "NativeScript", @@ -51,4 +51,4 @@ }, "dependencies": {}, "bootstrapper": "nativescript-plugin-seed" -} \ No newline at end of file +} From 1db18c81e8a4fd924ac5e922ebd5fecb85caa46b Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:08:39 +0200 Subject: [PATCH 06/16] No need to ignore demo/references.d.ts The file is no longer in the repo :) --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 67807d0..56b0326 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ seed-tests/seed-copy-new-git-repo/**/*.* !demo/karma.conf.js !demo/app/tests/*.js demo/*.d.ts -!demo/references.d.ts demo/lib demo/platforms node_modules From f3b35c2d17a7dbfc48d9d57cf709560bf51e48d9 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:19:20 +0200 Subject: [PATCH 07/16] Re-added demo/references.d.ts We need it to link native platform declarations to prevent errors when `tns run ` runs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 56b0326..67807d0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ seed-tests/seed-copy-new-git-repo/**/*.* !demo/karma.conf.js !demo/app/tests/*.js demo/*.d.ts +!demo/references.d.ts demo/lib demo/platforms node_modules From 3b03d227e062355dc409f4ab87115ca35b19174c Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:20:21 +0200 Subject: [PATCH 08/16] Suppress errors when running 'tns run ' Without this the TS compiler will complain when fi 'android.' is encountered. --- demo/references.d.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 demo/references.d.ts diff --git a/demo/references.d.ts b/demo/references.d.ts new file mode 100644 index 0000000..1e5e961 --- /dev/null +++ b/demo/references.d.ts @@ -0,0 +1,2 @@ +/// +/// From 00bade574fb934dca3f8b187d09424ce5b64c6bb Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:25:04 +0200 Subject: [PATCH 09/16] We don't want plugin .d.ts files on GitHub Those are only required on npm --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 67807d0..72d574a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ *.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/**/*.* From b366a6b6504865ed94e02a229528ee6c46df14d3 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:40:16 +0200 Subject: [PATCH 10/16] These are references from references.d.ts --- demo/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/demo/package.json b/demo/package.json index 42f2c72..27ff070 100644 --- a/demo/package.json +++ b/demo/package.json @@ -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" } } From b5819e7595c5997a5a18c6ecd8d3778b54d674a1 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:42:57 +0200 Subject: [PATCH 11/16] Support for shorthand tns-core-modules imports --- demo/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demo/tsconfig.json b/demo/tsconfig.json index ed6d540..80c1c98 100644 --- a/demo/tsconfig.json +++ b/demo/tsconfig.json @@ -23,6 +23,7 @@ "baseUrl": ".", "paths": { "*": [ + "./node_modules/tns-core-modules/*", "./node_modules/*" ] } @@ -32,4 +33,4 @@ "platforms" ], "compileOnSave": false -} \ No newline at end of file +} From c4fead1af26c6f21fa67cae259bd247b3631aaf9 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:43:39 +0200 Subject: [PATCH 12/16] No longer need the tns-core-modules prefix because of the tsconfig change --- demo/app/main-page.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts index 1bca237..715863e 100644 --- a/demo/app/main-page.ts +++ b/demo/app/main-page.ts @@ -1,5 +1,5 @@ -import * as observable from 'tns-core-modules/data/observable'; -import * as pages from 'tns-core-modules/ui/page'; +import * as observable from 'data/observable'; +import * as pages from 'ui/page'; import {HelloWorldModel} from './main-view-model'; // Event handler for Page 'loaded' event attached in main-page.xml @@ -7,4 +7,4 @@ export function pageLoaded(args: observable.EventData) { // Get the event sender let page = args.object; page.bindingContext = new HelloWorldModel(); -} \ No newline at end of file +} From 5c24056ef48f9c6c88a69ee5770a640374011bdb Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:44:02 +0200 Subject: [PATCH 13/16] No longer need the tns-core-modules prefix because of the tsconfig change --- demo/app/main-view-model.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/app/main-view-model.ts b/demo/app/main-view-model.ts index cc9f297..2b6144e 100644 --- a/demo/app/main-view-model.ts +++ b/demo/app/main-view-model.ts @@ -1,4 +1,4 @@ -import { Observable } from 'tns-core-modules/data/observable'; +import { Observable } from 'data/observable'; import { YourPlugin } from 'nativescript-yourplugin'; export class HelloWorldModel extends Observable { @@ -11,4 +11,4 @@ export class HelloWorldModel extends Observable { this.yourPlugin = new YourPlugin(); this.message = this.yourPlugin.message; } -} \ No newline at end of file +} From 728cc5b4b0b2f3af8c843458384a1a2d9575af36 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:44:17 +0200 Subject: [PATCH 14/16] No longer need the tns-core-modules prefix because of the tsconfig change --- demo/app/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/app/app.ts b/demo/app/app.ts index a17b0bd..98f8260 100644 --- a/demo/app/app.ts +++ b/demo/app/app.ts @@ -1,2 +1,2 @@ -import * as application from 'tns-core-modules/application'; +import * as application from 'application'; application.start({ moduleName: "main-page" }); From 5532d1506987c18178510c006e8b1e73a3783eda Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Thu, 3 Aug 2017 11:44:51 +0200 Subject: [PATCH 15/16] No longer need the tns-core-modules prefix because of the tsconfig change --- src/yourplugin.common.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/yourplugin.common.ts b/src/yourplugin.common.ts index c5801f9..4ff9213 100644 --- a/src/yourplugin.common.ts +++ b/src/yourplugin.common.ts @@ -1,6 +1,6 @@ -import { Observable } from 'tns-core-modules/data/observable'; -import * as app from 'tns-core-modules/application'; -import * as dialogs from 'tns-core-modules/ui/dialogs'; +import { Observable } from 'data/observable'; +import * as app from 'application'; +import * as dialogs from 'ui/dialogs'; export class Common extends Observable { public message: string; From 1536a60bc6888aeaac5f02cdbba8cc08c6c33179 Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Thu, 3 Aug 2017 21:59:12 +0200 Subject: [PATCH 16/16] Feedback by @sis0k0: keep the tns-core-modules prefix for AoT --- demo/app/app.ts | 2 +- demo/app/main-page.ts | 4 ++-- demo/app/main-view-model.ts | 2 +- demo/tsconfig.json | 1 - src/tsconfig.json | 9 +-------- src/yourplugin.common.ts | 6 +++--- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/demo/app/app.ts b/demo/app/app.ts index 98f8260..a17b0bd 100644 --- a/demo/app/app.ts +++ b/demo/app/app.ts @@ -1,2 +1,2 @@ -import * as application from 'application'; +import * as application from 'tns-core-modules/application'; application.start({ moduleName: "main-page" }); diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts index 715863e..8ef1850 100644 --- a/demo/app/main-page.ts +++ b/demo/app/main-page.ts @@ -1,5 +1,5 @@ -import * as observable from 'data/observable'; -import * as pages from 'ui/page'; +import * as observable from 'tns-core-modules/data/observable'; +import * as pages from 'tns-core-modules/ui/page'; import {HelloWorldModel} from './main-view-model'; // Event handler for Page 'loaded' event attached in main-page.xml diff --git a/demo/app/main-view-model.ts b/demo/app/main-view-model.ts index 2b6144e..b319e82 100644 --- a/demo/app/main-view-model.ts +++ b/demo/app/main-view-model.ts @@ -1,4 +1,4 @@ -import { Observable } from 'data/observable'; +import { Observable } from 'tns-core-modules/data/observable'; import { YourPlugin } from 'nativescript-yourplugin'; export class HelloWorldModel extends Observable { diff --git a/demo/tsconfig.json b/demo/tsconfig.json index 80c1c98..c9560fb 100644 --- a/demo/tsconfig.json +++ b/demo/tsconfig.json @@ -23,7 +23,6 @@ "baseUrl": ".", "paths": { "*": [ - "./node_modules/tns-core-modules/*", "./node_modules/*" ] } diff --git a/src/tsconfig.json b/src/tsconfig.json index 7c5a980..2c33e90 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -17,14 +17,7 @@ "noImplicitAny": false, "noImplicitReturns": true, "noImplicitUseStrict": false, - "noFallthroughCasesInSwitch": true, - "skipLibCheck": true, - "baseUrl": ".", - "paths": { - "*": [ - "./node_modules/tns-core-modules/*" - ] - } + "noFallthroughCasesInSwitch": true }, "exclude": [ "node_modules" diff --git a/src/yourplugin.common.ts b/src/yourplugin.common.ts index 4ff9213..c5801f9 100644 --- a/src/yourplugin.common.ts +++ b/src/yourplugin.common.ts @@ -1,6 +1,6 @@ -import { Observable } from 'data/observable'; -import * as app from 'application'; -import * as dialogs from 'ui/dialogs'; +import { Observable } from 'tns-core-modules/data/observable'; +import * as app from 'tns-core-modules/application'; +import * as dialogs from 'tns-core-modules/ui/dialogs'; export class Common extends Observable { public message: string;