Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何构建Meteor智能包_Meteor_Package - Fatal编程技术网

如何构建Meteor智能包

如何构建Meteor智能包,meteor,package,Meteor,Package,如何构建一个会出现在流星列表中的流星 构建软件包相当不错,但构建Meteor软件包却不是这样。注意:软件包开发目前没有文档记录,API将发生变化。你被警告了 也就是说,实际上很容易开始: 首先,git克隆了meteor repo的副本。在/packages中创建一个新目录。将package.js文件放在目录中(有关示例,请参阅其他包)。现在你有一个包裹了 接下来,从您的签出运行meteor脚本(不是安装程序安装的脚本)。从签出运行时,脚本将使用签出中的本地包目录。当您更改包中的代码时,它甚至会热

如何构建一个会出现在流星列表中的流星


构建软件包相当不错,但构建Meteor软件包却不是这样。

注意:软件包开发目前没有文档记录,API将发生变化。你被警告了

也就是说,实际上很容易开始:

首先,git克隆了meteor repo的副本。在/packages中创建一个新目录。将package.js文件放在目录中(有关示例,请参阅其他包)。现在你有一个包裹了

接下来,从您的签出运行meteor脚本(不是安装程序安装的脚本)。从签出运行时,脚本将使用签出中的本地包目录。当您更改包中的代码时,它甚至会热重新加载

查看其他包中的示例,了解API的功能


编辑:在第三方软件包方面已经取得了很大进展。退房,日期为2013年6月12日。这是当时的正确答案,仍然是一种替代解决方案:

就像我说的。这是没有文件的,你应该用陨石

如果你坚持用meteor创建一个包,我找到了一个很好的非官方的方法,但你真的不应该这样做。Meteor将在即将发布的版本中推出一种创建包的方法

构建流星包:

我会用陨石来做的

# cunneen:foo package
显然,您有node,我假设您有node包管理器(npm),所以到目前为止,制作meteor包的最佳方法是制作meteorite智能包

npm install meteorite
Meteorite智能包包含创建包所必需的2个关键文件 -package.js -smart.json

Meteorite文件存储在您的系统登录用户帐户下:~/.Meteorite/
但是,是否符号链接到您当前创建流星应用程序的位置:project/.meteor/meteorite/

Sample package.js:

Package.describe({
   summary: "User analytics suite for meteor"
});

Package.on_use(function (api) {
   api.add_files('user_analytics.js', 'client');
});
示例smart.json

{
   "name": "User analytics",
   "description": "User Analytics",
   "homepage": "http://yourHomepage.com",
   "author": "Eric Leroy",
   "version": "0.1",
   "git": "https://github.com/yipyo",
   "packages" : {}
}
如果您需要更多信息,请从以下列表中安装mrt包:

mrt list
然后分析app/.meteor/meteorite/目录下的文件

希望这会有所帮助,并继续发展未来最好的语言

以下是一些有用的链接:

  • -解释Meteor核心概念的优秀教程

上有一个很好的关于这个主题的屏幕放映。

请看科伯比的

以下是过时的信息:

Package.describe({
   summary: "User analytics suite for meteor"
});

Package.on_use(function (api) {
   api.add_files('user_analytics.js', 'client');
});
请参阅有关新meteor包装系统的信息:

**旧信息**

有关于和的更新信息。不过,API在1.0之前是不稳定的,所以要做好做很多更改的准备

我已经包括锅炉板,以帮助w/使其同时成为节点和流星可用库。我花了相当长的时间才弄明白这一点,并愿意接受建议

包:/lib/my.js

if (typeof Meteor === 'undefined) {
    // Not Running In Meteor (nodejs code)
    // example NPM/Node Dependencies that we'll use
    var async = require('async');
    var debug = require('debug')('my:package');
    var mongodb = require('mongodb');

    var http = require('http');  
} else {
    // Running as Meteor Package
    var async = Npm.require('async');
    var debug = Npm.require('debug')('my:package');
    var mongodb = Npm.require('mongodb');

    // node core module 'http'
    // use Npm.require to require node core modules
    // but doesnt need Npm.depends in the package.js file
    var http = Npm.require('http');
}

var constructor = function(property1) {
    this.property1 = property1; // or whatever in your constructor.
};

if (typeof Meteor === 'undefined') {
   // Export it node style
   My = exports = module.exports = constructor; // Limit scope to this nodejs file
} else {
   // Export it meteor style
   My = constructor; // Make it a global
}

// Proceed defining methods / properties as usual.
My.prototype.doStuff = function() { console.log('hello world'); }
Package.describe({
  summary: "My Meteor Package"
});

