This commit is contained in:
Jason San Jose 2013-10-30 19:01:36 -07:00
Родитель 86c003c184
Коммит 3b9c5c0449
9 изменённых файлов: 161 добавлений и 50 удалений

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

@ -8,21 +8,21 @@ Thumbs.db
/npm-debug.log
# ignore compiled files
dist
src/styles/brackets.css
/dist
/src/styles/brackets.css
# ignore everything in the dev extension directory EXCEPT the README
# (so that the directory is non-empty and can be in git)
src/extensions/dev/*
!src/extensions/dev/README
/src/extensions/dev/*
!/src/extensions/dev/README
src/extensions/disabled
/src/extensions/disabled
#OSX .DS_Store files
.DS_Store
# unit test working directory
test/results
/test/results
# Netbeans
/nbproject
@ -31,4 +31,4 @@ test/results
.idea
# Files that can be automatically downloaded that we don't want to ship with our builds
src/extensibility/node/node_modules/request/tests/
/src/extensibility/node/node_modules/request/tests/

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

@ -25,22 +25,8 @@ module.exports = function (grunt) {
'use strict';
// load dependencies
require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', 'grunt-usemin']});
grunt.loadTasks('tasks');
[
'grunt-contrib-jasmine',
'grunt-contrib-jshint',
'grunt-contrib-watch',
'grunt-contrib-clean',
'grunt-contrib-copy',
'grunt-contrib-concat',
'grunt-contrib-uglify',
'grunt-contrib-cssmin',
'grunt-contrib-concat',
'grunt-contrib-less',
'grunt-jasmine-node',
'grunt-usemin'
].forEach(function (task) { grunt.loadNpmTasks(task); });
var common = require("./tasks/lib/common")(grunt);
@ -53,17 +39,41 @@ module.exports = function (grunt) {
copy: {
dist: {
files: [
/* static files */
{
expand: true,
dest: 'dist/',
cwd: 'src/',
src: ['**']
src: [
'config.json',
'nls/{,*/}*.js',
'xorigin.js',
'dependencies.js',
'thirdparty/requirejs/require.js',
'thirdparty/CodeMirror2/**/*',
'thirdparty/i18n/*.js',
'thirdparty/text/*.js'
]
},
/* extensions and CodeMirror modes */
{
expand: true,
dest: 'dist/css',
dest: 'dist/',
cwd: 'src/',
src: [
'extensibility/**/*',
'extensions/default/**/*',
'thirdparty/CodeMirror2/**/*',
'thirdparty/i18n/*.js',
'thirdparty/text/*.js'
]
},
/* styles, fonts and images */
{
expand: true,
dest: 'dist/styles',
cwd: 'src/styles',
src: ['fonts/**', 'images/**']
src: ['jsTreeTheme.css', 'fonts/{,*/}*.*', 'images/*']
}
]
}
@ -75,13 +85,58 @@ module.exports = function (grunt) {
}
}
},
requirejs: {
dist: {
// Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
options: {
// `name` and `out` is set by grunt-usemin
baseUrl: 'src',
optimize: 'none',
// TODO: Figure out how to make sourcemaps work with grunt-usemin
// https://github.com/yeoman/grunt-usemin/issues/30
//generateSourceMaps: true,
// required to support SourceMaps
// http://requirejs.org/docs/errors.html#sourcemapcomments
preserveLicenseComments: true,
useStrict: true,
// Disable closure, we want define/require to be globals
wrap: false
//uglify2: {} // https://github.com/mishoo/UglifyJS2
}
}
},
useminPrepare: {
html: ['dist/index.html']
options: {
dest: 'dist'
},
html: 'src/index.html'
},
usemin: {
html: ['dist/index.html'],
options: {
dirs: ['dist/']
dirs: ['dist']
},
html: ['dist/{,*/}*.html'],
css: ['dist/css/{,*/}*.css']
},
htmlmin: {
dist: {
options: {
/*removeCommentsFromCDATA: true,
// https://github.com/yeoman/grunt-usemin/issues/44
//collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true*/
},
files: [{
expand: true,
cwd: 'src',
src: '*.html',
dest: 'dist'
}]
}
},
meta : {
@ -213,9 +268,16 @@ module.exports = function (grunt) {
// Default task.
grunt.registerTask('default', [
'less', 'test', 'clean', 'copy',
'test',
'less',
'clean',
'useminPrepare',
'concat', 'uglify', 'cssmin',
'htmlmin',
'requirejs',
'concat',
'cssmin',
'uglify',
'copy',
'usemin'
]);
};

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

@ -26,11 +26,14 @@
"grunt-contrib-cssmin": "0.6.0",
"grunt-contrib-clean": "0.4.1",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-htmlmin": "0.1.3",
"grunt-contrib-less": "0.5.1",
"grunt-contrib-requirejs": "0.4.1",
"grunt-contrib-uglify": "0.2.0",
"grunt-contrib-concat": "0.3.0",
"grunt-contrib-watch": "0.4.3",
"grunt-usemin": "0.1.11",
"load-grunt-tasks": "0.2.0",
"q": "0.9.2",
"jshint": "2.1.4"
},

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

