A generator for Yeoman to generate AngularJS libraries in just seconds.
- Make sure you have yo installed:
npm install -g yo - Install the generator:
npm install -g generator-angularjs-library - Run:
yo angularjs-library - Answer the questions and the generator will create the boilerplate for your library
The generator:
- creates a
srcdirectory structure with the boilerplate code for your AngularJS library - creates a
testdirectory structure to store your unit tests and e2e tests - creates a sample unit test in the
test/unit/directory - creates a custom
Gruntfile.jsto build, minify and uglify your library - creates a custom
karma-unit.conf.jsto let karma run your unit tests - creates a custom
bower.jsonfile for your library - creates a custom
package.jsonfile for your library - creates a custom
README.mdfile for your library - creates a custom
LICENSE.txtfile for your library
Here's an overview of the files that are automatically generated for you:
.
├── Gruntfile.js # Grunt config to build your library
├── LICENSE.txt # License file with your name in it
├── README.md # Basic README.md file with title of library
├── bower # Bower dependencies
├── bower.json # Bower config for your library
├── dist # Directory that contains files built by grunt
├── karma-unit.conf.js # Karma config to run your unit tests
├── package.json # Npm config for your library
├── src # Source directory with modular structure
│ └── yourLibraryName
│ ├── directives
│ ├── filters
│ ├── services
│ ├── yourLibraryName.js
│ ├── yourLibraryName.prefix
│ └── yourLibraryName.suffix
└── test # Test directory with modular structure
├── e2e
│ └── yourLibraryName
└── unit
└── yourLibraryName
├── directives
├── filters
├── services
└── yourLibraryName.js- Add custom code to your library
- Build your library files for distribution (see below)
- Test your code and add your own tests (see below)
- Use your library in any AngularJS app by adding it as a required module in your app definition
The basic library structure will be created automatically for you in the src folder.
You can edit the existing files or add additional files in the src folder to add functionality to your library.
Run: grunt
All files in the src directory will be jshinted and 2 files will be generated in the dist directory:
<yourLibraryName>.js: regular version of your library to use in development<yourLibraryName>.min.js: minified and uglified version of your library to use in production
There are two directory structures for storing tests:
- Unit tests are stored in
test/unit/ - E2E tests are stored in
test/e2e/
To run your unit tests: karma start ./karma-unit.conf.js
- Added automatic creation of README.md
- Added automatic creation of LICENSE.txt
- Added support for author name and email
- Removed obsolete dependencies
- Added support for PhantomJS in Karma configuration
- Fixed bower directory in gitignore
- Added support for library names with spaces and capitals
- Added chalk dependency