Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

chore(gen): bump yeoman-generator from 0.16.0 to 0.18.0 #1255

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
35 changes: 16 additions & 19 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ var chalk = require('chalk');

var Generator = module.exports = function Generator(args, options) {
yeoman.generators.Base.apply(this, arguments);
this.argument('appname', { type: String, required: false });
this.appname = this.appname || path.basename(process.cwd());
this.appname = this._.camelize(this._.slugify(this._.humanize(this.appname)));

this.option('app-suffix', {
desc: 'Allow a custom suffix to be added to the module name',
type: String
});
this.env.options['app-suffix'] = this.options['app-suffix'];
this.scriptAppName = this.appname + angularUtils.appName(this);

args = ['main'];

Expand Down Expand Up @@ -71,18 +66,6 @@ var Generator = module.exports = function Generator(args, options) {
this.env.options.typescript = this.options.typescript;
}

this.hookFor('angular:common', {
args: args
});

this.hookFor('angular:main', {
args: args
});

this.hookFor('angular:controller', {
args: args
});

this.on('end', function () {
var jsExt = this.options.coffee ? 'coffee' : 'js';

Expand All @@ -95,7 +78,7 @@ var Generator = module.exports = function Generator(args, options) {
bowerComments.push('endbower');
}

this.invoke('karma:app', {
this.composeWith('karma:app', {
options: {
'skip-install': this.options['skip-install'],
'base-path': '../',
Expand All @@ -118,7 +101,7 @@ var Generator = module.exports = function Generator(args, options) {
});

if (this.env.options.ngRoute) {
this.invoke('angular:route', {
this.composeWith('angular:route', {
args: ['about']
});
}
Expand All @@ -130,6 +113,13 @@ var Generator = module.exports = function Generator(args, options) {

util.inherits(Generator, yeoman.generators.Base);

Generator.prototype.initializing = function initializing() {
this.argument('appname', { type: String, required: false });
this.appname = this.appname || path.basename(process.cwd());
this.appname = this._.camelize(this._.slugify(this._.humanize(this.appname)));
this.scriptAppName = this.appname + angularUtils.appName(this);
}

Generator.prototype.welcome = function welcome() {
if (!this.options['skip-welcome-message']) {
this.log(yosay());
Expand Down Expand Up @@ -377,3 +367,10 @@ Generator.prototype._injectDependencies = function _injectDependencies() {
this.spawnCommand(taskRunner, ['wiredep']);
}
};

Generator.prototype.install = function install() {
var args = ['main'];
this.composeWith('angular:common', {args: args});
this.composeWith('angular:main', {args: args});
this.composeWith('angular:controller', {args: args});
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"dependencies": {
"chalk": "^1.0.0",
"wiredep": "^2.2.0",
"yeoman-generator": "^0.16.0",
"yeoman-generator": "^0.18.0",
"yosay": "^1.0.2"
},
"peerDependencies": {
Expand All @@ -52,7 +52,9 @@
"grunt-conventional-github-releaser": "^0.5.0",
"load-grunt-tasks": "^3.1.0",
"mocha": "*",
"underscore.string": "^3.0.3"
"underscore.string": "^3.0.3",
"yeoman-assert": "^2.1.1",
"yeoman-test": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
Expand Down
7 changes: 1 addition & 6 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AngularJS generator [![Build Status](https://secure.travis-ci.org/yeoman/generator-angular.svg?branch=master)](http://travis-ci.org/yeoman/generator-angular)
# AngularJS generator [![Build Status](https://secure.travis-ci.org/yeoman/generator-angular.svg?branch=master)](http://travis-ci.org/yeoman/generator-angular) [![Gitter](https://img.shields.io/badge/Gitter-Join_the_Yeoman_chat_%E2%86%92-00d06f.svg)](https://gitter.im/yeoman/yeoman)

> Yeoman generator for AngularJS - lets you quickly set up a project with sensible defaults and best practices.

Expand Down Expand Up @@ -234,11 +234,6 @@ angular.module('demoApp')
.controller('UserCtrl', demoApp.UserCtrl);
```


A project can mix TypeScript, CoffeScript, and JavaScript files.

To output JavaScript files, even if CoffeeScript (or TypeScript) files exist (the default is to output CoffeeScript files if the generator finds any in the project), use `--coffee=false` and/or `--typescript=false`.

### Minification Safe

**tl;dr**: You don't need to write annotated code as the build step will
Expand Down
9 changes: 6 additions & 3 deletions route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ var Generator = module.exports = function Generator() {
) {
this.foundWhenForRoute = true;
}

this.hookFor('angular:controller');
this.hookFor('angular:view');
};

util.inherits(Generator, ScriptBase);
Expand Down Expand Up @@ -78,3 +75,9 @@ Generator.prototype.rewriteAppJs = function () {

angularUtils.rewriteFile(config);
};

Generator.prototype.install = function install() {
var args = [this.name];
this.composeWith('angular:controller', {args: args});
this.composeWith('angular:view', {args: args});
};
2 changes: 1 addition & 1 deletion script-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Generator.prototype.addScriptToIndex = function (script) {

Generator.prototype.generateSourceAndTest = function (appTemplate, testTemplate, targetDirectory, skipAdd) {
// Services use classified names
if (this.generatorName.toLowerCase() === 'service') {
if (this.rootGeneratorName().toLowerCase() === 'service') {
this.cameledName = this.classedName;
}

Expand Down
144 changes: 144 additions & 0 deletions test/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
'use strict';

var path = require('path');
var helpers = require('yeoman-test');
var assert = require('yeoman-assert');

var getDefaultFilesForAppPath = function (appPath) {
return [
appPath + '/404.html',
appPath + '/favicon.ico',
appPath + '/robots.txt',
appPath + '/styles/main.scss',
appPath + '/views/main.html',
appPath + '/index.html',
'.bowerrc',
'.editorconfig',
'.gitignore',
'.jshintrc',
'Gruntfile.js',
'package.json',
'bower.json'
];
};

describe('angular:app', function () {
var appPath = 'customAppPath';

beforeEach(function () {
this.angular = helpers
.run(require.resolve('../app'))
.withGenerators([
require.resolve('../common'),
require.resolve('../controller'),
require.resolve('../main'),
[helpers.createDummyGenerator(), 'karma:app']
])
.withOptions({
'skip-welcome-message': true,
'skip-message': true
})
.withArguments(['upperCaseBug'])
.withPrompts({
compass: true,
bootstrap: true,
compassBootstrap: true,
modules: []
});
});

describe('default settings', function () {
beforeEach(function (done) {
this.angular.on('end', done);
});

it('generates base files', function () {
assert.file(getDefaultFilesForAppPath('app'));
assert.file([
'.jscsrc',
'app/index.html',
'app/scripts/app.js',
'app/scripts/controllers/main.js',
'test/spec/controllers/main.js'
]);
});
});

describe('--coffee', function () {
beforeEach(function (done) {
this.angular.withOptions({
coffee: true
}).on('end', done);
});

it('generates CoffeeScript files', function () {
assert.file([].concat(getDefaultFilesForAppPath('app'), [
'app/scripts/app.coffee',
'app/scripts/controllers/main.coffee',
'test/spec/controllers/main.coffee'
]));
});
});

describe('--typescript', function () {
beforeEach(function (done) {
this.angular.withOptions({
typescript: true
}).on('end', done);
});

it('generates CoffeeScript files', function () {
assert.file([].concat(getDefaultFilesForAppPath('app'), [
'app/scripts/app.ts',
'app/scripts/controllers/main.ts',
'test/spec/controllers/main.ts'
]));
});
});

describe('--appPath', function () {
beforeEach(function (done) {
this.angular.withOptions({
appPath: 'alternative'
}).on('end', done);
});

it('generates base files inside the appPath', function () {
assert.file(getDefaultFilesForAppPath('alternative'));
assert.file([
'.jscsrc',
'alternative/scripts/app.js',
'alternative/scripts/controllers/main.js',
'test/spec/controllers/main.js'
]);
});
});

describe('--appName', function () {
beforeEach(function (done) {
this.angular
.withArguments(['upperCaseBug'])
.on('end', done);
});

it('generates the same appName in every file', function () {
assert.fileContent(
'app/scripts/app.js',
/module\('upperCaseBugApp'/
);
assert.fileContent(
'app/scripts/controllers/main.js',
/module\('upperCaseBugApp'/
);
assert.fileContent(
'test/spec/controllers/main.js',
/module\('upperCaseBugApp'/
);

assert.fileContent(
'app/index.html',
/ng-app="upperCaseBugApp"/
);
});
});
});
22 changes: 22 additions & 0 deletions test/constant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';
var fs = require('fs');
var path = require('path');
var helpers = require('yeoman-test');
var assert = require('yeoman-assert');

describe('angular:constant', function () {
beforeEach(function (done) {
helpers
.run(require.resolve('../constant'))
.withArguments('foo')
.on('end', done);
});

it('generates a new constant', function () {
assert.file('test/spec/services/foo.js');
assert.fileContent(
path.join('app/scripts/services/foo.js'),
/constant\('foo'/
);
});
});
22 changes: 22 additions & 0 deletions test/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';
var fs = require('fs');
var path = require('path');
var helpers = require('yeoman-test');
var assert = require('yeoman-assert');

describe('angular:controller', function () {
beforeEach(function (done) {
helpers
.run(require.resolve('../controller'))
.withArguments('foo')
.on('end', done);
});

it('generates a new controller', function () {
assert.file('test/spec/controllers/foo.js');
assert.fileContent(
path.join('app/scripts/controllers/foo.js'),
/controller\('FooCtrl'/
);
});
});
22 changes: 22 additions & 0 deletions test/directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';
var fs = require('fs');
var path = require('path');
var helpers = require('yeoman-test');
var assert = require('yeoman-assert');

describe('angular:directive', function () {
beforeEach(function (done) {
helpers
.run(require.resolve('../directive'))
.withArguments('foo')
.on('end', done);
});

it('generates a new directive', function () {
assert.file('test/spec/directives/foo.js');
assert.fileContent(
path.join('app/scripts/directives/foo.js'),
/directive\('foo'/
);
});
});
22 changes: 22 additions & 0 deletions test/factory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';
var fs = require('fs');
var path = require('path');
var helpers = require('yeoman-test');
var assert = require('yeoman-assert');

describe('angular:factory', function () {
beforeEach(function (done) {
helpers
.run(require.resolve('../factory'))
.withArguments('foo')
.on('end', done);
});

it('generates a new factory', function () {
assert.file('test/spec/services/foo.js');
assert.fileContent(
path.join('app/scripts/services/foo.js'),
/factory\('foo'/
);
});
});
Loading