Skip to content

Commit 3aac05f

Browse files
committed
Merge pull request #1246 from kingcody/feature/angular-fullstack-deps-submodule
Feature: angular fullstack deps submodule
2 parents a764184 + 87b3136 commit 3aac05f

File tree

6 files changed

+63
-44
lines changed

6 files changed

+63
-44
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "angular-fullstack-deps"]
2+
path = angular-fullstack-deps
3+
url = git@github.com:angular-fullstack/angular-fullstack-deps.git

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ notifications:
2424
on_success: change # options: [always|never|change] default: always
2525
on_failure: always # options: [always|never|change] default: always
2626
on_start: false # default: false
27+
git:
28+
submodules: false

Gruntfile.js

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var semver = require('semver');
43
var shell = require('shelljs');
54
var child_process = require('child_process');
65
var Q = require('q');
@@ -28,15 +27,26 @@ module.exports = function (grunt) {
2827
},
2928
release: {
3029
options: {
30+
bump: false, // remove after 3.0.0 release
3131
commitMessage: '<%= version %>',
32-
tagName: 'v<%= version %>',
33-
bump: false, // we have our own bump
34-
file: 'package.json'
32+
tagName: '<%= version %>',
33+
file: 'package.json',
34+
afterBump: ['updateFixtures:deps', 'commitNgFullstackDeps'],
35+
beforeRelease: ['stage'],
36+
push: false,
37+
pushTags: false,
38+
npm: false
39+
}
40+
},
41+
commitNgFullstackDeps: {
42+
options: {
43+
cwd: 'angular-fullstack-deps',
44+
files: ['package.json', 'bower.json']
3545
}
3646
},
3747
stage: {
3848
options: {
39-
files: ['CHANGELOG.md']
49+
files: ['CHANGELOG.md', 'angular-fullstack-deps']
4050
}
4151
},
4252
buildcontrol: {
@@ -103,32 +113,34 @@ module.exports = function (grunt) {
103113
}
104114
});
105115

106-
grunt.registerTask('bump', 'bump manifest version', function (type) {
107-
var options = this.options({
108-
file: grunt.config('pkgFile') || 'package.json'
109-
});
110-
111-
function setup(file, type) {
112-
var pkg = grunt.file.readJSON(file);
113-
var newVersion = pkg.version = semver.inc(pkg.version, type || 'patch');
114-
return {
115-
file: file,
116-
pkg: pkg,
117-
newVersion: newVersion
118-
};
119-
}
120-
121-
var config = setup(options.file, type);
122-
grunt.file.write(config.file, JSON.stringify(config.pkg, null, ' ') + '\n');
123-
grunt.log.ok('Version bumped to ' + config.newVersion);
124-
});
125-
126116
grunt.registerTask('stage', 'git add files before running the release task', function () {
127-
var files = this.options().files;
117+
var files = grunt.config('stage.options').files, done = this.async();
128118
grunt.util.spawn({
129119
cmd: process.platform === 'win32' ? 'git.cmd' : 'git',
130120
args: ['add'].concat(files)
131-
}, grunt.task.current.async());
121+
}, done);
122+
});
123+
124+
grunt.registerTask('commitNgFullstackDeps', function() {
125+
grunt.config.requires(
126+
'commitNgFullstackDeps.options.files',
127+
'commitNgFullstackDeps.options.cwd'
128+
);
129+
var ops = grunt.config.get('commitNgFullstackDeps').options;
130+
var version = require('./package.json').version || 'NO VERSION SET';
131+
if (Array.isArray(ops.files) && ops.files.length > 0) {
132+
var done = this.async();
133+
var cwd = path.resolve(__dirname, ops.cwd);
134+
grunt.util.spawn({
135+
cmd: process.platform === 'win32' ? 'git.cmd' : 'git',
136+
args: ['commit', '-m', version].concat(ops.files),
137+
opts: {
138+
cwd: cwd
139+
}
140+
}, done);
141+
} else {
142+
grunt.log.writeln('No files were commited');
143+
}
132144
});
133145

