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-cpui

v1.3.1

Published

Custom code generator for Creator Platform Angular modules

Downloads

4

Readme

CPUI Module Generator

Custom code generator for Creator Platform Angular modules

Opinions

  • Uses coffeescript and the .coffee extension by default (not .js.coffee)

  • Encourages module creation for code separation (and makes it easy)

  • Assumes your Angular application file is named app.coffee

  • Require scripts as-needed in application.html.erb using the built-in Rails asset pipeline

    • Opening and closing syntax for loading scripts via sprockets:
    #== Requiring our modules
    #/= Requiring our modules
    • Opening and closing syntax for loading modules into Angular's DI:
    #== Our modules
    #/= Our modules
  • Never use #= require tree .

Usage

  1. Install yoeman: npm install -g yo
  2. Install the generator: npm install -g generator-cpui
  3. yo:cpui to get a menu of possible generators

Naming Conventions

These generators use some nice string helpers to make naming your files an afterthought. For instance, a common convention for Angular controllers is to append 'Ctrl' to the controller name. When using these generators, it will append that automatically to the controller's name, but not the file name. In fact, don't even worry about casing, or spaces for that matter. This works best with an example.

In the old days, you would name your controller something like MyFavoriteCtrl. And your file's name would be something similar. If we run the controller generator, it will ask us what we want to name our controller. Just type it in as english. Naming it my favorite will create a controller name of MyFavoriteCtrl. The file's name will be my-favorite.coffee, and inside a controllers directory. Try it out.

Configuration

If you don't have a .yo-rc.json file at the root of your repo, don't worry. Running yo cpui will detect that and walk you through creating one. You can always create a config file at any point by choosing it from the list of generators.

Note: There are separators used so that we know where to inject items into files. It's unlikely that you'll need to change them. If you do, you can tweak them manually in the .yo-rc.json file that gets created for you.

Angular Rails Templates

This generator creates templates assuming that they're being loaded via angular-rails-templates. The takeaway is this:

  1. add gem 'angular-rails-templates' to your Gemfile
  2. in your main application javascript file, load in angular-rails-templates via sprockets last. Here's an example:
  3. make sure to actually add 'templates' as a module that you load via Angular's DI, also in your main application file (you can see this in the example image above)