Issue #344 : cleanup dest folder(s), cleanup Gruntfile

This commit is contained in:
jdescottes 2015-12-01 00:28:41 +01:00
parent 070003a414
commit 3d1a24d5cf
3 changed files with 67 additions and 72 deletions

2
.gitignore vendored
View File

@ -21,8 +21,6 @@ diff.txt
# build destination # build destination
dest dest
dest-dev
dest-tmp
build/closure/closure_compiled_binary.js build/closure/closure_compiled_binary.js
# spriting artifacts # spriting artifacts

View File

@ -1,43 +1,42 @@
module.exports = function(grunt) { module.exports = function(grunt) {
var ip = 'localhost';
// Update this variable if you don't want or can't serve on localhost
var hostname = 'localhost';
// create a version based on the build timestamp
var dateFormat = require('dateformat'); var dateFormat = require('dateformat');
var now = new Date(); var version = '-' + dateFormat(new Date(), "yyyy-mm-dd-hh-MM");
var version = '-' + dateFormat(now, "yyyy-mm-dd-hh-MM");
// get the list of scripts paths to include /**
var piskelScripts = require('./src/piskel-script-list.js').scripts.map(function (path) { * Helper to prefix all strings in provided array with the provided path
return "src/" + path; */
}).filter(function (path) { var prefixPaths = function (paths, prefix) {
return path.indexOf('devtools') === -1; return paths.map(function (path) {
}); return prefix + path;
// get the list of styles paths to include });
var piskelStyles = require('./src/piskel-style-list.js').styles.map(function (path) {
return "src/" + path;
});
var casperEnvironments = {
'local' : {
suite : './test/casperjs/LocalTestSuite.js',
delay : 50
},
'travis' : {
suite : './test/casperjs/TravisTestSuite.js',
delay : 10000
}
}; };
var getCasperConfig = function (env) { // get the list of scripts paths to include
var conf = casperEnvironments[env]; var scriptPaths = require('./src/piskel-script-list.js').scripts;
var tests = require(conf.suite).tests.map(function (path) { var piskelScripts = prefixPaths(scriptPaths, "src/").filter(function (path) {
return "test/casperjs/" + path; return path.indexOf('devtools') === -1;
}); });
// get the list of styles paths to include
var stylePaths = require('./src/piskel-style-list.js').styles;
var piskelStyles = prefixPaths(stylePaths, "src/");
var getCasperConfig = function (suiteName, delay, host) {
var testPaths = require('./test/casperjs/' + suiteName).tests;
var tests = prefixPaths(testPaths, "test/casperjs/");
return { return {
filesSrc : tests, filesSrc : tests,
options : { options : {
args : { args : {
baseUrl : 'http://' + ip + ':' + '<%= express.test.options.port %>/', baseUrl : 'http://' + host + ':' + '<%= express.test.options.port %>/',
mode : '?debug', mode : '?debug',
delay : conf.delay delay : delay
}, },
async : false, async : false,
direct : false, direct : false,
@ -48,19 +47,16 @@ module.exports = function(grunt) {
}; };
}; };
var getExpressConfig = function (source, port, host) { var getExpressConfig = function (sourceFolders, port, host) {
var bases; if (typeof sourceFolders === 'string') {
if (typeof source === 'string') { sourceFolders = [sourceFolders];
bases = [source];
} else if (Array.isArray(source)) {
bases = source;
} }
return { return {
options: { options: {
port: port, port: port,
hostname : host || ip, hostname : host,
bases: bases bases: sourceFolders
} }
}; };
}; };
@ -70,8 +66,9 @@ module.exports = function(grunt) {
grunt.initConfig({ grunt.initConfig({
clean: { clean: {
prod: ['dest', 'dest-tmp'], prod: ['dest/prod', 'dest/tmp'],
dev: ['dest-dev', 'dest-tmp'] desktop: ['dest/desktop', 'dest/tmp'],
dev: ['dest/dev', 'dest/tmp']
}, },
/** /**
@ -119,17 +116,17 @@ module.exports = function(grunt) {
*/ */
express: { express: {
test: getExpressConfig(['dest-dev', 'test'], 9991), regular: getExpressConfig('dest/prod', 9001, hostname),
regular: getExpressConfig('dest', 9001), test: getExpressConfig(['dest/dev', 'test'], 9991, hostname),
debug: getExpressConfig(['dest-dev', 'test'], 9901) debug: getExpressConfig(['dest/dev', 'test'], 9901, hostname)
}, },
open : { open : {
regular : { regular : {
path : 'http://' + ip + ':9001/' path : 'http://' + hostname + ':9001/'
}, },
debug : { debug : {
path : 'http://' + ip + ':9901/?debug' path : 'http://' + hostname + ':9901/?debug'
} }
}, },
@ -168,11 +165,11 @@ module.exports = function(grunt) {
separator : ';' separator : ';'
}, },
src : piskelScripts, src : piskelScripts,
dest : 'dest/js/piskel-packaged' + version + '.js' dest : 'dest/prod/js/piskel-packaged' + version + '.js'
}, },
css : { css : {
src : piskelStyles, src : piskelStyles,
dest : 'dest/css/piskel-style-packaged' + version + '.css' dest : 'dest/prod/css/piskel-style-packaged' + version + '.css'
} }
}, },
@ -182,7 +179,7 @@ module.exports = function(grunt) {
}, },
js : { js : {
files : { files : {
'dest-tmp/js/piskel-packaged-min.js' : ['dest/js/piskel-packaged' + version + '.js'] 'dest/tmp/js/piskel-packaged-min.js' : ['dest/prod/js/piskel-packaged' + version + '.js']
} }
} }
}, },
@ -190,7 +187,7 @@ module.exports = function(grunt) {
includereplace: { includereplace: {
all: { all: {
src: 'src/index.html', src: 'src/index.html',
dest: 'dest-tmp/index.html', dest: 'dest/tmp/index.html',
options : { options : {
globals : { globals : {
'version' : version 'version' : version
@ -220,7 +217,7 @@ module.exports = function(grunt) {
}, },
files: [ files: [
// src/index.html should already have been moved by the includereplace task // src/index.html should already have been moved by the includereplace task
{src: ['dest-tmp/index.html'], dest: 'dest/piskelapp-partials/main-partial.html'} {src: ['dest/tmp/index.html'], dest: 'dest/prod/piskelapp-partials/main-partial.html'}
] ]
} }
}, },
@ -229,23 +226,23 @@ module.exports = function(grunt) {
prod: { prod: {
files: [ files: [
// dest/js/piskel-packaged-min.js should have been created by the uglify task // dest/js/piskel-packaged-min.js should have been created by the uglify task
{src: ['dest-tmp/js/piskel-packaged-min.js'], dest: 'dest/js/piskel-packaged-min' + version + '.js'}, {src: ['dest/tmp/js/piskel-packaged-min.js'], dest: 'dest/prod/js/piskel-packaged-min' + version + '.js'},
{src: ['dest-tmp/index.html'], dest: 'dest/index.html'}, {src: ['dest/tmp/index.html'], dest: 'dest/prod/index.html'},
{src: ['src/logo.png'], dest: 'dest/logo.png'}, {src: ['src/logo.png'], dest: 'dest/prod/logo.png'},
{src: ['src/js/lib/gif/gif.ie.worker.js'], dest: 'dest/js/lib/gif/gif.ie.worker.js'}, {src: ['src/js/lib/gif/gif.ie.worker.js'], dest: 'dest/prod/js/lib/gif/gif.ie.worker.js'},
{expand: true, src: ['img/**'], cwd: 'src/', dest: 'dest/', filter: 'isFile'}, {expand: true, src: ['img/**'], cwd: 'src/', dest: 'dest/prod/', filter: 'isFile'},
{expand: true, src: ['css/fonts/**'], cwd: 'src/', dest: 'dest/', filter: 'isFile'} {expand: true, src: ['css/fonts/**'], cwd: 'src/', dest: 'dest/prod/', filter: 'isFile'}
] ]
}, },
dev: { dev: {
files: [ files: [
// in dev copy everything to dest-dev // in dev copy everything to dest/dev
{src: ['dest-tmp/index.html'], dest: 'dest-dev/index.html'}, {src: ['dest/tmp/index.html'], dest: 'dest/dev/index.html'},
{src: ['src/piskel-script-list.js'], dest: 'dest-dev/piskel-script-list.js'}, {src: ['src/piskel-script-list.js'], dest: 'dest/dev/piskel-script-list.js'},
{src: ['src/piskel-style-list.js'], dest: 'dest-dev/piskel-style-list.js'}, {src: ['src/piskel-style-list.js'], dest: 'dest/dev/piskel-style-list.js'},
{expand: true, src: ['js/**'], cwd: 'src/', dest: 'dest-dev/', filter: 'isFile'}, {expand: true, src: ['js/**'], cwd: 'src/', dest: 'dest/dev/', filter: 'isFile'},
{expand: true, src: ['css/**'], cwd: 'src/', dest: 'dest-dev/', filter: 'isFile'}, {expand: true, src: ['css/**'], cwd: 'src/', dest: 'dest/dev/', filter: 'isFile'},
{expand: true, src: ['img/**'], cwd: 'src/', dest: 'dest-dev/', filter: 'isFile'}, {expand: true, src: ['img/**'], cwd: 'src/', dest: 'dest/dev/', filter: 'isFile'},
] ]
} }
}, },
@ -261,8 +258,8 @@ module.exports = function(grunt) {
}, },
ghost : { ghost : {
'travis' : getCasperConfig('travis'), 'travis' : getCasperConfig('TravisTestSuite.js', 10000, hostname),
'local' : getCasperConfig('local') 'local' : getCasperConfig('LocalTestSuite.js', 50, hostname)
}, },
/** /**
@ -278,7 +275,7 @@ module.exports = function(grunt) {
linux32: true, linux32: true,
linux64: true linux64: true
}, },
src: ['./dest/**/*', "./package.json", "!./dest/desktop/"] src: ['./dest/prod/**/*', "./package.json", "!./dest/desktop/"]
}, },
macos : { macos : {
options: { options: {
@ -287,7 +284,7 @@ module.exports = function(grunt) {
version : "0.10.5", version : "0.10.5",
build_dir: './dest/desktop/' build_dir: './dest/desktop/'
}, },
src: ['./dest/**/*', "./package.json", "!./dest/desktop/"] src: ['./dest/prod/**/*', "./package.json", "!./dest/desktop/"]
} }
} }
}); });
@ -316,8 +313,8 @@ module.exports = function(grunt) {
grunt.registerTask('default', ['lint', 'build']); grunt.registerTask('default', ['lint', 'build']);
// Build stand alone app with nodewebkit // Build stand alone app with nodewebkit
grunt.registerTask('desktop', ['default', 'nodewebkit:windows']); grunt.registerTask('desktop', ['clean:desktop', 'default', 'nodewebkit:windows']);
grunt.registerTask('desktop-mac', ['default', 'nodewebkit:macos']); grunt.registerTask('desktop-mac', ['clean:desktop', 'default', 'nodewebkit:macos']);
// Start webserver and watch for changes // Start webserver and watch for changes
grunt.registerTask('serve', ['build', 'express:regular', 'open:regular', 'watch:prod']); grunt.registerTask('serve', ['build', 'express:regular', 'open:regular', 'watch:prod']);

View File

@ -6,7 +6,7 @@ SETLOCAL
SET PISKELAPP_PATH="C:\Development\git\piskel-website" SET PISKELAPP_PATH="C:\Development\git\piskel-website"
ECHO "Copying files to piskelapp" ECHO "Copying files to piskelapp"
XCOPY "%PISKEL_PATH%\dest" "%PISKELAPP_PATH%\static\editor" /e /i /h /y XCOPY "%PISKEL_PATH%\dest\prod" "%PISKELAPP_PATH%\static\editor" /e /i /h /y
ECHO "Delete previous partial" ECHO "Delete previous partial"
DEL "%PISKELAPP_PATH%\templates\editor\main-partial.html" DEL "%PISKELAPP_PATH%\templates\editor\main-partial.html"