nat-test
您令人惊叹的 NativeScript + Angular 插件。
npm i --save nat-test

现在就开发一个 nativescript-angular 插件

Angular 2 Style Guide MIT license Dependency Status

Demo
Android 和 iPhone 运行相同的 {N} + Angular 插件。

种子已配置好,以便您快速创建一个 nativescript-angular 插件。

  • 准备好让您尝试的示例演示应用程序。
  • 已为您创建示例 ComponentDirectivePipeService 以便立即开始(测试即将推出)。
  • 根据需要自定义插件,并删除其他部分。

开始

  1. 下载此种子的 zip 文件。
  2. cd ... 解压文件夹的路径 ...
  3. npm install -g nativescript
  4. npm run setup
  5. 开始工作。

所需更改

您可能需要更改一些内容以适应您的插件。

  1. 将所有 nativescript-ngx-yourplugin 实例替换为 您的 插件名称
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/package.json
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/src/package.json#L22
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/tsconfig.json#L13(可能还需要根据您特定的插件 TypeScript 定义需求进行更多修改)
  1. 修改示例以导入您的插件文件等
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/src/app/main.ts#L12
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/src/app/main.ts#L18
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/src/app/app.component.ts#L3
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/src/app/app.component.ts#L22
  1. 将 'YourPluginModule' 替换为 您的 插件模块名称
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/nativescript-ngx-yourplugin.ts#L30
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/src/app/main.ts#L12
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/src/app/main.ts#L18
  1. 如果您修改了服务、组件等名称,或创建了新的并希望导出它们
  • 这里:https://github.com/NathanWalker/nativescript-ngx-plugin-seed/blob/master/nativescript-ngx-yourplugin.ts#L3-L28

开发工作流程

修改插件文件,然后

npm run demo.ios

// or...

npm run demo.android

构建插件

您应该在发布之前运行此操作。

npm run build

发布

packagedev.json 应始终与开发中的 package.json 保持一致。在为您的插件安装依赖项并运行示例后,只需将 package.json 的内容复制到 packagedev.json

然后,为了发布

  1. 设置 packagepublish.json 以符合您希望发布的插件方式(例如,提升正确的版本并设置描述、作者、关键词、repo、main 和 typings)。
  2. node prep publish(这将设置您的 package.jsonpackagepublish.json)。
  3. npm run build(创建您库的新版本)
  4. npm publish

返回开发

发布后,在提交更改之前将您的 package.json 返回到开发模式是一个好主意。您的 packagedev.json 应与发布上述内容之前开发模式中的包完全一致。

  1. node prep dev
  2. 继续开发。

故障排除

在准备您的演示时,如果您收到以下错误消息

Plugin "nativescript-ngx-yourplugin" is not installed.
Sending exception report (press Ctrl+C to stop).....

这意味着您的插件尚未复制到演示项目,或者之前运行演示命令时失败。要解决此问题,请运行 npm run repair

为什么使用 TNS 前缀名称?

TNS 代表 Telerik NativeScript

iOS 使用以 NS 前缀的类(源于古老的 NeXTSTEP 时代):https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/

为了避免与iOS原生类混淆,使用TNS代替。

许可证

MIT