reorganize build and demo
Conflicts: Makefile.dryice.js
This commit is contained in:
parent
0f0d12a709
commit
34f3cac4a8
6 changed files with 486 additions and 352 deletions
|
|
@ -38,6 +38,8 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var fs = require("fs");
|
||||
if (!fs.existsSync)
|
||||
fs.existsSync = require("path").existsSync;
|
||||
var copy = require('dryice').copy;
|
||||
|
||||
var ACE_HOME = __dirname;
|
||||
|
|
@ -47,10 +49,9 @@ function main(args) {
|
|||
if (args.length == 3) {
|
||||
target = args[2];
|
||||
// Check if 'target' contains some allowed value.
|
||||
if (target != "normal" && target != "bm" && target != "demo") {
|
||||
target = null;
|
||||
if (!/^(normal|bm|demo|minimal)$/.test(target))
|
||||
target = "help";
|
||||
}
|
||||
}
|
||||
|
||||
if (target == "help") {
|
||||
console.log("--- Ace Dryice Build Tool ---");
|
||||
|
|
@ -107,7 +108,7 @@ function bookmarklet(aceProject) {
|
|||
exportModule: "ace/ext/textarea",
|
||||
compress: false,
|
||||
noconflict: true,
|
||||
suffix: ".js",
|
||||
suffix: "",
|
||||
name: "ace-bookmarklet",
|
||||
workers: [],
|
||||
keybindings: []
|
||||
|
|
@ -121,13 +122,13 @@ function ace(aceProject) {
|
|||
buildAce(aceProject, {
|
||||
compress: false,
|
||||
noconflict: false,
|
||||
suffix: "-uncompressed",
|
||||
suffix: "",
|
||||
name: "ace"
|
||||
});
|
||||
buildAce(aceProject, {
|
||||
compress: false,
|
||||
noconflict: true,
|
||||
suffix: "-uncompressed-noconflict",
|
||||
suffix: "-noconflict",
|
||||
name: "ace",
|
||||
workers: []
|
||||
});
|
||||
|
|
@ -136,14 +137,14 @@ function ace(aceProject) {
|
|||
buildAce(aceProject, {
|
||||
compress: true,
|
||||
noconflict: false,
|
||||
suffix: "",
|
||||
suffix: "-min",
|
||||
name: "ace",
|
||||
workers: []
|
||||
});
|
||||
buildAce(aceProject, {
|
||||
compress: true,
|
||||
noconflict: true,
|
||||
suffix: "-noconflict",
|
||||
suffix: "-min-noconflict",
|
||||
name: "ace",
|
||||
workers: []
|
||||
});
|
||||
|
|
@ -179,33 +180,65 @@ function demo(aceProject) {
|
|||
ref = "";
|
||||
version = "";
|
||||
}
|
||||
|
||||
copy({
|
||||
source: "kitchen-sink.html",
|
||||
dest: "build/kitchen-sink.html",
|
||||
filter: [ function(data) {
|
||||
var changeComments = function(data) {
|
||||
return (data
|
||||
.replace("DEVEL-->", "")
|
||||
.replace("<!--DEVEL", "")
|
||||
.replace("PACKAGE-->", "")
|
||||
.replace("<!--PACKAGE", "")
|
||||
.replace("DEVEL*/", "")
|
||||
.replace("/*DEVEL", "")
|
||||
.replace("PACKAGE*/", "")
|
||||
.replace("/*PACKAGE", "")
|
||||
.replace("%version%", version)
|
||||
.replace("%commit%", ref)
|
||||
);
|
||||
}
|
||||
|
||||
copy({
|
||||
source: "kitchen-sink.html",
|
||||
dest: "build/kitchen-sink.html",
|
||||
filter: [changeComments, function(data) {
|
||||
return data.replace(/"(demo|build)\//g, "\"");
|
||||
}]
|
||||
});
|
||||
|
||||
buildAce(aceProject, {
|
||||
targetDir: "build/demo/kitchen-sink",
|
||||
ns: "ace",
|
||||
requires: "kitchen-sink/demo",
|
||||
compress: false,
|
||||
noconflict: false,
|
||||
compat: false,
|
||||
name: "kitchen-sink",
|
||||
suffix: "",
|
||||
keybindings: []
|
||||
copy({
|
||||
source: "demo/kitchen-sink/styles.css",
|
||||
dest: "build/kitchen-sink/styles.css",
|
||||
filter: [ changeComments ]
|
||||
});
|
||||
|
||||
fs.readdirSync("demo/kitchen-sink/docs/").forEach(function(x) {
|
||||
copy({
|
||||
source: "demo/kitchen-sink/docs/" + x,
|
||||
dest: "build/kitchen-sink/docs/" + x
|
||||
});
|
||||
});
|
||||
|
||||
var demo = copy.createDataObject();
|
||||
copy({
|
||||
source: "demo/kitchen-sink/demo.js",
|
||||
dest: demo,
|
||||
filter: [changeComments, function(data) {
|
||||
return data.replace(/"(demo|build)\//g, "\"");
|
||||
}, function(data) {
|
||||
return data.replace("define(", "define('kitchen-sink/demo',");
|
||||
}]
|
||||
});
|
||||
copy({
|
||||
source: "lib/ace/split.js",
|
||||
dest: demo,
|
||||
filter: [changeComments, function(data) {
|
||||
return data.replace("define(", "define('ace/split',");
|
||||
}]
|
||||
});
|
||||
copy({
|
||||
source: demo,
|
||||
dest: "build/kitchen-sink/demo.js",
|
||||
});
|
||||
|
||||
copyFileSync("demo/kitchen-sink/logo.png", "build/kitchen-sink/logo.png");
|
||||
}
|
||||
|
||||
function buildAce(aceProject, options) {
|
||||
|
|
@ -219,21 +252,13 @@ function buildAce(aceProject, options) {
|
|||
noconflict: false,
|
||||
suffix: "",
|
||||
name: "ace",
|
||||
modes: [
|
||||
"css", "html", "javascript", "php", "coldfusion", "python", "lua", "xml", "ruby", "java", "c_cpp",
|
||||
"coffee", "perl", "csharp", "haxe", "liquid", "svg", "clojure", "scss", "json", "groovy",
|
||||
"ocaml", "scala", "textile", "scad", "markdown", "latex", "powershell", "sql",
|
||||
"text", "pgsql", "sh", "xquery", "less", "golang", "c9search", "yaml"
|
||||
],
|
||||
themes: [
|
||||
"chrome", "clouds", "clouds_midnight", "cobalt", "crimson_editor", "dawn",
|
||||
"dreamweaver", "eclipse",
|
||||
"idle_fingers", "kr_theme", "merbivore", "merbivore_soft",
|
||||
"mono_industrial", "monokai", "pastel_on_dark", "solarized_dark",
|
||||
"solarized_light", "textmate", "tomorrow", "tomorrow_night",
|
||||
"tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties",
|
||||
"twilight", "vibrant_ink"
|
||||
],
|
||||
modes: fs.readdirSync("lib/ace/mode").map(function(x) {
|
||||
if (x.slice(-3) == ".js" && !/_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/.test(x))
|
||||
return x.slice(0, -3);
|
||||
}).filter(function(x){return !!x}),
|
||||
themes: fs.readdirSync("lib/ace/theme").map(function(x){
|
||||
return x.slice(-3) == ".js" && x.slice(0, -3)
|
||||
}).filter(function(x){return !!x}),
|
||||
workers: ["javascript", "coffee", "css", "json", "xquery"],
|
||||
keybindings: ["vim", "emacs"]
|
||||
};
|
||||
|
|
@ -278,12 +303,10 @@ function buildAce(aceProject, options) {
|
|||
dest: ace
|
||||
});
|
||||
copy({
|
||||
source: [
|
||||
{
|
||||
source: [{
|
||||
project: project,
|
||||
require: options.requires
|
||||
}
|
||||
],
|
||||
}],
|
||||
filter: [ copy.filter.moduleDefines ],
|
||||
dest: ace
|
||||
});
|
||||
|
|
@ -300,12 +323,10 @@ function buildAce(aceProject, options) {
|
|||
options.modes.forEach(function(mode) {
|
||||
console.log("mode " + mode);
|
||||
copy({
|
||||
source: [
|
||||
{
|
||||
source: [{
|
||||
project: cloneProject(project),
|
||||
require: [ 'ace/mode/' + mode ]
|
||||
}
|
||||
],
|
||||
}],
|
||||
filter: filters,
|
||||
dest: targetDir + suffix + "/mode-" + mode + ".js"
|
||||
});
|
||||
|
|
@ -380,12 +401,10 @@ function buildAce(aceProject, options) {
|
|||
project.assumeAllFilesLoaded();
|
||||
options.keybindings.forEach(function(keybinding) {
|
||||
copy({
|
||||
source: [
|
||||
{
|
||||
source: [{
|
||||
project: cloneProject(project),
|
||||
require: [ 'ace/keyboard/' + keybinding ]
|
||||
}
|
||||
],
|
||||
}],
|
||||
filter: filters,
|
||||
dest: targetDir + suffix + "/keybinding-" + keybinding + ".js"
|
||||
});
|
||||
|
|
@ -410,6 +429,27 @@ function cloneProject(project) {
|
|||
|
||||
return clone;
|
||||
}
|
||||
function copyFileSync(srcFile, destFile) {
|
||||
var BUF_LENGTH = 64*1024,
|
||||
buf = new Buffer(BUF_LENGTH),
|
||||
bytesRead = BUF_LENGTH,
|
||||
pos = 0,
|
||||
fdr = null,
|
||||
fdw = null;
|
||||
|
||||
|
||||
fdr = fs.openSync(srcFile, 'r');
|
||||
fdw = fs.openSync(destFile, 'w');
|
||||
|
||||
while (bytesRead === BUF_LENGTH) {
|
||||
bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
|
||||
fs.writeSync(fdw, buf, 0, bytesRead);
|
||||
pos += bytesRead;
|
||||
}
|
||||
|
||||
fs.closeSync(fdr);
|
||||
fs.closeSync(fdw);
|
||||
}
|
||||
|
||||
function quoteString(str) {
|
||||
return '"' + str.replace(/\\/, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\\n") + '"';
|
||||
|
|
@ -438,7 +478,7 @@ function exportAce(ns, module, requireBase) {
|
|||
var template = function() {
|
||||
(function() {
|
||||
REQUIRE_NS.require(["MODULE"], function(a) {
|
||||
a.config.init();
|
||||
a && a.config.init();
|
||||
if (!window.NS)
|
||||
window.NS = {};
|
||||
for (var key in a) if (a.hasOwnProperty(key))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue