Skip to content

Commit

Permalink
Add grunt tasks for jshint and jasmine. Refactor and move package.jso…
Browse files Browse the repository at this point in the history
…n, replace existing with config.json. Add Travis-CI support.
  • Loading branch information
jasonsanjose committed Jan 24, 2013
1 parent 8e43cd8 commit 67a97c2
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
@@ -1,5 +1,6 @@
Thumbs.db
node_modules
npm-debug.log
src/brackets.css
src/brackets.min.css

Expand All @@ -14,4 +15,5 @@ src/extensions/disabled
.DS_Store

# unit test working directory
test/temp
test/temp
test/results
75 changes: 75 additions & 0 deletions .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"
]
}
5 changes: 5 additions & 0 deletions .travis.yml
@@ -0,0 +1,5 @@
language: node_js
node_js:
- 0.8
before_script:
- npm install -g grunt-cli
108 changes: 108 additions & 0 deletions 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']);
};
30 changes: 30 additions & 0 deletions 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"
}
}
31 changes: 31 additions & 0 deletions 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"
}
}
1 change: 1 addition & 0 deletions 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"}}
4 changes: 2 additions & 2 deletions src/utils/Global.js
Expand Up @@ -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
//
Expand All @@ -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);
Expand Down

0 comments on commit 67a97c2

Please sign in to comment.