How to build a Meteor package?

 In this post we will see how to create a weather package in a few steps, if you want to see something more complete I recommend the post “writing the package in The Meteor Chef”.

The package in this tutorial: RSS2.0

The sources of the package: Github

The result : RSS

Initial setup.

The first thing to do is create a directory to store the packages that we’ll create in the future, in my case /Users/allanqueiroz/devtools/public/packages.

Within this directory, we’ll create the new package.

[code language=”shell”]
meteor create –package allandequeiroz:rss2.0
[/code]

Tip: An interesting tool is the package-kitchen, you may want to check there when you’re creating your next package =]

The next step is to override the environment variable PACKAGE_DIRS and points it to our new packages directory (I recommend putting this export into your .bash *).

[code language=”shell”]
export PACKAGE_DIRS="/Users/allanqueiroz/devtools/public/packages"
[/code]

If you changed your .bash*, update ir with source .bash*

Then, in the same “packages” directory, create a project for tests propose.

[code language=”shell”]
meteor create tester
cd tester
meteor add tinytest
[/code]

Now run to see what happens.

[code language=”shell”]
meteor test-packages allandequeiroz:rss2.0
[/code]

meteor test-packages allandequeiroz:rss2.0

The application starts up (http: // localhost: 3000) and you can see a panel with all your tests, the rss2.0 for example has only one.

Image 2015-06-04 at 12.52.42 PM.png

Now just let your application tests running, write the tests and implement your package 😉

 

Deploying at Atmosphere

To upload your creation to the Atmosphere, just run meteor publish –create at the root of the package. And when you need to update it meteor publish, but do not forget to change the version in package.js to avoid errors.

Or to upload changes in the current version meteor publish -update

 

Conclusion


It’s not difficult to create a Meteor package, the work is basically move that code that you perhaps already have in your application to other place. After that, has no mysteries, basically all packets follow the pattern Github and Atmosphere, with a few exceptions where the package sources are not available, but obviously you’ll not do this 😉

Leave a Reply