simplify config
This commit is contained in:
parent
4abb08fa92
commit
6bb805b40f
5 changed files with 44 additions and 24 deletions
|
|
@ -43,7 +43,7 @@ var copy = require('dryice').copy;
|
||||||
var ACE_HOME = __dirname;
|
var ACE_HOME = __dirname;
|
||||||
|
|
||||||
function main(args) {
|
function main(args) {
|
||||||
var target;
|
var target = "minimal";
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
target = args[2];
|
target = args[2];
|
||||||
// Check if 'target' contains some allowed value.
|
// Check if 'target' contains some allowed value.
|
||||||
|
|
@ -52,12 +52,13 @@ function main(args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!target) {
|
if (target == "help") {
|
||||||
console.log("--- Ace Dryice Build Tool ---");
|
console.log("--- Ace Dryice Build Tool ---");
|
||||||
console.log("");
|
console.log("");
|
||||||
console.log("Options:");
|
console.log("Options:");
|
||||||
|
console.log(" minimal Runs minimal build of Ace");
|
||||||
console.log(" normal Runs embedded build of Ace");
|
console.log(" normal Runs embedded build of Ace");
|
||||||
console.log(" demo Runs demo build of Ace");
|
console.log(" demo Runs demo build of Ace");
|
||||||
console.log(" bm Runs bookmarklet build of Ace");
|
console.log(" bm Runs bookmarklet build of Ace");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
@ -70,6 +71,15 @@ function main(args) {
|
||||||
textPluginPattern: /^ace\/requirejs\/text!/
|
textPluginPattern: /^ace\/requirejs\/text!/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (target == "minimal") {
|
||||||
|
buildAce(aceProject, {
|
||||||
|
compress: false,
|
||||||
|
noconflict: false,
|
||||||
|
suffix: "",
|
||||||
|
compat: true,
|
||||||
|
name: "ace"
|
||||||
|
});
|
||||||
|
}
|
||||||
if (target == "normal") {
|
if (target == "normal") {
|
||||||
ace(aceProject);
|
ace(aceProject);
|
||||||
}
|
}
|
||||||
|
|
@ -113,14 +123,14 @@ function ace(aceProject) {
|
||||||
buildAce(aceProject, {
|
buildAce(aceProject, {
|
||||||
compress: false,
|
compress: false,
|
||||||
noconflict: false,
|
noconflict: false,
|
||||||
suffix: "-uncompressed.js",
|
suffix: "-uncompressed",
|
||||||
compat: true,
|
compat: true,
|
||||||
name: "ace"
|
name: "ace"
|
||||||
});
|
});
|
||||||
buildAce(aceProject, {
|
buildAce(aceProject, {
|
||||||
compress: false,
|
compress: false,
|
||||||
noconflict: true,
|
noconflict: true,
|
||||||
suffix: "-uncompressed-noconflict.js",
|
suffix: "-uncompressed-noconflict",
|
||||||
compat: true,
|
compat: true,
|
||||||
name: "ace",
|
name: "ace",
|
||||||
workers: []
|
workers: []
|
||||||
|
|
@ -130,7 +140,7 @@ function ace(aceProject) {
|
||||||
buildAce(aceProject, {
|
buildAce(aceProject, {
|
||||||
compress: true,
|
compress: true,
|
||||||
noconflict: false,
|
noconflict: false,
|
||||||
suffix: ".js",
|
suffix: "",
|
||||||
compat: true,
|
compat: true,
|
||||||
name: "ace",
|
name: "ace",
|
||||||
workers: []
|
workers: []
|
||||||
|
|
@ -138,7 +148,7 @@ function ace(aceProject) {
|
||||||
buildAce(aceProject, {
|
buildAce(aceProject, {
|
||||||
compress: true,
|
compress: true,
|
||||||
noconflict: true,
|
noconflict: true,
|
||||||
suffix: "-noconflict.js",
|
suffix: "-noconflict",
|
||||||
compat: true,
|
compat: true,
|
||||||
name: "ace",
|
name: "ace",
|
||||||
workers: []
|
workers: []
|
||||||
|
|
@ -199,7 +209,7 @@ function demo(aceProject) {
|
||||||
noconflict: false,
|
noconflict: false,
|
||||||
compat: false,
|
compat: false,
|
||||||
name: "kitchen-sink",
|
name: "kitchen-sink",
|
||||||
suffix: "-uncompressed.js",
|
suffix: "",
|
||||||
keybindings: []
|
keybindings: []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +223,7 @@ function buildAce(aceProject, options) {
|
||||||
requires: null,
|
requires: null,
|
||||||
compress: false,
|
compress: false,
|
||||||
noconflict: false,
|
noconflict: false,
|
||||||
suffix: ".js",
|
suffix: "",
|
||||||
name: "ace",
|
name: "ace",
|
||||||
compat: true,
|
compat: true,
|
||||||
modes: [
|
modes: [
|
||||||
|
|
@ -252,6 +262,15 @@ function buildAce(aceProject, options) {
|
||||||
var exportFilter = exportAce(options.ns, options.exportModule);
|
var exportFilter = exportAce(options.ns, options.exportModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove use strict
|
||||||
|
filters.push(function(text) {
|
||||||
|
return text.replace(/['"]use strict['"];/g, "");
|
||||||
|
})
|
||||||
|
// remove redundant comments
|
||||||
|
filters.push(function(text) {
|
||||||
|
return text.replace(/(;)\s*\/\*[\d\D]*?\*\//g, "$1");
|
||||||
|
})
|
||||||
|
|
||||||
if (options.compress)
|
if (options.compress)
|
||||||
filters.push(copy.filter.uglifyjs);
|
filters.push(copy.filter.uglifyjs);
|
||||||
|
|
||||||
|
|
@ -279,7 +298,7 @@ function buildAce(aceProject, options) {
|
||||||
copy({
|
copy({
|
||||||
source: ace,
|
source: ace,
|
||||||
filter: exportFilter ? filters.concat(exportFilter) : filters,
|
filter: exportFilter ? filters.concat(exportFilter) : filters,
|
||||||
dest: targetDir + '/' + name + suffix
|
dest: targetDir + suffix + '/' + name + ".js"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (options.compat) {
|
if (options.compat) {
|
||||||
|
|
@ -292,7 +311,7 @@ function buildAce(aceProject, options) {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
filter: filters,
|
filter: filters,
|
||||||
dest: targetDir + "/" + name + "-compat" + suffix
|
dest: targetDir + suffix + "/" + name + "-compat.js"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,7 +328,7 @@ function buildAce(aceProject, options) {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
filter: filters,
|
filter: filters,
|
||||||
dest: targetDir + "/mode-" + mode + suffix
|
dest: targetDir + suffix + "/mode-" + mode + ".js"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -324,7 +343,7 @@ function buildAce(aceProject, options) {
|
||||||
require: ["ace/theme/" + theme]
|
require: ["ace/theme/" + theme]
|
||||||
}],
|
}],
|
||||||
filter: filters,
|
filter: filters,
|
||||||
dest: targetDir + "/theme-" + theme + suffix
|
dest: targetDir + suffix + "/theme-" + theme + ".js"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -377,7 +396,7 @@ function buildAce(aceProject, options) {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
filter: filters,
|
filter: filters,
|
||||||
dest: "build/src/keybinding-" + keybinding + suffix
|
dest: targetDir + suffix + "/keybinding-" + keybinding + ".js"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -423,10 +442,12 @@ function exportAce(ns, module, requireBase) {
|
||||||
var template = function() {
|
var template = function() {
|
||||||
(function() {
|
(function() {
|
||||||
REQUIRE_NS.require(["MODULE"], function(a) {
|
REQUIRE_NS.require(["MODULE"], function(a) {
|
||||||
|
a.config.init();
|
||||||
if (!window.NS)
|
if (!window.NS)
|
||||||
window.NS = {};
|
window.NS = {};
|
||||||
for (var key in a) if (a.hasOwnProperty(key))
|
for (var key in a) if (a.hasOwnProperty(key))
|
||||||
NS[key] = a[key];
|
NS[key] = a[key];
|
||||||
|
require("./config").init();
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@
|
||||||
<!--DEVEL -->
|
<!--DEVEL -->
|
||||||
|
|
||||||
<!--PACKAGE
|
<!--PACKAGE
|
||||||
<script src="demo/kitchen-sink/kitchen-sink-uncompressed.js" data-ace-suffix="-uncompressed.js" data-ace-base="demo/kitchen-sink" type="text/javascript" charset="utf-8"></script>
|
<script src="demo/kitchen-sink/kitchen-sink.js" data-ace-base="demo/kitchen-sink" type="text/javascript" charset="utf-8"></script>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
require("kitchen-sink/demo");
|
require("kitchen-sink/demo");
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,7 @@ require("./worker/worker_client");
|
||||||
require("./keyboard/hash_handler");
|
require("./keyboard/hash_handler");
|
||||||
require("./keyboard/state_handler");
|
require("./keyboard/state_handler");
|
||||||
require("./placeholder");
|
require("./placeholder");
|
||||||
require("./config").init();
|
exports.config = require("./config");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ace.edit(el) -> Editor
|
* Ace.edit(el) -> Editor
|
||||||
* - el (String | DOMElement): Either the id of an element, or the element itself
|
* - el (String | DOMElement): Either the id of an element, or the element itself
|
||||||
|
|
@ -76,6 +75,9 @@ exports.edit = function(el) {
|
||||||
el = document.getElementById(el);
|
el = document.getElementById(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (el.env && el.env.editor instanceof Editor)
|
||||||
|
return el.env.editor;
|
||||||
|
|
||||||
var doc = new EditSession(Dom.getInnerText(el));
|
var doc = new EditSession(Dom.getInnerText(el));
|
||||||
doc.setUndoManager(new UndoManager());
|
doc.setUndoManager(new UndoManager());
|
||||||
el.innerHTML = '';
|
el.innerHTML = '';
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ exports.init = function() {
|
||||||
|
|
||||||
var scriptOptions = {};
|
var scriptOptions = {};
|
||||||
var scriptUrl = "";
|
var scriptUrl = "";
|
||||||
var suffix;
|
|
||||||
|
|
||||||
var scripts = document.getElementsByTagName("script");
|
var scripts = document.getElementsByTagName("script");
|
||||||
for (var i=0; i<scripts.length; i++) {
|
for (var i=0; i<scripts.length; i++) {
|
||||||
|
|
@ -98,10 +97,9 @@ exports.init = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var m = src.match(/^(?:(.*\/)ace\.js|(.*\/)ace((-uncompressed)?(-noconflict)?\.js))(?:\?|$)/);
|
var m = src.match(/^(?:(.*\/)ace\.js)(?:\?|$)/);
|
||||||
if (m) {
|
if (m) {
|
||||||
scriptUrl = m[1] || m[2];
|
scriptUrl = m[1] || m[2];
|
||||||
suffix = m[3];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +108,6 @@ exports.init = function() {
|
||||||
scriptOptions.packaged = true;
|
scriptOptions.packaged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptOptions.suffix = scriptOptions.suffix || suffix;
|
|
||||||
scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
|
scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
|
||||||
scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
|
scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
|
||||||
scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
|
scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
|
||||||
|
|
|
||||||
|
|
@ -798,7 +798,7 @@ var EditSession = function(text, mode) {
|
||||||
return callback();
|
return callback();
|
||||||
|
|
||||||
var base = mode.split("/").pop();
|
var base = mode.split("/").pop();
|
||||||
var filename = config.get("modePath") + "/mode-" + base + config.get("suffix");
|
var filename = config.get("modePath") + "/mode-" + base + ".js";
|
||||||
net.loadScript(filename, callback);
|
net.loadScript(filename, callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -820,8 +820,8 @@ var EditSession = function(text, mode) {
|
||||||
} else {
|
} else {
|
||||||
this.bgTokenizer.setTokenizer(tokenizer);
|
this.bgTokenizer.setTokenizer(tokenizer);
|
||||||
}
|
}
|
||||||
this.bgTokenizer.setDocument(this.getDocument());
|
this.bgTokenizer.setDocument(this.getDocument());
|
||||||
|
|
||||||
this.tokenRe = this.$mode.tokenRe;
|
this.tokenRe = this.$mode.tokenRe;
|
||||||
this.nonTokenRe = this.$mode.nonTokenRe;
|
this.nonTokenRe = this.$mode.nonTokenRe;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue