npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

meteor-generate

v0.12.2

Published

Generate Meteor scaffolding on demand

Downloads

23

Readme

Generate Scaffolding for Meteor

Automate the common tasks used when building a Meteor app. Create 'pages', components, controllers, collections & more. User customizable templates and configuration. Meteor Generate borrows a few conventions from Rails but it still stays true to Meteor.

Installation

sudo install meteor-generate --global

Create

mgen create <project_name> Runs Meteor create command and scaffolds out a basic app structure. mgen create myblog creates the following files:

└── myblog
    ├── both
    │   ├── lib
    │   │   ├── _namespaces.js
    │   │   └── collections.js
    │   └── routes.js
    │
    ├── client/
    │   └── _startup.js
    │   └── main.html
    │   └── styles/
    │       ├── _components.scss
    │       ├── _pages.scss
    │       └── main.scss
    │
    ├── server/
    │
    ├── .jshintrc
    ├── .jshintignore
    ├── makefile
    └── smart.json

Components

mgen component <name> Re-useable widgets that are not tied to a page. These should be able to be included in any page on the app. These are typically things like the header, footer, etc... Appends the Sass import into the styles/_components.scss file. mgen comp header outputs the follwing:

└── client
    └── components
        └── header
            ├── _header.scss
            ├── header.html
            └── header.js

Pages

mgen page <name> <action> Create conceptual 'pages'. Creates template, script, and stylesheet. No controllers are generated. If no action flag is passed in, all actions will be created. Possible actions: index, show, new, and edit. See Example Pages - mgen page posts --index creates the following:

└── client
    └── pages
        └── posts
            ├── index.html
            ├── index.js
            └── _index.scss

Controllers

mgen controller <name> <actions> Creates controllers for Iron-Router, adds routes, creates pages for controllers. If only create, update, or destroy actions are passed, no pages are created. These are data only controllers. A namespace file is created if it doesn't exist which adds a db namespace for collections. This allows for a natural db.posts.find(...) synatax. Creating a posts controller adds a PostsController namespace. For example, PostsController.create() Possible actions: index, new, show, edit, create, update, and destroy. If no actions are passed, all will be created. See Example Controller - mgen controller posts --show generates the following:

├── both
│   ├── controllers
│   │   ├── _app.js
│   │   └── posts.js
│   ├── lib
│   │   └── namespaces.js   // adds a `db` namespace and `Posts` namespace
│   └── routes.js
│
└── client
    └── pages
        └── posts
            ├── show.html
            ├── show.js
            └── _show.scss
// show edit page for single Post : /posts/edit/:id
PostsController.Edit = AppController.extend({
  template: 'postsEdit',

  waitOn: function() {
    //return Meteor.subscribe('post', this.params.id);
  },

  data: function() {
    //return Post.findOne(this.params.id);
  },

  onBeforeAction: function() {
    console.log("  [PostsController.Edit]: loading", this.url);
    this.next();
  }
});

// controller to do something when complete
PostsController.create = function(data, callback) {
  console.log('Fired Create Post');

  // call Post model here...
  Post.create(data, function(err, id){
    if (callback) callback(err, id);
    if (err) return alert(err.reason);

    Router.go('/somewhere');
  });
};

Packages

mgen package <name> Creates a Meteor smart package. Flags for client/server/both coming soon.
mgen package mixpanel Generates the following:

└── packages
    └── mixpanel
        ├── both.js
        ├── client.js
        ├── package.js
        ├── server.js
        └── smart.json

Collections

Creates a Meteor collection in the both/lib/collections.js file. Collections are inserted into the db namespace, access them with db.posts.find(...) Passing in mgen collection posts generates the following:

db.posts = new Meteor.Collection('posts');

Models

Coming Soon

Publications

Creates a publication on the server. Publications are stored in the server/publications directory inside of a script file file with the same name as the resource. Passing in
mgen publish post:userPost will generate a 'userPost' publication for the resource 'post'.

Meteor.publish('userPost', function() {
  // TODO index query
  // XXX bad performance no limit
  return db.posts.find({});
});

Tests

Coming Soon. Meteor Generate will create tests for Velocity for you by default.

Custom Templates / Config

Generators are only helpful if they save you time.

Soon, you will be able to define your own templates folder so that you can include things like form helpers, test helpers... anything you want. A project level mgen config file will help team members sync settings and reduce command line flags.

Example blog fire it up to see the general structure it generates. note this has extra logic added in