Update deps, use grunt-connect instead of express, fix jscs errors

This commit is contained in:
jdescottes 2015-12-09 22:38:58 +01:00
parent 8c29afbca6
commit 21d4857b74
10 changed files with 155 additions and 60 deletions

75
.jscsrc Normal file
View File

@ -0,0 +1,75 @@
{
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireOperatorBeforeLineBreak": true,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"maximumLineLength": {
"value": 80,
"allExcept": ["comments", "regex"]
},
"validateIndentation": 2,
"validateQuoteMarks": "'",
"disallowMultipleLineStrings": true,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowMultipleVarDecl": true,
"disallowKeywordsOnNewLine": ["else"],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceBeforeBinaryOperators": [
"=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
"&=", "|=", "^=", "+=",
"+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
"|", "^", "&&", "||", "===", "==", ">=",
"<=", "<", ">", "!=", "!=="
],
"requireSpaceAfterBinaryOperators": true,
"requireSpacesInConditionalExpression": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpacesInForStatement": true,
"requireLineFeedAtFileEnd": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": false
},
"disallowSpacesInsideObjectBrackets": "all",
"disallowSpacesInsideArrayBrackets": "all",
"disallowSpacesInsideParentheses": true,
"disallowMultipleLineBreaks": true,
"disallowNewlineBeforeBlockStatements": true,
"disallowKeywords": ["with"],
"disallowSpacesInFunctionExpression": null,
"disallowSpacesInFunctionDeclaration": null,
"disallowSpacesInCallExpression": true,
"disallowSpaceAfterObjectKeys": false,
"requireSpaceBeforeObjectValues": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"requireSemicolons": true,
"validateParameterSeparator": ", ",
"jsDoc": null
}

View File

