Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Conversation

angeltsvetkov
Copy link
Contributor

No description provided.

@angeltsvetkov angeltsvetkov force-pushed the atsvetkov/plugin-sanity-check branch 2 times, most recently from 8cced80 to f224c75 Compare June 30, 2017 09:14
- built for iOS
- bundled with webpack

Ignoring any of these non-functional requirements could lead to not working app. Let’s call verification of these requirements – sanity checks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammatical - change to could lead to an app not working
Also grammatical/logical - Throughout the article we'll be referring to the verification of those requirements as 'sanity checks'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't get the first one. Is this really correct?
Agree on the second one.

Copy link
Contributor

@petekanev petekanev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments concerning style, grammar, and logic, which I believe will improve the article.


Ignoring any of these non-functional requirements could lead to not working app. Let’s call verification of these requirements – sanity checks.

This article answers the following questions:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to This article will cover:
and proceed with statements instead of questions. For example: What you need to setup sanity checks for your NS plugins; Check your plugin's code for readability.... The (lack of a) question mark makes all the difference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prerequisites might also be shorter for What you need ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


## What do you need to setup sanity checks for your NativeScript plugin?

As we mentioned earlier, NativeScript plugins are building blocks. They work as part of the NativeScript application.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. as part of Nativescript application**s**.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pluralize 'application'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

## What do you need to setup sanity checks for your NativeScript plugin?

