How to build a Meteor smart package

Meteor now supports a create --package command.

See the meteor docs.

Example (substitute your own meteor developer account for “cunneen”):

meteor create --package cunneen:foo

Output:

cunneen:foo: created in your app

Results:

packages/cunneen:foo/package.js

Package.describe({
  name: 'cunneen:foo',
  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.0.3.1');
  api.addFiles('cunneen:foo.js');
});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('cunneen:foo');
  api.addFiles('cunneen:foo-tests.js');
});

packages/cunneen:foo/foo.js (empty file)

// Write your package code here!

packages/cunneen:foo/foo-tests.js

// Write your tests here!
// Here is an example.
Tinytest.add('example', function (test) {
  test.equal(true, true);
});

packages/cunneen:foo/README.md (empty file)

# cunneen:foo package

For a good (VERY comprehensive) example, take a look at iron-router.

Leave a Comment