@ -25,18 +25,6 @@
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global require, define, brackets: true, $, window, navigator, Mustache */
require.config({
paths: {
"text" : "thirdparty/text/text",
"i18n" : "thirdparty/i18n/i18n"
},
// Use custom brackets property until CEF sets the correct navigator.language
// NOTE: When we change to navigator.language here, we also should change to
// navigator.language in ExtensionLoader (when making require contexts for each
// extension).
locale: window.localStorage.getItem("locale") || (typeof (brackets) !== "undefined" ? brackets.app.language : navigator.language)
});
/**
* brackets is the root of the Brackets codebase. This file pulls in all other modules as
* dependencies (or dependencies thereof), initializes the UI, and binds global menus & keyboard

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

@ -44,10 +44,13 @@
"grunt-contrib-cssmin": "0.6.0",
"grunt-contrib-clean": "0.4.1",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-htmlmin": "0.1.3",
"grunt-contrib-less": "0.5.1",
"grunt-contrib-requirejs": "0.4.1",
"grunt-contrib-uglify": "0.2.0",
"grunt-contrib-concat": "0.3.0",
"grunt-usemin": "0.1.11",
"load-grunt-tasks": "0.2.0",
"q": "0.9.2",
"jshint": "2.1.4"
},

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

@ -35,7 +35,7 @@
<script type="application/javascript" src="xorigin.js">
</script>
<!-- build:css css/brackets.min.css -->
<!-- build:css styles/brackets.min.css -->
<link rel="stylesheet" type="text/css" href="thirdparty/CodeMirror2/lib/codemirror.css">
<link rel="stylesheet" type="text/css" href="styles/brackets.css">
<!-- endbuild -->
@ -43,7 +43,7 @@
<!-- JavaScript -->
<!-- Pre-load third party scripts that cannot be async loaded. -->
<!-- build:js js/thirdparty.min.js -->
<!-- build:js thirdparty/thirdparty.min.js -->
<script src="thirdparty/less-1.4.2.min.js"></script>
<script src="thirdparty/mustache/mustache.js"></script>
<script src="thirdparty/jquery-2.0.1.min.js"></script>
@ -67,7 +67,9 @@
-->
<!-- All other scripts are loaded through require. -->
<script src="thirdparty/requirejs/require.js" data-main="brackets"></script>
<!-- build:js main.js -->
<script src="thirdparty/requirejs/require.js" data-main="main"></script>
<!-- endbuild -->
<!-- Verify that all dependencies are loaded. -->
<script src="dependencies.js"></script>

43
src/main.js Normal file
Просмотреть файл

@ -0,0 +1,43 @@
/*
* Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global require, window, brackets, navigator */
(function () {
"use strict";
require.config({
paths: {
"text" : "thirdparty/text/text",
"i18n" : "thirdparty/i18n/i18n"
}
});
// hack for r.js optimization
require.config({
locale: window.localStorage.getItem("locale") || (typeof (brackets) !== "undefined" ? brackets.app.language : navigator.language)
});
require(["brackets"], function (brackets) {});
}());

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

@ -69,7 +69,11 @@ define(function (require, exports, module) {
* C:\Users\<user>\AppData\Roaming\Brackets\extensions\user on windows.
*/
function getUserExtensionPath() {
return brackets.app.getApplicationSupportDirectory() + "/extensions/user";
if (brackets.app.getApplicationSupportDirectory) {
return brackets.app.getApplicationSupportDirectory() + "/extensions/user";
}
return null;
}
/**
@ -270,7 +274,9 @@ define(function (require, exports, module) {
},
function (error) {
console.error("[Extension] Error -- could not open native directory: " + directory);
result.reject();
// Silently ignore error
result.resolve();
});
return result.promise();
@ -337,8 +343,10 @@ define(function (require, exports, module) {
// If the directory *does* exist, nothing else needs to be done. It will be scanned normally
// during extension loading.
var extensionPath = getUserExtensionPath();
new NativeFileSystem.DirectoryEntry().getDirectory(extensionPath,
{create: true});
if (extensionPath) {
new NativeFileSystem.DirectoryEntry().getDirectory(extensionPath, {create: true});
}
// Create the extensions/disabled directory, too.
var disabledExtensionPath = extensionPath.replace(/\/user$/, "/disabled");

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

@ -56,7 +56,9 @@ define(function (require, exports, module) {
// which we have to return true (issue #3152).
return (eventName === Commands.FILE_CLOSE_WINDOW);
}
var promise, e = new Error(), stackDepth = e.stack.split("\n").length;
// Use E for Error so that uglify doesn't change this to simply Error()
var promise, E = Error, e = new E(), stackDepth = e.stack.split("\n").length;
// This function should *only* be called as a top-level function. If the current
// stack depth is > 2, it is most likely because we are at a breakpoint.