corrade-nucleus-nucleons – Blame information for rev 24

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 'use strict';
2  
3 var fs = require('fs');
4  
5 module.exports = function(grunt) {
6  
7 // Project configuration.
8 grunt.initConfig({
9 // Metadata.
10 pkg: grunt.file.readJSON('bootstrap-table.jquery.json'),
11 banner: '/*\n' +
12 '* <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
13 '<%= pkg.homepage ? "* " + pkg.homepage : "" %>\n' +
14 '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' +
15 '* Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
16 '*/\n',
17 // Task configuration.
18 clean: ['dist', 'docs/dist'],
19 concat: {
20 //basic_target: {
21 // src: ['src/<%= pkg.name %>.js', 'src/extensions/**/*.js'],
22 // dest: 'dist/<%= pkg.name %>-all.js'
23 //},
24 locale_target: {
25 src: ['src/locale/**/*.js'],
26 dest: 'dist/<%= pkg.name %>-locale-all.js'
27 }
28 },
29 uglify: {
30 options: {
31 banner: '<%= banner %>'
32 },
33 basic_target: {
34 files: {
35 'dist/<%= pkg.name %>.min.js': ['src/<%=pkg.name %>.js'],
36 //'dist/<%= pkg.name %>-all.min.js': ['dist/<%=pkg.name %>-all.js'],
37 'dist/<%= pkg.name %>-locale-all.min.js': ['dist/<%=pkg.name %>-locale-all.js']
38 }
39 },
40 locale_target: {
41 files: [{
42 expand: true,
43 cwd: 'src/locale',
44 src: '**/*.js',
45 dest: 'dist/locale',
46 ext: '.min.js' // replace .js to .min.js
47 }]
48 },
49 extensions_target: {
50 files: [{
51 expand: true,
52 cwd: 'src/extensions',
53 src: '**/*.js',
54 dest: 'dist/extensions',
55 ext: '.min.js' // replace .js to .min.js
56 }]
57 }
58 },
59 cssmin: {
60 add_banner: {
61 options: {
62 banner: '<%= banner %>'
63 },
64 files: {
65 'dist/<%= pkg.name %>.min.css': ['src/<%=pkg.name %>.css']
66 }
67 }
68 },
69 copy: {
70 source: {
71 cwd: 'src', // set working folder / root to copy
72 src: ['**/*.js', '**/*.css'], // copy all files and subfolders
73 dest: 'dist', // destination folder
74 expand: true // required when using cwd
75 },
76 files: {
77 cwd: 'dist', // set working folder / root to copy
78 src: '**/*', // copy all files and subfolders
79 dest: 'docs/dist', // destination folder
80 expand: true // required when using cwd
81 }
82 },
83 release: {
84 options: {
85 additionalFiles: ['bootstrap-table.jquery.json'],
86 beforeRelease: ['docs', 'default']
87 }
88 }
89 });
90  
91 var bumpVersion = function (path, version, startWith) {
92 var lines = fs.readFileSync(path, 'utf8').split('\n');
93 lines.forEach(function (line, i) {
94 if (line.indexOf(startWith) === 0) {
95 lines[i] = startWith + version;
96 }
97 });
98 fs.writeFileSync(path, lines.join('\n'), 'utf8');
99  
100 grunt.log.ok('bumped version of ' + path + ' to ' + version);
101 };
102  
103 grunt.registerTask('docs', 'build the docs', function () {
104 var version = require('./package.json').version;
105 bumpVersion('./_config.yml', version, 'current_version: ');
106 bumpVersion('./src/bootstrap-table.js', version, ' * version: ');
107 bumpVersion('./src/bootstrap-table.css', version, ' * version: ');
108  
109 var changeLog = fs.readFileSync('./CHANGELOG.md', 'utf8');
110 var latestLogs = changeLog.split('### ')[1];
111 var date = new Date();
112  
113 var lines = [
114 '### Latest release (' +
115 [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-') + ')',
116 '',
117 '#### v' + latestLogs
118 ];
119 fs.writeFileSync('./docs/_includes/latest-release.md', lines.join('\n'), 'utf8');
120  
121 grunt.log.ok('updated the latest-release.md to ' + version);
122 });
123  
124 grunt.loadNpmTasks('grunt-contrib-clean');
125 grunt.loadNpmTasks('grunt-contrib-concat');
126 grunt.loadNpmTasks('grunt-contrib-uglify');
127 grunt.loadNpmTasks('grunt-contrib-cssmin');
128 grunt.loadNpmTasks('grunt-contrib-copy');
129 grunt.loadNpmTasks('grunt-release');
130  
131 grunt.registerTask('default', ['clean', 'concat', 'uglify', 'cssmin', 'copy']);
132 };