├── .editorconfig
├── .gitattributes
├── .gitignore
├── .jshintrc
├── .travis.yml
├── .yo-rc.json
├── CHANGELOG.md
├── LICENSE
├── README.md
├── generators
└── app
│ ├── index.js
│ └── templates
│ ├── .babelrc
│ ├── .eslintignore
│ ├── VERSION
│ ├── _package.json
│ ├── _webpack.config.js
│ ├── app
│ ├── _app.js
│ ├── _index.html
│ ├── components
│ │ └── main
│ │ │ ├── _main-controller.js
│ │ │ ├── _main.routes.js
│ │ │ ├── main.html
│ │ │ └── main.scss
│ ├── directives
│ │ └── directives.js
│ ├── images
│ │ └── yeoman.png
│ └── services
│ │ └── services.js
│ ├── editorconfig
│ ├── eslintrc
│ ├── gitignore
│ ├── gulpfile.js
│ └── test
│ ├── karma.ci.conf.js
│ ├── karma.conf.js
│ └── spec
│ ├── components
│ └── _main-controller-test.js
│ └── tests.webpack.js
├── package.json
└── test
├── test-defaults.js
└── test-prompts.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": true,
3 | "esnext": true,
4 | "bitwise": true,
5 | "camelcase": true,
6 | "curly": true,
7 | "eqeqeq": true,
8 | "immed": true,
9 | "indent": 2,
10 | "latedef": true,
11 | "newcap": true,
12 | "noarg": true,
13 | "quotmark": "single",
14 | "undef": true,
15 | "unused": true,
16 | "strict": true
17 | }
18 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '4.1'
5 | - '0.12'
6 | env:
7 | - CXX=g++-4.8
8 | addons:
9 | apt:
10 | sources:
11 | - ubuntu-toolchain-r-test
12 | packages:
13 | - g++-4.8
14 | notifications:
15 | email:
16 | on_success: change
17 | on_failure: always
18 |
--------------------------------------------------------------------------------
/.yo-rc.json:
--------------------------------------------------------------------------------
1 | {
2 | "generator-generator": {}
3 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 1.1.0
2 |
3 | * Added example test file to Application
4 |
5 | # 1.0.0
6 |
7 | * Working generator for AngularJS apps with ES6 via Babel.js and Webpack
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Daniel Budden
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AngularJS + ES6 + Webpack Generator [](https://travis-ci.org/d3spis3d/generator-angular-es6-webpack)
2 |
3 | > [Yeoman](http://yeoman.io) generator for AngularJS applications built with Webpack and Babel.js
4 |
5 | More info on project structure [Angular + ES6 + Webpack blog post](http://d3spis3d.github.io/angular/webpack/2016/01/06/angular-es6-webpack.html)
6 |
7 | ## Usage
8 |
9 | For information on using Yeoman check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started).
10 |
11 | Install `yo` and `generator-angular-es6-webpack`:
12 | ```
13 | npm install -g yo generator-angular-es6-webpack
14 | ```
15 |
16 | Make a new directory for your application:
17 | ```
18 | mkdir new-project && cd $_
19 | ```
20 |
21 | Run the generator:
22 | ```
23 | yo angular-es6-webpack
24 | ```
25 |
26 | Follow the prompts to scaffold the application. Once finished run `gulp serve` to run Webpack's development server and `gulp build` to build minified bundle.
27 |
28 | ## Version Service
29 |
30 | The `version-service` is generated at build time using the `VERSION` file and a portion of the git hash for the commit. As a result of being created by the build, it is recommended to run the `gulp build` at least once before attempting to run the tests or running the development server.
31 |
32 | ## License
33 |
34 | [MIT](https://github.com/d3spis3d/generator-angular-es6-webpack/blob/master/LICENSE)
35 |
--------------------------------------------------------------------------------
/generators/app/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var yeoman = require('yeoman-generator');
3 | var chalk = require('chalk');
4 | var yosay = require('yosay');
5 |
6 | module.exports = yeoman.Base.extend({
7 | prompting: function () {
8 | var done = this.async();
9 |
10 | this.log(yosay(
11 | 'Welcome to the flawless ' + chalk.red('Angular ES6 Webpack') + ' generator!'
12 | ));
13 |
14 | var prompts = [
15 | {
16 | type: 'input',
17 | name: 'appName',
18 | message: 'What is the applications name?',
19 | default: 'Angular ES6 App'
20 | },
21 | {
22 | type: 'input',
23 | name: 'ngVersion',
24 | message: 'What version of Angular would you like to use?',
25 | default: '1.4.7'
26 | },
27 | {
28 | type: 'confirm',
29 | name: 'uiRouter',
30 | message: 'Would you like to use ui-router?',
31 | default: true
32 | }
33 | ];
34 |
35 | this.prompt(prompts, function (props) {
36 | this.appName = props.appName;
37 | this.ngVersion = props.ngVersion;
38 | this.uiRouter = props.uiRouter;
39 | done();
40 | }.bind(this));
41 | },
42 |
43 | writing: {
44 | app: function () {
45 | var context = {
46 | ngVersion: this.ngVersion,
47 | appName: this.appName,
48 | uiRouter: this.uiRouter
49 | };
50 |
51 | this.template('_package.json', 'package.json', context);
52 |
53 | this.fs.copy(
54 | this.templatePath('gulpfile.js'),
55 | this.destinationPath('gulpfile.js')
56 | );
57 |
58 | this.fs.copy(
59 | this.templatePath('app/directives'),
60 | this.destinationPath('app/directives')
61 | );
62 |
63 | this.fs.copy(
64 | this.templatePath('app/services'),
65 | this.destinationPath('app/services')
66 | );
67 |
68 | this.fs.copy(
69 | this.templatePath('app/images'),
70 | this.destinationPath('app/images')
71 | );
72 |
73 | this.template('app/_app.js', 'app/app.js', context);
74 | this.template('app/_index.html', 'app/index.html', context);
75 |
76 | this.fs.copy(
77 | this.templatePath('app/components/main/main.html'),
78 | this.destinationPath('app/components/main/main.html')
79 | );
80 |
81 | this.fs.copy(
82 | this.templatePath('app/components/main/main.scss'),
83 | this.destinationPath('app/components/main/main.scss')
84 | );
85 |
86 | this.template('app/components/main/_main.routes.js', 'app/components/main/main.routes.js', context);
87 | this.template('app/components/main/_main-controller.js', 'app/components/main/main-controller.js', context);
88 |
89 | this.fs.copy(
90 | this.templatePath('test/spec/tests.webpack.js'),
91 | this.destinationPath('test/spec/tests.webpack.js')
92 | );
93 |
94 | this.fs.copy(
95 | this.templatePath('test/karma.conf.js'),
96 | this.destinationPath('test/karma.conf.js')
97 | );
98 |
99 | this.fs.copy(
100 | this.templatePath('test/karma.ci.conf.js'),
101 | this.destinationPath('test/karma.ci.conf.js')
102 | );
103 |
104 | this.template('test/spec/components/_main-controller-test.js', 'test/spec/components/main-controller-test.js', context);
105 |
106 | this.fs.copy(
107 | this.templatePath('_webpack.config.js'),
108 | this.destinationPath('webpack.config.js')
109 | );
110 | },
111 |
112 | projectfiles: function () {
113 | this.fs.copy(
114 | this.templatePath('editorconfig'),
115 | this.destinationPath('.editorconfig')
116 | );
117 | this.fs.copy(
118 | this.templatePath('eslintrc'),
119 | this.destinationPath('.eslintrc')
120 | );
121 | this.fs.copy(
122 | this.templatePath('gitignore'),
123 | this.destinationPath('.gitignore')
124 | );
125 |
126 | this.fs.copy(
127 | this.templatePath('VERSION'),
128 | this.destinationPath('VERSION')
129 | );
130 |
131 | this.fs.copy(
132 | this.templatePath('.babelrc'),
133 | this.destinationPath('.babelrc')
134 | );
135 |
136 | this.fs.copy(
137 | this.templatePath('.eslintignore'),
138 | this.destinationPath('.eslintignore')
139 | );
140 | }
141 | },
142 |
143 | install: function () {
144 | this.npmInstall();
145 | }
146 | });
147 |
--------------------------------------------------------------------------------
/generators/app/templates/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015"]
3 | }
4 |
--------------------------------------------------------------------------------
/generators/app/templates/.eslintignore:
--------------------------------------------------------------------------------
1 | app/services/version-service.js
2 |
--------------------------------------------------------------------------------
/generators/app/templates/VERSION:
--------------------------------------------------------------------------------
1 | 1.0
--------------------------------------------------------------------------------
/generators/app/templates/_package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= appName.toLowerCase().replace(/\s/g, '-') %>",
3 | "version": "0.0.0",
4 | "dependencies": {
5 | "angular": "<%= ngVersion %>",
6 | "angular-sanitize": "<%= ngVersion %>",
7 | "angular-resource": "<%= ngVersion %>",
8 | <% if(uiRouter) { %> "angular-ui-router": "^0.2.15",<% } else { %>"angular-route": "<%= ngVersion %>",<% } %>
9 | "jquery": "^2.1.4"
10 | },
11 | "devDependencies": {
12 | "angular-mocks": "<%= ngVersion %>",
13 | "autoprefixer-loader": "^3.1.0",
14 | "babel": "^6.3.0",
15 | "babel-core": "^6.3.0",
16 | "babel-eslint": "^4.1.3",
17 | "babel-loader": "^6.2.0",
18 | "babel-polyfill": "^6.3.0",
19 | "babel-preset-es2015": "^6.1.18",
20 | "core-js": "^1.2.6",
21 | "css-loader": "^0.21.0",
22 | "eslint": "^1.8.0",
23 | "eslint-loader": "^1.1.1",
24 | "file-loader": "^0.8.4",
25 | "gulp": "^3.9.0",
26 | "gulp-git": "^1.6.0",
27 | "gulp-ng-constant": "^1.1.0",
28 | "gulp-protractor": "^1.0.0",
29 | "gulp-rename": "^1.2.2",
30 | "gulp-rimraf": "^0.2.0",
31 | "gulp-util": "^3.0.7",
32 | "html-loader": "^0.3.0",
33 | "isparta-loader": "^2.0.0",
34 | "jasmine": "^2.3.2",
35 | "jasmine-core": "^2.3.4",
36 | "jasmine-reporters": "^2.0.7",
37 | "karma": "^0.13.15",
38 | "karma-cli": "^0.1.1",
39 | "karma-coverage": "^0.5.3",
40 | "karma-jasmine": "^0.3.6",
41 | "karma-junit-reporter": "^0.3.8",
42 | "karma-phantomjs-launcher": "^0.2.1",
43 | "karma-sourcemap-loader": "^0.3.6",
44 | "karma-webpack": "^1.7.0",
45 | "minimist": "^1.2.0",
46 | "ng-annotate-loader": "0.0.10",
47 | "ng-annotate-webpack-plugin": "^0.1.2",
48 | "ngtemplate-loader": "^1.3.1",
49 | "node-sass": "^3.4.0",
50 | "phantomjs": "^1.9.18",
51 | "sass-loader": "^3.0.0",
52 | "style-loader": "^0.13.0",
53 | "webpack": "^1.12.2",
54 | "webpack-dev-server": "^1.12.1"
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/generators/app/templates/_webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var webpack = require('webpack');
3 |
4 | module.exports = {
5 | entry: './app/app.js',
6 | output: {
7 | path: __dirname + '/dist',
8 | filename: 'bundle.js'
9 | },
10 | module: {
11 | preLoaders: [
12 | {
13 | test: /\.js$/,
14 | loader: 'eslint-loader',
15 | exclude: /node_modules/
16 | }
17 | ],
18 | loaders: [
19 | {
20 | test: /\.js$/,
21 | loader: 'ng-annotate?add=true!babel',
22 | exclude: /node_modules/
23 | },
24 | {
25 | test: /.html$/,
26 | loader: 'ngtemplate?relativeTo=' + __dirname +'/app!html?root=' + __dirname + '/app'
27 | },
28 | {
29 | test: /\.scss$/,
30 | loaders: ['style', 'css?root=' + __dirname + '/app', 'autoprefixer-loader?browsers=last 2 versions', 'sass'],
31 | },
32 | {
33 | test: /\.png$/,
34 | loader: 'file-loader'
35 | }
36 | ]
37 | },
38 | plugins: [
39 | new webpack.optimize.DedupePlugin(),
40 | new webpack.optimize.UglifyJsPlugin({ minimize: true, output: { comments: false }}),
41 | new webpack.ProvidePlugin({
42 | $: 'jquery',
43 | jQuery: 'jquery',
44 | 'window.jQuery': 'jquery'
45 | })
46 | ],
47 | resolve: {
48 | root: path.resolve('app/'),
49 | extensions: ['', '.js']
50 | },
51 | eslint: {
52 | failOnError: true
53 | },
54 | sassLoader: {
55 | includePaths: [path.resolve(__dirname, "./app")]
56 | },
57 | devtool: '#source-map'
58 | };
59 |
--------------------------------------------------------------------------------
/generators/app/templates/app/_app.js:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 | import angular from 'angular';
3 | import 'angular-resource';
4 | <% if(uiRouter) { %>import 'angular-ui-router';<% } else { %>import 'angular-route';<% } %>
5 | import 'angular-sanitize';
6 |
7 | import 'services/services';
8 | import 'directives/directives';
9 | import 'services/version-service';
10 |
11 | import mainRoutes from 'components/main/main.routes';
12 |
13 | angular.module('<%= appName.replace(/\s/g, '') %>', ['ngResource', <% if(uiRouter) { %>'ui.router'<% } else { %>'ngRoute'<% } %>, 'services', 'directives', 'ngSanitize', 'version'])
14 |
15 | .config(mainRoutes);
16 |
--------------------------------------------------------------------------------
/generators/app/templates/app/_index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | <%= appName %>
7 |
8 |
9 |
10 | <% if(uiRouter) { %>
<% } else { %>
<% } %>
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/generators/app/templates/app/components/main/_main-controller.js:
--------------------------------------------------------------------------------
1 | export default /*@ngInject*/ function() {
2 | this.applicationName = '<%= appName %>';
3 | }
4 |
--------------------------------------------------------------------------------
/generators/app/templates/app/components/main/_main.routes.js:
--------------------------------------------------------------------------------
1 | import 'components/main/main.html';
2 | import 'components/main/main.scss';
3 | import mainCtrl from 'components/main/main-controller';
4 |
5 | <% if(uiRouter) { %>export default /*@ngInject*/ function($stateProvider, $urlRouterProvider) {
6 | $urlRouterProvider.otherwise('/');
7 |
8 | $stateProvider.state('main', {
9 | url: '/',
10 | views: {
11 | '@': {
12 | templateUrl: '/components/main/main.html',
13 | controller: mainCtrl,
14 | controllerAs: 'mainCtrl'
15 | }
16 | }
17 | });
18 | }<% } else { %>export default /*@ngInject*/ function($routeProvider) {
19 | $routeProvider.when('/', {
20 | templateUrl: '/components/main/main.html',
21 | controller: mainCtrl,
22 | controllerAs: 'mainCtrl'
23 | })
24 | .otherwise('/');
25 | }<% } %>
26 |
--------------------------------------------------------------------------------
/generators/app/templates/app/components/main/main.html:
--------------------------------------------------------------------------------
1 |
2 | {{mainCtrl.applicationName}}
3 |
4 |
5 |
6 |

7 |
8 |
9 |
Angular ES6 Webpack Application
10 |
With a little help from Yeoman
11 |
12 |
13 |
--------------------------------------------------------------------------------
/generators/app/templates/app/components/main/main.scss:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: sans-serif;
4 | }
5 |
6 | header {
7 | background-color: #EBF0F2;
8 | padding: 50px;
9 | text-align: center;
10 | }
11 |
12 | section {
13 | padding: 50px;
14 |
15 | .image-container {
16 | display: inline-block;
17 | margin-right: 50px;
18 | }
19 |
20 | .text-container {
21 | display: inline-block;
22 | vertical-align: bottom;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/generators/app/templates/app/directives/directives.js:
--------------------------------------------------------------------------------
1 | import angular from 'angular';
2 |
3 | angular.module('directives', []);
4 |
--------------------------------------------------------------------------------
/generators/app/templates/app/images/yeoman.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/d3spis3d/generator-angular-es6-webpack/44183b3b2ef15f22e0f5f7303efb0e121c5dc2f0/generators/app/templates/app/images/yeoman.png
--------------------------------------------------------------------------------
/generators/app/templates/app/services/services.js:
--------------------------------------------------------------------------------
1 | import angular from 'angular';
2 |
3 | angular.module('services', []);
4 |
--------------------------------------------------------------------------------
/generators/app/templates/editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 4
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/generators/app/templates/eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "env": {
4 | "browser": true,
5 | "es6": false,
6 | "commonjs": true
7 | },
8 | "ecmaFeatures": {
9 | "modules": true,
10 | "arrowFunctions": true,
11 | "blockBindings": true,
12 | "classes": true,
13 | "defaultParams": true,
14 | "destructuring": true,
15 | "forOf": true,
16 | "generators": false,
17 | "modules": true,
18 | "objectLiteralComputedProperties": true,
19 | "objectLiteralDuplicateProperties": false,
20 | "objectLiteralShorthandMethods": true,
21 | "objectLiteralShorthandProperties": true,
22 | "spread": true,
23 | "superInFunctions": true,
24 | "templateStrings": true,
25 | },
26 | "rules": {
27 | //Standard
28 | "accessor-pairs": 0,
29 | "block-scoped-var": 2,
30 | "complexity": [0, 11],
31 | "consistent-return": 2,
32 | "curly": 2,
33 | "default-case": 0,
34 | "dot-notation": [2, { "allowKeywords": true}],
35 | "dot-location": 0,
36 | "eqeqeq": 2,
37 | "guard-for-in": 1,
38 | "no-alert": 1,
39 | "no-caller": 2,
40 | "no-div-regex": 0,
41 | "no-else-return": 2,
42 | "no-empty-label": 2,
43 | "no-eq-null": 2,
44 | "no-eval": 2,
45 | "no-extend-native": 2,
46 | "no-extra-bind": 2,
47 | "no-fallthrough": 2,
48 | "no-floating-decimal": 2,
49 | "no-implicit-coercion": 0,
50 | "no-implied-eval": 2,
51 | "no-invalid-this": 0,
52 | "no-iterator": 2,
53 | "no-labels": 2,
54 | "no-lone-blocks": 2,
55 | "no-loop-func": 2,
56 | "no-multi-spaces": 2,
57 | "no-multi-str": 2,
58 | "no-native-reassign": 2,
59 | "no-new": 2,
60 | "no-new-func": 2,
61 | "no-new-wrappers": 2,
62 | "no-octal": 2,
63 | "no-octal-escape": 2,
64 | "no-param-reassign": 2,
65 | "no-process-env": 2,
66 | "no-proto": 2,
67 | "no-redeclare": 2,
68 | "no-return-assign": 2,
69 | "no-script-url": 2,
70 | "no-self-compare": 2,
71 | "no-sequences": 2,
72 | "no-throw-literal": 2,
73 | "no-unused-expressions": 2,
74 | "no-useless-call": 0,
75 | "no-void": 0,
76 | "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
77 | "no-with": 2,
78 | "radix": 0,
79 | "vars-on-top": 2,
80 | "wrap-iife": [2, "any"],
81 | "yoda": 2,
82 | //Possible errors
83 | "comma-dangle": 0,
84 | "no-cond-assign": [2, "always"],
85 | "no-console": 1,
86 | "no-constant-condition": 1,
87 | "no-control-regex": 2,
88 | "no-debugger": 1,
89 | "no-dupe-args": 2,
90 | "no-dupe-keys": 2,
91 | "no-duplicate-case": 2,
92 | "no-empty-character-class": 2,
93 | "no-empty": 2,
94 | "no-ex-assign": 2,
95 | "no-extra-boolean-cast": 0,
96 | "no-extra-parens": [2, "functions"],
97 | "no-extra-semi": 2,
98 | "no-func-assign": 2,
99 | "no-inner-declarations": 2,
100 | "no-invalid-regexp": 2,
101 | "no-irregular-whitespace": 2,
102 | "no-negated-in-lhs": 2,
103 | "no-obj-calls": 2,
104 | "no-regex-spaces": 2,
105 | "no-sparse-arrays": 2,
106 | "no-unreachable": 2,
107 | "use-isnan": 2,
108 | "valid-jsdoc": 0,
109 | "valid-typeof": 2,
110 | "no-unexpected-multiline": 0,
111 | //ES6
112 | "arrow-parens": 0,
113 | "arrow-spacing": 2,
114 | "constructor-super": 0,
115 | "generator-star-spacing": 0,
116 | "no-class-assign": 0,
117 | "no-const-assign": 2,
118 | "no-this-before-super": 2,
119 | "no-var": 2,
120 | "object-shorthand": 0,
121 | "prefer-const": 2,
122 | "prefer-spread": 1,
123 | "prefer-reflect": 0,
124 | "require-yield": 0,
125 | //Strict
126 | "strict": [2, "never"],
127 | //Variables
128 | "init-declarations": 0,
129 | "no-catch-shadow": 0,
130 | "no-delete-var": 2,
131 | "no-label-var": 0,
132 | "no-shadow-restricted-names": 2,
133 | "no-shadow": 2,
134 | "no-undef-init": 0,
135 | "no-undef": 1,
136 | "no-undefined": 0,
137 | "no-unused-vars": [2, {"vars": "local", "args": "after-used"}],
138 | "no-use-before-define": 2,
139 | //Style
140 | "array-bracket-spacing": 0,
141 | "brace-style": [2, "1tbs", {"allowSingleLine": true }],
142 | "camelcase": [2, {"properties": "never"}],
143 | "comma-spacing": [2, {"before": false, "after": true}],
144 | "comma-style": [2, "last"],
145 | "computed-property-spacing": 0,
146 | "consistent-this": 0,
147 | "eol-last": 2,
148 | "func-names": 0,
149 | "func-style": 0,
150 | "id-length": 0,
151 | "indent": 2,
152 | "key-spacing": [2, {"beforeColon": false, "afterColon": true}],
153 | "lines-around-comment": 0,
154 | "linebreak-style": 0,
155 | "max-nested-callbacks": 0,
156 | "new-cap": [1, {"newIsCap": true}],
157 | "new-parens": 0,
158 | "newline-after-var": 0,
159 | "no-array-constructor": 0,
160 | "no-continue": 0,
161 | "no-inline-comments": 0,
162 | "no-lonely-if": 0,
163 | "no-mixed-spaces-and-tabs": 2,
164 | "no-multiple-empty-lines": [2, {"max": 2}],
165 | "no-nested-ternary": 2,
166 | "no-new-object": 2,
167 | "no-spaced-func": 2,
168 | "no-ternary": 0,
169 | "no-trailing-spaces": 2,
170 | "no-underscore-dangle": 0,
171 | "no-unneeded-ternary": 0,
172 | "object-curly-spacing": 0,
173 | "one-var": [2, "never"],
174 | "operator-assignment": 0,
175 | "operator-linebreak": 0,
176 | "padded-blocks": [2, "never"],
177 | "quote-props": 0,
178 | "quotes": [1, "single", "avoid-escape"],
179 | "id-match": 0,
180 | "semi-spacing": [2, {"before": false, "after": true}],
181 | "semi": [2, "always"],
182 | "sort-vars": 0,
183 | "space-after-keywords": 2,
184 | "space-before-blocks": 2,
185 | "space-before-function-paren": 0,
186 | "space-in-parens": 0,
187 | "space-infix-ops": 2,
188 | "space-return-throw-case": 2,
189 | "space-unary-ops": 0,
190 | "spaced-comment": 0,
191 | "wrap-regex": 0
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/generators/app/templates/gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 |
--------------------------------------------------------------------------------
/generators/app/templates/gulpfile.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs');
2 |
3 | var gulp = require("gulp");
4 | var gutil = require("gulp-util");
5 | var rename = require('gulp-rename');
6 | var git = require('gulp-git');
7 | var ngConstant = require('gulp-ng-constant');
8 | var rm = require('gulp-rimraf');
9 |
10 | var KarmaServer = require('karma').Server;
11 | var webpack = require("webpack");
12 | var WebpackDevServer = require("webpack-dev-server");
13 | var webpackConfig = require("./webpack.config.js");
14 | var minimist = require('minimist');
15 |
16 | var knownOptions = {
17 | string: 'buildNumber',
18 | default: { buildNumber: 'LOCAL' }
19 | };
20 |
21 | var options = minimist(process.argv.slice(2), knownOptions);
22 |
23 | var versionMajorMinor = fs.readFileSync(__dirname + '/VERSION');
24 | var gitHash = '';
25 |
26 | gulp.task("webpack-dev-server", function(callback) {
27 | var myConfig = Object.create(webpackConfig);
28 | myConfig.devtool = "eval";
29 | myConfig.debug = true;
30 |
31 | new WebpackDevServer(webpack(myConfig), {
32 | contentBase: 'app/',
33 | stats: {
34 | colors: true
35 | }
36 | }).listen(9001, "localhost", function(err) {
37 | if(err) throw new gutil.PluginError("webpack-dev-server", err);
38 | gutil.log("[webpack-dev-server]", "http://127.0.0.1:9001");
39 | });
40 | });
41 |
42 | gulp.task('karma', function(done) {
43 | var server = new KarmaServer({
44 | configFile: __dirname + '/test/karma.conf.js',
45 | singleRun: false
46 | }, done);
47 | server.start();
48 | });
49 |
50 | gulp.task('karma:ci', function(done) {
51 | var server = new KarmaServer({
52 | configFile: __dirname + '/test/karma.ci.conf.js',
53 | singleRun: true
54 | }, done);
55 | server.start();
56 | });
57 |
58 | gulp.task("clean", function() {
59 | return gulp.src('dist/*').pipe(rm());
60 | });
61 |
62 | gulp.task("package", ["clean", "version"], function(done) {
63 | webpack(webpackConfig, function(err, stats) {
64 | if (stats.compilation.errors.length) {
65 | throw new gutil.PluginError('webpack', stats.compilation.errors.toString());
66 | }
67 | if (stats.compilation.warnings.length) {
68 | gutil.log('[WARNING]', stats.compilation.warnings.toString())
69 | }
70 | done();
71 | });
72 | });
73 |
74 | gulp.task("githash", function(done) {
75 | git.exec({args: 'rev-parse --short HEAD'}, function(err, stdout) {
76 | gitHash = stdout;
77 | done();
78 | });
79 | });
80 |
81 | gulp.task('version', ["githash"], function() {
82 | return ngConstant({
83 | name: 'version',
84 | constants: {
85 | versionNumber: {
86 | version: versionMajorMinor + options.buildNumber,
87 | gitHash: gitHash.trim()
88 | }
89 | },
90 | wrap: 'commonjs',
91 | stream: true
92 | })
93 | .pipe(rename({
94 | basename: 'version-service',
95 | extname: '.js'
96 | }))
97 | .pipe(gulp.dest('./app/services/'));
98 | });
99 |
100 | gulp.task("build", ["package"]);
101 |
102 | gulp.task("serve", ["webpack-dev-server"]);
103 |
--------------------------------------------------------------------------------
/generators/app/templates/test/karma.ci.conf.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack');
2 | var path = require('path');
3 |
4 | module.exports = function(config) {
5 | config.set({
6 | browsers: ['PhantomJS'],
7 | files: [
8 | './spec/tests.webpack.js'
9 | ],
10 | frameworks: ['jasmine'],
11 | preprocessors: {
12 | './spec/tests.webpack.js': ['webpack', 'sourcemap'],
13 | },
14 | reporters: ['dots', 'junit', 'coverage'],
15 | singleRun: true,
16 | junitReporter: {
17 | outputDir: '',
18 | outputFile: undefined,
19 | suite: '',
20 | useBrowserName: true
21 | },
22 | coverageReporter: {
23 | type: 'cobertura',
24 | dir: 'coverage/',
25 | file: 'coverage.xml'
26 | },
27 | webpack: {
28 | module: {
29 | loaders: [
30 | {
31 | test: /.html$/,
32 | loader: 'ngtemplate?relativeTo=/app!html?root=' + __dirname + '/../app'
33 | },
34 | {
35 | test: /\.scss$/,
36 | loaders: ["style", "css", "sass"]
37 | },
38 | {
39 | test: /\.png$/,
40 | loader: 'file-loader'
41 | }
42 | ],
43 | preLoaders: [
44 | {
45 | test: /\.js$/,
46 | exclude: /(test|node_modules)/,
47 | loader: 'isparta-loader'
48 | },
49 | {
50 | test: /test.js$/,
51 | exclude: /node_modules/,
52 | loader: 'babel-loader'
53 | }
54 | ]
55 | },
56 | resolve: {
57 | root: path.resolve(__dirname, '../app/'),
58 | extensions: ['', '.js']
59 | },
60 | plugins: [
61 | new webpack.ProvidePlugin({
62 | $: 'jquery',
63 | jQuery: 'jquery',
64 | 'window.jQuery': 'jquery'
65 | })
66 | ],
67 | watch: true,
68 | sassLoader: {
69 | includePaths: [path.resolve(__dirname, "../app")]
70 | },
71 | isparta: {
72 | babel: {
73 | presets: 'es2015'
74 | }
75 | }
76 | },
77 | webpackServer: {
78 | noInfo: true,
79 | }
80 | });
81 | };
82 |
--------------------------------------------------------------------------------
/generators/app/templates/test/karma.conf.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack');
2 | var path = require('path');
3 |
4 | module.exports = function(config) {
5 | config.set({
6 | browsers: ['PhantomJS'],
7 | files: [
8 | './spec/tests.webpack.js'
9 | ],
10 | frameworks: ['jasmine'],
11 | preprocessors: {
12 | './spec/tests.webpack.js': ['webpack', 'sourcemap'],
13 | },
14 | reporters: ['dots'],
15 | singleRun: true,
16 | webpack: {
17 | devtool: 'inline-source-map',
18 | module: {
19 | loaders: [
20 | {
21 | test: /\.js$/,
22 | exclude: /node_modules/,
23 | loader: 'babel-loader'
24 | },
25 | {
26 | test: /.html$/,
27 | loader: 'ngtemplate?relativeTo=/app!html?root=' + __dirname + '/../app'
28 | },
29 | {
30 | test: /\.scss$/,
31 | loaders: ["style", "css", "sass"]
32 | },
33 | {
34 | test: /\.png$/,
35 | loader: 'file-loader'
36 | }
37 | ]
38 | },
39 | resolve: {
40 | root: path.resolve('app/'),
41 | extensions: ['', '.js']
42 | },
43 | plugins: [
44 | new webpack.ProvidePlugin({
45 | $: 'jquery',
46 | jQuery: 'jquery',
47 | 'window.jQuery': 'jquery'
48 | })
49 | ],
50 | watch: true,
51 | sassLoader: {
52 | includePaths: [path.resolve(__dirname, "../app")]
53 | }
54 | },
55 | webpackServer: {
56 | noInfo: true,
57 | }
58 | });
59 | };
60 |
--------------------------------------------------------------------------------
/generators/app/templates/test/spec/components/_main-controller-test.js:
--------------------------------------------------------------------------------
1 | import mainCtrl from 'components/main/main-controller';
2 |
3 | describe('Main controller', () => {
4 | let ctrl;
5 | let scope;
6 |
7 | beforeEach(angular.mock.module('<%= appName.replace(/\s/g, '') %>'));
8 |
9 | beforeEach(inject(($controller, $rootScope) => {
10 | scope = $rootScope.$new();
11 |
12 | ctrl = $controller(mainCtrl, {
13 | $scope: scope
14 | });
15 | }));
16 |
17 | it('should set application name on controller', () => {
18 | expect(ctrl.applicationName).toEqual('<%= appName %>')
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/generators/app/templates/test/spec/tests.webpack.js:
--------------------------------------------------------------------------------
1 | require('core-js');
2 | require('core-js/es5');
3 | require('babel-polyfill');
4 |
5 | require('app');
6 | require('angular-mocks');
7 |
8 | var context = require.context('./', true, /-test\.js$/);
9 | context.keys().forEach(context);
10 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generator-angular-es6-webpack",
3 | "version": "1.1.1",
4 | "description": "Yeoman generator for Angular with ES6 and Webpack",
5 | "license": "MIT",
6 | "repository": "d3spis3d/generator-angular-es6-webpack",
7 | "author": {
8 | "name": "Daniel Budden",
9 | "email": "daniel.l.budden@gmail.com",
10 | "url": "https://github.com/d3spis3d"
11 | },
12 | "scripts": {
13 | "test": "mocha"
14 | },
15 | "files": [
16 | "generators/app"
17 | ],
18 | "keywords": [
19 | "yeoman-generator"
20 | ],
21 | "dependencies": {
22 | "chalk": "^1.0.0",
23 | "yeoman-generator": "^0.22.0",
24 | "yosay": "^1.0.2"
25 | },
26 | "devDependencies": {
27 | "mocha": "*",
28 | "yeoman-assert": "^2.1.1",
29 | "yeoman-test": "^1.0.0"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/test/test-defaults.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var assert = require('yeoman-assert');
5 | var helpers = require('yeoman-test');
6 | var os = require('os');
7 |
8 | describe('angular-es6-webpack:app with default prompt answers', function () {
9 | before(function (done) {
10 | helpers.run(path.join(__dirname, '../generators/app'))
11 | .withOptions({ skipInstall: true })
12 | .on('end', done);
13 | });
14 |
15 | it('should creates files', function () {
16 | assert.file([
17 | 'package.json',
18 | 'gulpfile.js',
19 | '.editorconfig',
20 | '.eslintrc',
21 | '.gitignore',
22 | 'VERSION',
23 | 'webpack.config.js',
24 | 'test/spec/tests.webpack.js',
25 | 'test/karma.conf.js',
26 | 'test/karma.ci.conf.js',
27 | 'app/app.js',
28 | 'app/services/services.js',
29 | 'app/directives/directives.js',
30 | 'app/components/main/main.routes.js',
31 | 'app/components/main/main.html',
32 | 'app/components/main/main-controller.js',
33 | 'app/images/yeoman.png'
34 | ]);
35 | });
36 |
37 | it('should have default angular version', function() {
38 | assert.fileContent([
39 | ['package.json', /"angular": "1\.4\.7"/],
40 | ['package.json', /"angular-resource": "1\.4\.7"/],
41 | ['package.json', /"angular-sanitize": "1\.4\.7"/],
42 | ['package.json', /"angular-mocks": "1\.4\.7"/]
43 | ]);
44 | });
45 |
46 | it('should have default name', function() {
47 | assert.fileContent('package.json', /"name": "angular-es6-app"/);
48 | });
49 |
50 | it('should have ui-router', function() {
51 | assert.fileContent('package.json', /"angular-ui-router":/);
52 | });
53 |
54 | it('should have default angular module name', function() {
55 | assert.fileContent('app/app.js', /angular\.module\('AngularES6App'/);
56 | });
57 |
58 | it('should import the correct router', function() {
59 | assert.fileContent([
60 | ['app/app.js', /import 'angular-ui-router'/],
61 | ['app/app.js', /'ngResource', 'ui.router',/]
62 | ]);
63 | });
64 |
65 | it('should use correct routing in main.routes.js', function() {
66 | assert.fileContent('app/components/main/main.routes.js', /\$stateProvider\.state\('main'/);
67 | });
68 |
69 | it('should use the correct view directive in index.html', function() {
70 | assert.fileContent('app/index.html', /<\/div>/);
71 | });
72 | });
73 |
--------------------------------------------------------------------------------
/test/test-prompts.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var assert = require('yeoman-assert');
5 | var helpers = require('yeoman-test');
6 | var os = require('os');
7 |
8 | describe('angular-es6-webpack:app with prompt answers', function () {
9 | before(function (done) {
10 | helpers.run(path.join(__dirname, '../generators/app'))
11 | .withOptions({ skipInstall: true })
12 | .withPrompts({
13 | appName: 'Test Angular Application',
14 | ngVersion: '1.4.6',
15 | uiRouter: false
16 | })
17 | .on('end', done);
18 | });
19 |
20 | it('should creates files', function () {
21 | assert.file([
22 | 'package.json',
23 | 'gulpfile.js',
24 | '.editorconfig',
25 | '.eslintrc',
26 | '.gitignore',
27 | 'VERSION',
28 | 'webpack.config.js',
29 | 'test/spec/tests.webpack.js',
30 | 'test/karma.conf.js',
31 | 'test/karma.ci.conf.js',
32 | 'app/app.js',
33 | 'app/services/services.js',
34 | 'app/directives/directives.js',
35 | 'app/components/main/main.routes.js',
36 | 'app/components/main/main.html',
37 | 'app/components/main/main-controller.js',
38 | 'app/images/yeoman.png'
39 | ]);
40 | });
41 |
42 | it('should have user defined angular version', function() {
43 | assert.fileContent([
44 | ['package.json', /"angular": "1\.4\.6"/],
45 | ['package.json', /"angular-resource": "1\.4\.6"/],
46 | ['package.json', /"angular-sanitize": "1\.4\.6"/],
47 | ['package.json', /"angular-mocks": "1\.4\.6"/]
48 | ]);
49 | });
50 |
51 | it('should have user defined name', function() {
52 | assert.fileContent('package.json', /"name": "test-angular-application"/);
53 | });
54 |
55 | it('should not have ui-router', function() {
56 | assert.fileContent('package.json', /"angular-route": "1\.4\.6"/);
57 | });
58 |
59 | it('should have user defined angular module name', function() {
60 | assert.fileContent('app/app.js', /angular\.module\('TestAngularApplication'/);
61 | });
62 |
63 | it('should import the correct router', function() {
64 | assert.fileContent([
65 | ['app/app.js', /import 'angular-route'/],
66 | ['app/app.js', /'ngResource', 'ngRoute',/]
67 | ]);
68 | });
69 |
70 | it('should use correct routing in main.routes.js', function() {
71 | assert.fileContent('app/components/main/main.routes.js', /\$routeProvider\.when\('\/'/);
72 | });
73 |
74 | it('should use the correct view directive in index.html', function() {
75 | assert.fileContent('app/index.html', /
<\/div>/);
76 | });
77 | });
78 |
--------------------------------------------------------------------------------