diff --git a/.github/issue_template.md b/.github/issue_template.md new file mode 100644 index 0000000..d103b9f --- /dev/null +++ b/.github/issue_template.md @@ -0,0 +1,28 @@ +### Make sure to check the demo app(s) for sample usage + +### Make sure to check the existing issues in this repository + +### If the demo apps cannot help and there is no issue for your problem, tell us about it +Please, ensure your title is less than 63 characters long and starts with a capital +letter. + +### Which platform(s) does your issue occur on? +- iOS/Android/Both +- iOS/Android versions +- emulator or device. What type of device? + +### Please, provide the following version numbers that your issue occurs with: + +- CLI: (run `tns --version` to fetch it) +- Cross-platform modules: (check the 'version' attribute in the +`node_modules/tns-core-modules/package.json` file in your project) +- Runtime(s): (look for the `"tns-android"` and `"tns-ios"` properties in the `package.json` file of your project) +- Plugin(s): (look for the version numbers in the `package.json` file of your +project and paste your dependencies and devDependencies here) + +### Please, tell us how to recreate the issue in as much detail as possible. +Describe the steps to reproduce it. + +### Is there any code involved? + - provide a code example to recreate the problem + - (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible. 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 8b49c30..5f5c757 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,26 @@ +.vscode +.idea +.DS_Store +*.esm.json *.js *.js.map *.log -!scripts/*.js -demo/app/*.js +src/*.d.ts +!src/index.d.ts +!src/references.d.ts +!src/scripts/*.js +!seed-tests/*.js +seed-tests/seed-copy +seed-tests/seed-copy-new-git-repo/**/*.* !demo/karma.conf.js !demo/app/tests/*.js demo/*.d.ts !demo/references.d.ts demo/lib demo/platforms -demo/node_modules -node_modules \ No newline at end of file +node_modules +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/.npmignore b/.npmignore deleted file mode 100644 index d222e7e..0000000 --- a/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -demo/ -screenshots/ -*.gif -*.png -*.log -*.map -*.ts -!*.d.ts diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..abe28a9 --- /dev/null +++ b/.travis.yml @@ -0,0 +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: "10" + script: cd src && npm run ci.tslint + - stage: "Build and Test" + env: + - BuildAndroid="29" + - NodeJs="8" + - Type="TypeScript" + language: android + dist: trusty + os: linux + jdk: oraclejdk8 + before_install: nvm install 8 + script: + - 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="12.0" + - Type="TypeScript" + 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=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 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 + - os: osx + env: + - UnitTests="iOS" + - TestVersion="latest" + language: node_js + node_js: "10" + jdk: oraclejdk8 + osx_image: xcode11.2 + before_script: + - cd seed-tests && npm i + 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-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 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..1c845d0 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,83 @@ +# NativeScript Community Code of Conduct + +Our community members come from all walks of life and are all at different stages of their personal and professional journeys. To support everyone, we've prepared a short code of conduct. Our mission is best served in an environment that is friendly, safe, and accepting; free from intimidation or harassment. + +Towards this end, certain behaviors and practices will not be tolerated. + +## tl;dr + +- Be respectful. +- We're here to help. +- Abusive behavior is never tolerated. +- Violations of this code may result in swift and permanent expulsion from the NativeScript community channels. + +## Administrators + +- Dan Wilson (@DanWilson on Slack) +- Jen Looper (@jen.looper on Slack) +- TJ VanToll (@tjvantoll on Slack) + +## Scope + +We expect all members of the NativeScript community, including administrators, users, facilitators, and vendors to abide by this Code of Conduct at all times in our community venues, online and in person, and in one-on-one communications pertaining to NativeScript affairs. + +This policy covers the usage of the NativeScript Slack community, as well as the NativeScript support forums, NativeScript GitHub repositories, the NativeScript website, and any NativeScript-related events. This Code of Conduct is in addition to, and does not in any way nullify or invalidate, any other terms or conditions related to use of NativeScript. + +The definitions of various subjective terms such as "discriminatory", "hateful", or "confusing" will be decided at the sole discretion of the NativeScript administrators. + +## Friendly, Harassment-Free Space + +We are committed to providing a friendly, safe, and welcoming environment for all, regardless of gender identity, sexual orientation, disability, ethnicity, religion, age, physical appearance, body size, race, or similar personal characteristics. + +We ask that you please respect that people have differences of opinion regarding technical choices, and acknowledge that every design or implementation choice carries a trade-off and numerous costs. There is seldom a single right answer. A difference of technology preferences is never a license to be rude. + +Any spamming, trolling, flaming, baiting, or other attention-stealing behaviour is not welcome, and will not be tolerated. + +Harassing other users of NativeScript is never tolerated, whether via public or private media. + +Avoid using offensive or harassing package names, nicknames, or other identifiers that might detract from a friendly, safe, and welcoming environment for all. + +Harassment includes, but is not limited to: harmful or prejudicial verbal or written comments related to gender identity, sexual orientation, disability, ethnicity, religion, age, physical appearance, body size, race, or similar personal characteristics; inappropriate use of nudity, sexual images, and/or sexually explicit language in public spaces; threats of physical or non-physical harm; deliberate intimidation, stalking or following; harassing photography or recording; sustained disruption of talks or other events; inappropriate physical contact; and unwelcome sexual attention. + +## Acceptable Content + +The NativeScript administrators reserve the right to make judgement calls about what is and isn't appropriate in published content. These are guidelines to help you be successful in our community. + +Content must contain something applicable to the previously stated goals of the NativeScript community. "Spamming", that is, publishing any form of content that is not applicable, is not allowed. + +Content must not contain illegal or infringing content. You should only publish content to NativeScript properties if you have the right to do so. This includes complying with all software license agreements or other intellectual property restrictions. For example, redistributing an MIT-licensed module with the copyright notice removed, would not be allowed. You will be responsible for any violation of laws or others’ intellectual property rights. + +Content must not be malware. For example, content (code, video, pictures, words, etc.) which is designed to maliciously exploit or damage computer systems, is not allowed. + +Content name, description, and other visible metadata must not include abusive, inappropriate, or harassing content. + +## Reporting Violations of this Code of Conduct + +If you believe someone is harassing you or has otherwise violated this Code of Conduct, please contact the administrators and send us an abuse report. If this is the initial report of a problem, please include as much detail as possible. It is easiest for us to address issues when we have more context. + +## Consequences + +All content published to the NativeScript community channels is hosted at the sole discretion of the NativeScript administrators. + +Unacceptable behavior from any community member, including sponsors, employees, customers, or others with decision-making authority, will not be tolerated. + +Anyone asked to stop unacceptable behavior is expected to comply immediately. + +If a community member engages in unacceptable behavior, the NativeScript administrators may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event or service). + +## Addressing Grievances + +If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify the administrators. We will do our best to ensure that your grievance is handled appropriately. + +In general, we will choose the course of action that we judge as being most in the interest of fostering a safe and friendly community. + +## Contact Info +Please contact Dan Wilson @DanWilson if you need to report a problem or address a grievance related to an abuse report. + +You are also encouraged to contact us if you are curious about something that might be "on the line" between appropriate and inappropriate content. We are happy to provide guidance to help you be a successful part of our community. + +## Credit and License + +This Code of Conduct borrows heavily from the WADE Code of Conduct, which is derived from the NodeBots Code of Conduct, which in turn borrows from the npm Code of Conduct, which was derived from the Stumptown Syndicate Citizen's Code of Conduct, and the Rust Project Code of Conduct. + +This document may be reused under a Creative Commons Attribution-ShareAlike License. \ 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 old mode 100644 new mode 100755 index 9d6ed2d..061c440 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,201 @@ -The MIT License (MIT) - -nativescript-yourplugin -Copyright (c) 2016, Your Name - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index 553eecc..34236ee 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,93 @@ -# Develop a NativeScript plugin +# Develop a NativeScript plugin [![Build Status](https://travis-ci.org/NativeScript/nativescript-plugin-seed.svg?branch=master)](https://travis-ci.org/NativeScript/nativescript-plugin-seed) + +> This repo is heavily based on [@NathanWalker](https://github.com/NathanWalker)'s [Plugin Seed](https://github.com/NathanWalker/nativescript-plugin-seed). Thanks, Nathan! + + + +- [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. -## Getting started +## Long Description -1. `git clone https://github.com/NathanWalker/nativescript-plugin-seed.git myplugin` -2. `cd myplugin` -3. `npm run postclone` -4. `npm run setup` -5. Get to work. +### What is NativeScript plugin seed? + +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 +* 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 +* a proper `.npmignore` to ensure everyone is happy when you publish your plugin to NPM. + +![Plugin seed demo](https://github.com/NativeScript/nativescript-plugin-seed/blob/master/screenshots/demo.png?raw=true) + +### Plugin folder structure + +|Folder/File name| Description +|---|---| +|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| +|src/README|Your plugin README stub explaining how other developers can use your plugin in their applications. Used when you publish your plugin to NPM. On postclone step, the README in the root is replaced with this one.| +|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 + +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` +3. Execute `npm run postclone` to: + * 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 + +Now you can continue with the development of your plugin by using the [Development setup](#Developmentsetup) described below. + +**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. + +#### Development setup +For easier development and debugging purposes continue with the following: -This seed expands on several things [presented here](http://developer.telerik.com/featured/creating-nativescript-plugins-in-typescript/). +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`. -## Usage +Now go and make a change to your plugin. It will be automatically applied to the demo project. -The seed is prepared to allow you to test and try out your plugin via the `demo` folder. -Additionally it provides a proper `.gitignore` to keep GitHub tidy as well as `.npmignore` to ensure everyone is happy when you publish your plugin via npm. +**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 -You will want to create these folders and files in the root: +You will want to create these folders and files in the `src` folder in order to use native APIs: ``` platforms -- @@ -32,64 +102,61 @@ Doing so will open up those native apis to your plugin :) 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/platforms) +* [nativescript-floatingactionbutton](https://github.com/bradmartin/nativescript-floatingactionbutton/tree/master/src/platforms) -### Typical development workflow: +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 -1. Make changes to plugin files -2. Make changes in `demo` that would test those changes out -3. `npm run demo.ios` or `npm run demo.android` **(must be run from the root directory)** +#### Generating typings for iOS -Those `demo` tasks are just general helpers. You may want to have more granular control on the device and/or emulator you want to run. For that, you can just run things the manual way: +- 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` -``` -cd demo +**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). -// when developing, to ensure the latest code is built into the demo, it's a guarantee to remove the plugin and add it back -tns plugin remove nativescript-yourplugin -tns plugin add .. +#### Generating typings for Android -// manual platform adds -tns platform add ios -// and/or -tns platform add 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` -Then use any of the available options from the `tns` command line: +### Clean plugin and demo files -* [Emulate your project](https://github.com/NativeScript/nativescript-cli#emulate-your-project) -* [Run your project](https://github.com/NativeScript/nativescript-cli#run-your-project) -* [Full list of commands](https://github.com/NativeScript/nativescript-cli#the-commands) +Sometimes you may need to wipe away the `src/node_modules`, `demo/node_modules` and `demo/platforms` folders to reinstall them fresh. -## Unittesting -This plugin automatically adds Jasmine-based unittest support to your plugin. -Open `demo/app/tests/tests.js` and adjust its contents. +* Run `npm run clean` to wipe those clean then you can can run `npm i` to install fresh dependencies. -You can read more about this topic [here](https://docs.nativescript.org/tooling/testing). +Sometimes you just need to wipe out the demo's `platforms` directory only: -Once you're ready to test your plugin's API execute one of these commands in the plugin root: +* Run `npm run demo.reset` or `npm run demo-angular.reset` to delete the application's `platforms` directory only. -``` -npm run test.ios -npm run test.android -``` +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. + +### 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). -## Publish +### Publish to NPM When you have everything ready to publish: -* Bump the version number in `package.json` -* `npm run build` - **very important** - ensure the latest is built **before** you publish -* `npm publish` +* Bump the version number in `src/package.json` +* Go to `publish` and execute `publish.sh` (run `chmod +x *.sh` if the file isn't executable) -## Contributing - Want to make the seed better? +If you just want to create a package, go to `publish` folder and execute `pack.sh`. The package will be created in `publish/package` folder. -Or at least help keep it up to date with NativeScript releases, which would be excellent. +**NOTE**: To run bash script on Windows you can install [GIT SCM](https://git-for-windows.github.io/) and use Git Bash. -``` -npm install -g typescript // if you don't already have it -git clone https://github.com/NathanWalker/nativescript-plugin-seed -cd nativescript-plugin-seed +### TravisCI -// Improve! -``` +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. + +## 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). + +## 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 51f7531..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.starter" - } - 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 634f26a..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 98f8260..0000000 --- a/demo/app/app.ts +++ /dev/null @@ -1,2 +0,0 @@ -import * as application from 'application'; -application.start({ moduleName: "main-page" }); diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts deleted file mode 100644 index 231d655..0000000 --- a/demo/app/main-page.ts +++ /dev/null @@ -1,10 +0,0 @@ -import * as observable from 'data/observable'; -import * as pages from 'ui/page'; -import {HelloWorldModel} from './main-view-model'; - -// Event handler for Page 'loaded' event attached in main-page.xml -export function pageLoaded(args: observable.EventData) { - // Get the event sender - let page = args.object; - page.bindingContext = new HelloWorldModel(); -} \ No newline at end of file diff --git a/demo/app/main-page.xml b/demo/app/main-page.xml deleted file mode 100644 index d66e1da..0000000 --- a/demo/app/main-page.xml +++ /dev/null @@ -1,5 +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 4e9abef..0000000 --- a/demo/app/main-view-model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {Observable} from '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; - } -} \ No newline at end of file diff --git a/demo/app/package.json b/demo/app/package.json deleted file mode 100644 index 31c9e0d..0000000 --- a/demo/app/package.json +++ /dev/null @@ -1,105 +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": {}, - "_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 4c7a2c6..0000000 --- a/demo/app/tests/tests.js +++ /dev/null @@ -1,13 +0,0 @@ -var YourPlugin = require("nativescript-yourplugin").YourPlugin; -var yourPlugin = new YourPlugin(); - -// TODO replace 'functionname' with an acual function name of your plugin class and run with 'npm test ' -describe("functionname", function() { - it("exists", function() { - expect(yourPlugin.functionname).toBeDefined(); - }); - - it("returns a promise", function() { - expect(yourPlugin.functionname()).toEqual(jasmine.any(Promise)); - }); -}); \ No newline at end of file diff --git a/demo/karma.conf.js b/demo/karma.conf.js deleted file mode 100644 index a29c222..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: false - }); -}; diff --git a/demo/package.json b/demo/package.json deleted file mode 100644 index b8c9835..0000000 --- a/demo/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "nativescript": { - "id": "org.nativescript.demo", - "tns-ios": { - "version": "2.5.0" - }, - "tns-android": { - "version": "2.5.0" - } - }, - "dependencies": { - "nativescript-theme-core": "^1.0.2", - "nativescript-unit-test-runner": "^0.3.4", - "nativescript-yourplugin": "file:..", - "tns-core-modules": "~2.5.2" - }, - "devDependencies": { - "babel-traverse": "6.12.0", - "babel-types": "6.11.1", - "babylon": "6.8.4", - "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-dev-typescript": "~0.3.7", - "typescript": "~2.1.0" - } -} diff --git a/demo/references.d.ts b/demo/references.d.ts deleted file mode 100644 index c7a379a..0000000 --- a/demo/references.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -/// diff --git a/package.json b/package.json deleted file mode 100644 index dca1b78..0000000 --- a/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "nativescript-yourplugin", - "version": "1.0.0", - "description": "Your awesome NativeScript plugin.", - "main": "yourplugin", - "typings": "index.d.ts", - "nativescript": { - "platforms": { - "android": "3.0.0", - "ios": "3.0.0" - } - }, - "scripts": { - "build": "tsc", - "demo.ios": "npm run preparedemo && cd demo && tns run ios --emulator", - "demo.ios.device": "npm run preparedemo && cd demo && tns run ios", - "demo.android": "npm run preparedemo && cd demo && tns run android --emulator", - "test.ios": "cd demo && tns test ios --emulator", - "test.ios.device": "cd demo && tns test ios", - "test.android": "cd demo && tns test android", - "preparedemo": "npm run build && cd demo && tns plugin remove nativescript-yourplugin && tns plugin add .. && tns install", - "setup": "npm i && cd demo && npm i && cd .. && npm run build && cd demo && tns plugin add .. && cd ..", - "postclone": "npm i && node scripts/postclone.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/YourName/nativescript-yourplugin.git" - }, - "keywords": [ - "NativeScript", - "JavaScript", - "Android", - "iOS" - ], - "author": { - "name": "Your Name", - "email": "youremail@yourdomain.com" - }, - "bugs": { - "url": "https://github.com/YourName/nativescript-yourplugin/issues" - }, - "license": "MIT", - "homepage": "https://github.com/YourName/nativescript-yourplugin", - "readmeFilename": "README.md", - "devDependencies": { - "tns-core-modules": "~3.0.0", - "tns-platform-declarations": "^3.0.1", - "typescript": "~2.2.1", - "prompt": "~1.0.0", - "rimraf": "~2.5.0" - } -} diff --git a/publish/pack.sh b/publish/pack.sh new file mode 100644 index 0000000..212f22f --- /dev/null +++ b/publish/pack.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +SOURCE_DIR=../src; +TO_SOURCE_DIR=src; +PACK_DIR=package; +ROOT_DIR=..; +PUBLISH=--publish + +install(){ + npm i +} + +pack() { + + echo 'Clearing /src and /package...' + node_modules/.bin/rimraf "$TO_SOURCE_DIR" + node_modules/.bin/rimraf "$PACK_DIR" + + # copy src + echo 'Copying src...' + node_modules/.bin/ncp "$SOURCE_DIR" "$TO_SOURCE_DIR" + + # copy README & LICENSE to src + echo 'Copying README and LICENSE to /src...' + node_modules/.bin/ncp "$ROOT_DIR"/LICENSE "$TO_SOURCE_DIR"/LICENSE + node_modules/.bin/ncp "$ROOT_DIR"/README.md "$TO_SOURCE_DIR"/README.md + + # compile package and copy files required by npm + echo 'Building /src...' + cd "$TO_SOURCE_DIR" + node_modules/.bin/tsc + cd .. + + echo 'Creating package...' + # create package dir + mkdir "$PACK_DIR" + + # create the package + cd "$PACK_DIR" + npm pack ../"$TO_SOURCE_DIR" + + # delete source directory used to create the package + cd .. + node_modules/.bin/rimraf "$TO_SOURCE_DIR" +} + +install && pack \ No newline at end of file diff --git a/publish/package.json b/publish/package.json new file mode 100644 index 0000000..d5c28e9 --- /dev/null +++ b/publish/package.json @@ -0,0 +1,9 @@ +{ + "name": "nativescript-publish", + "version": "1.0.0", + "description": "Publish helper", + "devDependencies": { + "ncp": "^2.0.0", + "rimraf": "^2.5.0" + } +} diff --git a/publish/publish.sh b/publish/publish.sh new file mode 100644 index 0000000..8e72704 --- /dev/null +++ b/publish/publish.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +PACK_DIR=package; + +publish() { + cd $PACK_DIR + echo 'Publishing to npm...' + npm publish *.tgz +} + +./pack.sh && publish \ No newline at end of file diff --git a/screenshots/demo.png b/screenshots/demo.png new file mode 100644 index 0000000..d48217f Binary files /dev/null and b/screenshots/demo.png differ diff --git a/scripts/postclone.js b/scripts/postclone.js deleted file mode 100644 index 35c50ae..0000000 --- a/scripts/postclone.js +++ /dev/null @@ -1,143 +0,0 @@ -var fs = require('fs'); -var prompt = require('prompt'); -var rimraf = require('rimraf'); -var exec = require('child_process').exec; - -var plugin_name, - class_name, - github_username, - seed_plugin_name = "yourplugin", - seed_class_name = "YourPlugin", - seed_demo_property_name = "yourPlugin", - seed_github_username = "YourName", - demo_folder = "demo", - init_git; - -console.log('NativeScript Plugin Seed Configuration'); -prompt.start(); -askGithubUsername(); - -function askGithubUsername() { - prompt.get({ - name: 'github_username', - description: 'What is your GitHub username (used for updating package.json)? Example: NathanWalker / EddyVerbruggen' - }, function (err, result) { - if (err) { - return console.log(err); - } - if (!result.github_username) { - return console.log("Dude, the GitHub username is mandatory!"); - } - github_username = result.github_username; - askPluginName(); - }); -} - -function askPluginName() { - prompt.get({ - name: 'plugin_name', - description: 'What will be the name of your plugin? Use lowercase characters and dashes only. Example: yourplugin / google-maps / bluetooth' - }, function (err, result) { - if (err) { - return console.log(err); - } - if (!result.plugin_name) { - return console.log("Dude, the plugin name is mandatory!"); - } - plugin_name = result.plugin_name; - generateClassName(); - }); -} - -function generateClassName() { - // the classname becomes 'GoogleMaps' when plugin_name is 'google_maps' - class_name = ""; - var plugin_name_parts = plugin_name.split("-"); - for (var p in plugin_name_parts) { - var part = plugin_name_parts[p]; - class_name += (part[0].toUpperCase() + part.substr(1)); - } - console.log('Using ' + class_name + ' as the TypeScript Class name..'); - renameFiles(); -} - -function renameFiles() { - console.log('Will now rename some files..'); - var files = fs.readdirSync("."); - for (var f in files) { - var file = files[f]; - if (file.indexOf(seed_plugin_name) === 0) { - var newName = plugin_name + file.substr(file.indexOf(".")); - fs.renameSync(file, newName); - } - } - - adjustScripts(); -} - -function adjustScripts() { - console.log('Adjusting scripts..'); - - // add all files in the root - var files = fs.readdirSync("."); - - // 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); - } - // add the tests - files.push(demo_folder + "/app/tests/tests.js"); - - // prepare and cache a few Regexp thingies - var regexp_seed_plugin_name = new RegExp(seed_plugin_name, "g"); - var regexp_seed_class_name = new RegExp(seed_class_name, "g"); - var regexp_seed_demo_property_name = new RegExp(seed_demo_property_name, "g"); - var regexp_seed_github_username = new RegExp(seed_github_username, "g"); - - for (var f in files) { - var file = files[f]; - if (file.indexOf(".") > 0) { - var contents = fs.readFileSync(file, 'utf8'); - var result = contents.replace(regexp_seed_plugin_name, 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)); - result = result.replace(regexp_seed_github_username, github_username); - fs.writeFileSync(file, result); - } - } - - initGit(); -} - -function initGit() { - prompt.get({ - name: 'init_git', - description: 'Do you want to init a fresh local git project? If you previously \'git clone\'d this repo that would be wise (y/n)', - default: 'y' - }, function (err, result) { - if (err) { - return console.log(err); - } - if (result.init_git && result.init_git.toLowerCase() === 'y') { - rimraf.sync('.git'); - exec('git init -q .', function(err, stdout, stderr) { - if (err) { - console.log(err); - } else { - exec("git add '*' '.*'", function(err, stdout, stderr) { - if (err) { - console.log(err); - } - }); - } - }); - } - console.log("Configuration finished! If you're not happy with the result please clone the seed again and rerun this script."); - console.log("You can now run 'npm run setup' and start cracking!"); - }); -} \ 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/jasmine.config.json b/seed-tests/jasmine.config.json new file mode 100644 index 0000000..ffd7e99 --- /dev/null +++ b/seed-tests/jasmine.config.json @@ -0,0 +1,6 @@ +{ + "spec_dir": ".", + "spec_files": ["./*tests.js"], + "stopSpecOnExpectationFailure": false, + "random": false +} \ No newline at end of file diff --git a/seed-tests/package.json b/seed-tests/package.json new file mode 100644 index 0000000..57373f9 --- /dev/null +++ b/seed-tests/package.json @@ -0,0 +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", + "@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": "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": {} +} diff --git a/seed-tests/postclone.tests.js b/seed-tests/postclone.tests.js new file mode 100644 index 0000000..2a52b66 --- /dev/null +++ b/seed-tests/postclone.tests.js @@ -0,0 +1,266 @@ +var exec = require('child_process').exec; +var fs = require('fs'); +var glob = require("glob"); +var testUtils = require("./tests.utils"); +var constants = require("./tests.constants"); +var path = require("path"); + +var _srcReadmeContent = ""; + +describe('postclone', function () { + + // keep before 'should not init new git repo' + // in order to avoid getting new files in the git repo + it('should init new git repo', function (done) { + testUtils.copySeedDir(constants.SEED_LOCATION, constants.SEED_COPY_LOCATION, function (err) { + if (err) { + done.fail(err); + } + + 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 { + exec("cd " + constants.SEED_COPY_LOCATION + "/src && git config --get remote.origin.url", function (error, stdout, stderr) { + expect(stdout).toEqual(""); + done(); + }); + } + }); + }); + }); + + it('should not init new git repo', 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", "n", function (error, stdout) { + if (error) { + done.fail(error); + } else { + exec("cd " + constants.SEED_COPY_LOCATION + " && git config --get remote.origin.url", function (execError, stdout, stderr) { + expect(stdout).toContain("NativeScript/nativescript-plugin-seed.git"); + done(); + }); + } + }); + }); + }); + + 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 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 rename each yourplugin file with the new plugin name in README', function () { + expect(fs.existsSync(constants.SEED_COPY_LOCATION + "/README.md")).toBeTruthy(); + + var readmeContent = fs.readFileSync(constants.SEED_COPY_LOCATION + "/README.md"); + 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) { + glob(constants.SEED_COPY_LOCATION + "/**/yourplugin*.*", function (er, files) { + expect(files.length).toEqual(0); + done(); + }); + }); + + it('should rename each yourplugin file with the new plugin name', function (done) { + glob(constants.SEED_COPY_LOCATION + "/**/" + constants.TEST_PLUGIN_NAME + "*.*", function (er, files) { + expect(files.length).toBeGreaterThan(0); + done(); + }); + }); + + it('should replace each yourplugin string', function (done) { + testUtils.findInFiles("yourplugin", constants.SEED_COPY_LOCATION, function (resultsCount) { + expect(resultsCount).toEqual(0); + done(); + }); + }); + + it('should replace each YourPlugin string', function (done) { + testUtils.findInFiles("YourPlugin", constants.SEED_COPY_LOCATION, function (resultsCount) { + expect(resultsCount).toEqual(0); + done(); + }); + }); + + it('should replace each yourPlugin string', function (done) { + testUtils.findInFiles("yourPlugin", constants.SEED_COPY_LOCATION, function (resultsCount) { + expect(resultsCount).toEqual(0); + done(); + }); + }); + + it('should replace each YourName string', function (done) { + testUtils.findInFiles("YourName", constants.SEED_COPY_LOCATION, function (resultsCount) { + expect(resultsCount).toEqual(0); + done(); + }); + }); + + it('should replace each YourName string with the test github username', function (done) { + testUtils.findInFiles(constants.TEST_GITHUB_USERNAME, constants.SEED_COPY_LOCATION, function (resultsCount) { + // plugin author in the package json + expect(resultsCount).toEqual(1); + done(); + }); + }); + + it('should replace each YourPlugin string with ThePlugin', function (done) { + testUtils.findInFiles(constants.TEST_PLUGIN_NAME, constants.SEED_COPY_LOCATION, function (resultsCount) { + expect(resultsCount).toBeGreaterThan(0); + done(); + }); + }); + + it('should replace each nativescript-YourPlugin string with nativescript-ThePlugin', function (done) { + testUtils.findInFiles("nativescript-" + constants.TEST_PLUGIN_NAME, constants.SEED_COPY_LOCATION, function (resultsCount) { + expect(resultsCount).toBeGreaterThan(0); + done(); + }); + }); +}); \ No newline at end of file diff --git a/seed-tests/tests.constants.js b/seed-tests/tests.constants.js new file mode 100644 index 0000000..c45ac53 --- /dev/null +++ b/seed-tests/tests.constants.js @@ -0,0 +1,7 @@ +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"; +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1200000; // 20 mins \ No newline at end of file diff --git a/seed-tests/tests.utils.js b/seed-tests/tests.utils.js new file mode 100644 index 0000000..0b88ee0 --- /dev/null +++ b/seed-tests/tests.utils.js @@ -0,0 +1,132 @@ +var exec = require('child_process').exec; +var rimraf = require('rimraf'); +var ncp = require('ncp').ncp; +var fs = require('fs'); +var async = require("async"); +var os = require('os'); +var constants = require('./tests.constants'); + +exports.findInFiles = function findInFiles(string, dir, callback) { + var _resultsCount = 0; + var _excludedPaths = ["node_modules", "src/scripts/postclone", "/seed-tests/", ".git"]; + + function _findInFiles(string, dir, callback) { + fs.readdir(dir, function (err, entries) { + entries = entries.filter(function (entry) { + var fullEntry = dir + '/' + entry; + var shouldBeIncluded = true; + _excludedPaths.forEach(function callback(currentValue) { + shouldBeIncluded = fullEntry.indexOf(currentValue) === -1 && shouldBeIncluded; + }); + + return shouldBeIncluded; + }); + async.eachSeries(entries, function (entry, foreachCallback) { + entry = dir + '/' + entry; + fs.stat(entry, function (err, stat) { + if (stat && stat.isDirectory()) { + _findInFiles(string, entry, foreachCallback); + } else { + fs.readFile(entry, 'utf-8', function (err, contents) { + if (contents.indexOf(string) > -1) { + _resultsCount++; + } + + foreachCallback(); + }); + } + }); + }, function (err) { + callback(); + }); + }); + }; + + _findInFiles(string, dir, function () { + callback(_resultsCount); + }); +}; + +exports.copySeedDir = function copySeedDir(seedLocation, copyLocation, callback) { + rimraf.sync(copyLocation); + + ncp(seedLocation, copyLocation, { + 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; + } + + return true; + } + }, function (err) { + if (!err) { + console.log(copyLocation + ' folder successfully created.'); + } + callback(err); + }); +}; + +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 + " 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); + }); +}; + +exports.callDevelopmentSetup = function callDevelopmentSetup(seedLocation, callback) { + exec("cd " + seedLocation + "/src && npm run development.setup", function (error, stdout, stderr) { + callback(error, stdout, stderr); + }); +}; + +exports.getNpmLinks = function getNpmLinks(callback) { + exec("npm list -g --depth=0", function (error, stdout, stderr) { + var links = stdout.split(os.EOL) + .map(function (item) { + return item.replace("├──", "").replace("└──", "").trim(); + }) + .filter(function (item) { + return !!item && item.indexOf("->") !== -1; + }); + + callback(links); + }); +} + +exports.removeNpmLink = function removeNpmLink(packageName, callback) { + exec("npm remove " + packageName + " -g", function (error, stdout, stderr) { + callback(); + }); +} + +exports.isAndroid = function isAndroid() { + return !!!process.env.IOS; +} + +function getPackageJsonPostcloneScript() { + var packageJsonFile = constants.SEED_COPY_LOCATION + "/src/package.json"; + + if (fs.lstatSync(packageJsonFile).isFile()) { + var packageJson = JSON.parse(fs.readFileSync(packageJsonFile, 'utf8')); + var packageJsonScripts = packageJson["scripts"]; + + if (packageJsonScripts && packageJsonScripts["postclone"]) { + return packageJsonScripts["postclone"]; + }; + } + + return ""; +} \ No newline at end of file diff --git a/src/.npmignore b/src/.npmignore new file mode 100644 index 0000000..43534c9 --- /dev/null +++ b/src/.npmignore @@ -0,0 +1,10 @@ +*.map +*.ts +!*.d.ts +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 new file mode 100644 index 0000000..c01d293 --- /dev/null +++ b/src/.travis.yml @@ -0,0 +1,77 @@ +matrix: + include: + - stage: "Lint" + language: node_js + os: linux + node_js: "10" + script: cd src && npm run ci.tslint + - stage: "WebPack, Build and Test" + os: osx + env: + - WebPack="iOS" + osx_image: xcode10.2 + language: node_js + node_js: "10" + jdk: oraclejdk8 + 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 10 + script: cd src && npm run build && cd ../demo && npm i && tns build android --bundle --env.uglify --env.snapshot + - language: android + env: + - BuildAndroid="28" + os: linux + jdk: oraclejdk8 + before_install: nvm install 10 + script: + - cd src && npm i && npm run tsc && cd ../demo && tns build android + - os: osx + env: + - BuildiOS="12" + - Xcode="10.0" + osx_image: xcode10.2 + language: node_js + node_js: "10" + jdk: oraclejdk8 + script: + - cd src && npm i && npm run tsc && cd ../demo && tns build ios + - os: linux + language: android + dist: precise + sudo: required + jdk: oraclejdk8 + before_script: + - 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 + before_install: + - nvm install 10 + script: cd src && npm run test.android + - os: osx + language: node_js + node_js: "10" + jdk: oraclejdk8 + osx_image: xcode10.2 + script: cd src && npm run test.ios + +android: + components: + - tools + - platform-tools + - 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 diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..46d3ce3 --- /dev/null +++ b/src/README.md @@ -0,0 +1,40 @@ +# nativescript-yourplugin + +Add your plugin badges here. See [nativescript-urlhandler](https://github.com/hypery2k/nativescript-urlhandler) for example. + +Then describe what's the purpose of your plugin. + +In case you develop UI plugin, this is where you can add some screenshots. + +## (Optional) Prerequisites / Requirements + +Describe the prerequisites that the user need to have installed before using your plugin. See [nativescript-firebase plugin](https://github.com/eddyverbruggen/nativescript-plugin-firebase) for example. + +## Installation + +Describe your plugin installation steps. Ideally it would be something like: + +```javascript +tns plugin add nativescript-yourplugin +``` + +## Usage + +Describe any usage specifics for your plugin. Give examples for Android, iOS, Angular if needed. See [nativescript-drop-down](https://www.npmjs.com/package/nativescript-drop-down) for example. + + ```javascript + Usage code snippets here + ```) + +## API + +Describe your plugin methods and properties here. See [nativescript-feedback](https://github.com/EddyVerbruggen/nativescript-feedback) for example. + +| Property | Default | Description | +| --- | --- | --- | +| some property | property default value | property description, default values, etc.. | +| another property | property default value | property description, default values, etc.. | + +## License + +Apache License Version 2.0, January 2004 diff --git a/index.d.ts b/src/index.d.ts similarity index 66% rename from index.d.ts rename to src/index.d.ts index 8e82945..ef77569 100644 --- a/index.d.ts +++ b/src/index.d.ts @@ -2,5 +2,5 @@ import { Common } from './yourplugin.common'; export declare class YourPlugin extends Common { // define your typings manually // or.. - // use take the ios or android .d.ts files and copy/paste them here + // take the ios or android .d.ts files and copy/paste them here } diff --git a/src/package.json b/src/package.json new file mode 100644 index 0000000..e92b64f --- /dev/null +++ b/src/package.json @@ -0,0 +1,52 @@ +{ + "name": "nativescript-yourplugin", + "version": "1.0.0", + "description": "Your awesome NativeScript plugin.", + "main": "yourplugin", + "typings": "index.d.ts", + "nativescript": { + "platforms": { + "android": "6.0.0", + "ios": "6.0.1" + } + }, + "repository": { + "type": "git", + "url": "https://github.com/YourName/nativescript-yourplugin.git" + }, + "scripts": { + "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/**\"", + "ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/platforms/**'", + "prepack": "npm run build.native" + }, + "keywords": [ + "NativeScript", + "JavaScript", + "Android", + "iOS" + ], + "author": { + "name": "Your Name", + "email": "youremail@yourdomain.com" + }, + "bugs": { + "url": "https://github.com/YourName/nativescript-yourplugin/issues" + }, + "license": "Apache-2.0", + "homepage": "https://github.com/YourName/nativescript-yourplugin", + "devDependencies": { + "tns-core-modules": "^6.0.0", + "tns-platform-declarations": "^6.0.0", + "typescript": "~3.4.5", + "prompt": "^1.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/AndroidManifest.xml b/src/platforms/android/AndroidManifest.xml new file mode 100644 index 0000000..08f1f21 --- /dev/null +++ b/src/platforms/android/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/src/platforms/android/README.md b/src/platforms/android/README.md new file mode 100644 index 0000000..ba1db50 --- /dev/null +++ b/src/platforms/android/README.md @@ -0,0 +1,9 @@ +# Android permissions and dependencies + +* (Optional) Use AndroidManifest.xml to describe any permissions, features or other configuration specifics required or used by your plugin for Android. +NOTE: The NativeScript CLI will not resolve any contradicting or duplicate entries during the merge. After the plugin is installed, you need to manually resolve such issues. + +* (Optional) Use include.gradle configuration to describe any native dependencies. If there are no such, this file can be removed. For more information, see the [include.gradle Specification](http://docs.nativescript.org/plugins/plugins#includegradle-specification) + + +[Read more about nativescript plugins](http://docs.nativescript.org/plugins/plugins) \ No newline at end of file diff --git a/src/platforms/android/include.gradle b/src/platforms/android/include.gradle new file mode 100644 index 0000000..612a631 --- /dev/null +++ b/src/platforms/android/include.gradle @@ -0,0 +1,11 @@ +/* Include.gradle configuration: http://docs.nativescript.org/plugins/plugins#includegradle-specification */ + +android { + +} + +dependencies { + // Describe plugin native Android dependencies like + // implementation "groupName:pluginName:ver" + // EXAMPLE: implementation "com.facebook.fresco:fresco:0.9.0+" +} \ No newline at end of file diff --git a/src/platforms/ios/Info.plist b/src/platforms/ios/Info.plist new file mode 100644 index 0000000..1beb9c0 --- /dev/null +++ b/src/platforms/ios/Info.plist @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/platforms/ios/README.md b/src/platforms/ios/README.md new file mode 100644 index 0000000..f12514c --- /dev/null +++ b/src/platforms/ios/README.md @@ -0,0 +1,9 @@ +# iOS permissions and dependencies + + +* (Optional) Use Info.plist to describe any permissions, features or other configuration specifics required or used by your plugin for iOS. +NOTE: The NativeScript CLI will not resolve any contradicting or duplicate entries during the merge. After the plugin is installed, you need to manually resolve such issues. +* (Optional) Use build.xcconfig configuration to describe any plugin the native dependencies. If there are no such, this file can be removed. For more information, see the [build.xcconfig Specification section](http://docs.nativescript.org/plugins/plugins#buildxcconfig-specification). + + +[Read more about nativescript plugins](http://docs.nativescript.org/plugins/plugins) \ No newline at end of file diff --git a/src/platforms/ios/build.xcconfig b/src/platforms/ios/build.xcconfig new file mode 100644 index 0000000..e69de29 diff --git a/references.d.ts b/src/references.d.ts similarity index 100% rename from references.d.ts rename to src/references.d.ts 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 new file mode 100644 index 0000000..1b3c92b --- /dev/null +++ b/src/scripts/postclone.js @@ -0,0 +1,720 @@ +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, + 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", + 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 = { + readmeFile: { + source: "README.md", + destination: "../README.md" + }, + travisFile: { + 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 = {}; + argv.forEach(function (pairString) { + var pair = pairString.split('='); + result[pair[0]] = pair[1]; + }); + + return result; +}; +var argv = parseArgv(); + +if (argv) { + inputParams.github_username = argv.gitHubUsername; + inputParams.plugin_name = argv.pluginName; + 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(); + +function askGithubUsername() { + if (inputParams.github_username !== undefined) { + askPluginName(); + } else { + prompt.start(); + prompt.get({ + name: 'github_username', + description: 'What is your GitHub username (used for updating package.json)? Example: NathanWalker' + }, function (err, result) { + if (err) { + return console.log(err); + } + if (!result.github_username) { + return console.log("Your GitHub username is required to configure plugin's package.json."); + } + inputParams.github_username = result.github_username; + askPluginName(); + }); + } +} + +function askPluginName() { + if (inputParams.plugin_name !== undefined) { + generateClassName(); + } else { + prompt.get({ + name: 'plugin_name', + description: 'What will be the name of your plugin? Use lowercase characters and dashes only. Example: yourplugin / google-maps / bluetooth' + }, function (err, result) { + if (err) { + return console.log(err); + } + if (!result.plugin_name) { + return console.log("Your plugin name is required to correct the file names and classes."); + } + + inputParams.plugin_name = result.plugin_name; + + if (inputParams.plugin_name.startsWith("nativescript-")) { + inputParams.plugin_name = inputParams.plugin_name.replace("nativescript-", ""); + } + + generateClassName(); + }); + } +} + +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 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) { + var part = plugin_name_parts[p]; + class_name += (part[0].toUpperCase() + part.substr(1)); + } + console.log('Using ' + class_name + ' as the TypeScript Class name..'); + renameFiles(); +} + +function renameFiles() { + console.log('Will now rename some files..'); + var files = fs.readdirSync("."); + for (var f in files) { + var file = files[f]; + if (file.indexOf(seed_plugin_name) === 0) { + var newName = inputParams.plugin_name + file.substr(file.indexOf(".")); + fs.renameSync(file, newName); + } + } + + askTypeScriptDemo(); +} + +function adjustScripts() { + console.log('Adjusting scripts..'); + + // add all files in the root + var files = fs.readdirSync("."); + + // add include.gradle + files.push("platforms/android/include.gradle"); + + // add the demo files + 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 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"); + var regexp_seed_class_name = new RegExp(seed_class_name, "g"); + var regexp_seed_demo_property_name = new RegExp(seed_demo_property_name, "g"); + var regexp_seed_github_username = new RegExp(seed_github_username, "g"); + + for (var f in files) { + var file = files[f]; + + 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)); + result = result.replace(regexp_seed_github_username, inputParams.github_username); + fs.writeFileSync(file, result); + } + } + + replaceFiles(); + updateSrcJson(); +} + +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); + } + + 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) + }); + + clearScriptResetCommands.push(resetScriptKey); + + 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