Skip to content

Commit

Permalink
WIP: building site from source
Browse files Browse the repository at this point in the history
  • Loading branch information
c0bra committed Dec 18, 2013
1 parent 7aeb576 commit b377d02
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ script:

after_success:
- grunt test:ci
- grunt release

after_script:
- ./travis_print_logs.sh
52 changes: 45 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ module.exports = function(grunt) {
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
version: util.getVersion(),
dist: 'dist',
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
site: process.env.TRAVIS ? 'ui.grid.info' : 'localhost:<%= connect.docs.options.port %>',
banner: '/*! <%= pkg.title || pkg.name %> - v<%= version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
Expand Down Expand Up @@ -179,10 +181,15 @@ module.exports = function(grunt) {
},

docs: {
files: ['misc/tutorial/**/*.ngdoc', 'misc/doc/**/*'],
files: ['misc/tutorial/**/*.ngdoc', 'misc/doc/**'],
tasks: 'ngdocs'
},

copy: {
files: ['misc/site/**'],
tasks: 'copy'
},

// karma: {
// files: ['src/**/*.js', 'test/unit/**/*.spec.js'],
// tasks: ['karma:dev:run'] //NOTE the :run flag
Expand All @@ -199,7 +206,7 @@ module.exports = function(grunt) {
options: {
base: '<%= dist %>',
repo: 'https://github.com/angular-ui/ui-grid.info.git',
message: 'gh-pages v<%= pkg.version %>',
message: 'gh-pages v<%= version %>',
add: true
},
src: ['**/*']
Expand All @@ -217,7 +224,7 @@ module.exports = function(grunt) {
docs: {
options: {
port: process.env.DOCS_PORT || 9003,
base: '<%= dist %>/docs',
base: '<%= dist %>',
livereload: true
}
}
Expand All @@ -231,19 +238,21 @@ module.exports = function(grunt) {
'http://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular-animate.js',
'bower_components/google-code-prettify/src/prettify.js',
'node_modules/marked/lib/marked.js',
'<%= concat.dist.dest %>'
'http://<%= site %>/release/<%= pkg.name %>.js'
],
styles: [
'misc/doc/css/prettify.css',
'misc/doc/css/bootstrap-flatly.css',
'<%= dist %>/release/ui-grid.css'
],
title: 'UI Grid',
titleLink: 'http://<%= site %>',
html5Mode: false,
analytics: {
account: 'UA-46391685-1',
domainName: 'ui-grid.info'
}
},
navTemplate: 'misc/doc/templates/nav.html'
},
api: {
src: ['src/**/*.js'],
Expand All @@ -255,11 +264,38 @@ module.exports = function(grunt) {
}
},

copy: {
site: {
options: {
processContent: grunt.template.process
},
files: [
{
expand: true,
cwd: 'misc/site/',
src: '**',
dest: '<%= dist %>'
}
]
}
},

changelog: {
options: {
dest: 'CHANGELOG.md',
github: 'angular-ui/ng-grid'
}
},

cutrelease: {
options: {
cleanup: true,
keepUnstable: false
},
dist: {
src: '<%= dist %>/release/*.{js,css}',
dest: '<%= dist %>/release/'
}
}
});
util.updateConfig();
Expand All @@ -272,6 +308,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-angular-templates');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-karma');
Expand All @@ -289,7 +326,7 @@ module.exports = function(grunt) {
grunt.registerTask('default', ['before-test', 'test', 'after-test']);

// Build with no testing
grunt.registerTask('build', ['concat', 'uglify', 'less', 'ngdocs']);
grunt.registerTask('build', ['concat', 'uglify', 'less', 'ngdocs', 'copy']);

// Development watch task
grunt.registerTask('dev', ['before-test', 'after-test', 'connect', 'karmangular:start', 'watch']);
Expand All @@ -310,4 +347,5 @@ module.exports = function(grunt) {
}
});

grunt.registerTask('release', ['clean', 'build', 'gh-pages']);
};
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
1. Figure out how to run e2e tests on docs (look at angularjs source)
1. `readableColumnNames` need to be overrideable by i18n.
1. SauceLabs Mac test hanging?
1. Add banners to compiled .css files (grunt-banner?)

1. [DONE] Add --browsers option for testing on saucelabs with specific browser(s)
1. [DONE] Make karmangular run in `watch` mode and in singlerun too.
84 changes: 84 additions & 0 deletions lib/grunt/plugins.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var fs = require('fs');
var path = require('path');
var util = require('./utils.js');
var semver = require('semver');
var shell = require('shelljs');

module.exports = function(grunt) {

Expand Down Expand Up @@ -132,4 +134,86 @@ module.exports = function(grunt) {
], { color: 'green', separator: '' }));
};
});

