how to setup a smart package

393 views
Skip to first unread message

Joc O'Connor

unread,
Nov 8, 2012, 4:28:45 AM11/8/12
to meteo...@googlegroups.com
I am writing a new smart package which I have working using meteorite and a path link in the smart.json file.

However, I can't seem to get it working as a testable package like the built-in Meteor ones i.e. I want to be
able to cd into the package and run either meteor or mrt and get back test results in the browser.

so far I have tried setting up a package.js file:

Package.describe({
  summary: "text comparison tools"
});

Package.on_use(function (api, where) {
  where = where || ['client', 'server'];

  api.use(['underscore'], where);

  api.add_files([
    'text-tools.js'
  ], where);
});

Package.on_test(function (api) {
  api.use('text-tools', 'client');
  api.use('tinytest');
  api.add_files('text_tools_tests.js', 'client');
});

with a single dummy test in the test file and
simple do nothing code in text-tools.js

which didn't work and gave me an error about the 'text-tools' not being found.
Then I made a new folder using 'meteor create text-tools' with the same files replacing the ones created by meteor.
This now runs (using meteor) but then I get an error saying 'Package is not defined'.

Is there something obvious I am doing wrong? Should this all be inside the meteor source packages folder?

Joc

Tom Coleman

unread,
Nov 8, 2012, 7:20:59 PM11/8/12
to meteo...@googlegroups.com
Hi Joc,

There isn't any easy way to run built in package tests for smart packages right now. I was annoyed by this just the other day.

You _can_ do it the pre-meteorite way--copy or symlink your smart package directly into a meteor install's packages folder and run it from there.

This isn't great; discouraging people from testing smart packages is _bad_. I'm on it.

Cheers,
Tom
--
You received this message because you are subscribed to the Google Groups "meteor-talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/meteor-talk/-/n0KTspojyewJ.
To post to this group, send email to meteo...@googlegroups.com.
To unsubscribe from this group, send email to meteor-talk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/meteor-talk?hl=en.

Joc O'Connor

unread,
Nov 8, 2012, 11:35:21 PM11/8/12
to meteo...@googlegroups.com
Hi Tom,

you're in danger of becoming Saint Tom at this rate, really do appreciate you taking time to help here and on IRC.

If there is any way I can help let me know, I'm spending all my time getting up to speed with Meteor while working
on our products so I'm well up for pitching in where I can. I was planning on tackling some of the minimongo to-do list
but thought I might tackle my own smart package first to get a feel for the smart packaging process and API.

Looks like I will have to place my smart package into the meteor source for now?

Thanks again,

Joc

Tom Coleman

unread,
Nov 9, 2012, 2:00:31 AM11/9/12
to meteo...@googlegroups.com
Hi Joc,

Thanks! Did I help you on IRC? I'm not sure I know what your handle is if so =)

Yeah, for now, you'll have to do that. I think developing packages is great, although it would also be awesome to take minimongo to the next level too...

I'm hopeful of getting the change made to meteorite sometime next week, so you won't be suffering for too long.

Cheers,
Tom
To view this discussion on the web visit https://groups.google.com/d/msg/meteor-talk/-/dDYnMkvdG_oJ.

Joc O'Connor

unread,
Nov 9, 2012, 6:29:42 AM11/9/12
to meteo...@googlegroups.com
Hi,

yes, you sorted out my issue old with packages hanging around in meteorite, that it wasn't deleting the .meteorite folder on trying to uninstall.

I'm oranj on IRC.

Would be awesome news if you could sort out working on smart packages as standalone projects. I have been wondering
why the base smart packages aren't separated out like this but I guess it boils down to speed and productivity for the core team.

Otherwise was just trying to find a way to contribute back to Meteor as I am really enjoying working in it so far.

Joc

Tom Coleman

unread,
Nov 11, 2012, 9:21:10 PM11/11/12
to meteo...@googlegroups.com
Hi Joc,

Ok, I just released a new version of meteorite that lets you run package tests for a meteorite package; just run `mrt` from the package's folder and things should act as you expect.

Let me know if you have any troubles. The tests for my router should run fine as an example[1]: https://github.com/tmeasday/meteor-router

Cheers,
Tom

[1] You do need to check the project out into a folder called router though, that's the one caveat. This is a limitation of meteor right now.
To view this discussion on the web visit https://groups.google.com/d/msg/meteor-talk/-/UHzKNPsSLhgJ.

Joc O'Connor

unread,
Nov 13, 2012, 9:38:24 AM11/13/12
to meteo...@googlegroups.com
Hi Tom,

thanks for working on this and sorry I didn't get back sooner but I have been trying various ways to set up
a package with little success.

Let me detail the steps I have taken:

Attempt 1
  • Used NPM to update Meteorite (version 0.4.4)
  • Created a new project using: mrt create robot
  • Stripped out the stuff I didn't need *.html, *.css
  • Added robot_test.js and referred to them in following:
  • Added package.js with contents adapted from yours in meteor-router
Attempt 2
  • Added smart.json to attempt 1 with similar contents to meteor-router's smart.json
Attempt 3
  • From scratch created a new folder with mkdir robot2
  • Added contents as above.
  • Added .meteor folder
  • Later added packages file
You will understand that this isn't an exact history of what I tried as there were many, many variations.

Mostly I get the error starting:

ReferenceError: Package is not defined
    at app/package.js:1:1
    at /Users/..<<folder path>>../robot2/.meteor/local/build/server/server.js:107:21

Is there something obvious I am not doing in setting up a package project?

Also, meteor-router when checked out into a folder called 'router' works OK.
I am going to try removing code from this until I hit a breaking point but wondered whether there was something that I was overlooking.

Joc

Tom Coleman

unread,
Nov 13, 2012, 6:41:50 PM11/13/12
to meteo...@googlegroups.com
Hi Joc,

Well that's a very strange error. I take it you are trying to run the tests in the same way as what works for the router?

Can you check what you have into github so I can try and see if I get the same problem?

Tom
To view this discussion on the web visit https://groups.google.com/d/msg/meteor-talk/-/UUGnSH0h_CMJ.

Joc O'Connor

unread,
Nov 14, 2012, 10:34:59 AM11/14/12
to meteo...@googlegroups.com
Hi Tom,

I seem to have worked through it by taking apart your meteor-router package and can now create and run tests on
my own newly created packages. Part of it was blowing away the contents of the .meteor folder and making sure
the package was named correctly but I think a restart didn't hurt either ;)

Anyway, thanks for pushing this through. I'm much happier being able to write tests for packages.

Joc
Reply all
Reply to author
Forward
0 new messages