NativeScript / NativeScript/nativescript-cli

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

未关闭
#1,530 17 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

breaking-change feature plugins
主要语言
JavaScript
星标
1.1k
派生
204
平均合并
1 天 9 小时
30 天内合并 PR
8

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

tns plugin add 的验证流程以及插件 package.json 文件中的 nativescript 部分入手;检查当前如何比较运行时版本。使用 npm 文档说明的 semver 范围,使精确值、caret 和 tilde 值产生所提议的兼容性行为,并通过测试验证受支持和被拒绝的运行时版本。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
cli, mobile-dev
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。