Skip to content

Commit 1bfc610

Browse files
committed
move all generators from root to lib/generators
0 parents  commit 1bfc610

47 files changed

Lines changed: 17762 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

all/USAGE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Description:
2+
Creates a default AngularJS folder layout in app/scripts/
3+
4+
Example:
5+
yeoman init angular
6+
7+
This will create:
8+
app/scripts/app.js
9+
app/scripts/controllers/main-ctrl.js

all/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
var path = require('path'),
3+
util = require('util'),
4+
yeoman = require('../../../../');
5+
6+
var Generator = module.exports = function Generator() {
7+
yeoman.generators.Base.apply(this, arguments);
8+
this.sourceRoot(path.join(__dirname, '../templates'));
9+
10+
this.appname = path.basename(process.cwd());
11+
12+
this.hookFor('angular:app', {
13+
args: ['main']
14+
});
15+
this.hookFor('testacular:app', {
16+
args: [false] // run testacular hook in non-interactive mode
17+
});
18+
};
19+
20+
util.inherits(Generator, yeoman.generators.Base);

app/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
var util = require('util'),
3+
path = require('path'),
4+
yeoman = require('../../../../');
5+
6+
module.exports = Generator;
7+
8+
function Generator() {
9+
yeoman.generators.Base.apply(this, arguments);
10+
this.appname = path.basename(process.cwd());
11+
}
12+
13+
util.inherits(Generator, yeoman.generators.Base);
14+
15+
Generator.prototype.setupEnv = function setupEnv() {
16+
// Copies the contents of the generator `templates`
17+
// directory into your users new application path
18+
this.sourceRoot(path.join(__dirname, '../templates'));
19+
20+
this.directory('app','.', true);
21+
};
22+
23+
Generator.prototype.createAppFile = function createAppFile() {
24+
this.template('app.js', 'app/scripts/' + this.appname + '.js');
25+
};
26+
27+
Generator.prototype.createMainFiles = function createMainFiles() {
28+
29+
this.template('index.html', 'app/index.html');
30+
31+
this.template('main.js', 'app/scripts/controllers/main.js');
32+
this.template('main.html', 'app/views/main.html');
33+
};

controller/USAGE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Description:
2+
Creates a new Angular controller
3+
4+
Example:
5+
yeoman init angular:controller Thing
6+
7+
This will create:
8+
app/scripts/controllers/thing-ctrl.js

controller/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
var path = require('path'),
3+
util = require('util'),
4+
yeoman = require('../../../../'),
5+
grunt = require('grunt'),
6+
angularUtils = require('../util.js');
7+
8+
module.exports = Generator;
9+
10+
function Generator() {
11+
yeoman.generators.NamedBase.apply(this, arguments);
12+
this.sourceRoot(path.join(__dirname, '../templates'));
13+
14+
this.appname = path.basename(process.cwd());
15+
}
16+
17+
util.inherits(Generator, yeoman.generators.NamedBase);
18+
19+
Generator.prototype.createControllerFiles = function createControllerFiles() {
20+
this.template('controller.js', 'app/scripts/controllers/' + this.name + '.js');
21+
this.template('spec/controller.js', 'test/spec/controllers/' + this.name + '.js');
22+
};
23+
24+
Generator.prototype.rewriteIndexHtml = function() {
25+
var file = 'app/index.html';
26+
var body = grunt.file.read(file);
27+
28+
body = angularUtils.rewrite({
29+
needle: '<!-- endbuild -->',
30+
haystack: body,
31+
splicable: [
32+
'<script src="scripts/controllers/' + this.name + '.js"></script>'
33+
]
34+
});
35+
36+
grunt.file.write(file, body);
37+
};

directive/USAGE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Description:
2+
Creates a new Angular directive
3+
4+
Example:
5+
yeoman init angular:directive thing
6+
7+
This will create:
8+
app/scripts/directives/thing.js

directive/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
var path = require('path'),
3+
util = require('util'),
4+
yeoman = require('../../../../'),
5+
grunt = require('grunt'),
6+
angularUtils = require('../util.js');
7+
8+
module.exports = Generator;
9+
10+
function Generator() {
11+
yeoman.generators.NamedBase.apply(this, arguments);
12+
this.sourceRoot(path.join(__dirname, '../templates'));
13+
14+
this.appname = path.basename(process.cwd());
15+
}
16+
17+
util.inherits(Generator, yeoman.generators.NamedBase);
18+
19+
Generator.prototype.createDirectiveFiles = function createDirectiveFiles() {
20+
this.template('directive.js', 'app/scripts/directives/' + this.name + '.js');
21+
this.template('spec/directive.js', 'test/spec/directives/' + this.name + '.js');
22+
};
23+
24+
Generator.prototype.rewriteIndexHtml = function() {
25+
var file = 'app/index.html';
26+
var body = grunt.file.read(file);
27+
28+
body = angularUtils.rewrite({
29+
needle: '<!-- endbuild -->',
30+
haystack: body,
31+
splicable: [
32+
'<script src="scripts/directives/' + this.name + '.js"></script>'
33+
]
34+
});
35+
36+
grunt.file.write(file, body);
37+
};

filter/USAGE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Description:
2+
Creates a new AngularJS filter
3+
4+
Example:
5+
yeoman init angular:filter thing
6+
7+
This will create:
8+
app/scripts/filters/thing.js

filter/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
var path = require('path'),
3+
util = require('util'),
4+
yeoman = require('../../../../'),
5+
grunt = require('grunt'),
6+
angularUtils = require('../util.js');
7+
8+
module.exports = Generator;
9+
10+
function Generator() {
11+
yeoman.generators.NamedBase.apply(this, arguments);
12+
this.sourceRoot(path.join(__dirname, '../templates'));
13+
14+
this.appname = path.basename(process.cwd());
15+
}
16+
17+
util.inherits(Generator, yeoman.generators.NamedBase);
18+
19+
Generator.prototype.createFilterFiles = function createFilterFiles() {
20+
this.template('filter.js', 'app/scripts/filters/' + this.name + '.js');
21+
this.template('spec/filter.js', 'test/spec/filters/' + this.name + '.js');
22+
};
23+
24+
Generator.prototype.rewriteIndexHtml = function() {
25+
var file = 'app/index.html';
26+
var body = grunt.file.read(file);
27+
28+
body = angularUtils.rewrite({
29+
needle: '<!-- endbuild -->',
30+
haystack: body,
31+
splicable: [
32+
'<script src="scripts/filters/' + this.name + '.js"></script>'
33+
]
34+
});
35+
36+
grunt.file.write(file, body);
37+
};

partial/USAGE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Description:
2+
Creates a new AngularJS partial
3+
4+
Example:
5+
yeoman init angular:partial Thing
6+
7+
This will create:
8+
app/scripts/partials/thing.html

0 commit comments

Comments
 (0)