grunt.registerMultiTask('cutrelease', 'Release the built code', function() {
// Require the build and ngdocs tassk to be run first
grunt.task.requires(['build']);

var options = this.options({
stableSuffix: '-stable',
unstableSuffix: '-edge',
cleanup: false
});

var done = this.async(),
self = this;

var tag = util.getVersion();

// Figure out if the tag is stable or not
var stable = !/-\w+$/.test(tag);

// Log release type
grunt.log.writeln(
'Preparing '
+ grunt.log.wordlist([stable ? 'stable' : 'unstable'], { color: stable ? 'green' : 'yellow'})
+ ' release version '
+ tag
);

// If this is a stable release, create a directory for it in the releases dir
var extension = stable ? options.stableSuffix : options.unstableSuffix;

self.files.forEach(function (file) {
var stableDir;

// If we're on a stable release or we want to keep unstable releases, create a directory for this release and copy the built files there
if (stable || options.keepUnstable) {
stableDir = path.join(file.dest, tag);
}

file.src.forEach(function (f) {
var oldFileName = path.basename(f);
var ext = path.extname(f);
var basename = path.basename(f, ext);

if (basename.match(/.min/)) {
ext = '.min' + ext;
basename = path.basename(f, ext);
}

// Skip file if it was already released
var re = new RegExp('(' + options.stableSuffix + '|' + options.unstableSuffix + ')');
if (basename.match(re)) {
return;
}

var newFileName = basename + extension + ext;

// If this is a stable release
if (stableDir) {
// Create the stable directory if it doesn't exist
if (!fs.existsSync(stableDir)) {
fs.mkdirSync(stableDir);
}

var stablePath = path.join(stableDir, oldFileName);

grunt.log.writeln('Copying ' + f + ' to ' + stablePath);
// fs.createReadStream(f).pipe(fs.createWriteStream(stablePath));
shell.cp(f, stablePath);
}

var newPath = path.join(file.dest, newFileName)

grunt.log.writeln('Copying ' + f + ' to ' + newPath);
// fs.createReadStream(f).pipe(fs.createWriteStream(newPath));
shell.cp(f, newPath);

if (options.cleanup) {
shell.rm(f);
}
});
});
});
};
13 changes: 13 additions & 0 deletions lib/grunt/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var fs = require('fs');
var path = require('path');
var grunt = require('grunt');
var semver = require('semver');
var shell = require('shelljs');

var util = module.exports = {

Expand Down Expand Up @@ -178,6 +179,18 @@ var util = module.exports = {
grunt.config('customLaunchers', util.customLaunchers());
util.createKarmangularConfig()
util.createSauceConfig();
},

// Get the current release version
getVersion: function() {
// Get the current git tag
var version = shell.exec('git describe', {silent:true}).output.trim();

// Clean up the tag
var tag = version.replace(/-\d+-/, '-');
tag = semver.clean(tag);

return tag;
}

};
File renamed without changes.
3 changes: 3 additions & 0 deletions misc/doc/templates/nav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ul class="nav pull-right">
<li><a href="github.com">Github</a></li>
</ul>
50 changes: 50 additions & 0 deletions misc/site/css/site.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
body {
padding-top: 50px;
}

.jumbotron {
padding: 30px;
margin-bottom: 30px;
font-size: 21px;
font-weight: 200;
line-height: 2.1428571435;
color: inherit;
background-color: #eeeeee;
}

.jumbotron h1,
.jumbotron .h1 {
line-height: 1;
color: inherit;
}

.jumbotron p {
line-height: 1.4;
}

.container .jumbotron {
border-radius: 6px;
}

.jumbotron .container {
max-width: 100%;
}

@media screen and (min-width: 768px) {
.jumbotron {
padding-top: 48px;
padding-bottom: 48px;
}
.container .jumbotron {
padding-right: 60px;
padding-left: 60px;
}
.jumbotron h1,
.jumbotron .h1 {
font-size: 63px;
}
}

.nav-ghbtn {
padding-top: 16px;
}
53 changes: 53 additions & 0 deletions misc/site/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="/docs/css/bootstrap.min.css" />
<link rel="stylesheet" href="/docs/css/bootstrap-flatly.css" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" />
<link rel="stylesheet" href="/css/site.css" />
</head>
<body>
<header class="header">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a href="/" class="brand">UI Grid</a>
<p class="navbar-text pull-right">
<iframe class="nav-ghbtn" src="http://ghbtns.com/github-btn.html?user=angular-ui&repo=ng-grid&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="80" height="50"></iframe>
<iframe class="nav-ghbtn" src="http://ghbtns.com/github-btn.html?user=angular-ui&repo=ng-grid&type=fork&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="80" height="50"></iframe>
</p>
</div>
</div>
</div>
</header>
<div class="jumbotron">
<div class="container text-center">
<h2>Angular UI Grid</h2>

<p>A data grid for <strong><a href="http://angularjs.org">AngularJS</a></strong></p>
<p>... more stuff ...</p>
<p class="btn-group2">
<a class="btn btn-success btn-large" href="https://github.com/angular-ui/ng-grid" title="Code on Github">
<i class="fa fa-github fa-fw"></i>
Code on Github
</a>
<a class="btn btn-danger btn-large" href="https://github.com/angular-ui/ui-grid.info/tree/gh-pages" title="Download <%= version %>">
<i class="fa fa-download fa-fw"></i>
Download <!-- <small>(<%= pkg.version %>)</small> -->
</a>
<a class="btn btn-success btn-large" href="http://<%= site %>/docs" title="API Documentation">
<i class="fa fa-gears fa-fw"></i>
API Documentation
</a>
</p>
</div>
</div>
</body>
</html>
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"grunt-ngdocs": "https://github.com/c0bra/grunt-ngdocs/tarball/0.1.7-custom3",
"grunt-conventional-changelog": "~1.0.0",
"grunt-gh-pages": "~0.9.0",
"semver": "~2.2.1"
"semver": "~2.2.1",
"shelljs": "~0.2.6",
"grunt-contrib-copy": "~0.4.1"
}
}
Loading

0 comments on commit b377d02

Please sign in to comment.