134146
grunt.registerTask('generateDemo', 'generate demo', function () {
@@ -220,21 +232,23 @@ module.exports = function (grunt) {
220232
}
221233
});
222234

223-
grunt.registerTask('updateFixtures', 'updates package and bower fixtures', function() {
224-
var packageJson = fs.readFileSync(path.resolve('app/templates/_package.json'), 'utf8');
225-
var bowerJson = fs.readFileSync(path.resolve('app/templates/_bower.json'), 'utf8');
226-
227-
// replace package name
228-
packageJson = packageJson.replace(/"name": "<%(.*)%>"/g, '"name": "tempApp"');
229-
packageJson = packageJson.replace(/<%(.*)%>/g, '');
230-
231-
// remove all ejs conditionals
232-
bowerJson = bowerJson.replace(/"name": "<%(.*)%>"/g, '"name": "tempApp"');
233-
bowerJson = bowerJson.replace(/<%(.*)%>/g, '');
234-
235-
// save files
236-
fs.writeFileSync(path.resolve(__dirname + '/test/fixtures/package.json'), packageJson);
237-
fs.writeFileSync(path.resolve(__dirname + '/test/fixtures/bower.json'), bowerJson);
235+
grunt.registerTask('updateFixtures', 'updates package and bower fixtures', function(target) {
236+
var genVer = require('./package.json').version;
237+
var dest = __dirname + ((target === 'deps') ? '/angular-fullstack-deps/' : '/test/fixtures/');
238+
var appName = (target === 'deps') ? 'angular-fullstack-deps' : 'tempApp';
239+
240+
var processJson = function(s, d) {
241+
// read file, strip all ejs conditionals, and parse as json
242+
var json = JSON.parse(fs.readFileSync(path.resolve(s), 'utf8').replace(/<%(.*)%>/g, ''));
243+
// set properties
244+
json.name = appName, json.version = genVer;
245+
if (target === 'deps') { json.private = false; }
246+
// stringify json and write it to the destination
247+
fs.writeFileSync(path.resolve(d), JSON.stringify(json, null, 2));
248+
};
249+
250+
processJson('app/templates/_package.json', dest + 'package.json');
251+
processJson('app/templates/_bower.json', dest + 'bower.json');
238252
});
239253

240254
grunt.registerTask('installFixtures', 'install package and bower fixtures', function() {

angular-fullstack-deps

Submodule angular-fullstack-deps added at 45f8b09

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"mocha": "^2.2.5",
5555
"q": "^1.0.1",
5656
"recursive-readdir": "^1.2.0",
57-
"semver": "^5.0.1",
5857
"shelljs": "^0.5.3",
5958
"underscore.string": "^3.1.1"
6059
},

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AngularJS Full-Stack generator
22
[![Build Status](https://travis-ci.org/DaftMonk/generator-angular-fullstack.svg?branch=master)](http://travis-ci.org/DaftMonk/generator-angular-fullstack) [![npm version](https://badge.fury.io/js/generator-angular-fullstack.svg)](http://badge.fury.io/js/generator-angular-fullstack) [![Dependency Status](https://david-dm.org/daftmonk/generator-angular-fullstack.png)](https://david-dm.org/daftmonk/generator-angular-fullstack) [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/DaftMonk/generator-angular-fullstack)
3-
3+
#### Generated project: [![Dependency Status](https://david-dm.org/angular-fullstack/angular-fullstack-deps.svg)](https://david-dm.org/angular-fullstack/angular-fullstack-deps) [![Dev-Dependency Status](https://david-dm.org/angular-fullstack/angular-fullstack-deps/dev-status.svg)](https://david-dm.org/angular-fullstack/angular-fullstack-deps#info=devDependencies)
44
> Yeoman generator for creating MEAN stack applications, using MongoDB, Express, AngularJS, and Node - lets you quickly set up a project following best practices.
55
66
## Example project

0 commit comments

Comments
 (0)