From 67a97c2457b1b7d696fc4436da31d144d14294c8 Mon Sep 17 00:00:00 2001 From: Jason San Jose Date: Thu, 24 Jan 2013 10:45:28 -0800 Subject: [PATCH] Add grunt tasks for jshint and jasmine. Refactor and move package.json, replace existing with config.json. Add Travis-CI support. --- .gitignore | 4 +- .jshintrc | 75 +++++++++++++++++++++++++++ .travis.yml | 5 ++ Gruntfile.js | 108 +++++++++++++++++++++++++++++++++++++++ package.json | 30 +++++++++++ src/brackets.config.json | 31 +++++++++++ src/config.json | 1 + src/utils/Global.js | 4 +- 8 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 .jshintrc create mode 100644 .travis.yml create mode 100644 Gruntfile.js create mode 100644 package.json create mode 100644 src/brackets.config.json create mode 100644 src/config.json diff --git a/.gitignore b/.gitignore index 6870f1d04..b6416d2d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ Thumbs.db node_modules +npm-debug.log src/brackets.css src/brackets.min.css @@ -14,4 +15,5 @@ src/extensions/disabled .DS_Store # unit test working directory -test/temp \ No newline at end of file +test/temp +test/results \ No newline at end of file diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..33c869c08 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,75 @@ +{ + "bitwise" : true, + "curly" : true, + "eqeqeq" : true, + "forin" : true, + "immed" : true, + "latedef" : true, + "newcap" : true, + "noarg" : true, + "noempty" : true, + "nonew" : true, + "plusplus" : true, + "regexp" : true, + "undef" : true, + "strict" : true, + "trailing" : false, + + "asi" : false, + "boss" : false, + "debug" : false, + "eqnull" : false, + "es5" : false, + "esnext" : false, + "evil" : false, + "expr" : false, + "funcscope" : false, + "globalstrict" : false, + "iterator" : false, + "lastsemic" : false, + "laxbreak" : false, + "laxcomma" : false, + "loopfunc" : false, + "multistr" : false, + "onecase" : false, + "proto" : false, + "regexdash" : false, + "scripturl" : false, + "smarttabs" : false, + "shadow" : false, + "sub" : false, + "supernew" : false, + "validthis" : false, + + "browser" : true, + "couch" : false, + "devel" : false, + "dojo" : false, + "jquery" : false, + "mootools" : false, + "node" : false, + "nonstandard" : false, + "prototypejs" : false, + "rhino" : false, + "wsh" : false, + + "nomen" : false, + "onevar" : false, + "passfail" : false, + "white" : false, + + "maxerr" : 100, + "predef" : [ + ], + "indent" : 4, + "globals" : [ + "require", + "define", + "brackets", + "$", + "PathUtils", + "window", + "navigator", + "Mustache" + ] +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..2d6cd8f4f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.8 +before_script: + - npm install -g grunt-cli \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 000000000..06103fea0 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,108 @@ +module.exports = function(grunt) { + 'use strict'; + + // Project configuration. + grunt.initConfig({ + meta : { + src : [ + 'src/**/*.js', + '!src/thirdparty/**', + '!src/widgets/bootstrap-*.js', + '!src/extensions/**/unittest-files/**/*.js', + '!src/**/*-min.js', + '!src/**/*.min.js' + ], + test : [ + 'test/**/*.js', + '!test/perf/*-files/**/*.js', + '!test/spec/*-files/**/*.js', + '!test/smokes/**', + '!test/temp/**', + '!test/thirdparty/**' + ], + /* specs that can run in phantom.js */ + specs : [ + 'test/spec/CommandManager-test.js', + 'test/spec/PreferencesManager-test.js', + 'test/spec/ViewUtils-test.js' + ] + }, + watch: { + test : { + files: ['Gruntfile.js','<%= meta.src %>','<%= meta.test %>'], + tasks: 'test' + } + }, + /* FIXME (jasonsanjose): how to handle extension tests */ + jasmine : { + src : 'undefined.js', /* trick the default runner to run without importing src files */ + options : { + junit : { + path: 'test/results', + consolidate: true + }, + specs : '<%= meta.specs %>', + vendor : [ + 'src/thirdparty/jquery-1.7.js', + 'src/thirdparty/CodeMirror2/lib/codemirror.js', + 'src/thirdparty/CodeMirror2/lib/util/dialog.js', + 'src/thirdparty/CodeMirror2/lib/util/searchcursor.js', + 'src/thirdparty/mustache/mustache.js' + ], + template : require('grunt-template-jasmine-requirejs'), + templateOptions: { + requireConfig : { + baseUrl: 'src', + paths: { + 'test' : '../test', + 'perf' : '../test/perf', + 'spec' : '../test/spec', + 'text' : 'thirdparty/text', + 'i18n' : 'thirdparty/i18n' + } + } + } + } + }, + jshint: { + all: [ + 'Gruntfile.js', + '<%= meta.src %>', + '<%= meta.test %>' + ], + /* use strict options to mimic JSLINT until we migrate to JSHINT in Brackets */ + options: { + jshintrc: '.jshintrc' + } + } + }); + + // load dependencies + grunt.loadNpmTasks('grunt-contrib-jasmine'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-watch'); + + // task: install + grunt.registerTask('install', ['write-config']); + + // task: write-config + // merge package.json and src/brackets.config.json into src/config.json + grunt.registerTask('write-config', function () { + var packageJSON = grunt.file.readJSON("package.json"), + appConfigJSON = grunt.file.readJSON("src/brackets.config.json"); + + Object.keys(packageJSON).forEach(function (key) { + if (appConfigJSON[key] === undefined) { + appConfigJSON[key] = packageJSON[key]; + } + }); + + grunt.file.write("src/config.json", JSON.stringify(appConfigJSON)); + }); + + // task: test + grunt.registerTask('test', ['jshint', 'jasmine']); + + // Default task. + grunt.registerTask('default', ['test']); +}; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 000000000..2b0e225ab --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name" : "Brackets", + "version" : "0.20.0-0", + "homepage" : "http://brackets.io", + "issues" : + { + "url" : "http://github.com/jasonsanjose/brackets/issues" + }, + "repository" : + { + "type" : "git", + "url" : "https://github.com/jasonsanjose/brackets.git", + "branch" : "", + "SHA" : "" + }, + "devDependencies" : + { + "grunt" : ">=0.4.0rc5", + "grunt-contrib-jshint" : "git://github.com/gruntjs/grunt-contrib-jshint.git#master", + "grunt-contrib-watch" : ">=0.2.0rc5", + "grunt-contrib-jasmine" : "git://github.com/gruntjs/grunt-contrib-jasmine.git#master", + "grunt-template-jasmine-requirejs" : ">=0.1.0", + "socket.io" : ">=0.9.13" + }, + "scripts" : + { + "install" : "grunt install", + "test" : "grunt test" + } +} \ No newline at end of file diff --git a/src/brackets.config.json b/src/brackets.config.json new file mode 100644 index 000000000..3aad56093 --- /dev/null +++ b/src/brackets.config.json @@ -0,0 +1,31 @@ +{ + "name" : "Brackets", + "homepage" : "http://brackets.io", + "issues" : + { + "url" : "http://github.com/adobe/brackets/issues" + }, + "repository" : + { + "type" : "git", + "url" : "https://github.com/adobe/brackets.git", + "branch" : "", + "SHA" : "" + }, + "config" : + { + "app_title" : "Brackets", + "app_name_about" : "Brackets", + "about_icon" : "styles/images/brackets_icon.svg", + "show_debug_menu" : true, + "enable_jslint" : true, + "update_info_url" : "http://dev.brackets.io/updates/stable/", + "how_to_use_url" : "https://github.com/adobe/brackets/wiki/How-to-Use-Brackets", + "forum_url" : "https://groups.google.com/forum/?fromgroups#!forum/brackets-dev", + "release_notes_url" : "https://github.com/adobe/brackets/wiki/Release-Notes", + "report_issue_url" : "https://github.com/adobe/brackets/wiki/How-to-Report-an-Issue", + "twitter_url" : "https://twitter.com/brackets", + "troubleshoot_url" : "https://github.com/adobe/brackets/wiki/Troubleshooting#wiki-livedev", + "twitter_name" : "@brackets" + } +} \ No newline at end of file diff --git a/src/config.json b/src/config.json new file mode 100644 index 000000000..0901caf56 --- /dev/null +++ b/src/config.json @@ -0,0 +1 @@ +{"name":"Brackets","homepage":"http://brackets.io","issues":{"url":"http://github.com/adobe/brackets/issues"},"repository":{"type":"git","url":"https://github.com/adobe/brackets.git","branch":"","SHA":""},"config":{"app_title":"Brackets","app_name_about":"Brackets","about_icon":"styles/images/brackets_icon.svg","show_debug_menu":true,"enable_jslint":true,"update_info_url":"http://dev.brackets.io/updates/stable/","how_to_use_url":"https://github.com/adobe/brackets/wiki/How-to-Use-Brackets","forum_url":"https://groups.google.com/forum/?fromgroups#!forum/brackets-dev","release_notes_url":"https://github.com/adobe/brackets/wiki/Release-Notes","report_issue_url":"https://github.com/adobe/brackets/wiki/How-to-Report-an-Issue","twitter_url":"https://twitter.com/brackets","troubleshoot_url":"https://github.com/adobe/brackets/wiki/Troubleshooting#wiki-livedev","twitter_name":"@brackets"},"version":"0.20.0-0","devDependencies":{"grunt":">=0.4.0rc5","grunt-contrib-jshint":"git://github.com/gruntjs/grunt-contrib-jshint.git#master","grunt-contrib-watch":">=0.2.0rc5","grunt-contrib-jasmine":"git://github.com/gruntjs/grunt-contrib-jasmine.git#master","grunt-template-jasmine-requirejs":">=0.1.0","socket.io":">=0.9.13"},"scripts":{"install":"grunt install","test":"grunt test"}} \ No newline at end of file diff --git a/src/utils/Global.js b/src/utils/Global.js index b4b1b9d28..c088fe026 100644 --- a/src/utils/Global.js +++ b/src/utils/Global.js @@ -34,7 +34,7 @@ define(function (require, exports, module) { "use strict"; - var packageJSON = require("text!package.json"); + var configJSON = require("text!config.json"); // Define core brackets namespace if it isn't already defined // @@ -52,7 +52,7 @@ define(function (require, exports, module) { // Parse src/config.json try { - global.brackets.metadata = JSON.parse(packageJSON); + global.brackets.metadata = JSON.parse(configJSON); global.brackets.config = global.brackets.metadata.config; } catch (err) { console.log(err);