tweak c9 publish

pull/85/head
nightwing 2015-04-14 04:44:47 +04:00 zatwierdzone przez nightwing
rodzic a6fa441e64
commit 734f2bd3b2
3 zmienionych plików z 46 dodań i 35 usunięć

Wyświetl plik

@ -294,20 +294,22 @@ function getDeps(src, name) {
return getReqDeps(src, name).concat(getAmdDeps(src, name)); return getReqDeps(src, name).concat(getAmdDeps(src, name));
} }
function resolveModuleId(id, paths) { function resolveModuleId(id, paths) {
var chunks = id.split("/"); var testPath = id, tail = "";
while (testPath) {
var alias = paths[chunks[0]]; var alias = paths[testPath];
if (typeof alias == "string") { if (typeof alias == "string") {
chunks[0] = alias; return alias + tail;
} else if (alias) { } else if (alias) {
chunks[0] = alias.location; return alias.location + (tail || alias.main || alias.name);
if (chunks.length == 1) } else if (alias === false) {
chunks.push(alias.main || alias.name); return "";
} else if (alias === false) { }
return ""; var i = testPath.lastIndexOf("/");
if (i === -1) break;
tail = testPath.substr(i) + tail;
testPath = testPath.slice(0, i);
} }
return id;
return chunks.join("/");
} }
function resolveModulePath(id, pathMap) { function resolveModulePath(id, pathMap) {
var testPath = id, tail = ""; var testPath = id, tail = "";

Wyświetl plik

@ -448,11 +448,9 @@ define(function(require, exports, module) {
var base = dirname(cwd); var base = dirname(cwd);
var packageName = json.name; var packageName = json.name;
var config = Object.keys(plugins).map(function(p) { var config = Object.keys(plugins).map(function(p) {
return packageName + "/" + p.replace(/\.js$/, ""); return "plugins/" + packageName + "/" + p.replace(/\.js$/, "");
}); });
var paths = {}; var result, packedFiles = [], staticPlugin;
paths[packageName] = cwd;
var result, packedFiles, staticPlugin;
async.series([ async.series([
function(next) { function(next) {
fs.readdir(cwd, function(err, files) { fs.readdir(cwd, function(err, files) {
@ -473,6 +471,7 @@ define(function(require, exports, module) {
if (files.indexOf("builders") != -1) { if (files.indexOf("builders") != -1) {
forEachFile(cwd + "/builders", function(filename, data) { forEachFile(cwd + "/builders", function(filename, data) {
packedFiles.push(cwd + "/builders/" + filename);
extraCode.push({ extraCode.push({
type: "builders", type: "builders",
filename: filename, filename: filename,
@ -482,6 +481,7 @@ define(function(require, exports, module) {
} }
if (files.indexOf("keymaps") != -1) { if (files.indexOf("keymaps") != -1) {
forEachFile(cwd + "/keymaps", function(filename, data) { forEachFile(cwd + "/keymaps", function(filename, data) {
packedFiles.push(cwd + "/keymaps/" + filename);
extraCode.push({ extraCode.push({
type: "keymaps", type: "keymaps",
filename: filename, filename: filename,
@ -503,6 +503,7 @@ define(function(require, exports, module) {
} }
if (files.indexOf("outline") != -1) { if (files.indexOf("outline") != -1) {
forEachFile(cwd + "/outline", function(filename, data) { forEachFile(cwd + "/outline", function(filename, data) {
packedFiles.push(cwd + "/outline/" + filename);
extraCode.push({ extraCode.push({
type: "outline", type: "outline",
filename: filename, filename: filename,
@ -512,6 +513,7 @@ define(function(require, exports, module) {
} }
if (files.indexOf("runners") != -1) { if (files.indexOf("runners") != -1) {
forEachFile(cwd + "/runners", function(filename, data) { forEachFile(cwd + "/runners", function(filename, data) {
packedFiles.push(cwd + "/runners/" + filename);
extraCode.push({ extraCode.push({
type: "runners", type: "runners",
filename: filename, filename: filename,
@ -521,6 +523,7 @@ define(function(require, exports, module) {
} }
if (files.indexOf("snippets") != -1) { if (files.indexOf("snippets") != -1) {
forEachFile(cwd + "/snippets", function(filename, data) { forEachFile(cwd + "/snippets", function(filename, data) {
packedFiles.push(cwd + "/snippets/" + filename);
extraCode.push({ extraCode.push({
type: "snippets", type: "snippets",
filename: filename, filename: filename,
@ -530,6 +533,7 @@ define(function(require, exports, module) {
} }
if (files.indexOf("themes") != -1) { if (files.indexOf("themes") != -1) {
forEachFile(cwd + "/themes", function(filename, data) { forEachFile(cwd + "/themes", function(filename, data) {
packedFiles.push(cwd + "/themes/" + filename);
extraCode.push({ extraCode.push({
type: "themes", type: "themes",
filename: filename, filename: filename,
@ -537,10 +541,11 @@ define(function(require, exports, module) {
}); });
}); });
} }
if (files.indexOf("template") != -1) { if (files.indexOf("templates") != -1) {
forEachFile(cwd + "/template", function(filename, data) { forEachFile(cwd + "/templates", function(filename, data) {
packedFiles.push(cwd + "/templates/" + filename);
extraCode.push({ extraCode.push({
type: "template", type: "templates",
filename: filename, filename: filename,
data: data data: data
}); });
@ -551,7 +556,7 @@ define(function(require, exports, module) {
return next(); return next();
var code = (function() { var code = (function() {
define("packageName/__static__", [], function(require, exports, module) { define(function(require, exports, module) {
main.consumes = [ main.consumes = [
"Plugin", "plugin.debug" "Plugin", "plugin.debug"
]; ];
@ -559,7 +564,7 @@ define(function(require, exports, module) {
return main; return main;
function main(options, imports, register) { function main(options, imports, register) {
var debug = imports["plugin.debug"]; var debug = imports["plugin.debug"];
var Plugin = imports["plugin.debug"]; var Plugin = imports.Plugin;
var plugin = new Plugin(); var plugin = new Plugin();
extraCode.forEach(function(x) { extraCode.forEach(function(x) {
debug.addStaticPlugin(x.type, "packageName", x.filename, x.data, plugin); debug.addStaticPlugin(x.type, "packageName", x.filename, x.data, plugin);
@ -583,7 +588,7 @@ define(function(require, exports, module) {
staticPlugin = { staticPlugin = {
source: code, source: code,
id: packageName + "/__static__", id: "plugins/" + packageName + "/__static__",
path: "" path: ""
}; };
next(); next();
@ -592,7 +597,9 @@ define(function(require, exports, module) {
function(next) { function(next) {
var build = require("architect-build/build"); var build = require("architect-build/build");
console.log(config); var paths = {};
paths["plugins/" + packageName] = cwd;
build(config, { build(config, {
additional: staticPlugin ? [staticPlugin] : [], additional: staticPlugin ? [staticPlugin] : [],
paths: paths, paths: paths,
@ -609,8 +616,8 @@ define(function(require, exports, module) {
basepath: base, basepath: base,
}, function(e, r) { }, function(e, r) {
result = r; result = r;
packedFiles = result.sources.map(function(m) { result.sources.forEach(function(m) {
return m.file; packedFiles.push(m.file);
}); });
next(); next();
}); });
@ -619,21 +626,23 @@ define(function(require, exports, module) {
fs.writeFile("__packed__.js", result.code, "utf8", next); fs.writeFile("__packed__.js", result.code, "utf8", next);
}, },
function(next) { function(next) {
packedFiles.push(cwd + "/themes"); console.log(packedFiles)
zip(packedFiles); zip(packedFiles);
} }
]); ]);
} }
function normalizePath(p) {
if (process.platform == "win32")
p = p.replace(/\\/g, "/").replace(/^(\w):/, "/$1");
return p;
}
function zip(ignore){ function zip(ignore){
zipFilePath = join(os.tmpDir(), json.name + "@" + json.version) + ".tar.gz"; zipFilePath = join(os.tmpDir(), json.name + "@" + json.version) + ".tar.gz";
var tarArgs = ["-zcvf", zipFilePath, "."]; var tarArgs = ["-zcvf", normalizePath(zipFilePath), "."];
var c9ignore = process.env.HOME + "/.c9/.c9ignore"; var c9ignore = normalizePath(process.env.HOME + "/.c9/.c9ignore");
if (process.platform == "win32") {
tarArgs[1]= zipFilePath.replace(/\\/g, "/").replace(/^(\w):/, "/$1");
c9ignore = c9ignore.replace(/\\/g, "/");
}
fs.exists(c9ignore, function (exists) { fs.exists(c9ignore, function (exists) {
if (exists) { if (exists) {
tarArgs.push("--exclude-from=" + c9ignore); tarArgs.push("--exclude-from=" + c9ignore);
@ -641,7 +650,7 @@ define(function(require, exports, module) {
ignore.forEach(function(p) { ignore.forEach(function(p) {
p = Path.relative(cwd, p); p = Path.relative(cwd, p);
if (!/^\.+\//.test(p)) { if (!/^\.+\//.test(p)) {
tarArgs.push("--exclude=./" + p); tarArgs.push("--exclude=./" + normalizePath(p));
} }
}); });
// console.log(tarArgs) // console.log(tarArgs)

Wyświetl plik

@ -311,7 +311,7 @@ define(function(require, exports, module) {
case "themes": case "themes":
services.ace.addTheme(data, plugin); services.ace.addTheme(data, plugin);
break; break;
case "template": case "templates":
services.newresource.addFileTemplate(data, plugin); services.newresource.addFileTemplate(data, plugin);
break; break;
} }