-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit. Refactoring angular-project-template into yeoman gene…
…rator.
- Loading branch information
Chris Gross
committed
Jun 18, 2013
0 parents
commit e41fe83
Showing
38 changed files
with
982 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
temp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"node": true, | ||
"es5": true, | ||
"esnext": true, | ||
"bitwise": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"indent": 4, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"quotmark": "single", | ||
"regexp": true, | ||
"undef": true, | ||
"unused": true, | ||
"strict": true, | ||
"trailing": true, | ||
"smarttabs": true, | ||
"white": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- '0.8' | ||
- '0.10' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright 2013 Chris Gross | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#generator-cg-angular | ||
|
||
>Yeoman Generator for Enterprise Angular Projects | ||
Features | ||
|
||
* Provides a directory structure geared towards large Angular projects. | ||
* Each controller, service, filter, and directive are placed in their own file. | ||
* All files related to a conceptual unit are placed together. For example, the controller and HTML file for a partial are placed together in the same directory. | ||
* Provides a ready-made Grunt build that produces an extremely optimized distribution. | ||
* Integrates Bower for package management | ||
* Includes Yeoman sub-generators for directives, services, partials, and filters | ||
* Integrates LESS and includes Bootstrap via the source LESS files allowing you to reuse Bootstrap vars/mixins/etc. | ||
* Testable - Included Yeoman sub-generators also build test skeletons. Run test via `grunt test`. | ||
|
||
Directory Layout | ||
------------- | ||
Below is an explanation of the folder structure. | ||
|
||
/css ........................................... usually only contains app.less | ||
app.less ................................... main app-wide styles | ||
/img ........................................... images (not created by default but included in bin if added) | ||
/js ............................................ app global javascript files | ||
setup.js ................................... angular module initialization and route setup | ||
/directive. .................................... angular directives folder | ||
my-directive.js ............................ example simple directive | ||
/my-directive2 ............................. example complex directive (contains external partial) | ||
my-directive2.js ....................... complex directive javascript | ||
my-directive2.html ..................... complex directive partial | ||
my-directive2.less ..................... complex directive LESS | ||
/filter ........................................ angular filters folder | ||
my-filter.js ............................... example filter | ||
/partial ....................................... angular partials folder | ||
/my-partial ................................ example partial | ||
my-partial.html ........................ example partial html | ||
my-partial.js .......................... example partial controller | ||
my-partial.less ........................ example partial LESS | ||
/service ....................................... angular services folder | ||
my-service.js .............................. example service | ||
/bin ........................................... distributable version of app built using grunt and Gruntfile.js | ||
/lib ........................................... 3rd party libraries, managed by bower (renamed components to lib) | ||
/node_modules .................................. npm managed libraries used by grunt | ||
|
||
Getting Started | ||
------------- | ||
|
||
Prerequisites: Node, Grunt, Yeoman, and Bower. Once Node is installed, do: | ||
|
||
npm install -g grunt-cli yo bower | ||
|
||
Next, install this generator: | ||
|
||
npm install -g generator-cg-angular | ||
|
||
To create a project: | ||
|
||
mkdir MyNewAwesomeApp | ||
cd MyNewAwesomeApp | ||
yo cg-angular | ||
|
||
Grunt Tasks | ||
------------- | ||
|
||
Now that the project is created, you have 3 simple Grunt commands available: | ||
|
||
grunt server #This will run a development server with watch & reload enabled. | ||
grunt test #Run headless unit tests using PhantomJS. | ||
grunt build #Places a fully optimized (minified, concatenated, and more) in /bin | ||
|
||
Yeoman Subgenerators | ||
------------- | ||
|
||
There are a set of sub-generators to initialize empty Angular components. Each of these generators will: | ||
|
||
* Create one or more skeleton files (javascript, LESS, html, etc) for the component type | ||
* Create a skeleton unit test in /test | ||
* Update index.html and add the necessary `script` tags. | ||
* Update app.less and add the @import as needed. | ||
* For partials, update the setup.js, adding the necessary route call if a route was entered in the generator prompts. | ||
|
||
There are generators for `directive`,`partial`,`service`, and `filter`. | ||
|
||
Running a generator: | ||
|
||
yo cg-angular:directive my-awesome-directive | ||
yo cg-angular:partial my-partial | ||
yo cg-angular:service my-service | ||
yo cg-angular:filter my-filter | ||
|
||
The name paramater passed (i.e. 'my-awesome-directive') will be used for directory and/or file names. The generators will derive appropriate class names from this parameter (ex. 'my-awesome-directive' will convert to a class name of 'MyAwesomeDirective'). | ||
|
||
One quick note, each sub-generator pulls the Angular app/module name from the package.json. Therefore, if you choose to change the name of your Angular app/module, you must ensure that the name in the package.json stays in sync. | ||
|
||
Release History | ||
------------- | ||
|
||
* 6/18/2013 v1.0.0 - Initial release of template as Yeoman generator. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
var util = require('util'); | ||
var path = require('path'); | ||
var yeoman = require('yeoman-generator'); | ||
|
||
|
||
var CgangularGenerator = module.exports = function CgangularGenerator(args, options, config) { | ||
yeoman.generators.Base.apply(this, arguments); | ||
|
||
this.on('end', function () { | ||
this.installDependencies({ skipInstall: options['skip-install'] }); | ||
}); | ||
|
||
this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); | ||
}; | ||
|
||
util.inherits(CgangularGenerator, yeoman.generators.Base); | ||
|
||
CgangularGenerator.prototype.askFor = function askFor() { | ||
var cb = this.async(); | ||
|
||
var prompts = [{ | ||
name: 'appname', | ||
message: 'What would you like the angular app/module name to be?', | ||
default: path.basename(process.cwd()) | ||
}]; | ||
|
||
this.prompt(prompts, function (props) { | ||
this.appname = props.appname; | ||
|
||
cb(); | ||
}.bind(this)); | ||
}; | ||
|
||
CgangularGenerator.prototype.app = function app() { | ||
this.directory('skeleton/','./'); | ||
this.template('skeleton/js/setup.js','./js/setup.js'); | ||
this.template('skeleton/bower.json','./bower.json'); | ||
this.template('skeleton/index.html','./index.html'); | ||
this.template('skeleton/package.json','./package.json'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory" : "lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"node": true, | ||
"es5": true, | ||
"esnext": true, | ||
"bitwise": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"indent": 4, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"quotmark": "single", | ||
"regexp": true, | ||
"undef": true, | ||
"unused": true, | ||
"strict": true, | ||
"trailing": true, | ||
"smarttabs": true, | ||
"white": true | ||
} |
Oops, something went wrong.