Skip to content

Commit

Permalink
Merge pull request angular-fullstack#1246 from kingcody/feature/angul…
Browse files Browse the repository at this point in the history
…ar-fullstack-deps-submodule

Feature: angular fullstack deps submodule
  • Loading branch information
Awk34 committed Sep 5, 2015
2 parents a764184 + 87b3136 commit 3aac05f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 44 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "angular-fullstack-deps"]
path = angular-fullstack-deps
url = [email protected]:angular-fullstack/angular-fullstack-deps.git
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ notifications:
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: false # default: false
git:
submodules: false
98 changes: 56 additions & 42 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

var semver = require('semver');
var shell = require('shelljs');
var child_process = require('child_process');
var Q = require('q');
Expand Down Expand Up @@ -28,15 +27,26 @@ module.exports = function (grunt) {
},
release: {
options: {
bump: false, // remove after 3.0.0 release
commitMessage: '<%= version %>',
tagName: 'v<%= version %>',
bump: false, // we have our own bump
file: 'package.json'
tagName: '<%= version %>',
file: 'package.json',
afterBump: ['updateFixtures:deps', 'commitNgFullstackDeps'],
beforeRelease: ['stage'],
push: false,
pushTags: false,
npm: false
}
},
commitNgFullstackDeps: {
options: {
cwd: 'angular-fullstack-deps',
files: ['package.json', 'bower.json']
}
},
stage: {
options: {
files: ['CHANGELOG.md']
files: ['CHANGELOG.md', 'angular-fullstack-deps']
}
},
buildcontrol: {
Expand Down Expand Up @@ -103,32 +113,34 @@ module.exports = function (grunt) {
}
});

grunt.registerTask('bump', 'bump manifest version', function (type) {
var options = this.options({
file: grunt.config('pkgFile') || 'package.json'
});

function setup(file, type) {
var pkg = grunt.file.readJSON(file);
var newVersion = pkg.version = semver.inc(pkg.version, type || 'patch');
return {
file: file,
pkg: pkg,
newVersion: newVersion
};
}

var config = setup(options.file, type);
grunt.file.write(config.file, JSON.stringify(config.pkg, null, ' ') + '\n');
grunt.log.ok('Version bumped to ' + config.newVersion);
});

grunt.registerTask('stage', 'git add files before running the release task', function () {
var files = this.options().files;
var files = grunt.config('stage.options').files, done = this.async();
grunt.util.spawn({
cmd: process.platform === 'win32' ? 'git.cmd' : 'git',
args: ['add'].concat(files)
}, grunt.task.current.async());
}, done);
});

grunt.registerTask('commitNgFullstackDeps', function() {
grunt.config.requires(
'commitNgFullstackDeps.options.files',
'commitNgFullstackDeps.options.cwd'
);
var ops = grunt.config.get('commitNgFullstackDeps').options;
var version = require('./package.json').version || 'NO VERSION SET';
if (Array.isArray(ops.files) && ops.files.length > 0) {
var done = this.async();
var cwd = path.resolve(__dirname, ops.cwd);
grunt.util.spawn({
cmd: process.platform === 'win32' ? 'git.cmd' : 'git',
args: ['commit', '-m', version].concat(ops.files),
opts: {
cwd: cwd
}
}, done);
} else {
grunt.log.writeln('No files were commited');
}
});

grunt.registerTask('generateDemo', 'generate demo', function () {
Expand Down Expand Up @@ -220,21 +232,23 @@ module.exports = function (grunt) {
}
});

grunt.registerTask('updateFixtures', 'updates package and bower fixtures', function() {
var packageJson = fs.readFileSync(path.resolve('app/templates/_package.json'), 'utf8');
var bowerJson = fs.readFileSync(path.resolve('app/templates/_bower.json'), 'utf8');

// replace package name
packageJson = packageJson.replace(/"name": "<%(.*)%>"/g, '"name": "tempApp"');
packageJson = packageJson.replace(/<%(.*)%>/g, '');

// remove all ejs conditionals
bowerJson = bowerJson.replace(/"name": "<%(.*)%>"/g, '"name": "tempApp"');
bowerJson = bowerJson.replace(/<%(.*)%>/g, '');

// save files
fs.writeFileSync(path.resolve(__dirname + '/test/fixtures/package.json'), packageJson);
fs.writeFileSync(path.resolve(__dirname + '/test/fixtures/bower.json'), bowerJson);
grunt.registerTask('updateFixtures', 'updates package and bower fixtures', function(target) {
var genVer = require('./package.json').version;
var dest = __dirname + ((target === 'deps') ? '/angular-fullstack-deps/' : '/test/fixtures/');
var appName = (target === 'deps') ? 'angular-fullstack-deps' : 'tempApp';

var processJson = function(s, d) {
// read file, strip all ejs conditionals, and parse as json
var json = JSON.parse(fs.readFileSync(path.resolve(s), 'utf8').replace(/<%(.*)%>/g, ''));
// set properties
json.name = appName, json.version = genVer;
if (target === 'deps') { json.private = false; }
// stringify json and write it to the destination
fs.writeFileSync(path.resolve(d), JSON.stringify(json, null, 2));
};

processJson('app/templates/_package.json', dest + 'package.json');
processJson('app/templates/_bower.json', dest + 'bower.json');
});

grunt.registerTask('installFixtures', 'install package and bower fixtures', function() {
Expand Down
1 change: 1 addition & 0 deletions angular-fullstack-deps
Submodule angular-fullstack-deps added at 45f8b0
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"mocha": "^2.2.5",
"q": "^1.0.1",
"recursive-readdir": "^1.2.0",
"semver": "^5.0.1",
"shelljs": "^0.5.3",
"underscore.string": "^3.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AngularJS Full-Stack generator
[![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)

#### 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)
> Yeoman generator for creating MEAN stack applications, using MongoDB, Express, AngularJS, and Node - lets you quickly set up a project following best practices.
## Example project
Expand Down

0 comments on commit 3aac05f

Please sign in to comment.