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-angularjs-gulp-library

v2.0.3

Published

Yeoman generator to create an AngularJS component library

Downloads

5

Readme

AngularJS component library generator

Yeoman generator to create standalone AngularJS component libraries in seconds!

Build Status

In short

If you want to create a standalone library with filters, directives, services, etc for use in your AngularJS applications, then this generator may just be what you need.

The generator automatically:

  • creates a complete directory structure with boilerplate code for your AngularJS library
  • creates a complete directory structure for your tests
  • configures Gulp to build your code and automate testing
  • sets up Karma to run your unit tests using Mocha, Chai and Sinon

This generator is NOT made to generate complete AngularJS applications. If you want to generate a complete AngularJS web application with routes, views, etc then please use generator-angular.

Quick start

Make sure you have yeoman installed:

$ npm install -g yo

Install the generator:

$ npm install -g generator-angularjs-gulp-library

Create a new project directory:

$ mkdir project
$ cd project

Run:

$ yo angularjs-gulp-library

Answer the questions and the generator will create the boilerplate for your library:

AngularJS library generator

What the generator does for you

The generator automatically:

  • creates a src directory structure with the boilerplate code for your AngularJS library
  • creates a test directory structure to store your unit tests and e2e tests
  • creates initial unit tests in the test/unit/ directory
  • creates a custom gulpfile.js to build, minify and uglify your library
  • creates a custom karma-src.conf.js to let karma run your unit tests
  • creates a custom karma-dist-concatenated.conf.js to let karma run your unit tests
  • creates a custom karma-dist-minified.conf.js to let karma run your unit tests
  • creates a custom bower.json file for your library
  • creates a custom package.json file for your library
  • creates a custom README.md file for your library
  • creates a custom LICENSE file for your library

Running the generator using library name "Your Library" will result in the following files being generated for you:

.
├── LICENSE                                     # License file with your name in it
├── README.md                                   # Basic README.md file with title of library
├── bower.json                                  # Bower configuration for your library
├── dist
│   ├── your-library.js                         # Your library ready to use in your application
│   └── your-library.min.js                     # Minified version of your library for production
├── gulpfile.js                                 # Gulp configuration to build your library
├── karma-dist-concatenated.conf.js             # Karma configuration to run unit tests using your-library.js
├── karma-dist-minified.conf.js                 # Karma configuration to run unit tests using your-library.min.js
├── karma-src.conf.js                           # Karma configuration to run unit tests using src/**/*.js
├── package.json                                # Npm configuration for your library
├── src                                         # Source directory with modular structure
│   └── yourLibrary
│       ├── directives
│       ├── filters
│       ├── services
│       ├── yourLibrary.js
│       ├── yourLibrary.prefix
│       └── yourLibrary.suffix
└── test                                        # Test directory with modulare structure
    ├── e2e
    │   └── yourLibrary
    └── unit
        └── yourLibrary
            ├── directives
            ├── filters
            ├── services
            └── yourLibrarySpec.js

14 directories, 14 files

How to use the generated boilerplate

The basic library structure is automatically created for you in the src folder.

You can edit the existing files or add additional files in the src folder to add components to your library.

Once you have added files in the src directory, you can update the files in the dist directory using:

$ gulp

First gulp will run all unit tests using the code in your src directory to make sure the code is fine.

Then all files in the src directory will be concatenated into 2 files in the dist directory:

  • <yourLibraryName>.js: regular version of your library to use in a development environment
  • <yourLibraryName>.min.js: minified version of your library to use in a production environment

AngularJS library generator

Manually testing your code

The generator creates 3 configurations for unit testing:

  • karma-src.conf.js: run unit tests using src/**/*.js
  • karma-dist-concatenated.conf.js: run unit tests using dist/<yourLibraryName>.js
  • karma-dist-minified.conf.js: run unit tests using dist/<yourLibraryName>.min.js

By default, gulp will run karma-src.conf.js, but you can use the following preconfigured Gulp tasks to specify the suite you want to run:

# Run unit tests using src/**/*.js
$ gulp test-src

# Run unit tests using dist/<yourLibraryName>.js
$ gulp test-dist-concatenated

# Run unit tests using dist/<yourLibraryName>.min.js
$ gulp test-dist-minified

AngularJS library generator

This allows you to unit test the different builds of your code to ensure they all work as expected.

Frequently asked questions

Want to contribute?

Help make this project better - fork and send a PR or create an (issue)[https://github.com/jvandemo/generator-angularjs-library/issues].

Change log

v2.0.0

  • Completely rewritten to support newer version of Yeoman
  • Now uses Gulp instead of Grunt as task runner
  • Now uses Mocha as test framework instead of Jasmine
  • Add travis

v1.4.0

  • Update bower and npm package versions

v1.3.0

  • Added automatic creation of README.md
  • Added automatic creation of LICENSE.txt
  • Added support for author name and email

v1.2.1

  • Removed obsolete dependencies

v1.2.0

  • Added support for PhantomJS in Karma configuration
  • Fixed bower directory in gitignore

v1.1.0

  • Added support for library names with spaces and capitals

v1.0.3

  • Added chalk dependency

License

MIT