@ -3,6 +3,14 @@ module.exports = function(grunt) {
// Update this variable if you don't want or can't serve on localhost
var hostname = 'localhost';
var PORT = {
PROD : 9001,
DEV : 9901,
TEST : 9991
};
var DEV_MODE = '?debug';
// create a version based on the build timestamp
var dateFormat = require('dateformat');
var version = '-' + dateFormat(new Date(), "yyyy-mm-dd-hh-MM");
@ -34,8 +42,8 @@ module.exports = function(grunt) {
filesSrc : tests,
options : {
args : {
baseUrl : 'http://' + host + ':' + '<%= express.test.options.port %>/',
mode : '?debug',
baseUrl : 'http://' + host + ':' + PORT.TEST,
mode : DEV_MODE,
delay : delay
},
async : false,
@ -47,16 +55,16 @@ module.exports = function(grunt) {
};
};
var getExpressConfig = function (sourceFolders, port, host) {
if (typeof sourceFolders === 'string') {
sourceFolders = [sourceFolders];
var getConnectConfig = function (base, port, host) {
if (typeof base === 'string') {
base = [base];
}
return {
options: {
port: port,
hostname : host,
bases: sourceFolders
base: base
}
};
};
@ -85,7 +93,7 @@ module.exports = function(grunt) {
jscs : {
options : {
"preset": "google",
"config": ".jscsrc",
"maximumLineLength": 120,
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
"validateQuoteMarks": { "mark": "'", "escape": true },
@ -116,18 +124,18 @@ module.exports = function(grunt) {
* SERVERS, BROWSER LAUNCHERS
*/
express: {
regular: getExpressConfig('dest/prod', 9001, hostname),
test: getExpressConfig(['dest/dev', 'test'], 9991, hostname),
debug: getExpressConfig(['dest/dev', 'test'], 9901, hostname)
connect: {
prod: getConnectConfig('dest/prod', PORT.PROD, hostname),
test: getConnectConfig(['dest/dev', 'test'], PORT.TEST, hostname),
dev: getConnectConfig(['dest/dev', 'test'], PORT.DEV, hostname)
},
open : {
regular : {
path : 'http://' + hostname + ':9001/'
prod : {
path : 'http://' + hostname + ':' + PORT.PROD + '/'
},
debug : {
path : 'http://' + hostname + ':9901/?debug'
dev : {
path : 'http://' + hostname + ':' + PORT.DEV + '/' + DEV_MODE
}
},
@ -297,10 +305,10 @@ module.exports = function(grunt) {
grunt.registerTask('unit-test', ['karma']);
// Validate & Test
grunt.registerTask('test-travis', ['lint', 'unit-test', 'build-dev', 'express:test', 'ghost:travis']);
grunt.registerTask('test-travis', ['lint', 'unit-test', 'build-dev', 'connect:test', 'ghost:travis']);
// Validate & Test (faster version) will NOT work on travis !!
grunt.registerTask('test-local', ['lint', 'unit-test', 'build-dev', 'express:test', 'ghost:local']);
grunt.registerTask('test-local-nolint', ['unit-test', 'build-dev', 'express:test', 'ghost:local']);
grunt.registerTask('test-local', ['lint', 'unit-test', 'build-dev', 'connect:test', 'ghost:local']);
grunt.registerTask('test-local-nolint', ['unit-test', 'build-dev', 'connect:test', 'ghost:local']);
grunt.registerTask('test', ['test-travis']);
grunt.registerTask('precommit', ['test-local']);
@ -318,8 +326,10 @@ module.exports = function(grunt) {
grunt.registerTask('desktop-mac', ['clean:desktop', 'default', 'nodewebkit:macos']);
// Start webserver and watch for changes
grunt.registerTask('serve', ['build', 'express:regular', 'open:regular', 'watch:prod']);
grunt.registerTask('serve', ['build', 'connect:prod', 'open:prod', 'watch:prod']);
// Start webserver on src folder, in debug mode
grunt.registerTask('serve-debug', ['build-dev', 'express:debug', 'open:debug', 'watch:dev']);
grunt.registerTask('play', ['serve-debug']);
grunt.registerTask('serve-dev', ['build-dev', 'connect:dev', 'open:dev', 'watch:dev']);
grunt.registerTask('serve-debug', ['serve-dev']);
grunt.registerTask('play', ['serve-dev']);
};

View File

@ -14,30 +14,30 @@
"start": "nodewebkit"
},
"devDependencies": {
"dateformat": "^1.0.11",
"grunt": "~0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-jshint": "^0.11.1",
"grunt-contrib-uglify": "^0.9.1",
"dateformat": "1.0.11",
"grunt": "0.4.5",
"grunt-contrib-clean": "0.7.0",
"grunt-contrib-concat": "0.5.1",
"grunt-contrib-connect": "0.11.2",
"grunt-contrib-copy": "0.8.0",
"grunt-contrib-jshint": "0.11.1",
"grunt-contrib-uglify": "0.11.0",
"grunt-contrib-watch": "0.6.1",
"grunt-express": "1.4.1",
"grunt-ghost": "1.1.0",
"grunt-include-replace": "^3.2.0",
"grunt-jscs": "^2.5.0",
"grunt-karma": "^0.12.1",
"grunt-leading-indent": "^0.2.0",
"grunt-node-webkit-builder": "^1.0.2",
"grunt-include-replace": "3.2.0",
"grunt-jscs": "2.5.0",
"grunt-karma": "0.12.1",
"grunt-leading-indent": "0.2.0",
"grunt-node-webkit-builder": "1.0.2",
"grunt-open": "0.2.3",
"grunt-replace": "^0.8.0",
"grunt-spritesmith": "^6.1.0",
"jasmine-core": "^2.1.0",
"karma": "0.12.31",
"karma-chrome-launcher": "^0.1.4",
"karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "^0.1.4",
"load-grunt-tasks": "^3.1.0"
"grunt-replace": "0.11.0",
"grunt-spritesmith": "6.1.0",
"jasmine-core": "2.1.0",
"karma": "0.13.15",
"karma-chrome-launcher": "0.2.2",
"karma-jasmine": "0.3.5",
"karma-phantomjs-launcher": "0.1.4",
"load-grunt-tasks": "3.1.0"
},
"window": {
"title": "Piskel",

View File

@ -167,7 +167,7 @@
if (pskl.utils.Environment.detectNodeWebkit() && pskl.utils.UserAgent.isMac) {
var gui = require('nw.gui');
var mb = new gui.Menu({type:'menubar'});
var mb = new gui.Menu({type : 'menubar'});
mb.createMacBuiltin('Piskel');
gui.Window.get().menu = mb;
}

View File

@ -49,12 +49,18 @@
};
ns.CursorCoordinatesController.prototype.onCursorMoved_ = function (event, x, y) {
this.coordinates = {x:x, y:y};
this.coordinates = {
x : x,
y : y
};
this.redraw();
};
ns.CursorCoordinatesController.prototype.onDragStart_ = function (event, x, y) {
this.origin = {x:x, y:y};
this.origin = {
x : x,
y : y
};
this.redraw();
};

View File

@ -7,8 +7,8 @@
* @public
*/
ns.PaletteController.prototype.init = function() {
$.subscribe(Events.SELECT_PRIMARY_COLOR, this.onColorSelected_.bind(this, {isPrimary:true}));
$.subscribe(Events.SELECT_SECONDARY_COLOR, this.onColorSelected_.bind(this, {isPrimary:false}));
$.subscribe(Events.SELECT_PRIMARY_COLOR, this.onColorSelected_.bind(this, {isPrimary : true}));
$.subscribe(Events.SELECT_SECONDARY_COLOR, this.onColorSelected_.bind(this, {isPrimary : false}));
var shortcuts = pskl.service.keyboard.Shortcuts;
pskl.app.shortcutService.registerShortcut(shortcuts.COLOR.SWAP, this.swapColors.bind(this));

View File

@ -24,23 +24,23 @@
};
ns.PaletteImportService.prototype.getReader_ = function (file, onSuccess, onError) {
var readerClass = this.getReaderClass_(file);
if (readerClass) {
return new readerClass(file, onSuccess, onError);
var ReaderClass = this.getReaderClass_(file);
if (ReaderClass) {
return new ReaderClass(file, onSuccess, onError);
} else {
return null;
}
};
ns.PaletteImportService.prototype.getReaderClass_ = function (file) {
var readerClass;
var ReaderClass;
if (this.isImage_(file)) {
readerClass = fileReaders.img;
ReaderClass = fileReaders.img;
} else {
var extension = this.getExtension_(file);
readerClass = fileReaders[extension];
ReaderClass = fileReaders[extension];
}
return readerClass;
return ReaderClass;
};
ns.PaletteImportService.prototype.getExtension_ = function (file) {

View File

@ -157,7 +157,11 @@
return;
}
var paintedPixels = pskl.PixelUtils.visitConnectedPixels({col:col, row:row}, frame, function (pixel) {
var startPixel = {
col : col,
row : row
};
var paintedPixels = pskl.PixelUtils.visitConnectedPixels(startPixel, frame, function (pixel) {
if (frame.containsPixel(pixel.col, pixel.row) && frame.getPixel(pixel.col, pixel.row) == targetColor) {
frame.setPixel(pixel.col, pixel.row, replacementColor);
return true;

View File

@ -25,14 +25,14 @@ if (!Function.prototype.bind) {
var bindArgs = Array.prototype.slice.call(arguments, 1);
var fToBind = this;
var fNOP = function () {};
var FNOP = function () {};
var fBound = function () {
var args = bindArgs.concat(Array.prototype.slice.call(arguments));
return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, args);
return fToBind.apply(this instanceof FNOP && oThis ? this : oThis, args);
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
FNOP.prototype = this.prototype;
fBound.prototype = new FNOP();
return fBound;
};

View File

@ -105,7 +105,7 @@
var isSelected = (index === this.selectedIndex);
html += pskl.utils.Template.replace(tpl, {
'color' : color, index:index,
'color' : color, index : index,
':selected' : isSelected,
':light-color' : this.isLight_(color)
});