Add grunt tasks for jshint and jasmine. Refactor and move package.json, replace existing with config.json. Add Travis-CI support.

This commit is contained in:
Jason San Jose 2013-01-24 10:45:28 -08:00
Родитель 8e43cd8d8e
Коммит 67a97c2457
8 изменённых файлов: 255 добавлений и 3 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -1,5 +1,6 @@
Thumbs.db
node_modules
npm-debug.log
src/brackets.css
src/brackets.min.css
@ -15,3 +16,4 @@ src/extensions/disabled
# unit test working directory
test/temp
test/results

75
.jshintrc Normal file
Просмотреть файл

@ -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
.travis.yml Normal file
Просмотреть файл

@ -0,0 +1,5 @@
language: node_js
node_js:
- 0.8
before_script:
- npm install -g grunt-cli

108
Gruntfile.js Normal file
Просмотреть файл

@ -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
package.json Normal file
Просмотреть файл

@ -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
src/brackets.config.json Normal file
Просмотреть файл

@ -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
src/config.json Normal file
Просмотреть файл

@ -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"}}

Просмотреть файл

@ -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);