generator-bookon v1.4.11
BookOn Generator
A Yeoman generator for scaffolding boilerplate web applications with Material Angular
Goal and Motivation
The goal of generator-bookon is to facilitate modular client-side programming for small front-end projects and prototypes. It illustrates how AngularJS can be used in combination with RequireJs to produce reusable, manageable code.
Table of Contents
Installation
npm install -g generator-bookon
Usage
Projects may be scaffolded from the default menu...
yo bookon
.. or directly from the command line.
yo bookon:webapp
Web App
There are 2 types of web app generators:
App Type | Generator |
---|---|
Dynamic | bookon:webapp |
Static | bookon:static |
Each generator will allow you to create a Single-View or Multi-View web application.
Application
Dynamic applications are served using Node, so after scaffolding be sure to install dependencies and start the web server.
cd <application-name>
npm install
...
node index.js
server listening on port 3000!
After starting the server, visit http://localhost:3000/
.
Static Application
Static applications run off the filesystem using the file://
protocol. To run your static application open index.html
in a browser.
Note:
Angular uses XHR calls to download template files. Several browsers restrict XHR calls when using the
file://
protocol. This will result in an error. The right approach here is to (1) runindex.html
in another browser such as FireFox, or (2) generate a Dynamic Multi-View application usingbookon:webapp
.
Feature
By default, when you generate components they are organized by type.
App Type | Location |
---|---|
Dynamic | public/app/<component-type>/ |
Static | app/<component-type>/ |
For example:
cd myDynamicApp
yo bookon:controller "contactCtrl"
create public/app/controllers/contactCtrl.js
Use the bookon:feature
generator if you want to group related codefiles. You will have an option to name the Feature. After selecting the components you would like to include, the code files will be placed under app/<feature-name>/
(if you are in a Static Application). If you are in a Dynamic Application the components will be placed in public/app/<feature-name>/
. More components may be added to the Feature directory also (see Options).
Components
There are 7 component generators:
bookon:controller
bookon:directive
bookon:factory
bookon:filter
bookon:provider
bookon:service
bookon:template
Command:
yo bookon:<component-name>
Arguments
All generators accept a single argument for the name.
Example:
yo bookon:feature "contact"
Options
Each of the 7 component generators have a --path
option to specify the component location. You may use this option to add files to a Feature directory.
Example:
yo bookon:template --path "public/app/contact"
Templates
The bookon:template
generator has an option for the template type: --controller
or --directive
. The previous command could be written as:
yo bookon:template --path "public/app/contact" --controller
Static App
The bookon:static
generator has an option for the view type: --single
or --multi
.
Example:
yo bookon:static "demoApp" --single
Arguments + Options
You may combine Arguments and Options in a single command. Keep in mind that the name
argument must come before --option
.
yo bookon:<generator> "<name>" --<option> "<value>" --<another-option>
Notes
When you generate components the file path is relative to the project root (not the current working directory). This also applies when using the
--path
option.Each time you generate a component you must also modify
app/app.js
to load the component script file and inject it as a dependency.Generators create directories and subdirectories if they do not already exist.
You may also generate components with
bookon:component
. This generator accepts thename
argument and 3 options:Option Type Description path String path/to/a/folder type String Component type (ex. filter) templateType String controller or directive Beneath the hood,
bookon:webapp
calls 2 generators not discussed earlier - these generate Dynamic applications.bookon:single
bookon:multi
License
Copyright (c) 2016 Stephen Tillman | Licensed under the GPL license.