nativescript-linkpreview
获取链接预览数据
npm i --save nativescript-linkpreview

现在开发 NativeScript 插件(使用 TypeScript)

入门

  1. git clone https://github.com/NathanWalker/nativescript-plugin-seed.git myplugin
  2. npm install -g typescript
  3. cd myplugin
  4. npm run postclone
  5. npm run setup
  6. 开始工作。

此种子扩展了在此处介绍的一些功能 (点击查看).

用法

该种子已准备好,允许您通过 demo 文件夹测试和试用您的插件。此外,它还提供了适当的 .gitignore 以保持 GitHub 整洁,以及 .npmignore 以确保您通过 npm 发布插件时每个人都满意。

链接到 CocoaPod 或 Android Arsenal 插件

您需要在根目录中创建这些文件夹和文件

platforms --
ios --
Podfile
android --
include.gradle

这样做将使原生 API 对您的插件可用 :)

查看这些现有插件以了解如何非常简单地完成此操作

典型开发工作流程

  1. 修改插件文件
  2. demo 中进行更改以测试这些更改
  3. npm run demo.iosnpm run demo.android (必须从根目录运行)

这些 demo 任务只是通用助手。您可能希望对您想要运行的设备或仿真器有更精细的控制。为此,您只需手动运行即可

cd demo

// 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-linkpreview
tns plugin add ..

// manual platform adds
tns platform add ios
// and/or
tns platform add android

然后使用 tns 命令行中的任何可用选项

单元测试

此插件自动将基于 Jasmine 的单元测试支持添加到您的插件中。打开 demo/app/tests/tests.js 并调整其内容。

您可以在此处了解更多关于此主题的信息 (点击查看).

一旦您准备好测试插件的 API,请在插件根目录中执行以下命令之一

npm run test.ios
npm run test.android

发布

当您准备发布时

  • package.json 中增加版本号
  • npm run build - 非常重要 - 在您发布之前确保已构建最新版本
  • npm publish

贡献 - 想让种子变得更好吗?

或者至少帮助它保持与 NativeScript 发布的同步,这将是非常出色的。

npm install -g typescript  // if you don't already have it
git clone https://github.com/NathanWalker/nativescript-plugin-seed
cd nativescript-plugin-seed

// Improve!