question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use npm's semver rules for plugin's nativescript key

See original GitHub issue

Problem with plugins verification with runtimes

Currently each NativeScript plugin must have nativescript key in it’s package.json and define the minimum required version of each supported runtime. The structure is :

"name": "my-plugin",
"version": "1.0.0",
"nativescript": { 
    "platforms": {
        "ios": "1.5.0",
        "android": "1.5.0",
    }
}

When tns plugin add my-plugin is executed, CLI checks the values against current runtimes versions and informs the user if a plugin cannot be used with current version. However CLI uses the specified version in the plugin as minimum required. So for example in case the project uses tns-android 1.6.0, 1.6.2 or even 2.0.0 for example, it can use my-plugin. This makes it really hard to control the versions against which the plugin is tested and verified by the plugin author.

Suggested solution

Do not reinvent the wheel! Use semver rules for the nativescript key in package.json, for example:

"name": "my-plugin",
"version": "1.0.0",
"nativescript": { 
    "platforms": {
        "ios": "^1.5.0",
        "android": "~1.5.0",
    }
}

This way in case the project targets android 1.5.2, the plugin can be installed, but in case it targets 1.6.0, the plugin will not be available. More information for the version ranges: https://docs.npmjs.com/getting-started/semantic-versioning#semver-for-consumers

Breaking change

In case we implement this idea, all plugins, which currently has nativescript key inside their package.json, will not work, as the values: “1.5.0” will mean - can work with this version only.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
EddyVerbruggencommented, Feb 28, 2016

Just trying to understand the implications:

If I change the version in my plugins today to say ~1.5.0 would that mean users of the current tns CLI won’t be able to use the plugin? I’m not sure minimum version ~1.5.0 currently matches anything.

If that breaks usage with the current CLI, then plugins can only be upgraded after the new CLI algorithm has been implemented and released, and when it is NO ONE (using plugins) will be able to use those plugins. Until the plugin versions have been updated to no longer exactly match a specific version.

0reactions
rosen-vladimirovcommented, Jan 14, 2020

I think much better approach is to have runtimes as dependencies/devDependencies in the application instead of reinventing the wheel with additional keys and rules for package.json: https://github.com/NativeScript/nativescript-cli/issues/4511

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Use npm's semver rules for plugin's nativescript key -
Problem with plugins verification with runtimes. Currently each NativeScript plugin must have nativescript key in it's package.json and define the minimum ...
Read more >
Plugin Reference - NativeScript Docs
A collection of reference material for NativeScript plugin authors, including a plugin's required folder structure, npm configuration, and gradle ...
Read more >
nativescript-code-push-cli - npm
Start using nativescript-code-push-cli in your project by running `npm ... After you create an app, the CLI will output the deployment keys ......
Read more >
How to Use Semantic Versioning in NPM | heynode.com
In this tutorial we learned that Semantic Versioning dictates how a packages version number is incremented by following the MAJOR.MINOR.PATCH format. We learned ......
Read more >
nativescript-plugin-firebase-ssi - npm package - Snyk
Just run $ANDROID_HOME/tools/bin/sdkmanager --update from a command prompt or launch the SDK manager from Android Studio, expand Extras and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found