/**
 * Ex: Some NPM Dependencies
 */
Npm.depends({
  'async': '0.2.9',
  'debug': '0.7.2',
  'mongodb': '1.3.18'
});

/**
 * On use we'll add files and export our tool
 */
Package.on_use(function (api) {
  /**
   * Add all the files, in the order of their dependence (eg, if A.js depends on B.js, B.js must be before A.js)
   */
  api.add_files([
    'lib/my.js' // <-- include all the necessary files in the package
    ],
    'server'); // Can be 'server', 'client' , ['client','server']

  /**
   * Only expose the My constructor, only export if meteor > 0.6.5
   */
  api.export && api.export(['My'], 'server'); // 1st arg can be array of exported constructors/objects, 2nd can be 'server', 'client', ['client', 'server']
});
var my = new My('a property');
my.doStuff(); // console logs 'hello world' on the server
package:/package.js

if (typeof Meteor === 'undefined) {
    // Not Running In Meteor (nodejs code)
    // example NPM/Node Dependencies that we'll use
    var async = require('async');
    var debug = require('debug')('my:package');
    var mongodb = require('mongodb');

    var http = require('http');  
} else {
    // Running as Meteor Package
    var async = Npm.require('async');
    var debug = Npm.require('debug')('my:package');
    var mongodb = Npm.require('mongodb');

    // node core module 'http'
    // use Npm.require to require node core modules
    // but doesnt need Npm.depends in the package.js file
    var http = Npm.require('http');
}

var constructor = function(property1) {
    this.property1 = property1; // or whatever in your constructor.
};

if (typeof Meteor === 'undefined') {
   // Export it node style
   My = exports = module.exports = constructor; // Limit scope to this nodejs file
} else {
   // Export it meteor style
   My = constructor; // Make it a global
}

// Proceed defining methods / properties as usual.
My.prototype.doStuff = function() { console.log('hello world'); }
Package.describe({
  summary: "My Meteor Package"
});

/**
 * Ex: Some NPM Dependencies
 */
Npm.depends({
  'async': '0.2.9',
  'debug': '0.7.2',
  'mongodb': '1.3.18'
});

/**
 * On use we'll add files and export our tool
 */
Package.on_use(function (api) {
  /**
   * Add all the files, in the order of their dependence (eg, if A.js depends on B.js, B.js must be before A.js)
   */
  api.add_files([
    'lib/my.js' // <-- include all the necessary files in the package
    ],
    'server'); // Can be 'server', 'client' , ['client','server']

  /**
   * Only expose the My constructor, only export if meteor > 0.6.5
   */
  api.export && api.export(['My'], 'server'); // 1st arg can be array of exported constructors/objects, 2nd can be 'server', 'client', ['client', 'server']
});
var my = new My('a property');
my.doStuff(); // console logs 'hello world' on the server
meteor app:smart.json,将您的文件添加到包列表中

{
    packages:{
        "node-my": {
            "git": "git@github.com:myAccount/node-my.git"
        }
    }
}

最后在命令行上运行
mrt install
,让它安装软件包<嘘

Meteor现在支持
创建--package
命令

示例(将您自己的替换为“cunneen”):

meteor创建--package cunneen:foo 输出:

cunneen:foo:在应用程序中创建

结果:

packages/cunneen:foo/package.js

if (typeof Meteor === 'undefined) {
    // Not Running In Meteor (nodejs code)
    // example NPM/Node Dependencies that we'll use
    var async = require('async');
    var debug = require('debug')('my:package');
    var mongodb = require('mongodb');

    var http = require('http');  
} else {
    // Running as Meteor Package
    var async = Npm.require('async');
    var debug = Npm.require('debug')('my:package');
    var mongodb = Npm.require('mongodb');

    // node core module 'http'
    // use Npm.require to require node core modules
    // but doesnt need Npm.depends in the package.js file
    var http = Npm.require('http');
}

var constructor = function(property1) {
    this.property1 = property1; // or whatever in your constructor.
};

if (typeof Meteor === 'undefined') {
   // Export it node style
   My = exports = module.exports = constructor; // Limit scope to this nodejs file
} else {
   // Export it meteor style
   My = constructor; // Make it a global
}

// Proceed defining methods / properties as usual.
My.prototype.doStuff = function() { console.log('hello world'); }
Package.describe({
  summary: "My Meteor Package"
});

/**
 * Ex: Some NPM Dependencies
 */
Npm.depends({
  'async': '0.2.9',
  'debug': '0.7.2',
  'mongodb': '1.3.18'
});

/**
 * On use we'll add files and export our tool
 */
