UNPKG

8.71 kBMarkdownView Raw
1# Meteorite
2
3Meteorite is a Meteor version manager and package manager. It provides an easy way to run different versions of meteor, use non-core packages, and to install packages from the [Atmosphere package repository](https://atmosphere.meteor.com/).
4
5Meteorite provides the `mrt` that can be used to add and install smart packages from atmosphere.
6
7``` sh
8# Create an app based on Meteor's devel branch.
9$ mrt create my-app --branch devel
10$ cd my-app
11# Install an Atmosphere package, recursively fetching dependencies.
12$ mrt add router
13# Check for and install any updates, and run the app.
14$ mrt
15```
16
17## Installing Meteorite
18
19Meteorite can be installed via [npm](https://npmjs.org/).
20
21``` sh
22$ npm install -g meteorite
23```
24
25### NOTE:
26If your system requires root access to install global npm packages, make sure you use the `-H` flag:
27
28``` sh
29$ sudo -H npm install -g meteorite
30```
31
32## Updating from pre-0.6.0 Meteorite
33
34Meteorite now symlinks packages into the `packages/` directory of your app, so it's no longer necessary to run `mrt` when you want to start a server. Just make sure you `mrt install` in your app, and delete the `"meteor"` section from your `smart.json`.
35
36Subsequently, you can simply use `meteor` to run your development server, and just `mrt install` to ensure all packages are installed from atmosphere.
37
38### NOTES
39
40- Meteor is not officially supported on windows; you can run it thanks to [Tom Wijman's excellent work](http://win.meteor.com). However, meteorite's git based approach runs counter to the MSI installation that's required to get it working. So meteorite *does not* work under windows right now. Pull Requests which change this would be gladly accepted! Also, see [this blog post](http://www.discovermeteor.com/2013/03/20/using-meteor-and-atmopshere-on-windows/) for some information about how to use it.
41
42- You'll also need to ensure you have [git](http://git-scm.com) installed and available in your path. Also, you'll need to make sure that `mrt`'s install location (usually `/usr/local/bin/`) is on your path.
43
44
45## Usage
46
47### `mrt add <package>`
48
49Works like `meteor add`, but if the package isn't one of Meteor's included packages, it installs it from [Atmosphere](https://atmosphere.meteor.com).
50
51Unlike `meteor add`, only one package can be added at a time with `mrt add`.
52
53``` sh
54# Add the latest version of the moment package on Atmosphere.
55$ mrt add moment
56# Add a specific version of a package.
57$ mrt add router --version 0.3.4
58# Meteorite will install page.js too, because router depends on it.
59```
60
61### `mrt install`
62
63Install all packages listed in `smart.json` that aren't already installed on your machine. Use this command if you are working collaboratively and your colleagues install new packages.
64
65### `mrt update`
66
67Installs any available updates to the app's desired Meteor version and packages.
68
69### `mrt create-package [path/to/]foo`
70
71Puts the basic building blocks down for creating a package named `foo`, (potentially in a sub directory, usually `packages/`).
72
73### `mrt link-package path/to/foo`
74
75Links `packages/foo` to `path/to/foo` so that you can use a local version without changing `smart.json`. Useful for quick changes to a package you maintain when developing an application.
76
77Note that `mrt install` or `mrt` will _overwrite_ this link if you also have `foo` in your `smart.json` (which you probably will). This may change in the future.
78
79## Deprecated commands
80
81As Meteorite now installs packages into the `packages/` directory, you can simply run `meteor` to start your app. You may need to run `mrt install` first.
82You can run any meteor executable you like (e.g. from a checkout somewhere on your machine).
83
84### `mrt`
85
86Works like `meteor`, but checks and installs the app's desired Meteor version and package dependencies before running the app. You may still want to use this, but it's no longer the official way to use Meteorite.
87
88If however you want to use a forked version of Meteor in your project, you can still list it in your `smart.json`, and Meteorite will run it via `mrt`. (Of course you could just run it directly from a checkout too, which may be simpler).
89
90### `mrt create <name>`
91
92Works like `meteor create`, but you can specify the desired branch, tag or reference of [Meteor's git repository](https://github.com/meteor/meteor) that the app should be based on.
93
94``` sh
95# By default, apps are based on Meteor's master branch.
96$ mrt create cool-app
97# You can create apps based on a branch of Meteor's repo.
98$ mrt create risky-app --branch devel
99# Or, on a tag (such as version numbers).
100$ mrt create safe-app --tag v0.5.4
101# Or, or on a commit.
102$ mrt create choosy-app --ref a9a717
103```
104### Other commands
105
106When Meteorite is executed for an app, it checks or installs the app's desired Meteor version, packages and dependencies, then does the required book-keeping (described below), and finally passes the command onto `meteor`.
107
108## Permission woes?
109
110It is *not* required that you run `sudo mrt`. If you do so, your home directory will pick up some root-owned files and you'll struggle to run `mrt` without `sudo` from then on. This isn't good.
111
112To fix the problem, try cleaning up potentially "sudo-ed" files:
113
114```bash
115sudo mrt uninstall
116sudo mrt uninstall --system
117sudo chown -R `whoami` ~/.npm
118```
119
120If possible, try not to install Meteorite as root either. If you have permissions problems, make sure you install with `sudo -H npm install -g meteorite`. If you've installed without `-H`, your `~/.npm` directory will be owned by root and you should run the `chown` command above to fix it.
121
122
123
124## How Meteorite works
125
126Apps tell Meteorite the Meteor version and packages they want with a file called `smart.json` in their root directory. Meteorite will install those dependencies the next time it is executed within that app.
127
128Meteorite writes to a `smart.lock` file in the app's root directory to track the exact versions of its dependencies, even when it's set up in a fresh environment. You should check the `smart.lock` file into your app's version control, to ensure that other developers are running the same versions of the dependencies. Any changes in `smart.json` take precendency over `smart.lock`. The `smart.lock` file is reset with the `mrt update` command.
129
130### Example `smart.json`
131
132The `meteor` property is not required: apps will depend on Meteor's master branch by default. You can specify `meteor.branch`, `meteor.tag` or `meteor.git` to use alternate branches, tags and forks respectively. Note that `meteor.git` expects an actual URL, use `ssh://git@github.com/meteor/meteor.git` instead of `git@github.com:meteor/meteor.git`.
133
134``` json
135{
136 "meteor": {
137 "tag": "v0.5.4"
138 },
139 "packages": {
140 "moment": {},
141 "router": "0.3.4",
142 "roles": {
143 "version": "1.0.1"
144 },
145 "accounts-persona": {
146 "git": "https://github.com/vladikoff/meteor-accounts-persona"
147 },
148 "normalize.css": {
149 "git": "https://github.com/rithis/meteor-normalize.css",
150 "tag": "v2.0.1"
151 },
152 "my-experiment": {
153 "path": "/path/to/local/package"
154 }
155 }
156}
157```
158
159## Writing Meteorite packages
160
161Meteorite packages include a `smart.json` file in their root directory to provide information about the package, and to list their dependencies. For an example, see [Meteor Router's `smart.json`](https://github.com/tmeasday/meteor-router/blob/master/smart.json).
162
163Meteorite packages also include a `package.js` file in their root directory to tell Meteorite how it should be installed. For an example, see [Meteor Roles' `package.js`](https://github.com/alanning/meteor-roles/blob/master/roles/package.js).
164
165See [Atmosphere's documentation on writing packages](https://atmosphere.meteor.com/wtf/package) for more information.
166
167## Bash Completion
168
169Use Meteorite's bash completion by sourcing it in your .bashrc or .bash_profile.
170
171Depending on where you installed Meteorite:
172
173```bash
174if [ -f /path/to/meteorite/completions/mrt.bash ]; then
175 . /path/to/meteorite/completions/mrt.bash
176fi
177```
178
179Alternatively, you can create a symbolic link under bash_completion.d:
180
181```bash
182ln -s /path/to/meteorite/completions/mrt.bash /path/to/bash_completion.d/mrt
183```
184
185## Running Meteorite In a Git Hook Script
186
187If you encounter checkout errors while running `mrt install` or `mrt update` within a Git hook script, it is because `GIT_DIR` is set to an unexpected value when running within a hook. The solution is to temporarily unset it just before running the `mrt` command.
188
189```bash
190(unset GIT_DIR; mrt update)
191```
192
193## Contributing
194
195Contributions to meteorite are very welcome! Please see the [Contribution Guide](https://github.com/oortcloud/meteorite/blob/master/CONTRIBUTING.md) for details.