diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..e1becd3 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,36 @@ + + + + + +## PR Checklist + +- [ ] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages. +- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it. +- [ ] All existing tests are passing +- [ ] Tests for the changes are included + +## What is the current behavior? + + +## What is the new behavior? + + +Fixes/Implements/Closes #[Issue Number]. + + + + + diff --git a/.gitignore b/.gitignore index ffd6809..5f5c757 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .vscode .idea .DS_Store +*.esm.json *.js *.js.map *.log @@ -9,7 +10,7 @@ src/*.d.ts !src/references.d.ts !src/scripts/*.js !seed-tests/*.js -seed-tests/seed-copy/**/*.* +seed-tests/seed-copy seed-tests/seed-copy-new-git-repo/**/*.* !demo/karma.conf.js !demo/app/tests/*.js @@ -22,3 +23,4 @@ publish/src publish/package demo/report/report.html demo/report/stats.json +!demo-vue/app/app.js \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 4579eea..abe28a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,71 +1,187 @@ branches: only: - master +env: + global: + - ANDROID_PACKAGE_JS='seed-js.apk' + - ANDROID_PACKAGE_FOLDER_JS=$TRAVIS_BUILD_DIR/demo/outputs + - ANDROID_PACKAGE_NG='seed-ng.apk' + - ANDROID_PACKAGE_FOLDER_NG=$TRAVIS_BUILD_DIR/demo-angular/outputs + - ANDROID_SAUCE_STORAGE="https://saucelabs.com/rest/v1/storage/$SAUCE_USER" + - IOS_PACKAGE_JS='seed-js.zip' + - IOS_PACKAGE_FOLDER_JS=$TRAVIS_BUILD_DIR/demo/outputs + - IOS_PACKAGE_NG='seed-ng.zip' + - IOS_PACKAGE_FOLDER_NG=$TRAVIS_BUILD_DIR/demo-angular/outputs + - IOS_SAUCE_STORAGE="https://saucelabs.com/rest/v1/storage/$SAUCE_USER" + matrix: include: - stage: "Lint" language: node_js os: linux - node_js: "6" - script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint + node_js: "10" + script: cd src && npm run ci.tslint - stage: "Build and Test" - env: - - BuildAndroid="26" + env: + - BuildAndroid="29" + - NodeJs="8" + - Type="TypeScript" language: android + dist: trusty os: linux jdk: oraclejdk8 - before_install: nvm install stable + before_install: nvm install 8 script: - - cd src && npm i && npm run tsc && cd ../demo - - travis_wait travis_retry tns build android + - cd src && npm run postclone gitHubUsername=TheGitHubUser pluginName=ThePlugin initGit=y includeTypeScriptDemo=y includeAngularDemo=n + - npm run build + - cd ../demo + - tns build android + - env: + - BuildAndroid="29" + - Type="TypeScript" + language: android + dist: trusty + os: linux + jdk: oraclejdk8 + before_install: nvm install 10 + script: + - cd src && npm run postclone gitHubUsername=TheGitHubUser pluginName=ThePlugin initGit=y includeTypeScriptDemo=y includeAngularDemo=n + - npm run tsc + - cd ../demo + - travis_wait travis_retry tns build android --copy-to "$ANDROID_PACKAGE_FOLDER_JS/$ANDROID_PACKAGE_JS" + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $ANDROID_SAUCE_STORAGE/$ANDROID_PACKAGE_JS?overwrite=true --data-binary @$ANDROID_PACKAGE_FOLDER_JS/$ANDROID_PACKAGE_JS" - os: osx env: - - BuildiOS="11" - - Xcode="9.2" - osx_image: xcode9.2 + - BuildiOS="12.0" + - Type="TypeScript" + osx_image: xcode11.2 language: node_js - node_js: "6" + node_js: "10" jdk: oraclejdk8 script: - - cd src && npm i && npm run tsc && cd ../demo - - travis_wait travis_retry tns build ios + - cd src && npm run postclone gitHubUsername=TheGitHubUser pluginName=ThePlugin initGit=y includeTypeScriptDemo=y includeAngularDemo=n + - npm run tsc + - cd ../demo + - travis_wait travis_retry tns build ios --copy-to "./outputs/demo.app" + - cd $IOS_PACKAGE_FOLDER_JS && zip -r $IOS_PACKAGE_JS demo.app + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $IOS_SAUCE_STORAGE/$IOS_PACKAGE_JS?overwrite=true --data-binary @$IOS_PACKAGE_FOLDER_JS/$IOS_PACKAGE_JS" - os: linux + env: + - BuildAndroid="29" + - Type="Angular" language: android + dist: trusty + jdk: oraclejdk8 + before_install: nvm install 10 + script: + - cd src && npm run postclone gitHubUsername=TheGitHubUser pluginName=ThePlugin initGit=y includeTypeScriptDemo=n includeAngularDemo=y + - npm run tsc + - cd ../demo-angular + - travis_wait travis_retry tns build android --copy-to "$ANDROID_PACKAGE_FOLDER_NG/$ANDROID_PACKAGE_NG" + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $ANDROID_SAUCE_STORAGE/$ANDROID_PACKAGE_NG?overwrite=true --data-binary @$ANDROID_PACKAGE_FOLDER_NG/$ANDROID_PACKAGE_NG" + - os: osx + env: + - BuildiOS="12.0" + - Type="Angular" + osx_image: xcode11.2 + language: node_js + node_js: "10" + jdk: oraclejdk8 + script: + - cd src && npm run postclone gitHubUsername=TheGitHubUser pluginName=ThePlugin initGit=y includeTypeScriptDemo=n includeAngularDemo=y + - npm run tsc + - cd ../demo-angular + - travis_wait travis_retry tns build ios --copy-to "./outputs/demo-angular.app" + - cd $IOS_PACKAGE_FOLDER_NG && zip -r $IOS_PACKAGE_NG demo-angular.app + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $IOS_SAUCE_STORAGE/$IOS_PACKAGE_NG?overwrite=true --data-binary @$IOS_PACKAGE_FOLDER_NG/$IOS_PACKAGE_NG" + - os: linux + language: android + dist: trusty env: + - UnitTests="Android" - TestVersion="latest" jdk: oraclejdk8 before_install: - - nvm install stable + - nvm install 10 before_script: - cd seed-tests && npm i + - android list targets - echo no | android create avd --force -n test -t android-21 -b armeabi-v7a - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - script: travis_wait travis_retry npm run test.android - dist: precise + script: + - travis_wait travis_retry npm run test.android - os: osx env: + - UnitTests="iOS" - TestVersion="latest" language: node_js - node_js: "6" + node_js: "10" jdk: oraclejdk8 - osx_image: xcode8.3 + osx_image: xcode11.2 before_script: - cd seed-tests && npm i - script: travis_wait travis_retry npm run test.ios + script: + - travis_wait travis_retry npm run test.ios + - stage: "UI Tests" + env: + - Android="24" + - Type="TypeScript" + language: node_js + os: linux + node_js: "10" + script: + - npm i -g appium + - cd seed-tests && npm i + - travis_wait travis_retry npm run e2e -- --runType android24 --sauceLab --appPath $ANDROID_PACKAGE_JS + - os: linux + env: + - Android="24" + - Type="Angular" + language: node_js + os: linux + node_js: "10" + script: + - npm i -g appium + - cd seed-tests && npm i + - travis_wait travis_retry npm run e2e -- --runType android24 --sauceLab --appPath $ANDROID_PACKAGE_NG + - os: linux + env: + - iOS="12.0" + - Type="TypeScript" + language: node_js + node_js: "10" + script: + - npm i -g appium + - cd seed-tests && npm i + - travis_wait travis_retry npm run e2e -- --runType sim12iPhoneX --sauceLab --appPath $IOS_PACKAGE_JS + - os: linux + env: + - iOS="12.0" + - Type="Angular" + language: node_js + node_js: "10" + script: + - npm i -g appium + - cd seed-tests && npm i + - travis_wait travis_retry npm run e2e -- --runType sim12iPhoneX --sauceLab --appPath $IOS_PACKAGE_NG + android: components: - tools - platform-tools - - build-tools-26.0.1 - - android-23 - - android-26 + - build-tools-29.0.2 + - android-21 + - android-29 - extra-android-m2repository - sys-img-armeabi-v7a-android-21 +before_install: + - sudo pip install --upgrade pip + - sudo pip install six + install: - echo no | npm install -g nativescript - tns usage-reporting disable - tns error-reporting disable - \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6637ee7 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,79 @@ +# Contributing to NativeScript Plugin Seed + +:+1: First of all, thank you for taking the time to contribute! :+1: + +Here are some guides on how to do that: + + + +- [Code of Conduct](#code-of-conduct) +- [Reporting Bugs](#reporting-bugs) +- [Requesting Features](#requesting-features) +- [Submitting a PR](#submitting-a-pr) +- [Where to Start](#where-to-start) + + + +## Code of Conduct +Help us keep a healthy and open community. We expect all participants in this project to adhere to the [NativeScript Code Of Conduct](https://github.com/NativeScript/codeofconduct). + + +## Reporting Bugs + +1. Always update to the most recent master release; the bug may already be resolved. +2. Search for similar issues in the issues list for this repo; it may already be an identified problem. +3. If this is a bug or problem that is clear, simple, and is unlikely to require any discussion -- it is OK to open an issue on GitHub with a reproduction of the bug including workflows and screenshots. If possible, submit a Pull Request with a failing test, entire application or module. If you'd rather take matters into your own hands, fix the bug yourself (jump down to the [Submitting a PR](#submitting-a-pr) section). + +## Requesting Features + +1. Use Github Issues to submit feature requests. +2. First, search for a similar request and extend it if applicable. This way it would be easier for the community to track the features. +3. When requesting a new feature, please provide as much detail as possible about why you need the feature in your apps. We prefer that you explain a need rather than explain a technical solution for it. That might trigger a nice conversation on finding the best and broadest technical solution to a specific need. + +## Submitting a PR + +Before you begin: +* Make sure there is an issue for the bug or feature you will be working on. + +Following these steps is the best way to get your code included in the project: + +1. Fork and clone the nativescript-plugin-seed repo: +```bash +git clone https://github.com//nativescript-plugin-seed.git +# Navigate to the newly cloned directory +cd nativescript-plugin-seed +# Add an "upstream" remote pointing to the original repo. +git remote add upstream https://github.com/NativeScript/nativescript-plugin-seed.git +``` +2. Create a branch for your PR +```bash +git checkout -b master +``` + +3. The fun part! Make your code changes. Make sure you: + - Follow the [code conventions guide](https://github.com/NativeScript/NativeScript/blob/master/CodingConvention.md). + - Follow the [commit message guidelines](https://github.com/NativeScript/NativeScript/blob/pr-template/CONTRIBUTING.md#commit-messages) + - Setup your development workflow. The seed itself is a plugin so you can follow the [development setup][https://github.com/NativeScript/nativescript-plugin-seed#development-setup] described in the README. + - Write unit tests for your fix or feature. If this is not possible, explain how your change can be tested. + > NOTE: For changes in the postclone step, make sure you create tests in `seed-tests/postclone.tests.js`! + +4. Before you submit your PR: + - Rebase your changes to the latest master: `git pull --rebase upstream master`. + - Ensure all unit test are green. How? + - Go to `seed-tests` + - Run `npm install` + - Run `npm run test.ios` or `npm run test.android` + - Ensure your changes pass tslint validation. (run `npm run tslint` in the root of the repo). + +6. Push your fork. If you have rebased you might have to use force-push your branch: +``` +git push origin --force +``` + +7. [Submit your pull request](https://github.com/NativeScript/nativescript-plugin-seed/compare) and compare to `NativeScript/nativescript-plugin-seed`. Please, fill in the Pull Request template - it will help us better understand the PR and increase the chances of it getting merged quickly. + +It's our turn from there on! We will review the PR and discuss changes you might have to make before merging it! Thanks! + +## Where to Start + +If you want to contribute, but you are not sure where to start - look for issues labeled [`help wanted`](https://github.com/NativeScript/nativescript-plugin-seed/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). diff --git a/LICENSE b/LICENSE index ced13b4..061c440 100755 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Apache License + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -186,7 +186,7 @@ Apache License same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (c) 2015-2018 Telerik AD + Copyright (c) 2015-2019 Progress Software Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 7c65c54..34236ee 100644 --- a/README.md +++ b/README.md @@ -2,44 +2,44 @@ > 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) -* [Long Description](#LongDescription) - * [What is NativeScript plugin seed?](#WhatisNativeScriptpluginseed) - * [Plugin folder structure](#Pluginfolderstructure) - * [Getting started](#Gettingstarted) - * [Development setup](#Developmentsetup) - * [Linking to CocoaPod or Android Arsenal plugins](#LinkingtoCocoaPodorAndroidArsenalplugins) - * [Unittesting](#Unittesting) - * [Publish to NPM](#PublishtoNPM) - * [TravisCI](#TravisCI) - * [Referring tns-core-modules in the Plugin](#ReferringtnscoremodulesinthePlugin) - - - - -## TL;DR + + +- [TL;DR](#tldr) +- [Long Description](#long-description) + - [What is NativeScript plugin seed?](#what-is-nativescript-plugin-seed) + - [Plugin folder structure](#plugin-folder-structure) + - [Getting started](#getting-started) + - [Development setup](#development-setup) + - [Linking to CocoaPod or Android Arsenal plugins](#linking-to-cocoapod-or-android-arsenal-plugins) + - [Generating typings for iOS](#generating-typings-for-ios) + - [Generating typings for Android](#generating-typings-for-android) + - [Clean plugin and demo files](#clean-plugin-and-demo-files) + - [Unittesting](#unittesting) + - [Publish to NPM](#publish-to-npm) + - [TravisCI](#travisci) + - [Referring tns-core-modules in the Plugin](#referring-tns-core-modules-in-the-plugin) +- [Contribute](#contribute) +- [Get Help](#get-help) + + + +## TL;DR The NativeScript plugin seed is built to be used as a starting point by NativeScript plugin developers. To bootstrap your plugin development execute the following: 1. `git clone https://github.com/NativeScript/nativescript-plugin-seed nativescript-yourplugin` where `nativescript-yourplugin` is the name of your plugin. 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 typescript changes in the plugin and to automatically apply them in the demo. -## Long Description +## Long Description -### What is NativeScript plugin seed? +### What is NativeScript plugin seed? -The NativeScript plugin seed is built to be used as a starting point by NativeScript plugin developers. It expands on several things [presented here](http://developer.telerik.com/featured/creating-nativescript-plugins-in-typescript/). +The NativeScript plugin seed is built to be used as a starting point by NativeScript plugin developers. What does the seed give you out of the box? * the plugin structure with option for easy development and debugging (see [Development setup section](#Developmentsetup) below) * a simple working plugin * a demo project working with the plugin. It is useful during development and for running tests via Travis CI -* plugin tests * a guideline how to structure your plugin README file that will be published to NPM * a shell script to create your plugin package * a proper `.gitignore` to keep GitHub tidy @@ -47,12 +47,12 @@ What does the seed give you out of the box? ![Plugin seed demo](https://github.com/NativeScript/nativescript-plugin-seed/blob/master/screenshots/demo.png?raw=true) -### Plugin folder structure +### Plugin folder structure |Folder/File name| Description |---|---| -|demo| The plugin demo source code| -|demo/tests| The tests for your plugin| +|demo| The plugin demo source code (optional during __postclone__ setup)| +|demo-angular| The plugin demo source code (optional during __postclone__ setup)| |src| The plugin source code| |src/platform/android| Plugin Android specific configuration| |src/platform/ios|Plugin ios specific configuration| @@ -60,7 +60,7 @@ What does the seed give you out of the box? |src/scripts|The postclone script run when you execute `npm run postclone`. Feel free to delete it after you have executed the postclone step from the [Getting started](#Gettingstarted) section| |publish|Contains a shell script to create and publish your package. Read more on creating a package and publishing in the [Publish to NPM](#Publishtonpm) section| -### Getting started +### Getting started 1. Open a command prompt/terminal and execute `git clone https://github.com/NativeScript/nativescript-plugin-seed nativescript-yourplugin` to clone the plugin seed repository into the `nativescript-yourplugin` folder where `nativescript-yourplugin` is the name of your plugin.. 2. Open a command prompt/terminal and navigate to `nativescript-yourplugin/src` folder using `cd nativescript-yourplugin/src` @@ -68,22 +68,24 @@ What does the seed give you out of the box? * configure your github username - it will be changed in the package.json for you * configure your plugin name - all files and classes in the seed will be renamed for you * stub your plugin README.md file + * add TypeScript NativeScript application which is setup to use your plugin from its local `src` folder + * add Angular NativeScript application which is setup to use your plugin from its local `src` folder * create a new repository for your plugin - * 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. -#### Development setup -For easier development and debugging purposes continue with the following steps: +**NOTE**: The plugin seed is updated to use the latest version of NativeScript. If you are not ready to upgrade, you can checkout a [tagged version](https://github.com/NativeScript/nativescript-plugin-seed/tags) that is compatible with your NativeScript version. -1. Open a command prompt/terminal, navigate to `src` folder and run `npm run demo.ios` or `npm run demo.android` to run the demo. -2. Open another command prompt/terminal, navigate to `src` folder and run `npm run plugin.tscwatch` to watch for file changes in your plugin. +#### Development setup +For easier development and debugging purposes continue with the following: + +Open a command prompt/terminal, navigate to `src` folder and run `npm run demo.ios`, `npm run demo.android`, `npm run demo-angular.ios`, `npm run demo-angular.android` to run the demo applications created during `postclone`. 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**: Any changes that you need to make in a native library used in your plugin or in any other files inside `src/platforms` directory such as Info.plist or AndroidManifest.xml can't be directly reflected in the demo applications. You need to use `npm run demo.reset` or `npm run demo-angular.reset` and run the application again. -### Linking to CocoaPod or Android Arsenal plugins +### Linking to CocoaPod or Android Arsenal plugins You will want to create these folders and files in the `src` folder in order to use native APIs: @@ -102,34 +104,41 @@ Take a look at these existing plugins for how that can be done very simply: * [nativescript-cardview](https://github.com/bradmartin/nativescript-cardview/tree/master/platforms) * [nativescript-floatingactionbutton](https://github.com/bradmartin/nativescript-floatingactionbutton/tree/master/src/platforms) +It's highly recommended to generate typings for the native libraries used in your plugin. By generating typings you'll be able to see what APIs exactly are exposed to Javascript and use them easily in your plugin code + +#### Generating typings for iOS + +- Run the command for typings generation as explained in the [documentation](https://docs.nativescript.org/plugins/Use-Native-iOS-Libraries#troubleshooting) +- Open `demo/typings/x86_64` and copy the `d.ts` files that you plan to use in your plugin to `src/platforms/ios/typings` +- Open `src/references.d.ts` and add a reference to each of the files added to `src/platforms/ios/typings` + +**NOTE**: Swift APIs that are not exported to Objective-C are not supported. This means that you can only call APIs from JavaScript that are visible to the Objective-C runtime. This include all Objective-C APIs and only the subset of all Swift APIs that are exposed to Objective-C. So, to use a Swift API (class/function/method etc.) from NativeScript, first make sure that it can be used from Objective-C code. For more information which Swfit APIs can be exposed to Objective-C, see [here](https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html#//apple_ref/doc/uid/TP40014216-CH4-ID53). + +#### Generating typings for Android + +- Clone [Android DTS Generator repo](https://github.com/NativeScript/android-dts-generator) +- Follow the steps in the [README](https://github.com/NativeScript/android-dts-generator/blob/master/README.md) +- Copy the generated d.ts files in `src/platforms/android/typings`. Feel free to rename the generated files for readablity. +- Open `src/references.d.ts` and add a reference to each of the files added to `src/platforms/android/typings` + ### Clean plugin and demo files -Sometimes you may need to wipe away the `node_modules` and `demo/platforms` folders to reinstall them fresh. +Sometimes you may need to wipe away the `src/node_modules`, `demo/node_modules` and `demo/platforms` folders to reinstall them fresh. * Run `npm run clean` to wipe those clean then you can can run `npm i` to install fresh dependencies. Sometimes you just need to wipe out the demo's `platforms` directory only: -* Run `npm run demo.reset` to delete the demo's `platforms` directory only. +* Run `npm run demo.reset` or `npm run demo-angular.reset` to delete the application's `platforms` directory only. 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. -### 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. - -You can read more about this topic [here](https://docs.nativescript.org/tooling/testing). - -Once you're ready to test your plugin's API go to `src` folder and execute one of these commands: +### Unit testing +In order to add unit testing to the demo applications and in relation to test your plugin inside of them you should follow our latest guide [here](https://docs.nativescript.org/tooling/testing/testing). -``` -npm run test.ios -npm run test.android -``` - -### Publish to NPM +### Publish to NPM When you have everything ready to publish: @@ -140,40 +149,14 @@ If you just want to create a package, go to `publish` folder and execute `pack.s **NOTE**: To run bash script on Windows you can install [GIT SCM](https://git-for-windows.github.io/) and use Git Bash. -### TravisCI +### TravisCI -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. +The plugin structure comes with a fully functional .travis.yml file that deploys the testing app on Android emulator and iOS simulator to make sure that those apps start correctly while your plugin is linked to them. 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. -### Referring tns-core-modules in the Plugin -We recommend to use full imports of `tns-core-modules` due to [an issue in Angular CLI](https://github.com/angular/angular-cli/issues/5618#issuecomment-306479219). Read more detailed explanation in [this discussion](https://github.com/NativeScript/nativescript-plugin-seed/pull/32#discussion_r131147787). - -Ultimately after the issue in Angular CLI is fixed this would not be a restriction, but till then the recommended approach is to import from `tns-core-modules` using full path. Here is an example: - -**WRONG** - -*tsconfig.json* -```` -... - -"paths": { - "*": [ - "./node_modules/*", - "./node_modules/tns-core-modules/*" - ] -} -... -```` - -*yourplugin.common.ts* -```` -import * as app from 'application'; -```` - -**RIGHT** +## Contribute +We love PRs! Check out the [contributing guidelines](CONTRIBUTING.md). If you want to contribute, but you are not sure where to start - look for issues labeled [`help wanted`](https://github.com/NativeScript/tns-core-modules-widgets/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). -*yourplugin.common.ts* -```` -import * as app from 'tns-core-modules/application'; -```` +## Get Help +Please, use [github issues](https://github.com/NativeScript/tns-core-modules-widgets/issues) strictly for [reporting bugs](CONTRIBUTING.md#reporting-bugs) or [requesting features](CONTRIBUTING.md#requesting-new-features). For general questions and support, check out [Stack Overflow](https://stackoverflow.com/questions/tagged/nativescript) or ask our experts in [NativeScript community Slack channel](http://developer.telerik.com/wp-login.php?action=slack-invitation). diff --git a/demo/app/App_Resources/Android/AndroidManifest.xml b/demo/app/App_Resources/Android/AndroidManifest.xml deleted file mode 100644 index 9db8321..0000000 --- a/demo/app/App_Resources/Android/AndroidManifest.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demo/app/App_Resources/Android/app.gradle b/demo/app/App_Resources/Android/app.gradle deleted file mode 100644 index c9d40ec..0000000 --- a/demo/app/App_Resources/Android/app.gradle +++ /dev/null @@ -1,16 +0,0 @@ -// Add your native dependencies here: - -// Uncomment to add recyclerview-v7 dependency -//dependencies { -// compile 'com.android.support:recyclerview-v7:+' -//} - -android { - defaultConfig { - generatedDensities = [] - applicationId = "org.nativescript.demo" - } - aaptOptions { - additionalParameters "--no-version-vectors" - } -} diff --git a/demo/app/App_Resources/Android/drawable-hdpi/background.png b/demo/app/App_Resources/Android/drawable-hdpi/background.png deleted file mode 100644 index eb381c2..0000000 Binary files a/demo/app/App_Resources/Android/drawable-hdpi/background.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-hdpi/icon.png b/demo/app/App_Resources/Android/drawable-hdpi/icon.png deleted file mode 100644 index 1034356..0000000 Binary files a/demo/app/App_Resources/Android/drawable-hdpi/icon.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-hdpi/logo.png b/demo/app/App_Resources/Android/drawable-hdpi/logo.png deleted file mode 100644 index 5218f4c..0000000 Binary files a/demo/app/App_Resources/Android/drawable-hdpi/logo.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-ldpi/background.png b/demo/app/App_Resources/Android/drawable-ldpi/background.png deleted file mode 100644 index 748b2ad..0000000 Binary files a/demo/app/App_Resources/Android/drawable-ldpi/background.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-ldpi/icon.png b/demo/app/App_Resources/Android/drawable-ldpi/icon.png deleted file mode 100644 index ddfc17a..0000000 Binary files a/demo/app/App_Resources/Android/drawable-ldpi/icon.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-ldpi/logo.png b/demo/app/App_Resources/Android/drawable-ldpi/logo.png deleted file mode 100644 index b9e102a..0000000 Binary files a/demo/app/App_Resources/Android/drawable-ldpi/logo.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-mdpi/background.png b/demo/app/App_Resources/Android/drawable-mdpi/background.png deleted file mode 100644 index efeaf29..0000000 Binary files a/demo/app/App_Resources/Android/drawable-mdpi/background.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-mdpi/icon.png b/demo/app/App_Resources/Android/drawable-mdpi/icon.png deleted file mode 100644 index 486e410..0000000 Binary files a/demo/app/App_Resources/Android/drawable-mdpi/icon.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-mdpi/logo.png b/demo/app/App_Resources/Android/drawable-mdpi/logo.png deleted file mode 100644 index 6263387..0000000 Binary files a/demo/app/App_Resources/Android/drawable-mdpi/logo.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-nodpi/splash_screen.xml b/demo/app/App_Resources/Android/drawable-nodpi/splash_screen.xml deleted file mode 100644 index ada77f9..0000000 --- a/demo/app/App_Resources/Android/drawable-nodpi/splash_screen.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/demo/app/App_Resources/Android/drawable-xhdpi/background.png b/demo/app/App_Resources/Android/drawable-xhdpi/background.png deleted file mode 100644 index 612bbd0..0000000 Binary files a/demo/app/App_Resources/Android/drawable-xhdpi/background.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-xhdpi/icon.png b/demo/app/App_Resources/Android/drawable-xhdpi/icon.png deleted file mode 100644 index f291882..0000000 Binary files a/demo/app/App_Resources/Android/drawable-xhdpi/icon.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-xhdpi/logo.png b/demo/app/App_Resources/Android/drawable-xhdpi/logo.png deleted file mode 100644 index ad8ee2f..0000000 Binary files a/demo/app/App_Resources/Android/drawable-xhdpi/logo.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-xxhdpi/background.png b/demo/app/App_Resources/Android/drawable-xxhdpi/background.png deleted file mode 100644 index 0fa88e2..0000000 Binary files a/demo/app/App_Resources/Android/drawable-xxhdpi/background.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-xxhdpi/icon.png b/demo/app/App_Resources/Android/drawable-xxhdpi/icon.png deleted file mode 100644 index 4f69cb2..0000000 Binary files a/demo/app/App_Resources/Android/drawable-xxhdpi/icon.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-xxhdpi/logo.png b/demo/app/App_Resources/Android/drawable-xxhdpi/logo.png deleted file mode 100644 index 6683278..0000000 Binary files a/demo/app/App_Resources/Android/drawable-xxhdpi/logo.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-xxxhdpi/background.png b/demo/app/App_Resources/Android/drawable-xxxhdpi/background.png deleted file mode 100644 index c650f64..0000000 Binary files a/demo/app/App_Resources/Android/drawable-xxxhdpi/background.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png b/demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png deleted file mode 100644 index 50887a8..0000000 Binary files a/demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png b/demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png deleted file mode 100644 index fa6331c..0000000 Binary files a/demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png and /dev/null differ diff --git a/demo/app/App_Resources/Android/values-v21/colors.xml b/demo/app/App_Resources/Android/values-v21/colors.xml deleted file mode 100644 index a64641a..0000000 --- a/demo/app/App_Resources/Android/values-v21/colors.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #3d5afe - \ No newline at end of file diff --git a/demo/app/App_Resources/Android/values-v21/styles.xml b/demo/app/App_Resources/Android/values-v21/styles.xml deleted file mode 100644 index dac8727..0000000 --- a/demo/app/App_Resources/Android/values-v21/styles.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demo/app/App_Resources/Android/values/colors.xml b/demo/app/App_Resources/Android/values/colors.xml deleted file mode 100644 index 74ad882..0000000 --- a/demo/app/App_Resources/Android/values/colors.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - #F5F5F5 - #757575 - #33B5E5 - #272734 - \ No newline at end of file diff --git a/demo/app/App_Resources/Android/values/styles.xml b/demo/app/App_Resources/Android/values/styles.xml deleted file mode 100644 index 1e8c7f2..0000000 --- a/demo/app/App_Resources/Android/values/styles.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 5f53593..0000000 --- a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "images" : [ - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "icon-29.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "icon-29@2x.png", - "scale" : "2x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "icon-29@3x.png", - "scale" : "3x" - }, - { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "icon-40@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "icon-40@3x.png", - "scale" : "3x" - }, - { - "size" : "57x57", - "idiom" : "iphone", - "filename" : "icon-57.png", - "scale" : "1x" - }, - { - "size" : "57x57", - "idiom" : "iphone", - "filename" : "icon-57@2x.png", - "scale" : "2x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "icon-60@2x.png", - "scale" : "2x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "icon-60@3x.png", - "scale" : "3x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "icon-29.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "icon-29@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "icon-40.png", - "scale" : "1x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "icon-40@2x.png", - "scale" : "2x" - }, - { - "size" : "50x50", - "idiom" : "ipad", - "filename" : "icon-50.png", - "scale" : "1x" - }, - { - "size" : "50x50", - "idiom" : "ipad", - "filename" : "icon-50@2x.png", - "scale" : "2x" - }, - { - "size" : "72x72", - "idiom" : "ipad", - "filename" : "icon-72.png", - "scale" : "1x" - }, - { - "size" : "72x72", - "idiom" : "ipad", - "filename" : "icon-72@2x.png", - "scale" : "2x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "icon-76.png", - "scale" : "1x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "icon-76@2x.png", - "scale" : "2x" - }, - { - "size" : "83.5x83.5", - "idiom" : "ipad", - "filename" : "icon-83.5@2x.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png deleted file mode 100644 index 9e15af0..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png deleted file mode 100644 index 7b9e555..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png deleted file mode 100644 index 76f61ec..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png deleted file mode 100644 index 15b06db..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png deleted file mode 100644 index 585065f..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png deleted file mode 100644 index a450c42..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png deleted file mode 100644 index 4a62478..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png deleted file mode 100644 index 01ff7c1..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png deleted file mode 100644 index beea819..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png deleted file mode 100644 index c3dc7b0..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png deleted file mode 100644 index 457b6d9..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png deleted file mode 100644 index fa5a6ac..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png deleted file mode 100644 index 556bdd6..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png deleted file mode 100644 index 4f69cb2..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png deleted file mode 100644 index 94abcf7..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png deleted file mode 100644 index 2e71dd3..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png deleted file mode 100644 index 4abc9ec..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164..0000000 --- a/demo/app/App_Resources/iOS/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json deleted file mode 100644 index 4414bad..0000000 --- a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json +++ /dev/null @@ -1,158 +0,0 @@ -{ - "images" : [ - { - "extent" : "full-screen", - "idiom" : "iphone", - "subtype" : "736h", - "filename" : "Default-736h@3x.png", - "minimum-system-version" : "8.0", - "orientation" : "portrait", - "scale" : "3x" - }, - { - "extent" : "full-screen", - "idiom" : "iphone", - "subtype" : "736h", - "filename" : "Default-Landscape@3x.png", - "minimum-system-version" : "8.0", - "orientation" : "landscape", - "scale" : "3x" - }, - { - "extent" : "full-screen", - "idiom" : "iphone", - "subtype" : "667h", - "filename" : "Default-667h@2x.png", - "minimum-system-version" : "8.0", - "orientation" : "portrait", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "filename" : "Default@2x.png", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "2x" - }, - { - "extent" : "full-screen", - "idiom" : "iphone", - "subtype" : "retina4", - "filename" : "Default-568h@2x.png", - "minimum-system-version" : "7.0", - "orientation" : "portrait", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "filename" : "Default-Portrait.png", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "1x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "filename" : "Default-Landscape.png", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "1x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "filename" : "Default-Portrait@2x.png", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "2x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "filename" : "Default-Landscape@2x.png", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "filename" : "Default.png", - "extent" : "full-screen", - "scale" : "1x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "filename" : "Default@2x.png", - "extent" : "full-screen", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "filename" : "Default-568h@2x.png", - "extent" : "full-screen", - "subtype" : "retina4", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "extent" : "to-status-bar", - "scale" : "1x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "filename" : "Default-Portrait.png", - "extent" : "full-screen", - "scale" : "1x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "extent" : "to-status-bar", - "scale" : "1x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "filename" : "Default-Landscape.png", - "extent" : "full-screen", - "scale" : "1x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "extent" : "to-status-bar", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "filename" : "Default-Portrait@2x.png", - "extent" : "full-screen", - "scale" : "2x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "extent" : "to-status-bar", - "scale" : "2x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "filename" : "Default-Landscape@2x.png", - "extent" : "full-screen", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png deleted file mode 100644 index d7f17fc..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png deleted file mode 100644 index b884154..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png deleted file mode 100644 index faab4b6..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png deleted file mode 100644 index 3365ba3..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png deleted file mode 100644 index a44945c..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png deleted file mode 100644 index e6dca62..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png deleted file mode 100644 index 1a50079..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png deleted file mode 100644 index 73d8b92..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png deleted file mode 100644 index 9f1f6ce..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png deleted file mode 100644 index 514fc5c..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json deleted file mode 100644 index 4f4e9c5..0000000 --- a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "LaunchScreen-AspectFill.png", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "LaunchScreen-AspectFill@2x.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png deleted file mode 100644 index c293f9c..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png deleted file mode 100644 index 233693a..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json deleted file mode 100644 index 23c0ffd..0000000 --- a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "LaunchScreen-Center.png", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "LaunchScreen-Center@2x.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png deleted file mode 100644 index a5a775a..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png deleted file mode 100644 index 154c193..0000000 Binary files a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png and /dev/null differ diff --git a/demo/app/App_Resources/iOS/Info.plist b/demo/app/App_Resources/iOS/Info.plist deleted file mode 100644 index ea3e3ea..0000000 --- a/demo/app/App_Resources/iOS/Info.plist +++ /dev/null @@ -1,47 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleDisplayName - ${PRODUCT_NAME} - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIRequiresFullScreen - - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/demo/app/App_Resources/iOS/LaunchScreen.storyboard b/demo/app/App_Resources/iOS/LaunchScreen.storyboard deleted file mode 100644 index 2ad9471..0000000 --- a/demo/app/App_Resources/iOS/LaunchScreen.storyboard +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demo/app/App_Resources/iOS/build.xcconfig b/demo/app/App_Resources/iOS/build.xcconfig deleted file mode 100644 index 0562055..0000000 --- a/demo/app/App_Resources/iOS/build.xcconfig +++ /dev/null @@ -1,5 +0,0 @@ -// You can add custom settings here -// for example you can uncomment the following line to force distribution code signing -// CODE_SIGN_IDENTITY = iPhone Distribution -ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; -ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; diff --git a/demo/app/app.css b/demo/app/app.css deleted file mode 100644 index 911130f..0000000 --- a/demo/app/app.css +++ /dev/null @@ -1 +0,0 @@ -@import '~nativescript-theme-core/css/core.light.css'; diff --git a/demo/app/app.ts b/demo/app/app.ts deleted file mode 100644 index 8986233..0000000 --- a/demo/app/app.ts +++ /dev/null @@ -1,3 +0,0 @@ -import "./bundle-config"; -import * as application from 'tns-core-modules/application'; -application.start({ moduleName: "main-page" }); diff --git a/demo/app/bundle-config.ts b/demo/app/bundle-config.ts deleted file mode 100644 index a6a7c20..0000000 --- a/demo/app/bundle-config.ts +++ /dev/null @@ -1,9 +0,0 @@ -if (global.TNS_WEBPACK) { - // registers tns-core-modules UI framework modules - require("bundle-entry-points"); - - // register application modules - // This will register each `page` postfixed xml, css, js, ts, scss etc. in the app/ folder - const context = require.context("~/", true, /(page|fragment)\.(xml|css|js|ts|scss|less|sass)$/); - global.registerWebpackModules(context); -} \ No newline at end of file diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts deleted file mode 100644 index 8ef1850..0000000 --- a/demo/app/main-page.ts +++ /dev/null @@ -1,10 +0,0 @@ -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 -export function pageLoaded(args: observable.EventData) { - // Get the event sender - let page = args.object; - page.bindingContext = new HelloWorldModel(); -} diff --git a/demo/app/main-page.xml b/demo/app/main-page.xml deleted file mode 100644 index eab562f..0000000 --- a/demo/app/main-page.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/demo/app/main-view-model.ts b/demo/app/main-view-model.ts deleted file mode 100644 index b319e82..0000000 --- a/demo/app/main-view-model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Observable } from 'tns-core-modules/data/observable'; -import { YourPlugin } from 'nativescript-yourplugin'; - -export class HelloWorldModel extends Observable { - public message: string; - private yourPlugin: YourPlugin; - - constructor() { - super(); - - this.yourPlugin = new YourPlugin(); - this.message = this.yourPlugin.message; - } -} diff --git a/demo/app/package.json b/demo/app/package.json deleted file mode 100644 index cb4b874..0000000 --- a/demo/app/package.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "name": "tns-template-hello-world-ts", - "main": "app.js", - "version": "1.6.0", - "author": { - "name": "Telerik", - "email": "support@telerik.com" - }, - "description": "Nativescript hello-world-ts project template", - "license": "Apache-2.0", - "keywords": [ - "telerik", - "mobile", - "nativescript", - "{N}", - "tns", - "appbuilder", - "template" - ], - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/NativeScript/template-hello-world-ts.git" - }, - "bugs": { - "url": "https://github.com/NativeScript/template-hello-world-ts/issues" - }, - "homepage": "https://github.com/NativeScript/template-hello-world-ts", - "android": { - "v8Flags": "--expose_gc" - }, - "devDependencies": { - "nativescript-dev-typescript": "^0.3.0" - }, - "_id": "tns-template-hello-world-ts@1.6.0", - "_shasum": "a567c2b9a56024818c06596dab9629d155c5b8a8", - "_resolved": "https://registry.npmjs.org/tns-template-hello-world-ts/-/tns-template-hello-world-ts-1.6.0.tgz", - "_from": "tns-template-hello-world-ts@latest", - "scripts": { - "build.plugin": "cd ../src && npm run build", - "ci.tslint": "npm i && tslint --config '../tslint.json' 'app/**/*.ts' --exclude '**/node_modules/**'" - }, - "_npmVersion": "2.14.7", - "_nodeVersion": "4.2.2", - "_npmUser": { - "name": "enchev", - "email": "vladimir.enchev@gmail.com" - }, - "dist": { - "shasum": "a567c2b9a56024818c06596dab9629d155c5b8a8", - "tarball": "http://registry.npmjs.org/tns-template-hello-world-ts/-/tns-template-hello-world-ts-1.6.0.tgz" - }, - "maintainers": [ - { - "name": "enchev", - "email": "vladimir.enchev@gmail.com" - }, - { - "name": "erjangavalji", - "email": "erjan.gavalji@gmail.com" - }, - { - "name": "fatme", - "email": "hfatme@gmail.com" - }, - { - "name": "hdeshev", - "email": "hristo@deshev.com" - }, - { - "name": "kerezov", - "email": "d.kerezov@gmail.com" - }, - { - "name": "ligaz", - "email": "stefan.dobrev@gmail.com" - }, - { - "name": "nsndeck", - "email": "nedyalko.nikolov@telerik.com" - }, - { - "name": "rosen-vladimirov", - "email": "rosen.vladimirov.91@gmail.com" - }, - { - "name": "sdobrev", - "email": "stefan.dobrev@gmail.com" - }, - { - "name": "tailsu", - "email": "tailsu@gmail.com" - }, - { - "name": "teobugslayer", - "email": "teobugslayer@gmail.com" - }, - { - "name": "valio.stoychev", - "email": "valio.stoychev@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-5-east.internal.npmjs.com", - "tmp": "tmp/tns-template-hello-world-ts-1.6.0.tgz_1455717516189_0.6427943941671401" - }, - "directories": {}, - "readme": "ERROR: No README data found!" -} diff --git a/demo/app/tests/tests.js b/demo/app/tests/tests.js deleted file mode 100644 index 9748b12..0000000 --- a/demo/app/tests/tests.js +++ /dev/null @@ -1,12 +0,0 @@ -var YourPlugin = require("nativescript-yourplugin").YourPlugin; -var yourPlugin = new YourPlugin(); - -describe("greet function", function() { - it("exists", function() { - expect(yourPlugin.greet).toBeDefined(); - }); - - it("returns a string", function() { - expect(yourPlugin.greet()).toEqual("Hello, NS"); - }); -}); \ No newline at end of file diff --git a/demo/app/vendor-platform.android.ts b/demo/app/vendor-platform.android.ts deleted file mode 100644 index 719f264..0000000 --- a/demo/app/vendor-platform.android.ts +++ /dev/null @@ -1,9 +0,0 @@ -require("application"); -if (!global["__snapshot"]) { - // In case snapshot generation is enabled these modules will get into the bundle - // but will not be required/evaluated. - // The snapshot webpack plugin will add them to the tns-java-classes.js bundle file. - // This way, they will be evaluated on app start as early as possible. - require("ui/frame"); - require("ui/frame/activity"); -} diff --git a/demo/app/vendor-platform.ios.ts b/demo/app/vendor-platform.ios.ts deleted file mode 100644 index 5ce49d8..0000000 --- a/demo/app/vendor-platform.ios.ts +++ /dev/null @@ -1,3 +0,0 @@ -// There is a bug in angular: https://github.com/angular/angular-cli/pull/8589/files -// Legendary stuff, its webpack plugin pretty much doesn't work with empty TypeScript files in v1.8.3 -void 0; diff --git a/demo/app/vendor.ts b/demo/app/vendor.ts deleted file mode 100644 index 8a38137..0000000 --- a/demo/app/vendor.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Snapshot the ~/app.css and the theme -const application = require("application"); -require("ui/styling/style-scope"); -const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/); -global.registerWebpackModules(appCssContext); -application.loadAppCss(); - -require("./vendor-platform"); - -require("bundle-entry-points"); diff --git a/demo/karma.conf.js b/demo/karma.conf.js deleted file mode 100644 index 5d2286a..0000000 --- a/demo/karma.conf.js +++ /dev/null @@ -1,77 +0,0 @@ -module.exports = function(config) { - config.set({ - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['jasmine'], - - - // list of files / patterns to load in the browser - files: [ - 'app/**/*.js' - ], - - - // list of files to exclude - exclude: [ - ], - - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - }, - - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress'], - - - // web server port - port: 9876, - - - // enable / disable colors in the output (reporters and logs) - colors: true, - - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, - - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: [], - - customLaunchers: { - android: { - base: 'NS', - platform: 'android' - }, - ios: { - base: 'NS', - platform: 'ios' - }, - ios_simulator: { - base: 'NS', - platform: 'ios', - arguments: ['--emulator'] - } - }, - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: true - }); -}; diff --git a/demo/package.json b/demo/package.json deleted file mode 100644 index c590778..0000000 --- a/demo/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "nativescript": { - "id": "org.nativescript.demo", - "tns-android": { - "version": "3.4.0" - }, - "tns-ios": { - "version": "3.4.0" - } - }, - "dependencies": { - "nativescript-theme-core": "^1.0.4", - "nativescript-unit-test-runner": "^0.3.4", - "nativescript-yourplugin": "../src", - "tns-core-modules": "^3.4.0" - }, - "devDependencies": { - "awesome-typescript-loader": "~3.1.3", - "babel-traverse": "6.12.0", - "babel-types": "6.11.1", - "babylon": "6.8.4", - "copy-webpack-plugin": "~4.0.1", - "css-loader": "~0.28.7", - "extract-text-webpack-plugin": "~3.0.0", - "filewalker": "0.1.2", - "jasmine-core": "^2.5.2", - "karma": "^1.3.0", - "karma-jasmine": "^1.0.2", - "karma-nativescript-launcher": "^0.4.0", - "lazy": "1.0.11", - "nativescript-css-loader": "~0.26.0", - "nativescript-dev-typescript": "^0.6.0", - "nativescript-dev-webpack": "^0.9.0", - "nativescript-worker-loader": "~0.8.1", - "raw-loader": "~0.5.1", - "resolve-url-loader": "~2.1.0", - "tns-platform-declarations": "^3.1.0", - "tslint": "~5.4.3", - "typescript": "~2.3.0", - "webpack": "~3.8.1", - "webpack-bundle-analyzer": "^2.8.2", - "webpack-sources": "~1.0.1" - }, - "scripts": { - "build.plugin": "cd ../src && npm run build", - "ci.tslint": "npm i && tslint --config '../tslint.json' 'app/**/*.ts' --exclude '**/node_modules/**'" - } -} diff --git a/demo/references.d.ts b/demo/references.d.ts deleted file mode 100644 index 1e5e961..0000000 --- a/demo/references.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -/// diff --git a/demo/tsconfig.json b/demo/tsconfig.json deleted file mode 100644 index ed6d540..0000000 --- a/demo/tsconfig.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "declaration": false, - "removeComments": true, - "noLib": false, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "lib": [ - "es6", - "dom" - ], - "pretty": true, - "allowUnreachableCode": false, - "allowUnusedLabels": false, - "noEmitHelpers": true, - "noEmitOnError": false, - "noImplicitAny": false, - "noImplicitReturns": true, - "noImplicitUseStrict": false, - "noFallthroughCasesInSwitch": true, - "baseUrl": ".", - "paths": { - "*": [ - "./node_modules/*" - ] - } - }, - "exclude": [ - "node_modules", - "platforms" - ], - "compileOnSave": false -} \ No newline at end of file diff --git a/seed-tests/e2e/config/appium.capabilities.json b/seed-tests/e2e/config/appium.capabilities.json new file mode 100644 index 0000000..7a7e908 --- /dev/null +++ b/seed-tests/e2e/config/appium.capabilities.json @@ -0,0 +1,128 @@ +{ + "android19": { + "platformName": "Android", + "platformVersion": "4.4", + "deviceName": "Emulator-Api19-Default", + "avd": "Emulator-Api19-Default", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android21": { + "platformName": "Android", + "platformVersion": "5.0", + "deviceName": "Emulator-Api21-Default", + "avd": "Emulator-Api21-Default", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android23": { + "platformName": "Android", + "platformVersion": "6.0", + "deviceName": "Emulator-Api23-Default", + "avd": "Emulator-Api23-Default", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android24": { + "platformName": "Android", + "platformVersion": "7.0", + "deviceName": "Android GoogleAPI Emulator", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": true, + "fullReset": false, + "app": "", + "idleTimeout": 120, + "automationName": "Appium" + }, + "android25": { + "platformName": "Android", + "platformVersion": "7.1", + "deviceName": "Emulator-Api25-Google", + "avd": "Emulator-Api25-Google", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android26": { + "platformName": "Android", + "platformVersion": "8.0", + "deviceName": "Emulator-Api26-Google", + "avd": "Emulator-Api26-Google", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android27": { + "platformName": "Android", + "platformVersion": "27", + "deviceName": "Emulator-Api27-Google", + "avd": "Emulator-Api27-Google", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android28": { + "platformName": "Android", + "platformVersion": "28", + "deviceName": "Emulator-Api28-Google", + "avd": "Emulator-Api28-Google", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "sim.iPhone7": { + "platformName": "iOS", + "platformVersion": "/12.*/", + "deviceName": "iPhone 7", + "noReset": false, + "fullReset": false, + "app": "" + }, + "sim.iPhone8": { + "platformName": "iOS", + "platformVersion": "/12*/", + "deviceName": "iPhone 8", + "noReset": false, + "fullReset": false, + "app": "" + }, + "sim12iPhoneX": { + "platformName": "iOS", + "platformVersion": "12.0", + "deviceName": "iPhone X", + "appium-version": "1.9.1", + "app": "", + "noReset": true, + "fullReset": false, + "density": 3, + "offsetPixels": 87, + "idleTimeout": 120, + "automationName": "Appium" + }, + "sim.iPhoneXS": { + "platformName": "ios", + "platformVersion": "/12*/", + "deviceName": "iPhone XS", + "noReset": false, + "fullReset": false, + "app": "" + } +} \ No newline at end of file diff --git a/seed-tests/e2e/config/mocha.opts b/seed-tests/e2e/config/mocha.opts new file mode 100644 index 0000000..d7d26a6 --- /dev/null +++ b/seed-tests/e2e/config/mocha.opts @@ -0,0 +1,5 @@ +--timeout 800000 +--recursive e2e +--reporter mocha-multi +--reporter-options mochawesome=-,mocha-junit-reporter=test-results.xml +--exit \ No newline at end of file diff --git a/seed-tests/e2e/setup.ts b/seed-tests/e2e/setup.ts new file mode 100644 index 0000000..40afb8b --- /dev/null +++ b/seed-tests/e2e/setup.ts @@ -0,0 +1,24 @@ +import { startServer, stopServer, ITestReporter, nsCapabilities, LogImageType } from "nativescript-dev-appium"; +const addContext = require('mochawesome/addContext'); + +const testReporterContext = {}; +testReporterContext.name = "mochawesome"; +/** + * This folder should be the one provided in mocha.opts. + * If omitted the default one is "mochawesome-report". + * This is necessary because we need the logged images to be relatively + * positioned according to mochawesome.html in the same folder + */ +testReporterContext.reportDir = "mochawesome-report"; +testReporterContext.log = addContext; +testReporterContext.logImageTypes = [LogImageType.screenshots]; +nsCapabilities.testReporter = testReporterContext; + +before("start server", async function () { + nsCapabilities.testReporter.context = this; + await startServer(); +}); + +after("stop server", async function () { + await stopServer(); +}); diff --git a/seed-tests/e2e/tests.e2e.ts b/seed-tests/e2e/tests.e2e.ts new file mode 100644 index 0000000..f5f0519 --- /dev/null +++ b/seed-tests/e2e/tests.e2e.ts @@ -0,0 +1,55 @@ +import { AppiumDriver, createDriver, SearchOptions, nsCapabilities } from "nativescript-dev-appium"; +import { isSauceLab } from "nativescript-dev-appium/lib/parser"; +import { expect } from "chai"; +import "mocha"; + +const fs = require('fs'); +const addContext = require('mochawesome/addContext'); +const rimraf = require('rimraf'); +const isSauceRun = isSauceLab; + +describe("sample scenario", () => { + let driver: AppiumDriver; + + before(async function() { + nsCapabilities.testReporter.context = this; + driver = await createDriver(); + driver.defaultWaitTime = 20000; + let dir = "mochawesome-report"; + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } + rimraf('mochawesome-report/*', function () { }); + }); + + after(async function () { + if (isSauceRun) { + driver.sessionId().then(function (sessionId) { + console.log("Report: https://saucelabs.com/beta/tests/" + sessionId); + }); + } + await driver.quit(); + console.log("Driver successfully quit"); + }); + + afterEach(async function () { + if (this.currentTest.state && this.currentTest.state === "failed") { + let png = await driver.logScreenshot(this.currentTest.title); + fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) { + if (err) { + throw err; + } + console.log('Screenshot saved.'); + }); + addContext(this, './' + this.currentTest.title + '.png'); + } + }); + + it("should find an element by text", async function () { + const alertTitle = await driver.findElementByText("Alert", SearchOptions.contains); + expect(alertTitle).to.exist; + + const okBtn = await driver.findElementByText("OK", SearchOptions.contains); + await okBtn.click(); + }); +}); \ No newline at end of file diff --git a/seed-tests/e2e/tsconfig.json b/seed-tests/e2e/tsconfig.json new file mode 100644 index 0000000..0c3f525 --- /dev/null +++ b/seed-tests/e2e/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "importHelpers": false, + "types": [ + "mocha", + "chai", + "node" + ], + "lib": [ + "es2015", + "dom" + ], + "baseUrl": "." + } +} \ No newline at end of file diff --git a/seed-tests/package.json b/seed-tests/package.json index b5eafb8..57373f9 100644 --- a/seed-tests/package.json +++ b/seed-tests/package.json @@ -1,14 +1,28 @@ { "devDependencies": { "async": "^2.4.1", + "cross-env": "^5.1.3", "glob": "^7.1.2", "jasmine": "^2.6.0", "ncp": "^2.0.0", - "rimraf": "^2.6.1" + "rimraf": "^2.6.1", + "@types/chai": "~4.1.7", + "@types/mocha": "~5.2.5", + "@types/node": "~10.12.18", + "chai": "^4.1.2", + "mocha": "^5.2.0", + "mocha-junit-reporter": "~1.18.0", + "mocha-multi": "~1.0.1", + "mochawesome": "~3.1.2", + "nativescript-dev-appium": "^5.3.0", + "nativescript-dev-typescript": "~0.10.0", + "nativescript-dev-webpack": "~0.24.0" }, "scripts": { - "test.android": "ANDROID=true jasmine --config=jasmine.config.json", - "test.ios": "IOS=true jasmine --config=jasmine.config.json" + "test.android": "cross-env ANDROID=true jasmine --config=jasmine.config.json", + "test.ios": "cross-env IOS=true jasmine --config=jasmine.config.json", + "e2e": "node ./node_modules/nativescript-dev-appium/check-dev-deps.js && tsc -p e2e && mocha --opts ./e2e/config/mocha.opts", + "e2e-watch": "tsc -p e2e --watch" }, "dependencies": {} -} \ No newline at end of file +} diff --git a/seed-tests/postclone.tests.js b/seed-tests/postclone.tests.js index 6c9aaeb..2a52b66 100644 --- a/seed-tests/postclone.tests.js +++ b/seed-tests/postclone.tests.js @@ -3,6 +3,7 @@ var fs = require('fs'); var glob = require("glob"); var testUtils = require("./tests.utils"); var constants = require("./tests.constants"); +var path = require("path"); var _srcReadmeContent = ""; @@ -16,7 +17,7 @@ describe('postclone', function () { done.fail(err); } - testUtils.callPostclone(constants.SEED_COPY_LOCATION, constants.TEST_GITHUB_USERNAME, constants.TEST_PLUGIN_NAME, "y", function (error) { + testUtils.callPostclone(constants.SEED_COPY_LOCATION, constants.TEST_GITHUB_USERNAME, constants.TEST_PLUGIN_NAME, "y", "n", "n", function (error) { if (error) { done.fail(error); } else { @@ -36,7 +37,7 @@ describe('postclone', function () { } _srcReadmeContent = fs.readFileSync(constants.SEED_LOCATION + "/src/README.md"); - testUtils.callPostclone(constants.SEED_COPY_LOCATION, constants.TEST_GITHUB_USERNAME, constants.TEST_PLUGIN_NAME, "n", function (error, stdout) { + testUtils.callPostclone(constants.SEED_COPY_LOCATION, constants.TEST_GITHUB_USERNAME, constants.TEST_PLUGIN_NAME, "n", "n", "n", function (error, stdout) { if (error) { done.fail(error); } else { @@ -49,24 +50,154 @@ describe('postclone', function () { }); }); + it('should create only TypeScript app (demo)', function (done) { + testUtils.copySeedDir(constants.SEED_LOCATION, constants.SEED_COPY_LOCATION, function (err) { + if (err) { + done.fail(err); + } + + _srcReadmeContent = fs.readFileSync(constants.SEED_LOCATION + "/src/README.md"); + testUtils.callPostclone(constants.SEED_COPY_LOCATION, constants.TEST_GITHUB_USERNAME, constants.TEST_PLUGIN_NAME, "n", "y", "n", function (error, stdout) { + if (error) { + done.fail(error); + } else { + var seedCopyPath = path.resolve(__dirname, constants.SEED_COPY_LOCATION); + let tsConfigContents = fs.readFileSync(seedCopyPath + "/demo/tsconfig.json").toString('utf-8'); + + expect(fs.existsSync(seedCopyPath + "/demo")).toBe(true); + expect(stdout.includes("Updating ../demo/")).toBe(true); + expect(tsConfigContents.includes("app/*")).toBe(true); + + expect(fs.existsSync(seedCopyPath + "/demo-angular")).toBe(false); + expect(stdout.includes("Updating ../demo-angular/")).toBe(false); + + done(); + } + }); + }); + }); + + it('should create only TypeScript app (demo) for Release branch', function (done) { + testUtils.copySeedDir(constants.SEED_LOCATION, constants.SEED_COPY_LOCATION, function (err) { + if (err) { + done.fail(err);x + } + + _srcReadmeContent = fs.readFileSync(constants.SEED_LOCATION + "/src/README.md"); + testUtils.callPostcloneForBranch(constants.SEED_COPY_LOCATION, constants.TEST_GITHUB_USERNAME, constants.TEST_PLUGIN_NAME, "n", "y", "n", function (error, stdout) { + if (error) { + done.fail(error); + } else { + var seedCopyPath = path.resolve(__dirname, constants.SEED_COPY_LOCATION); + let tsConfigContents = fs.readFileSync(seedCopyPath + "/demo/tsconfig.json").toString('utf-8'); + + expect(fs.existsSync(seedCopyPath + "/demo")).toBe(true); + expect(stdout.includes("Updating ../demo/")).toBe(true); + expect(stdout.includes("Creating 'TypeScript' application from branch release...")).toBe(true); + expect(tsConfigContents.includes("app/*")).toBe(true); + + expect(fs.existsSync(seedCopyPath + "/demo-angular")).toBe(false); + expect(stdout.includes("Updating ../demo-angular/")).toBe(false); + + done(); + } + }); + }); + }); + + it('should create only Angular app (demo-angular)', function (done) { + testUtils.copySeedDir(constants.SEED_LOCATION, constants.SEED_COPY_LOCATION, function (err) { + if (err) { + done.fail(err); + } + + _srcReadmeContent = fs.readFileSync(constants.SEED_LOCATION + "/src/README.md"); + testUtils.callPostclone(constants.SEED_COPY_LOCATION, constants.TEST_GITHUB_USERNAME, constants.TEST_PLUGIN_NAME, "n", "n", "y", function (error, stdout) { + if (error) { + done.fail(error); + } else { + var seedCopyPath = path.resolve(__dirname, constants.SEED_COPY_LOCATION); + expect(fs.existsSync(seedCopyPath + "/demo")).toBe(false); + expect(stdout.includes("Updating ../demo/")).toBe(false); + + let angularTsConfigContents = fs.readFileSync(seedCopyPath + "/demo-angular/tsconfig.json").toString('utf-8'); + + expect(fs.existsSync(seedCopyPath + "/demo-angular")).toBe(true); + expect(stdout.includes("Updating ../demo-angular/")).toBe(true); + expect(angularTsConfigContents.includes("src/*")).toBe(true); + + done(); + } + }); + }); + }); + + it('should create both TypeScript & Angular app (demo & demo-angular)', function (done) { + testUtils.copySeedDir(constants.SEED_LOCATION, constants.SEED_COPY_LOCATION, function (err) { + if (err) { + done.fail(err); + } + + _srcReadmeContent = fs.readFileSync(constants.SEED_LOCATION + "/src/README.md"); + testUtils.callPostclone(constants.SEED_COPY_LOCATION, constants.TEST_GITHUB_USERNAME, constants.TEST_PLUGIN_NAME, "n", "y", "y", function (error, stdout) { + if (error) { + done.fail(error); + } else { + var seedCopyPath = path.resolve(__dirname, constants.SEED_COPY_LOCATION); + let tsConfigContents = fs.readFileSync(seedCopyPath + "/demo/tsconfig.json").toString('utf-8'); + + expect(fs.existsSync(seedCopyPath + "/demo")).toBe(true); + expect(stdout.includes("Updating ../demo/")).toBe(true); + expect(tsConfigContents.includes("app/*")).toBe(true); + + let angularTsConfigContents = fs.readFileSync(seedCopyPath + "/demo-angular/tsconfig.json").toString('utf-8'); + + expect(fs.existsSync(seedCopyPath + "/demo-angular")).toBe(true); + expect(stdout.includes("Updating ../demo-angular/")).toBe(true); + expect(angularTsConfigContents.includes("src/*")).toBe(true); + + done(); + } + }); + }); + }); + it('should delete the seed screenshots folder', function () { expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/screenshots")).toBeFalsy(); }); - it('should delete the seed scripts folder', function () { - expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/src/scripts")).toBeFalsy(); + it('should delete the seed CONTRIBUTING.md', function () { + expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/CONTRIBUTING.md")).toBeFalsy(); + }); + + it('should delete the seed CODE_OF_CONDUCT.md', function () { + expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/CODE_OF_CONDUCT.md")).toBeFalsy(); + }); + + it('should delete the postclone.js', function () { + expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/src/scripts/postclone.js")).toBeFalsy(); + }); + + it('should delete the postclone script', function () { + let packageJsonContents = fs.readFileSync(constants.SEED_COPY_LOCATION + "/src/package.json").toString('utf-8'); + expect(packageJsonContents.includes("postclone")).toBeFalsy(); }); it('should delete the seed tests folder', function () { expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/seed-tests")).toBeFalsy(); }); - it('should replace the seed README with the plugin one', function () { + it('should rename each yourplugin file with the new plugin name in README', function () { expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/README.md")).toBeTruthy(); - expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/src/README.md")).toBeFalsy(); var readmeContent = fs.readFileSync(constants.SEED_COPY_LOCATION + "/README.md"); - expect(_srcReadmeContent).toEqual(readmeContent); + expect(readmeContent).toContain("nativescript-" + constants.TEST_PLUGIN_NAME); + expect(readmeContent).toContain("tns plugin add nativescript-" + constants.TEST_PLUGIN_NAME); + }); + + it('should remove old src/README and create a new /README', function() { + expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/README.md")).toBeTruthy(); + expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/src/README.md")).toBeFalsy(); }); it('should rename each yourplugin file', function (done) { @@ -132,32 +263,4 @@ describe('postclone', function () { done(); }); }); - - it('should create an npm link to the src folder', function (done) { - testUtils.getNpmLinks(function (links) { - var expectedLink = links.filter(function (item) { - return item.startsWith("nativescript-" + constants.TEST_PLUGIN_NAME + "@1.0.0") && item.endsWith(constants.SEED_COPY_LOCATION + "/src"); - }); - - expect(expectedLink.length).toEqual(1); - done(); - }); - }); - - it('should link the plugin in the demo folder', function (done) { - var demoPluginPackageJson = constants.SEED_COPY_LOCATION + "/demo/node_modules/nativescript-" + constants.TEST_PLUGIN_NAME + "/package.json"; - var srcPluginPackageJson = constants.SEED_COPY_LOCATION + "/src/package.json"; - - expect(fs.realpathSync(demoPluginPackageJson)).toEqual(fs.realpathSync(srcPluginPackageJson)); - done(); - }); - - it('should prepare a working demo with passing tests', function (done) { - var testsCommand = "cd " + constants.SEED_COPY_LOCATION + "/src && npm run test"; - testsCommand += testUtils.isAndroid() ? ".android" : ".ios"; - exec(testsCommand, function (error, stdout, stderr) { - expect(error).toBeNull(); - done(); - }); - }); }); \ No newline at end of file diff --git a/seed-tests/tests.constants.js b/seed-tests/tests.constants.js index 7115dab..c45ac53 100644 --- a/seed-tests/tests.constants.js +++ b/seed-tests/tests.constants.js @@ -1,5 +1,6 @@ exports.SEED_LOCATION = "../"; exports.SEED_COPY_LOCATION = "seed-copy"; +exports.SEED_TESTS_LOCATION = "seed-tests"; exports.DEFAULT_PLUGIN_NAME = "nativescript-yourplugin"; exports.TEST_PLUGIN_NAME = "ThePlugin"; exports.TEST_GITHUB_USERNAME = "TheGitHubUser"; diff --git a/seed-tests/tests.utils.js b/seed-tests/tests.utils.js index aa69e0f..0b88ee0 100644 --- a/seed-tests/tests.utils.js +++ b/seed-tests/tests.utils.js @@ -51,11 +51,10 @@ exports.copySeedDir = function copySeedDir(seedLocation, copyLocation, callback) rimraf.sync(copyLocation); ncp(seedLocation, copyLocation, { - filter: function (fileName) { - if (fileName.indexOf("seed-tests/" + constants.SEED_COPY_LOCATION) > -1 || - fileName.indexOf("demo/node_modules") > -1 || - fileName.indexOf("src/node_modules") > -1 || - fileName.indexOf("demo/platforms") > -1) { + filter: function (fileName) { + if ((fileName.indexOf("seed-tests") > -1 && fileName.indexOf(constants.SEED_COPY_LOCATION) > -1) || + (fileName.indexOf("seed-tests") > -1 && fileName.indexOf("node_modules") > -1) || + (fileName.indexOf("src") > -1 && fileName.indexOf("node_modules") > -1)) { return false; } @@ -69,9 +68,19 @@ exports.copySeedDir = function copySeedDir(seedLocation, copyLocation, callback) }); }; -exports.callPostclone = function callPostclone(seedLocation, githubUsername, pluginName, initGit, callback) { +exports.callPostclone = function callPostclone(seedLocation, githubUsername, pluginName, initGit, includeTypeScriptDemo, includeAngularDemo, callback) { var postcloneScript = getPackageJsonPostcloneScript(); - postcloneScript = postcloneScript.replace("postclone.js", "postclone.js gitHubUsername=" + githubUsername + " pluginName=" + pluginName + " initGit=" + initGit); + postcloneScript = postcloneScript.replace("postclone.js", "postclone.js gitHubUsername=" + githubUsername + " pluginName=" + pluginName + " initGit=" + initGit + " includeTypeScriptDemo=" + includeTypeScriptDemo + " includeAngularDemo=" + includeAngularDemo); + console.log("Executing postclone script with args: " + postcloneScript); + exec("cd " + seedLocation + "/src && " + postcloneScript, function (error, stdout, stderr) { + callback(error, stdout, stderr); + }); +}; + +exports.callPostcloneForBranch = function callPostcloneForBranch(seedLocation, githubUsername, pluginName, initGit, includeTypeScriptDemo, includeAngularDemo, callback) { + var postcloneScript = getPackageJsonPostcloneScript(); + postcloneScript = postcloneScript.replace("postclone.js", "postclone.js templatesBranch=release gitHubUsername=" + githubUsername + " pluginName=" + pluginName + " initGit=" + initGit + " includeTypeScriptDemo=" + includeTypeScriptDemo + " includeAngularDemo=" + includeAngularDemo); + console.log("Executing postclone script with args: " + postcloneScript); exec("cd " + seedLocation + "/src && " + postcloneScript, function (error, stdout, stderr) { callback(error, stdout, stderr); }); diff --git a/src/.npmignore b/src/.npmignore index 6dcf540..43534c9 100644 --- a/src/.npmignore +++ b/src/.npmignore @@ -1,4 +1,10 @@ *.map *.ts !*.d.ts -tsconfig.json \ No newline at end of file +tsconfig.json +scripts/* +platforms/android/* +!platforms/android/include.gradle +!platforms/android/*.aar +!platforms/android/*.jar +.DS_Store \ No newline at end of file diff --git a/src/.travis.yml b/src/.travis.yml index 1f93147..c01d293 100644 --- a/src/.travis.yml +++ b/src/.travis.yml @@ -3,39 +3,39 @@ matrix: - stage: "Lint" language: node_js os: linux - node_js: "6" - script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint + node_js: "10" + script: cd src && npm run ci.tslint - stage: "WebPack, Build and Test" os: osx env: - WebPack="iOS" - osx_image: xcode9.2 + osx_image: xcode10.2 language: node_js - node_js: "6" + node_js: "10" jdk: oraclejdk8 - script: cd demo && npm run build.plugin && npm i && tns build ios --bundle --env.uglify + script: cd src && npm run build && cd ../demo && npm i && tns build ios --bundle --env.uglify - language: android os: linux env: - WebPack="Android" jdk: oraclejdk8 - before_install: nvm install 6.10.3 - script: cd demo && npm run build.plugin && npm i && tns build android --bundle --env.uglify --env.snapshot + before_install: nvm install 10 + script: cd src && npm run build && cd ../demo && npm i && tns build android --bundle --env.uglify --env.snapshot - language: android env: - - BuildAndroid="26" + - BuildAndroid="28" os: linux jdk: oraclejdk8 - before_install: nvm install stable + before_install: nvm install 10 script: - cd src && npm i && npm run tsc && cd ../demo && tns build android - os: osx env: - - BuildiOS="11" - - Xcode="9.2" - osx_image: xcode9.2 + - BuildiOS="12" + - Xcode="10.0" + osx_image: xcode10.2 language: node_js - node_js: "6" + node_js: "10" jdk: oraclejdk8 script: - cd src && npm i && npm run tsc && cd ../demo && tns build ios @@ -49,26 +49,29 @@ matrix: - emulator -avd test -no-audio -no-window & - android-wait-for-emulator before_install: - - nvm install 6 + - nvm install 10 script: cd src && npm run test.android - os: osx language: node_js - node_js: "6" + node_js: "10" jdk: oraclejdk8 - osx_image: xcode9.2 + osx_image: xcode10.2 script: cd src && npm run test.ios android: components: - tools - platform-tools - - build-tools-26.0.1 - - android-26 - - android-23 + - build-tools-28.0.3 + - android-28 - extra-android-m2repository - sys-img-armeabi-v7a-android-21 +before_install: + - sudo pip install --upgrade pip + - sudo pip install six + install: - echo no | npm install -g nativescript - tns usage-reporting disable - - tns error-reporting disable \ No newline at end of file + - tns error-reporting disable diff --git a/src/README.md b/src/README.md index 0fd119f..46d3ce3 100644 --- a/src/README.md +++ b/src/README.md @@ -1,4 +1,4 @@ -# Your Plugin Name +# nativescript-yourplugin Add your plugin badges here. See [nativescript-urlhandler](https://github.com/hypery2k/nativescript-urlhandler) for example. @@ -15,7 +15,7 @@ Describe the prerequisites that the user need to have installed before using you Describe your plugin installation steps. Ideally it would be something like: ```javascript -tns plugin add +tns plugin add nativescript-yourplugin ``` ## Usage diff --git a/src/package.json b/src/package.json index eb5be5a..e92b64f 100644 --- a/src/package.json +++ b/src/package.json @@ -6,25 +6,22 @@ "typings": "index.d.ts", "nativescript": { "platforms": { - "android": "3.0.0", - "ios": "3.0.0" + "android": "6.0.0", + "ios": "6.0.1" } }, + "repository": { + "type": "git", + "url": "https://github.com/YourName/nativescript-yourplugin.git" + }, "scripts": { - "tsc": "tsc -skipLibCheck", - "build": "npm i && tsc", - "postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src && npm run plugin.link", - "test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch", - "test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch", + "tsc": "npm i && tsc", + "build": "npm run tsc && npm run build.native", + "build.native": "node scripts/build-native.js", + "postclone": "npm i && node scripts/postclone.js", "tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\"", - "plugin.link": "npm link && cd ../demo && npm link nativescript-yourplugin && cd ../src", - "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 && rimraf platforms", - "plugin.prepare": "npm run tsc && cd ../demo && tns plugin remove nativescript-yourplugin && tns plugin add ../src", - "clean": "cd ../demo && rimraf hooks node_modules platforms && cd ../src && rimraf node_modules && npm run plugin.link", - "ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**'" + "ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/platforms/**'", + "prepack": "npm run build.native" }, "keywords": [ "NativeScript", @@ -41,14 +38,14 @@ }, "license": "Apache-2.0", "homepage": "https://github.com/YourName/nativescript-yourplugin", - "readmeFilename": "README.md", "devDependencies": { - "tns-core-modules": "^3.1.0", - "tns-platform-declarations": "^3.1.0", - "typescript": "~2.3.0", + "tns-core-modules": "^6.0.0", + "tns-platform-declarations": "^6.0.0", + "typescript": "~3.4.5", "prompt": "^1.0.0", - "rimraf": "^2.5.0", - "tslint": "^5.0.0" + "rimraf": "^2.6.3", + "tslint": "^5.12.1", + "semver": "^5.6.0" }, "dependencies": {}, "bootstrapper": "nativescript-plugin-seed" diff --git a/src/platforms/android/include.gradle b/src/platforms/android/include.gradle index 90a6cd2..612a631 100644 --- a/src/platforms/android/include.gradle +++ b/src/platforms/android/include.gradle @@ -1,15 +1,11 @@ /* Include.gradle configuration: http://docs.nativescript.org/plugins/plugins#includegradle-specification */ android { - productFlavors { - "nativescript-yourplugin" { - dimension "nativescript-yourplugin" - } - } + } dependencies { // Describe plugin native Android dependencies like - // compile "groupName:pluginName:ver" - // EXAMPLE: compile "com.facebook.fresco:fresco:0.9.0+" + // implementation "groupName:pluginName:ver" + // EXAMPLE: implementation "com.facebook.fresco:fresco:0.9.0+" } \ No newline at end of file diff --git a/src/scripts/build-native.js b/src/scripts/build-native.js new file mode 100644 index 0000000..dd96312 --- /dev/null +++ b/src/scripts/build-native.js @@ -0,0 +1,32 @@ +const { exec } = require('child_process'); +const semver = require('semver'); + +exec('tns --version', (err, stdout, stderr) => { + if (err) { + // node couldn't execute the command + console.log(`tns --version err: ${err}`); + return; + } + + // In case the current Node.js version is not supported by CLI, a warning in `tns --version` output is shown. + // Sample output: + // + /*Support for Node.js ^8.0.0 is deprecated and will be removed in one of the next releases of NativeScript. Please, upgrade to the latest Node.js LTS version. + + 6.0.0 + */ + // Extract the actual version (6.0.0) from it. + const tnsVersion = semver.major((stdout.match(/^(?:\d+\.){2}\d+.*?$/m) || [])[0]); + + // execute 'tns plugin build' for {N} version > 4. This command builds .aar in platforms/android folder. + if (tnsVersion >= 4) { + console.log(`executing 'tns plugin build'`); + exec('tns plugin build', (err, stdout, stderr) => { + if (err) { + // node couldn't execute the command + console.log(`${err}`); + return; + } + }); + } +}); diff --git a/src/scripts/postclone.js b/src/scripts/postclone.js index ed2d253..1b3c92b 100644 --- a/src/scripts/postclone.js +++ b/src/scripts/postclone.js @@ -2,19 +2,32 @@ var fs = require('fs'); var prompt = require('prompt'); var rimraf = require('rimraf'); var exec = require('child_process').exec; +const spawn = require('child_process').spawn; +const pathModule = require("path"); var class_name, inputParams = { plugin_name: undefined, github_username: undefined, - init_git: undefined + init_git: undefined, + include_javascript_demo: undefined, + include_typescript_demo: undefined, + include_angular_demo: undefined, + include_vue_demo: undefined, + templates_branch: undefined }, seed_plugin_name = "yourplugin", seed_class_name = "YourPlugin", seed_demo_property_name = "yourPlugin", seed_github_username = "YourName", - demo_folder = "../demo", + tsAppName = "demo", + angularAppName = "demo-angular", + // vueAppName = "demo-vue", + demoTsFolder = "../" + tsAppName, + demoAngularFolder = "../" + angularAppName, + // demoVueFolder = "../" + vueAppName, screenshots_dir = "../screenshots", + templates_dir = "../nativescript-app-templates", seed_tests_dir = "../seed-tests", scripts_dir = "scripts", filesToReplace = { @@ -26,10 +39,62 @@ var class_name, source: ".travis.yml", destination: "../.travis.yml" } + }, + appsToCreate = [], + appsToInstallPluginIn = [], + demoTsSearchTerm = ".bindingContext =", + demoAngularSearchTerm = 'templateUrl: "app.component.html"', + demoVueSearchTerm = '', + preDefinedInclude = [ + "../src", + "**/*" + ], + preDefinedExclude = [ + "../src/node_modules", + "node_modules", + "platforms" + ], + preDefinedPaths = [ + { + key: "*", + value: [ + "./node_modules/*" + ] + } + ], + appNamePlaceholderStr = "appNamePlaceholder", + pluginNamePlaceholderStr = "pluginNamePlaceholder", + appPathPlaceholderStr = "appPathPlaceholder", + removeAddPluginCommand = "cd appNamePlaceholder && tns plugin remove pluginNamePlaceholder && tns plugin add ../src", + removeAddPluginCommandPlaceholderStr = "removeAddPluginCommandPlaceholder", + cleanAppsScriptPlaceholderStr = "cleanAppsScriptPlaceholder", + preDefinedAppScripts = [ + { + key: "appNamePlaceholder.ios", + value: "npm i && cd appPathPlaceholder && tns run ios" + }, + { + key: "appNamePlaceholder.android", + value: "npm i && cd appPathPlaceholder && tns run android" + }], + preDefinedPrepareScript = + { + key: "plugin.prepare", + value: "npm run build removeAddPluginCommandPlaceholder" + }, + preDefinedResetScript = { + key: "appNamePlaceholder.reset", + value: "cd appPathPlaceholder && npx rimraf -- hooks node_modules platforms package-lock.json" + }, + preDefinedCleanScript = { + key: "clean", + value: "cleanAppsScriptPlaceholder && npx rimraf -- node_modules package-lock.json && npm i", }; console.log('NativeScript Plugin Seed Configuration'); +// Expected order: `gitHubUsername` `pluginName` `initGit` `includeTypeScriptDemo` `includeAngularDemo` +// Example: gitHubUsername=PluginAuthor pluginName=myPluginClassName initGit=n includeTypeScriptDemo=y includeAngularDemo=n var parseArgv = function () { var argv = Array.prototype.slice.call(process.argv, 2); var result = {}; @@ -37,14 +102,29 @@ var parseArgv = function () { var pair = pairString.split('='); result[pair[0]] = pair[1]; }); + return result; }; var argv = parseArgv(); -if (argv.gitHubUsername !== undefined && argv.pluginName !== undefined && argv.initGit !== undefined) { +if (argv) { inputParams.github_username = argv.gitHubUsername; inputParams.plugin_name = argv.pluginName; - inputParams.init_git = argv.initGit + inputParams.init_git = argv.initGit; + inputParams.include_typescript_demo = argv.includeTypeScriptDemo; + inputParams.include_angular_demo = argv.includeAngularDemo; + // inputParams.include_vue_demo = argv.includeVueDemo; + inputParams.templates_branch = argv.templatesBranch; +} + +if (!isInteractive() && (!inputParams.github_username || !inputParams.plugin_name || !inputParams.init_git || !inputParams.include_typescript_demo || !inputParams.include_angular_demo)) { + console.log("Using default values for plugin creation since your shell is not interactive."); + inputParams.github_username = "PluginAuthor"; + inputParams.plugin_name = "myPluginClassName"; + inputParams.init_git = "y"; + inputParams.include_typescript_demo = "y"; + inputParams.include_angular_demo = "n"; + // inputParams.include_vue_demo = "n"; } askGithubUsername(); @@ -56,7 +136,7 @@ function askGithubUsername() { prompt.start(); prompt.get({ name: 'github_username', - description: 'What is your GitHub username (used for updating package.json)? Example: NathanWalker / EddyVerbruggen' + description: 'What is your GitHub username (used for updating package.json)? Example: NathanWalker' }, function (err, result) { if (err) { return console.log(err); @@ -96,8 +176,158 @@ function askPluginName() { } } +function askTypeScriptDemo() { + if (inputParams.include_typescript_demo !== undefined) { + askAngularDemo(); + } else { + prompt.start(); + prompt.get({ + name: 'include_typescript_demo', + description: 'Do you want to include a "TypeScript NativeScript" application linked with your plugin to make development easier (y/n)?', + default: 'y' + }, function (err, result) { + if (err) { + return console.log(err); + } + + inputParams.include_typescript_demo = result.include_typescript_demo; + askAngularDemo(); + }); + } +} + +function askAngularDemo() { + if (inputParams.include_angular_demo !== undefined) { + // askVueDemo(); + prepareDemoAppsFromTemplates(); + } else { + prompt.start(); + prompt.get({ + name: 'include_angular_demo', + description: 'Do you want to include an "Angular NativeScript" application linked with your plugin to make development easier (y/n)?', + default: 'n' + }, function (err, result) { + if (err) { + return console.log(err); + } + + inputParams.include_angular_demo = result.include_angular_demo; + // askVueDemo(); + prepareDemoAppsFromTemplates(); + }); + } +} + +// function askVueDemo() { +// if (inputParams.include_vue_demo !== undefined) { +// prepareDemoAppsFromTemplates(); +// } else { +// prompt.start(); +// prompt.get({ +// name: 'include_vue_demo', +// description: 'Do you want to include a "Vue NativeScript" application linked with your plugin to make development easier (y/n)?', +// default: 'n' +// }, function (err, result) { +// if (err) { +// return console.log(err); +// } + +// inputParams.include_vue_demo = result.include_vue_demo; +// prepareDemoAppsFromTemplates(); +// }); +// } +// } + +function prepareDemoAppsFromTemplates() { + let templatesOrigin = inputParams.templates_branch ? + "nativescript-app-templates/packages/template-blank" : + "tns-template-blank"; + let templatesOriginName = inputParams.templates_branch ? + "branch " + inputParams.templates_branch : + "latest published template"; + if (inputParams.include_typescript_demo && inputParams.include_typescript_demo.toLowerCase() === "y") { + appsToCreate.push({ + command: "cd ../ && tns create " + tsAppName + " --template " + templatesOrigin + "-ts && cd " + tsAppName + " && cd ../src/", + startMessage: "Creating 'TypeScript' application from " + templatesOriginName + "...", + successMessage: "TypeScript-NativeScript application created at: " + demoTsFolder, + type: "TypeScript" + }); + appsToInstallPluginIn.push(demoTsFolder); + } + + if (inputParams.include_angular_demo && inputParams.include_angular_demo.toLowerCase() === "y") { + appsToCreate.push({ + command: "cd ../ && tns create " + angularAppName + " --template " + templatesOrigin + "-ng && cd " + angularAppName + " && cd ../src/", + startMessage: "Creating 'Angular' application from " + templatesOriginName + "...", + successMessage: "Angular-NativeScript application created at: " + demoAngularFolder, + type: "Angular" + }); + appsToInstallPluginIn.push(demoAngularFolder); + } + + // if (inputParams.include_vue_demo && inputParams.include_vue_demo.toLowerCase() === "y") { + // appsToCreate.push({ + // command: "cd ../ && tns create " + vueAppName + " --vue && cd " + vueAppName + " && cd ../src/", + // startMessage: "Creating 'Vue' application from " + templatesOriginName + "...", + // successMessage: "Vue-NativeScript application created at: /demo-vue", + // type: "Vue" + // }); + // appsToInstallPluginIn.push(demoVueFolder); + // } + + if (appsToCreate.length > 0 && inputParams.templates_branch) { + console.log("Cloning repository NativeScript/nativescript-app-templates..."); + exec('cd ../ && git clone https://github.com/NativeScript/nativescript-app-templates.git', function (err, stdout, stderr) { + if (err) { + console.log(err); + } else { + console.log("Repository cloned."); + exec('cd ../nativescript-app-templates && git checkout ' + inputParams.templates_branch, function (err, stdout, stderr) { + if (err) { + console.log(err); + } else { + console.log("Checked out branch " + inputParams.templates_branch); + } + }); + + createDemoAppsFromTemplates(); + } + }); + } else { + createDemoAppsFromTemplates(); + } +} + +function createDemoAppsFromTemplates() { + let appObject = appsToCreate.pop(); + if (appObject) { + startProcess(appObject); + } else { + adjustScripts(); + } +} + +function startProcess(commandAndMessage) { + if (commandAndMessage.startMessage) { + console.log(commandAndMessage.startMessage); + } + let mainChildProcess = spawn(commandAndMessage.command, [], { stdio: 'inherit', shell: true, detached: false }); + mainChildProcess.on("close", function (code, signal) { + if (commandAndMessage.successMessage) { + console.log(commandAndMessage.successMessage); + } + + if (appsToCreate.length == 0) { + adjustScripts(); + } else { + let appObject = appsToCreate.pop(); + startProcess(appObject); + } + }); +} + function generateClassName() { - // the classname becomes 'GoogleMaps' when plugin_name is 'google_maps' + // the class_name becomes 'GoogleMaps' when plugin_name is 'google-maps' class_name = ""; var plugin_name_parts = inputParams.plugin_name.split("-"); for (var p in plugin_name_parts) { @@ -119,7 +349,7 @@ function renameFiles() { } } - adjustScripts(); + askTypeScriptDemo(); } function adjustScripts() { @@ -131,17 +361,44 @@ function adjustScripts() { // add include.gradle files.push("platforms/android/include.gradle"); - // add demo's package.json - files.push(demo_folder + "/package.json"); - // add the demo files - var demoFiles = fs.readdirSync(demo_folder + "/app/"); - for (var d in demoFiles) { - var demoFile = demoFiles[d]; - files.push(demo_folder + "/app/" + demoFile); + let demoAppPath = pathModule.join(demoTsFolder + "/app/home/"); + if (fs.existsSync(demoAppPath)) { + files.push(demoTsFolder + "/package.json"); + var demoFiles = fs.readdirSync(demoAppPath); + for (var d in demoFiles) { + var demoFile = demoFiles[d]; + files.push(demoAppPath + demoFile); + } + + updateAppsTsConfigFile(pathModule.resolve(__dirname, pathModule.join("../" + demoTsFolder))); + } + + // add the demo-angular files + let demoAngularAppPath = pathModule.join(demoAngularFolder + "/src/app/"); + if (fs.existsSync(demoAngularAppPath)) { + files.push(demoAngularFolder + "/package.json"); + var demoFiles = fs.readdirSync(demoAngularAppPath); + for (var d in demoFiles) { + var demoFile = demoFiles[d]; + files.push(demoAngularAppPath + demoFile); + } + + updateAppsTsConfigFile(pathModule.resolve(__dirname, pathModule.join("../" + demoAngularFolder))); + } - // add the tests - files.push(demo_folder + "/app/tests/tests.js"); + + // add the demo-angular files + // let demoVueAppPath = path.join(demoVueFolder + "/app/components/"); + // if (fs.existsSync(demoVueAppPath)) { + // files.push(demoVueFolder + "/package.json"); + // var demoFiles = fs.readdirSync(demoVueAppPath); + // for (var d in demoFiles) { + // var demoFile = demoFiles[d]; + // files.push(demoVueAppPath + demoFile); + // } + // updateAppsTsConfigFile(path.resolve(__dirname, path.join("../" + demoVueFolder))); + // } // prepare and cache a few Regexp thingies var regexp_seed_plugin_name = new RegExp(seed_plugin_name, "g"); @@ -154,6 +411,12 @@ function adjustScripts() { if (fs.lstatSync(file).isFile()) { var contents = fs.readFileSync(file, 'utf8'); + + // Adds an 'import' and console.log() of the 'message' filed of 'nativescript-yourplugin' to the includes apps + contents = file.includes(pathModule.join(demoTsFolder)) ? updateApp(contents, file, demoTsSearchTerm) : contents; + contents = file.includes(pathModule.join(demoAngularFolder)) ? updateApp(contents, file, demoAngularSearchTerm) : contents; + // contents = file.includes(pathModule.join(demoVueFolder)) ? updateDemoVueApp(contents, file) : contents; + var result = contents.replace(regexp_seed_plugin_name, inputParams.plugin_name); result = result.replace(regexp_seed_class_name, class_name); result = result.replace(regexp_seed_demo_property_name, class_name[0].toLowerCase() + class_name.substr(1)); @@ -163,29 +426,181 @@ function adjustScripts() { } replaceFiles(); + updateSrcJson(); } -function replaceFiles() { - for (key in filesToReplace) { - var file = filesToReplace[key]; - var contents = fs.readFileSync(file.source); - fs.writeFileSync(file.destination, contents); - fs.unlinkSync(file.source); +function updateAppsTsConfigFile(path) { + let jsonPath = pathModule.join(path + "/tsconfig.json"); + let jsonFile = fs.readFileSync(jsonPath); + let jsonObject = JSON.parse(jsonFile); + var jsonInclude = ensureJsonArray(jsonObject["include"]); + var newInclude = updateJsonArray(preDefinedInclude, jsonInclude); + jsonObject["include"] = newInclude; + var jsonExclude = ensureJsonArray(jsonObject["exclude"]); + var newExclude = updateJsonArray(preDefinedExclude, jsonExclude); + jsonObject["exclude"] = newExclude; + + var jsonPaths = ensureJsonArray(jsonObject["compilerOptions"])["paths"]; + var newPaths = updateObject(preDefinedPaths, jsonPaths); + jsonObject["compilerOptions"]["paths"] = newPaths; + + fs.writeFileSync(jsonPath, JSON.stringify(jsonObject, null, "\t")); +} + +function updateSrcJson() { + let jsonPath = pathModule.join(pathModule.resolve(__dirname, "../") + "/package.json"); + let jsonFile = fs.readFileSync(jsonPath); + let jsonObject = JSON.parse(jsonFile); + var jsonScripts = ensureJsonArray(jsonObject["scripts"]); + let pluginScripts = getPluginScripts(); + + var newScripts = updateObject(pluginScripts, jsonScripts); + delete newScripts["postclone"]; + jsonObject["scripts"] = newScripts; + + fs.writeFileSync(jsonPath, JSON.stringify(jsonObject, null, "\t")); +} + +function getPluginScripts() { + let scripts = []; + let prepareScriptCommand; + let clearScriptResetCommands = []; + let pluginName = `nativescript-` + inputParams.plugin_name; + if (inputParams.include_typescript_demo === "y") { + preDefinedAppScripts.forEach((script) => { + scripts.push( + { + key: script.key.replace(appNamePlaceholderStr, tsAppName), + value: script.value.replace(appPathPlaceholderStr, demoTsFolder) + }); + }); + let resetScriptKey = preDefinedResetScript.key.replace(appNamePlaceholderStr, tsAppName); + scripts.push({ + key: resetScriptKey, + value: preDefinedResetScript.value.replace(appPathPlaceholderStr, demoTsFolder) + }); + + clearScriptResetCommands.push(resetScriptKey); + + let updatedRemoveAddPluginCommand = removeAddPluginCommand.replace(appNamePlaceholderStr, demoTsFolder); + prepareScriptCommand = "&& " + updatedRemoveAddPluginCommand.replace(pluginNamePlaceholderStr, pluginName); } - rimraf(screenshots_dir, function () { - console.log('Screenshots removed.'); - rimraf(seed_tests_dir, function () { - console.log('Seed tests removed.'); + if (inputParams.include_angular_demo === "y") { + preDefinedAppScripts.forEach((script) => { + scripts.push( + { + key: script.key.replace(appNamePlaceholderStr, angularAppName), + value: script.value.replace(appPathPlaceholderStr, demoAngularFolder) + }); + }); + + let resetScriptKey = preDefinedResetScript.key.replace(appNamePlaceholderStr, angularAppName); + scripts.push({ + key: resetScriptKey, + value: preDefinedResetScript.value.replace(appPathPlaceholderStr, demoAngularFolder) + }); - // delete scripts folder - rimraf.sync(scripts_dir); + clearScriptResetCommands.push(resetScriptKey); - askInitGit(); + let updatedRemoveAddPluginCommand = removeAddPluginCommand.replace(appNamePlaceholderStr, demoAngularFolder); + prepareScriptCommand += " && " + updatedRemoveAddPluginCommand.replace(pluginNamePlaceholderStr, pluginName); + } + + if (inputParams.include_vue_demo) { + preDefinedAppScripts.forEach((script) => { + scripts.push( + { + key: script.key.replace(appNamePlaceholderStr, demoVueFolder), + value: script.value.replace(appPathPlaceholderStr, demoVueFolder) + }); }); + + let resetScriptKey = preDefinedResetScript.key.replace(appNamePlaceholderStr, angularAppName); + scripts.push({ + key: resetScriptKey, + value: preDefinedResetScript.value.replace(appPathPlaceholderStr, demoAngularFolder) + }); + + clearScriptResetCommands.push(resetScriptKey); + + let updatedRemoveAddPluginCommand = removeAddPluginCommand.replace(appNamePlaceholderStr, demoVueFolder); + prepareScriptCommand += " && " + updatedRemoveAddPluginCommand.replace(pluginNamePlaceholderStr, pluginName); + } + + scripts.push({ + key: preDefinedPrepareScript.key, + value: preDefinedPrepareScript.value.replace(removeAddPluginCommandPlaceholderStr, prepareScriptCommand) + }); + + let fullAppResetCommand = ""; + clearScriptResetCommands.forEach((tag) => { + fullAppResetCommand += fullAppResetCommand.length === 0 ? "npm run " + tag : " && npm run " + tag; + }); + + scripts.push({ + key: preDefinedCleanScript.key, + value: preDefinedCleanScript.value.replace(cleanAppsScriptPlaceholderStr, fullAppResetCommand) }); + + + + return scripts; +} + +function updateJsonArray(newValues, oldValues) { + newValues.forEach((value) => { + if (!oldValues.includes(value)) { + oldValues.push(value); + } + }); + + return oldValues; } +function updateObject(newObjects, oldObjects) { + newObjects.forEach((script) => { + oldObjects[script.key] = script.value; + }); + + return oldObjects; +} + +function ensureJsonArray(jsonSection) { + if (!jsonSection) { + return []; + } + + return jsonSection; +} + +function updateApp(contents, file, searchTerm) { + if (contents.includes(searchTerm)) { + let fullPluginName = `'nativescript-` + inputParams.plugin_name + `'`; + console.log("Updating " + file + " with " + fullPluginName + " import ."); + let typeScriptImportSnippet = `import { ` + class_name + ` } from ` + fullPluginName + `;\n`, + typeScriptAlertSnippet = `console.log(new ` + class_name + `().message);\n`; + contents = typeScriptAlertSnippet + contents; + contents = typeScriptImportSnippet + contents; + } + + return contents; +} + +// function updateDemoVueApp(contents, file) { +// if (contents.includes(demoVueSearchTerm)) { +// let pluginName = `'nativescript-`+ inputParams.plugin_name + `'`; +// console.log("Updating " + file + " with " + pluginName + " import"); +// let typeScriptImportSnippet = `import { ` + class_name + ` } from ` + pluginName + `;\n`, +// typeScriptAlertSnippet = `console.log(new ` + class_name + `().message);\n`; +// // contents = typeScriptAlertSnippet + contents; +// // contents = typeScriptImportSnippet + contents; +// // TODO: insert this after the