Package.on_use(function (api) {
  /**
   * Add all the files, in the order of their dependence (eg, if A.js depends on B.js, B.js must be before A.js)
   */
  api.add_files([
    'lib/my.js' // <-- include all the necessary files in the package
    ],
    'server'); // Can be 'server', 'client' , ['client','server']

  /**
   * Only expose the My constructor, only export if meteor > 0.6.5
   */
  api.export && api.export(['My'], 'server'); // 1st arg can be array of exported constructors/objects, 2nd can be 'server', 'client', ['client', 'server']
});
var my = new My('a property');
my.doStuff(); // console logs 'hello world' on the server
Package.description({
名称:'cunneen:foo',
版本:“0.0.1”,
//简单的一行程序包摘要。
摘要:“”,
//指向包含此包源代码的Git存储库的URL。
git:“”,
//默认情况下,Meteor将默认使用README.md作为文档。
//为避免提交文档,请将此字段设置为null。
文档:“README.md”
});
包.onUse(函数(api){
api.versionFrom('1.0.3.1');
addFiles('cunneen:foo.js');
});
Package.onTest(函数(api){
api.使用(“tinytest”);
api.use('cunneen:foo');
addFiles('cunneen:foo tests.js');
});
packages/cunneen:foo/foo.js(空文件)

//在这里编写您的包代码!
packages/cunneen:foo/foo tests.js

if (typeof Meteor === 'undefined) {
    // Not Running In Meteor (nodejs code)
    // example NPM/Node Dependencies that we'll use
    var async = require('async');
    var debug = require('debug')('my:package');
    var mongodb = require('mongodb');

    var http = require('http');  
} else {
    // Running as Meteor Package
    var async = Npm.require('async');
    var debug = Npm.require('debug')('my:package');
    var mongodb = Npm.require('mongodb');

    // node core module 'http'
    // use Npm.require to require node core modules
    // but doesnt need Npm.depends in the package.js file
    var http = Npm.require('http');
}

var constructor = function(property1) {
    this.property1 = property1; // or whatever in your constructor.
};

if (typeof Meteor === 'undefined') {
   // Export it node style
   My = exports = module.exports = constructor; // Limit scope to this nodejs file
} else {
   // Export it meteor style
   My = constructor; // Make it a global
}

// Proceed defining methods / properties as usual.
My.prototype.doStuff = function() { console.log('hello world'); }
Package.describe({
  summary: "My Meteor Package"
});

/**
 * Ex: Some NPM Dependencies
 */
Npm.depends({
  'async': '0.2.9',
  'debug': '0.7.2',
  'mongodb': '1.3.18'
});

/**
 * On use we'll add files and export our tool
 */
Package.on_use(function (api) {
  /**
   * Add all the files, in the order of their dependence (eg, if A.js depends on B.js, B.js must be before A.js)
   */
  api.add_files([
    'lib/my.js' // <-- include all the necessary files in the package
    ],
    'server'); // Can be 'server', 'client' , ['client','server']

  /**
   * Only expose the My constructor, only export if meteor > 0.6.5
   */
  api.export && api.export(['My'], 'server'); // 1st arg can be array of exported constructors/objects, 2nd can be 'server', 'client', ['client', 'server']
});
var my = new My('a property');
my.doStuff(); // console logs 'hello world' on the server
//在这里编写测试!
//这里有一个例子。
Tinytest.add('示例',函数(测试){
测试。相等(真,真);
});
packages/cunneen:foo/README.md(空文件)


要获得一个好的(非常全面的)示例,请看。

如果有一个类似npm的工具,那就太好了;)我正在寻找一种方法来导入我的Meteor项目。访问此库客户端/服务器端的最佳解决方案是什么?谢谢你出色的工作!太神了app_root/lib/moment.js和。。。那就是坐??只是太神了我没有在doc中找到它,没有?@n1mmy我从github克隆了repo,转到克隆的
meteor
文件夹,下载了一个自定义jquery构建,并将生成的js文件放在
包中的一个新子文件夹中。我从现有的
jquery
包中复制/粘贴了一个
package.js
文件,并编辑其内容以反映我的自定义
jquery
构建的名称。接下来,我转到克隆的
meteor
文件夹的根目录,运行
/meteor
,在dev_bundle中安装了
依赖项工具包v0.1.4。
。到现在为止,一直都还不错。但是运行meteor list(流星列表)不会显示我的新包。想法?
mrt list
实际上将
list
命令传递到
meteor
,因此您将获得智能包,而不是应该在
mrt
之前运行
mrt add node my
我没有看到关于如何在引用链接处创建包的清晰文档。是否有一个很好的参考当前的方法在某处这样做?见答案b