As we mentioned earlier, NativeScript plugins are building blocks. They work as part of the NativeScript application.
Add a simple `demo` application that shows how the plugin works. If the plugin is Angular compatible, there should be another `demo-angular` application as well.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence doesn't sound logically related to the previous one - As we mentioned earlier... Consider adding something along the lines of NativeScript apps can be written in both Angular, or just plain JavaScript/TypeScript, they can also take advantage of the webpack feature to cut off the excess code. In order to ensure that your/our plugin runs reliably in any NativeScript application, there are certain prerequisites you may need to complete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"prepublishOnly": "npm run build"
```

This script will be executed before the package is prepared and packed, only on npm publish. More details can be found in the [npm-script documentation](https://docs.npmjs.com/misc/scripts). The build script (defined above) will be executed. This is important because in this way the TypeScript of the plugin will be compiled and the required metadata will be generated any time before publishing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script will be executed before the package is prepared and packed, only on npm publish. is shortly followed by The build script (defined above) will be executed. Which statement is correct, and when?

also (grammatical) ... will be generated any time ... replace with ... will be generated every time ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


## How to check your plugin’s code for readability, maintainability, and functionality errors?

[TSLint](https://palantir.github.io/tslint/) is a great tool for static analysis of your plugin’s code. It will test the plugin for readability and maintainability as well as functionality errors based on customizable rules. This is a [list of all TSLint rules](https://palantir.github.io/tslint/rules/) you can check for.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Logical) change the last sentence to A complete list with the available TSLint rules can be found in the [tsling repository](https://palantir.github.io/tslint/rules/)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


`tools` and `platform-tools` components define that the latest revision of Android SDK Tools will be installed. More info [here](https://docs.travis-ci.com/user/languages/android/#Overview)

`build-tools-23.0.1` component defines the BuildTools version that will be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we recommend building with build-tools 25.0.2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should clarify this! My understanding was that {N} works great with the latest versions of Android and iOS but I think the right approach is to test the apps and plugins with the most popular versions of Android and iOS and as you can see from the statistics for Android it is not 25.

Copy link
Contributor

@petekanev petekanev Jun 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you are confusing build-tools with compileSdk, or possibly even with targetSdk. {N} works equally well with all compileSdks. And we do also recommend building against the latest compileSdk, we do it implicitly too, unless stated otherwise while tns build-ing with the --compileSdk flag.

As for the build-tools - it is a set of libraries and executables that processes resources, packages your application, signs your app package, etc. They are required to build android applications.
The build-tools requirement is also in our setup articles - http://uatdocs.nativescript.org/start/ns-setup-os-x#system-requirements

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it. Thanks for the info.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


`extra-android-m2repository` component defines the support library repositories.

`sys-img-armeabi-v7a-android-23` component defines the system image.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

component defines the system image of the android emulator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

```
The scripts (`ci.android.build` and `ci.ios.build`) that are executed for building for iOS and Android are located in [package.json](https://github.com/NativeScript/nativescript-facebook/blob/master/demo/package.json#L48) file of any of the demo apps.

If everything is configured appropriately these sanity checks will be executed on every code change. The result will look like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If everything is configured appropriately these sanity checks will be executed on every code change. The result will look like this: -> If everything is configured properly, the sanity checks will execute on every code change. The result, and whether the checks pass or not, will look like this:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


![](../img/plugins/travis-ci.png)

The huge benefit for NativeScript plugin authors is that once having this sanity checks set up, You guys can be more confident about the quality of your plugins.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are addressing plugin authors directly, you can talk about their plugins. The huge benefit for NativeScript plugin authors is that once having this sanity checks set up, You guys can be more confident about the quality of your plugins. -> The main benefit of having sanity checks in place for your NativeScript plugins is that you can develop without spending additional time to ensure your changes don't break existing applications depending on your plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


The huge benefit for NativeScript plugin authors is that once having this sanity checks set up, You guys can be more confident about the quality of your plugins.

By the way, do not forget to [add TravisCI badge](https://docs.travis-ci.com/user/status-images/) in your NativeScript plugin's project! It's fancy! No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, do not forget to [add TravisCI badge](https://docs.travis-ci.com/user/status-images/) in your NativeScript plugin's project! It's fancy! -> Do not forget to .... plugin repository/project/readme. It reports live status of your CI build and makes your plugin look more reliable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@tjvantoll tjvantoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I think this is great. My comments are mostly minor grammatical things, although I did have a few relatively trivial things I thought could use some clarifications.

If you have any questions let me know, although I will be out next Monday & Tuesday for a US holiday 🇺🇸 🎆

@@ -0,0 +1,291 @@
---
title: Sanity Check A Plugin
description: Guideline how to sanity check NativeScript plugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A series of tips on how to sanity check a NativeScript plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

---
title: Sanity Check A Plugin
description: Guideline how to sanity check NativeScript plugin
position: 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same position as the “Plugin Reference” article. I think we’d want this article to come before that one... but I could go either way. In any case make sure you alter these numbers before you publish. I’d probably just change the position in plugin-reference.md to something like 100 because I think we’ll always want that one last.

- built for iOS
- bundled with webpack

Ignoring any of these non-functional requirements could lead to not working app. Throughout the article we'll be referring to the verification of those requirements as 'sanity checks'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could lead to not working app

could lead to an app that doesn’t work as expected

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throughout the article

Throughout this article,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Ignoring any of these non-functional requirements could lead to not working app. Throughout the article we'll be referring to the verification of those requirements as 'sanity checks'.

This article will cover:
- [Setup sanity checks for your NativeScript plugin](#setup-sanity-checks-for-your-nativescript-plugin)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setup sanity checks

Setting up sanity checks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


This article will cover:
- [Setup sanity checks for your NativeScript plugin](#setup-sanity-checks-for-your-nativescript-plugin)
- [Check your plugin’s code for readability, maintainability, and functionality errors](#check-your-plugins-code-for-readability-maintainability-and-functionality-errors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

```
- npm install -g nativescript
- npm install -g tslint
- npm install -g typescript@2.2.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have to be TypeScript version 2.2.2? Seems like that might become a maintenance nightmare for this documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

```
- tns usage-reporting disable
```
Configures anonymous usage reporting for the NativeScript CLI. More info [here](https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/general/usage-reporting.md).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean error reporting here....? You’re including the same text twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

```
Refer to nativescript-facebook [.travis.yml file](https://github.com/NativeScript/nativescript-facebook/blob/doc/.travis.yml#L61-L67) to see this in reality.

As we mention earlier the plugin should be sanity checked on Android as well as on iOS. The Android specific requirements can be defined in `.travis.yml` file in `android` section:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we mentioned earlier,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

before_install: nvm install 6.10.3
script: cd demo && npm run build.plugin && npm i && npm run build-android-bundle && cd ../demo-angular && npm run build.plugin && npm i && npm run build-android-bundle
```
This stage includes 2 builds that run in parallel. One for Android and one for iOS. Note that the nodejs on the Linux machine is installed because it is not included in the image.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stage includes two builds that run in parallel—one for Android, and one for iOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


The main benefit of having sanity checks in place for your NativeScript plugins is that you can develop without spending additional time to ensure your changes don't break existing applications depending on your plugin.

Do not forget to [add TravisCI badge](https://docs.travis-ci.com/user/status-images/) in your NativeScript plugin's project! It reports live status of your CI build and makes your plugin look more reliable. No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to add a Travis CI badge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

position: 50
slug: sanity-check-plugin
---

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to add your article title here as h1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


NativeScript apps can be written in both Angular, or just plain JavaScript/TypeScript and they can also take advantage of the [webpack bundling]({% slug bundling-with-webpack %}) to cut off the excess code. In order to ensure that your plugin runs reliably in any NativeScript application, there are certain prerequisites you may need to complete.

All plugins should have a demo folder that contains a demo application showing how the plugin works. If you use the NativeScript plugin seed you will have this folder by default. If your plugin is a user interface plugin, and you need to test the plugin in both Angular and non-Angular apps, you should have an additional demo-angular folder containing an Angular app you can test your plugin in. Refer to the article ["Supporting Angular in UI Plugins"]({% slug supporting-angular-in-ui-plugins %}) for more details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can link the plugin seed when you mention it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


[TSLint](https://palantir.github.io/tslint/) is a great tool for static analysis of your plugin’s code. It will test the plugin for readability and maintainability as well as functionality errors based on customizable rules. A complete list with the available TSLint rules can be found in the [tsling repository](https://palantir.github.io/tslint/rules/).

The official NativeScript plugin seed recommends TSLint rules defined in this [tslint.json](https://github.com/NativeScript/nativescript-plugin-seed/blob/master/tslint.json) file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LInk the seed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

```

This script executes the `tslint` command passing the tslint rules defined in `tslint.json` file. The installed `node_modules` will be excluded from the static analysis.
Having `tslint.json` on root level allows using same TSLint rules for demo apps as well adding the same script.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Having tslint.json on root level allows using same TSLint rules for demo apps as well adding the same script." -> @tjvantoll can correct this better but I would say it like "Having tslint.json on root level allows using the same TSLint rules for both demo apps by adding the same script."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


The NativeScript command for building Android and iOS apps is:

`tns build Android` and `tns build ios`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the casing doesn't matter but for integrity I would suggest to use "android" instead of "Android"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

```
Refer to nativescript-facebook [.travis.yml file](https://github.com/NativeScript/nativescript-facebook/blob/doc/.travis.yml#L60-L62) to see this in reality.

As we mention earlier, the plugin should be sanity checked on Android as well as on iOS. The Android specific requirements can be defined in `.travis.yml` file in `android` section:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: mention -> mentioned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

before_install: nvm install 6.10.3
script: cd demo && npm run build.plugin && npm i && npm run build-android-bundle && cd ../demo-angular && npm run build.plugin && npm i && npm run build-android-bundle
```
This stage includes two builds that run in parallel—one for Android, and one for iOS. Note that the nodejs on the Linux machine is installed because it is not included in the image.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add spaces before and after the dash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

jdk: oraclejdk8
script: cd demo && npm run ci.ios.build && cd ../demo-angular && npm run ci.ios.build
```
The scripts (`ci.android.build` and `ci.ios.build`) that are executed for building for iOS and Android are located in [package.json](https://github.com/NativeScript/nativescript-facebook/blob/master/demo/package.json#L49) file of any of the demo apps.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can escape the repetition of "for" -> .. executed to build for iOS and Android..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


The main benefit of having sanity checks in place for your NativeScript plugins is that you can develop without spending additional time to ensure your changes don't break existing applications depending on your plugin.

Do not forget to [add a Travis CI badge](https://docs.travis-ci.com/user/status-images/) in your NativeScript plugin's project! It reports live status of your CI build and makes your plugin look more reliable. No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add ".. in github" -> Do not forget to add a Travis CI badge in your NativeScript plugin's project in github.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is no other place I think it is common sense that we are talking about GitHub repo.


Travis CI is a great way to automate plugin’s sanity checks. It is free for open-source projects. More details can be found in [Travis CI documentation](https://docs.travis-ci.com/). Travis CI will boot a virtual machine and execute commands based on the provided configuration in your `.travis.yml` file.

First things first! Add an empty `.travis.yml` file on the root level of your plugin.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think somewhere between these row you can add a sentence saying that if you use the seed, you have an initial .travis.yml file setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@angeltsvetkov angeltsvetkov force-pushed the atsvetkov/plugin-sanity-check branch 2 times, most recently from 4182d02 to e1d53ed Compare July 4, 2017 07:04
@angeltsvetkov angeltsvetkov force-pushed the atsvetkov/plugin-sanity-check branch 2 times, most recently from 557c9d0 to e6654fa Compare July 6, 2017 12:58
@angeltsvetkov angeltsvetkov force-pushed the atsvetkov/plugin-sanity-check branch from e6654fa to 0b6b3a8 Compare July 6, 2017 13:04
@angeltsvetkov angeltsvetkov changed the title Add article "Sanity Check A Plugin" Add article "Ensure Plugins Quality" Jul 6, 2017
@angeltsvetkov angeltsvetkov merged commit 110aa6a into master Jul 6, 2017
@angeltsvetkov angeltsvetkov deleted the atsvetkov/plugin-sanity-check branch July 6, 2017 13:52
@lock
Copy link

lock bot commented Aug 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants