Skip to content

Commit

Permalink
[grunt] added file size report to the script
Browse files Browse the repository at this point in the history
  • Loading branch information
Grovkillen committed Jan 4, 2020
1 parent 9933ec4 commit b04354d
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 24 deletions.
90 changes: 68 additions & 22 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = function(grunt) {
main: {
files: {'build/temp/index.min.html': ['src/index.html']}
},
nodash: {
noDash: {
files: {'build/temp/no-dash.index.min.html': ['src/no-dash.index.html']}
}
},
Expand All @@ -71,9 +71,12 @@ module.exports = function(grunt) {
version: {
src: ['build/<%= version %>']
},
nodash: {
noDash: {
src: ['src/no-dash.index.html']
},
releaseInfo: {
src: ['release.txt']
},
tempFiles: {
src: ['build/temp/*.html', 'build/temp/*.js']
}
Expand Down Expand Up @@ -104,7 +107,7 @@ module.exports = function(grunt) {
dest: 'build/temp/main/index.htm.gz'
}]
},
nodash: {
noDash: {
options: {
mode: 'gzip',
level: 9 //default is 1, max is 9
Expand Down Expand Up @@ -164,20 +167,49 @@ module.exports = function(grunt) {
}
]
}
},
// file sizes
folder_list : {
options: {
files: true,
folders: true
},
files:
{
src: ['**'],
dest: 'build/temp/source_files.json',
cwd: 'src/'
}
},
// copy release info
copy: {
releaseInfo : {
src: 'release.txt',
dest: 'build/temp/',
flatten: true,
filter: 'isFile',
}
}
});
});

// Load the plugin(s)
grunt.loadNpmTasks('grunt-contrib-uglify-es');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-rename');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-processhtml');
grunt.loadNpmTasks('grunt-file-append');
grunt.loadNpmTasks('grunt-folder-list');

// Load the plugin(s)
grunt.loadNpmTasks('grunt-contrib-uglify-es');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-rename');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-processhtml');
grunt.loadNpmTasks('grunt-file-append');
// the 'default' task can be run just by typing "grunt" on the command line
grunt.registerTask('default', [
'buildGuiEasy'
]);

// build gui easy task
grunt.registerTask('buildGuiEasy', 'Will build the project',
// build gui easy task
grunt.registerTask('buildGuiEasy', 'Will build the project',
function () {
let settings = grunt.file.read('src/gui_easy_settings.js');
settings = settings.match(/--GRUNT-START--([\s\S]*?)\/\/--GRUNT-END--/)[1];
Expand All @@ -202,14 +234,19 @@ module.exports = function(grunt) {
packageJSON = JSON.parse(packageJSON);
packageJSON.version = guiEasy.major + '.' + guiEasy.minor + '.' + guiEasy.minimal;
packageJSON.bin["index.html.gz"] = "build/main/" + version + "/";
packageJSON.date = Date.now();
grunt.file.write('package.json',
JSON.stringify(packageJSON,null,2)
);
grunt.file.write('release.txt',
'major:' + guiEasy.major + '\nminor:' + guiEasy.minor + '\nminimal:' + guiEasy.minimal + '\nrc:' + guiEasy.releaseCandidate
);
grunt.log.ok(version);
// add version as a property for the grunt ini loop
grunt.config("version", version);
grunt.config("semVer", semVer);
grunt.task.run(
'verifyCopyright',
'clean:temp',
'clean:version',
'uglify',
Expand All @@ -218,17 +255,15 @@ module.exports = function(grunt) {
'file_append',
'compress',
'clean:tempFiles',
'folder_list',
'copy:releaseInfo',
'rename',
'clean:nodash'
)
'clean:noDash',
'clean:releaseInfo',
'listBuilds'
);
});

// the 'default' task can be run just by typing "grunt" on the command line
grunt.registerTask('default', [
'verifyCopyright',
'buildGuiEasy'
]);

grunt.registerTask('verifyCopyright', function () {

let fileRead, firstLine, counter = 0, fileExtension, commentWrapper;
Expand Down Expand Up @@ -283,4 +318,15 @@ module.exports = function(grunt) {

grunt.log.ok('Searched through', counter, 'files.');
});

grunt.registerTask('listBuilds', function () {
let folders = "";
grunt.file.expand(
{filter: 'isDirectory', cwd: 'build/'},
['*'])
.forEach(function (dir) {
folders += dir + "\n";
});
grunt.file.write( 'build/releases.txt', folders);
});
};
2 changes: 1 addition & 1 deletion build/0.0.nightly.1/gui.min.css

Large diffs are not rendered by default.

Binary file modified build/0.0.nightly.1/main/index.htm.gz
Binary file not shown.
Binary file modified build/0.0.nightly.1/noDash/index.htm.gz
Binary file not shown.
1 change: 1 addition & 0 deletions build/0.0.nightly.1/source_files.json

Large diffs are not rendered by default.

Binary file modified build/0.0.nightly.1/src-0.0.nightly.1.zip
Binary file not shown.
1 change: 1 addition & 0 deletions build/releases.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.nightly.1
2 changes: 1 addition & 1 deletion extra/theme_3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ main-success-color|0,174,65
main-sunny-color|255,209,0
main-warning-color|239,72,61
max-width-page-size|1400px
overflow-tab-text-size|30
overflow-tab-text-size|40
row-size|16
scale-size|19
state-of-navbar-toggle|fixed
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "gui-easy",
"date": 1578173076803,
"version": "0.0.1",
"author": "Jimmy 'Grovkillen' Westberg <jimmy@grovkillen.com> (https://grovkillen.com)",
"license": "GPL-3.0-or-later",
Expand All @@ -18,6 +19,8 @@
"grunt-zopfli-native": "^2.0.0",
"grunt-processhtml": "^0.4.2",
"grunt-file-append": "^0.0.7",
"grunt-contrib-copy": "^1.0.0",
"grunt-folder-list": "^1.1.0",
"npm": "^6.13.4"
},
"scripts": {
Expand Down

0 comments on commit b04354d

Please sign in to comment.