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

generator-vile

v0.2.2

Published

A generator for Yeoman

Downloads

25

Readme

generator-vile Build Status

Yeoman generator that goes beyond the MEAN stack. Uses MongoDB, Express, Angular, and Stylus and is configured for easy deployment to Heroku. Enables easier directory system by calling subgenerators with groups.

Usage

Install generator-vile:

npm install -g generator-vile

Make a new directory and cd into it:

mkdir new-project && cd $_

run yo vile

yo vile

Run grunt to build and grunt server to start local server.

All generators (except model) are called using the following syntax: [group:[subgroup1:subgroup2...]]:name This will generate the given files inside the group folder if given. Subgroups are created inside the generators type folder. For example:

yo vile:service games:entities:shapes:ball

Will create app/scripts/games/services/entities/shape/ball.js. This allows subgrouping within a general angular type.

Available generators:

App

Sets up a new AngularJS app using the MEAN stack. Automatically links to Twitter Bootstrap via CDN.

Example:

yo vile

Route

Generates a controller and view within an optional group folder. Configures a route in app/scripts/app.js connecting them.

Example:

yo angular:route posts:show

Produces app/scripts/posts/show.js:

angular.module('myApp').controller('ShowCtrl', function ($scope) {
  $scope.foo = 'foo';
});

Produces app/views/posts/show.html:

<p>This is the Posts:Show view</p>

Model

Generates a Mongoose document with given parameters. Adds RESTful backend routes to Express server. RESTful ID defaults to name property if exists, else uses _id. Can be overridden by --identifier option. Generates Angular $resource for frontend. Use : to attach types to property, default is String.

Example:

yo vile:model post name description date:date ranking:number

Produces db/post.js

//... Dependencies

var PostSchema = new Schema({
  name: String,
  description: String,
  date: Date,
  ranking: Number,
  urlString: String
});

PostSchema.pre('save', function (next) {
  if (this.name) {
    this.urlString = this.name.toLocaleLowerCase().replace(/\s+/g, '-');
  }
  next();
});

mongoose.model('Post', PostSchema);

Produces routes/posts.js:

var mongoose = require('mongoose');

module.exports = function (app) {
  var Post = mongoose.model('Post');

  // GET /posts => Index
  app.get('/posts', function (req, res) {
    Post.find()
      .exec(function (err, posts) {
        if (err) { console.log(err); }
        res.send(posts);
      });
  });

  // GET /posts/id => Show
  app.get('/posts/:id', function (req, res) {
    Post.findOne({urlString: req.params.id})
      .exec(function (err, post) {
        if (err) { console.log(err); }
        res.send(post);
      });
  });

  // DEL /posts/id => Remove
  app.del('/posts/:id', function (req, res) {
    Post.findOneAndRemove({urlString: req.params.id}, function (err, post) {
      if (err) { console.log(err); }
      res.send(post);
    });
  });

  // POST /posts => Create
  app.post('/posts', function (req, res) {
    var post = new Post(req.body);
    post.save(function (err) {
      if (err) { console.log(err); }
      res.send(post);
    });
  });

  // PUT /posts/id => Update
  app.put('/posts', function (req, res) {
    Post.findOne({urlString: req.params.id}, function (err, post) {
      if (err) {console.log(err);}
      
      post.name = req.body.name;
      
      post.description = req.body.description;
      
      post.date = req.body.date;
      
      post.ranking = req.body.ranking;
      
      post.save(function (err) {
        if (err) { console.log(err); }
        res.send(post);
      });
    });
  });

};

Controller

Generates a controller file within an optional group folder

Example:

yo vile:controller posts:new

Produces app/scripts/posts/controllers/new.js:

angular.module('myApp').controller('NewCtrl', function ($scope) {
  // ...
});

Directive

Generates a directive file within an optional group folder Add --template to use a seperate template file created in app/templates

Example:

yo vile:directive posts:details

Produces app/scripts/posts/directives/details.js:

angular.module('myApp').directive('details', function () {

  return {
   template: '<div></div>',
   restrict: 'E',
   link: function postLink(scope, element, attrs) {
    element.text('this is the details directive');
   }
  };
});

Filter

Generates a filter within an optional group folder

Example:

yo vile:filter groupBy

Produces app/scripts/filters/groupBy.js:

angular.module(myApp).filter('groupBy', function () {
  return function (input) {
    return 'groupBy filter:' + input;
  };
});

View

Generates an HTML view file within an optional group folder

Example:

yo vile:view posts:new

Produces app/views/posts/new.html:

<p>This is the Page:View page</p>

Service

Generates an AngularJS service within an optional group folder.

Example:

yo vile:service myService

Produces app/scripts/services/myService.js:

angular.module('myApp').service('myService', function () {
  // ...
});

Factory

Generates an AngularJS factory within an optional group folder.

Example:

yo vile:factory factoryName

Produces app/scripts/services/factoryName.js:

angular.module('myApp')
  .factory('factoryName', function () {
  // ...
  });

Class

Generates an AngularJS class within an optional group folder.

Example:

yo vile:class games:renderer

Produces app/scripts/games/services/renderer:

angular.module('myApp')
  .factory('Renderer', function () {
    var Renderer = function () {

    };

    return Renderer;
  });

Add to Index

By default, new scripts are added to index.html. To skip this behaviour, pass in the skip-add argument:

yo vile:service serviceName --skip-add

Bower Components

The app generator always installs these packages:

  • jQuery
  • angular
  • angular-resource
  • angular-route
  • angular-cookies
  • angular-sanitzie
  • angular-mocks
  • angular-scenario

License

MIT License