Meteor package.js
C:\Users\Administrator\Desktop\meteorApp> mkdir packages
现在我们可以在上面创建的文件夹中创建你的包。运行命令提示符运行以下命令。Username 是您的 Meteor 开发者的用户名和package-name是你的包的名称。
C:\Users\Administrator\Desktop\meteorApp\packages>meteor create --package username:package-name
添加包
为了能够本地包添加到我们的应用程序,需要设置环境变量(ENVIRONMENT VARIABLE),将告诉 meteor 从本地文件夹加载包。右键单击"计算机"图标,然后选择属性/高级系统设置/环境变量/新建。
变量名应该是PACKAGE_DIR变量值路径应该是指向创建的文件夹。在我们的示例中是:C:\Users\Administrator\Desktop\meteorApp\packages.
C:\Users\Administrator\Desktop\meteorApp>meteor add username:package-name
包文件
- package-name-test.js
- package-name.js
- package.js
- README.md
测试包(package-name-test.js)
C:\Users\Adminitrator\Desktop\meteorApp>meteor add tinytest
如果你打开 package-name-test.js, 你会看到默认的测试例子。我们将用这个例子来测试应用程序。开发 Meteor 包时,你应该要写写自己的测试。
C:\Users\Administrator\Desktop>meteor test-packages packages/package-name


package.js文件
我们可以在这个文件中编写代码。现在我们在包中实现一些简单的功能。包将日志记录一些文本到控制台。
packages/package.js
myPackageFunction = function() {
console.log('This is simple package...');
}
package-name.js文件
这是我们可以设定一些程序包配置文件。 我们一会再回到它,但现在需要导出myPackageFunction,就可以在应用程序中使用它了。我们需要添加这些到 Package.onUse 函数内。该文件将是这个样子。
packages/package-name.js
Package.describe({
name: 'username:package-name',
version: '0.0.1',
// Brief, one-line summary of the package.
summary: '',
// URL to the Git repository containing the source code for this package.
git: '',
// By default, Meteor will default to using README.md for documentation.
// To avoid submitting documentation, set this field to null.
documentation: 'README.md'
});
Package.onUse(function(api) {
api.versionsFrom('1.2.1');
api.use('ecmascript');
api.addFiles('mypackage.js');
api.export('myPackageFunction'); // We are exporting the function we created above...
});
Package.onTest(function(api) {
api.use('ecmascript');
api.use('tinytest');
api.use('username:package-name');
api.addFiles('package-name-tests.js');
});
packages/package.js
if(Meteor.isClient) {
myPackageFunction();
}


