more fixed for publish on windows

pull/85/head
nightwing 2015-04-04 05:07:31 +04:00 zatwierdzone przez nightwing
rodzic bb5cfce7e9
commit aae131da51
3 zmienionych plików z 56 dodań i 14 usunięć

Wyświetl plik

@ -35,11 +35,14 @@ define(function(require, exports, module) {
var os = require("os"); var os = require("os");
var FormData = require("form-data"); var FormData = require("form-data");
var http = require(APIHOST.indexOf("localhost") > -1 ? "http" : "https"); var http = require(APIHOST.indexOf("localhost") > -1 ? "http" : "https");
var Path = require("path");
var basename = require("path").basename; var basename = require("path").basename;
var dirname = require("path").dirname; var dirname = require("path").dirname;
var async = require("async");
var verbose = false; var verbose = false;
var force = false; var force = false;
var dryRun = false;
// Set up basic auth for api if needed // Set up basic auth for api if needed
if (BASICAUTH) api.basicAuth = BASICAUTH; if (BASICAUTH) api.basicAuth = BASICAUTH;
@ -70,6 +73,11 @@ define(function(require, exports, module) {
"alias": "f", "alias": "f",
"default": false, "default": false,
"boolean": true "boolean": true
},
"dry-run" : {
"description": "Only build a test version",
"default": false,
"boolean": true
} }
}, },
check: function(argv) { check: function(argv) {
@ -79,6 +87,7 @@ define(function(require, exports, module) {
exec: function(argv) { exec: function(argv) {
verbose = argv["verbose"]; verbose = argv["verbose"];
force = argv["force"]; force = argv["force"];
dryRun = argv["dry-run"];
publish( publish(
argv._[1], argv._[1],
@ -344,7 +353,7 @@ define(function(require, exports, module) {
// Validate plugins // Validate plugins
var plugins = {}; var plugins = {};
fs.readdirSync(cwd).forEach(function(filename) { fs.readdirSync(cwd).forEach(function(filename) {
if (/_test\.js$/.test(filename) || !/\.js$/.test(filename)) return; if (/(__packed__|_test)\.js$/.test(filename) || !/\.js$/.test(filename)) return;
try { try {
var val = fs.readFileSync(cwd + "/" + filename); var val = fs.readFileSync(cwd + "/" + filename);
} catch(e) { } catch(e) {
@ -400,6 +409,8 @@ define(function(require, exports, module) {
fs.writeFile(packagePath, JSON.stringify(json, 1, " "), function(err){ fs.writeFile(packagePath, JSON.stringify(json, 1, " "), function(err){
if (err) return callback(err); if (err) return callback(err);
if (dryRun) return build();
SHELLSCRIPT = SHELLSCRIPT SHELLSCRIPT = SHELLSCRIPT
.replace(/\$1/, packagePath) .replace(/\$1/, packagePath)
.replace(/\$2/, json.version); .replace(/\$2/, json.version);
@ -448,7 +459,7 @@ define(function(require, exports, module) {
enableBrowser: true, enableBrowser: true,
includeConfig: false, includeConfig: false,
noArchitect: true, noArchitect: true,
compress: true, compress: !dryRun,
obfuscate: true, obfuscate: true,
oneLine: true, oneLine: true,
filter: [], filter: [],
@ -458,26 +469,51 @@ define(function(require, exports, module) {
basepath: base, basepath: base,
}, function(e, result) { }, function(e, result) {
var packedFiles = result.sources.map(function(m) { var packedFiles = result.sources.map(function(m) {
return m.file return m.file;
}); });
fs.writeFile("__packed__.js", result.code, "utf8", function(err, result) {
if (err) console.log(err);
zip(packedFiles); async.series([
function(next) {
fs.writeFile("__packed__.js", result.code, "utf8", next);
},
function(next) {
fs.readdir(cwd, function(files) {
if (files.indexOf("themes") != -1) {
}
}); });
},
function(next) {
packedFiles.push(cwd + "/themes");
zip(packedFiles);
}
]);
}); });
} }
function zip(ignore){ function zip(ignore){
zipFilePath = join(os.tmpDir(), json.name + "@" + json.version); zipFilePath = join(os.tmpDir(), json.name + "@" + json.version) + ".tar.gz";
var tarArgs = ["-zcvf", zipFilePath, "."]; var tarArgs = ["-zcvf", zipFilePath, "."];
var c9ignore = process.env.HOME + "/.c9/.c9ignore"; var c9ignore = 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);
} }
ignore.forEach(function(p) {
p = Path.relative(cwd, p);
if (!/^\.+\//.test(p)) {
tarArgs.push("--exclude=./" + p);
}
});
console.log(tarArgs)
proc.spawn(TAR, { proc.spawn(TAR, {
args: tarArgs args: tarArgs,
cwd: cwd
}, function(err, p){ }, function(err, p){
if (err) return callback(err); if (err) return callback(err);
@ -496,6 +532,8 @@ define(function(require, exports, module) {
console.log("Built package", json.name + "@" + json.version); console.log("Built package", json.name + "@" + json.version);
if (dryRun) return callback(1);
upload(); upload();
}); });
}); });

Wyświetl plik

@ -21,7 +21,7 @@ define(function(require, exports, module) {
var module; var module;
var argv; var argv;
process.argv.some(function(n){ process.argv.slice(2).some(function(n){
if (!n.match(/^[-\/]/) && n != "node") { if (!n.match(/^[-\/]/) && n != "node") {
module = n; module = n;
return true; return true;

Wyświetl plik

@ -232,14 +232,18 @@ define(function(require, exports, module) {
abs = true; abs = true;
} }
if (path.lastIndexOf(VFSROOT, 0) === 0) { if (path.toLowerCase().lastIndexOf(VFSROOT.toLowerCase(), 0) === 0) {
path = path.substr(VFSROOT.length); path = path.substr(VFSROOT.length);
abs = false; abs = false;
} }
else if (path.toLowerCase().lastIndexOf(c9.home.toLowerCase(), 0) === 0) {
path = c9.home + "/" + path.substr(c9.home.length);
abs = true;
}
else else
abs = true; abs = true;
if (path[0] != "/") if (path[0] != "/" && !abs)
path = "/" + path; path = "/" + path;
return { return {