Skip to content

Commit 3cbb097

Browse files
committed
Bower support (see #132). Also rename the output files to angular-ui-router.
1 parent c201b14 commit 3cbb097

File tree

4 files changed

+82
-33
lines changed

4 files changed

+82
-33
lines changed

Gruntfile.js

Lines changed: 71 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ module.exports = function (grunt) {
1313
grunt.initConfig({
1414
builddir: 'build',
1515
pkg: grunt.file.readJSON('package.json'),
16+
buildtag: '-dev-' + grunt.template.today('yyyy-mm-dd'),
1617
meta: {
17-
banner: '/**\n' + ' * <%= pkg.description %>\n' +
18-
' * @version v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
18+
banner: '/**\n' +
19+
' * <%= pkg.description %>\n' +
20+
' * @version v<%= pkg.version %><%= buildtag %>\n' +
1921
' * @link <%= pkg.homepage %>\n' +
20-
' * @license MIT License, http://www.opensource.org/licenses/MIT\n' + ' */'
22+
' * @license MIT License, http://www.opensource.org/licenses/MIT\n' +
23+
' */'
2124
},
2225
clean: [ '<%= builddir %>' ],
2326
concat: {
@@ -48,6 +51,11 @@ module.exports = function (grunt) {
4851
}
4952
}
5053
},
54+
release: {
55+
files: ['<%= pkg.name %>.js', '<%= pkg.name %>.min.js'],
56+
src: '<%= builddir %>',
57+
dest: 'release'
58+
},
5159
jshint: {
5260
all: ['Gruntfile.js', 'src/*.js', '<%= builddir %>/<%= pkg.name %>.js'],
5361
options: {
@@ -79,11 +87,62 @@ module.exports = function (grunt) {
7987
});
8088

8189
grunt.registerTask('default', ['build', 'jshint', 'karma:unit']);
82-
8390
grunt.registerTask('build', 'Perform a normal build', ['concat', 'uglify']);
8491
grunt.registerTask('dist', 'Perform a clean build and generate documentation', ['clean', 'build', 'jsdoc']);
92+
grunt.registerTask('release', 'Tag and perform a release', ['prepare-release', 'dist', 'perform-release']);
8593
grunt.registerTask('dev', 'Run dev server and watch for changes', ['build', 'connect', 'karma:debug', 'watch']);
8694

95+
grunt.registerTask('jsdoc', 'Generate documentation', function () {
96+
promising(this,
97+
system('node_modules/jsdoc/jsdoc -c jsdoc-conf.json -d \'' + grunt.config('builddir') + '\'/doc src')
98+
);
99+
});
100+
101+
grunt.registerTask('publish-pages', 'Publish a clean build, docs, and sample to github.io', function () {
102+
promising(this,
103+
ensureCleanMaster().then(function () {
104+
shjs.rm('-rf', 'build');
105+
return system('git checkout gh-pages');
106+
}).then(function () {
107+
return system('grunt dist');
108+
}).then(function () {
109+
return system('git commit -a -m \'Automatic gh-pages build\'');
110+
}).then(function () {
111+
return system('git checkout master');
112+
})
113+
);
114+
});
115+
116+
grunt.registerTask('prepare-release', function () {
117+
var bower = grunt.file.readJSON('bower.json'),
118+
version = bower.version;
119+
if (version != grunt.config('pkg.version')) throw 'Version mismatch in bower.json';
120+
121+
promising(this,
122+
ensureCleanMaster().then(function () {
123+
return exec('git tag -l \'' + version + '\'');
124+
}).then(function (result) {
125+
if (result.stdout.trim() !== '') throw 'Tag \'' + version + '\' already exists';
126+
grunt.config('buildtag', '');
127+
grunt.config('builddir', 'release');
128+
})
129+
);
130+
});
131+
132+
grunt.registerTask('perform-release', function () {
133+
grunt.task.requires([ 'prepare-release', 'dist' ]);
134+
135+
var version = grunt.config('pkg.version'), releasedir = grunt.config('builddir');
136+
promising(this,
137+
system('git add \'' + releasedir + '\'').then(function () {
138+
return system('git commit -m \'release ' + version + '\'');
139+
}).then(function () {
140+
return system('git tag \'' + version + '\'');
141+
})
142+
);
143+
});
144+
145+
87146
// Helpers for custom tasks, mainly around promises / exec
88147
var exec = require('faithful-exec'), shjs = require('shelljs');
89148

@@ -107,30 +166,12 @@ module.exports = function (grunt) {
107166
});
108167
}
109168

110-
grunt.registerTask('jsdoc', 'Generate documentation', function () {
111-
promising(this,
112-
system("node_modules/jsdoc/jsdoc -c jsdoc-conf.json -d '" + grunt.config('builddir') + "'/doc src")
113-
);
114-
});
115-
116-
grunt.registerTask('publish-pages', 'Publish a clean build, docs, and sample to github.io', function () {
117-
promising(this,
118-
exec('git symbolic-ref HEAD').then(function (result) {
119-
if (result.stdout.trim() !== 'refs/heads/master') throw 'Not on master branch, aborting';
120-
}).then(function () {
121-
return exec('git status --porcelain');
122-
}).then(function (result) {
123-
if (result.stdout.trim() !== '') throw 'Working copy is dirty, aborting';
124-
}).then(function () {
125-
shjs.rm('-rf', 'build');
126-
return system('git checkout gh-pages');
127-
}).then(function () {
128-
return system('grunt dist');
129-
}).then(function () {
130-
return system('git commit -a -m "Automatic gh-pages build"');
131-
}).then(function () {
132-
return system('git checkout master');
133-
})
134-
);
135-
});
169+
function ensureCleanMaster() {
170+
return exec('git symbolic-ref HEAD').then(function (result) {
171+
if (result.stdout.trim() !== 'refs/heads/master') throw 'Not on master branch, aborting';
172+
return exec('git status --porcelain');
173+
}).then(function (result) {
174+
if (result.stdout.trim() !== '') throw 'Working copy is dirty, aborting';
175+
});
176+
}
136177
};

bower.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "ui-router",
3+
"version": "0.0.1",
4+
"main": "./release/angular-ui-states.min.js",
5+
"dependencies": {
6+
"angular": ">= 1.0.6"
7+
}
8+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "angular-ui-states",
2+
"name": "angular-ui-router",
33
"description": "State-based routing for AngularJS",
44
"version": "0.0.1",
55
"homepage": "http://angular-ui.github.com/",

sample/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
}
1717
</style>
1818
<script src="../lib/angular-1.1.4.js"></script>
19-
<script src="../build/angular-ui-states.js"></script>
19+
<script src="../build/angular-ui-router.js"></script>
2020

2121
<!-- could easily use a custom property of the state here instead of 'name' -->
22-
<title ng-bind="$state.current.name + ' - angular-states'">angular-states</title>
22+
<title ng-bind="$state.current.name + ' - ui-router'">ui-router</title>
2323
</head><body>
2424
<div class="navbar navbar-fixed-top">
2525
<div class="navbar-inner"><div class="container">

0 commit comments

Comments
 (0)