这是一个例子文件...看看一就知道了
/* Information about this package */
Package.describe({
// Short two-sentence summary.
summary: "What this does",
// Version number.
version: "1.0.0",
// Optional. Default is package directory name.
name: "username:package-name",
// Optional github URL to your source repository.
git: "https://github.com/something/something.git",
}); /* This defines your actual package */
Package.onUse(function (api) {
// If no version is specified for an 'api.use' dependency, use the
// one defined in Meteor 0.9.0.
api.versionsFrom('0.9.0');
// Use Underscore package, but only on the server.
// Version not specified, so it will be as of Meteor 0.9.0.
api.use('underscore', 'server');
// Use iron:router package, version 1.0.0 or newer.
api.use('iron:router@1.0.0');
// Give users of this package access to the Templating package.
api.imply('templating')
// Export the object 'Email' to packages or apps that use this package.
api.export('Email', 'server');
// Specify the source code for the package.
api.addFiles('email.js', 'server');
}); /* This defines the tests for the package */
Package.onTest(function (api) {
// Sets up a dependency on this package
api.use('username:package-name');
// Allows you to use the 'tinytest' framework
api.use('tinytest@1.0.0');
// Specify the source code for the package tests
api.addFiles('email_tests.js', 'server');
}); /* This lets you use npm packages in your package*/
Npm.depends({
simplesmtp: "0.3.10",
"stream-buffers": "0.2.5"
});
Meteor package.js的更多相关文章
- 更改package.js后重新加载
node --save可有省略掉手动修改package.json的步骤 当你为你的模块安装一个依赖模块时,正常情况下你得先安装他们(在模块根目录下npm install module-name), ...
- 安装package.js
- windows下Meteor+AngularJS开发的坑
有复杂的地方我再开贴记录,这里只记录容易解决的坑. 1. windows下手工增加smart package.直接将下载下来的包扔到meteor package中.记得将文件夹名字改得和smart.j ...
- 示例开发过程记录:meteor,react,apollo
本示例记录一个开发过程: 1)参考 Meteor React TUTORIAL教程 https://www.meteor.com/tutorials/react/creating-an-app 2). ...
- vue.js源码精析
MVVM大比拼之vue.js源码精析 VUE 源码分析 简介 Vue 是 MVVM 框架中的新贵,如果我没记错的话作者应该毕业不久,现在在google.vue 如作者自己所说,在api设计上受到了很多 ...
- vulcanjs 简单package 编写
vulcanjs 功能是以包进行管理,包里面包含了运行依赖的组件以及对于路由的注册 参考项目 项目结构 ├── README.md ├── license.md ├── package-lock.js ...
- OHIFViewer meteor build 问题
D:\Viewers-master\OHIFViewer>meteor build --directory d:/h2zViewerC:\Users\h2z\AppData\Local\.met ...
- 基于webpack和vue.js搭建开发环境
前言 在对着产品高举中指怒发心中之愤后,真正能够解决问题的是自身上的改变,有句话说的好:你虽然改变不了全世界,但是你有机会改变你自己.秉承着“不听老人言,吃亏在眼前”的优良作风,我还是决定玩火自焚. ...
- 用Javascript(js)进行HTML转义工具(处理特殊字符显示)
转自:http://blog.csdn.net/hj7jay/article/details/51280405 众所周知页面上的字符内容通常都需要进行HTML转义才能正确显示,尤其对于Input,T ...
随机推荐
- Codeforces Gym 2015 ACM Arabella Collegiate Programming Contest(二月十日训练赛)
A(By talker): 题意分析:以a(int) op b(int)形式给出两个整数和操作符, 求两个整数是否存在操作符所给定的关系 ,有则输出true,无则输出false: 思路:由于无时间复杂 ...
- hasChildNodes()方法,nodeName、nodeValue、nodeType介绍
Document对象的使用:hasChildNodes()方法,nodeName.nodeValue.nodeType的简单介绍 一.hasChildNodes() 说明: (1) 该方法 ...
- k8s集群之Docker安装镜像加速器配置与k8s容器网络
安装Docker 参考:https://www.cnblogs.com/rdchenxi/p/10381631.html 加速器配置 参考:https://www.cnblogs.com/rdchen ...
- postman设置环境变量、全局变量
讲postman环境变量设置之前,先讲一个小插曲,环境变量.全局变量的区别在于Globals,只能用一组,而Environmen可以设置多组,所以我更喜欢设置环境变量 1.环境变量-Environme ...
- reciting
When I was seventeen, I read a quote that went something like, '' if you live your each day as if it ...
- JavaEE-07 过滤器和监听器
学习要点 过滤器 监听器 过滤器Filter 过滤器的概念 过滤器位于客户端和web应用程序之间,用于检查和修改两者之间流过的请求和响应. 在请求到达Servlet/JSP之前,过滤器截获请求. 在响 ...
- _vimrc配置
set nocompatible set encoding=utf8 set guioptions-=T set number set guifont=consolas:h12 source $VIM ...
- jquery 拖动(Draggable) 约束运动,输出数组排序Array
<!doctype html><html lang="en"><head> <meta charset="utf-8" ...
- POJ-3624-背包问题
它这个问题问的是,在有限的容量下,能装下的最大价值是多少. 所以我们可以递归求解,记忆性递归,用二维数组,但是这样的话就会超内存,所以我们只能用动规来写,而且不能开二维数组, 只能用滚动数组. 我们设 ...
- bacula快速部署
快速部署: Server端:DD.SD.Monitor.Console均部署在Server上Client端:FD Server端部署:上传事先下载的源码包 tar xvf bacula-9.2.0.t ...