Useful scripts

Useful little scripts and helper codes

List all packages(meteor) and their dependencies

For listing all meteor packages installed to a meteor project you can simply run
meteor list on command line. But if you need to know which packages those are
depending on then you need this amazing piece of commands:

1
for p in `meteor list | grep '^[a-z]' | awk '{ print $1"@"$2 }'`; do echo "$p"; meteor show "$p" | grep -E '^ [a-z]'; echo; done

List all linked modules(npm)

Locally linked namespaced modules (@namespace/moduleName).

1
( ls -l node_modules ; ls -l node_modules/@* ) | grep ^l

Creating and setting new password

Locate yourself into Meteor project folder and make sure that the installation
has sha and bcrypt installed.

1
2
meteor add sha
meteor npm install --save bcrypt

Then fire up your meteor project and open meteor shell

1
2
3
4
import bcrypt from 'bcrypt';
import { SHA256 } from 'meteor/sha';
bcrypt.hash(SHA256('NEW-PASSWORD'), 10).then(console.log);

Password hash will be printed in server console logs copy it from there.
Open meteor mongo and find your user:

1
db.users.find({ 'emails.address': 'YOUR@EMAIL.COM' }, { _id: 1 })

Then use that id to update new password for your user:

1
db.users.update({ _id: 'USERID' }, {$set: { 'services.password.bcrypt': 'HASH' }})

And voila! now you should be able to login with your new password =]

SIDENOTE: you could also skip finding id and just do it like this:

1
db.users.update({ 'emails.address': 'YOUR@EMAIL.COM' }, {$set: { 'services.password.bcrypt': 'HASH' }})

Edit on GitHub