kopia lustrzana https://github.com/c9/core
fix c9 install
rodzic
7b69f069dc
commit
a34c7e88bf
|
@ -81,7 +81,7 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
check: function(argv) {
|
check: function(argv) {
|
||||||
if (argv._.length < 2 && !argv["newversion"])
|
if (argv._.length < 2 && !argv["newversion"] && !argv["dry-run"])
|
||||||
throw new Error("Missing version");
|
throw new Error("Missing version");
|
||||||
},
|
},
|
||||||
exec: function(argv) {
|
exec: function(argv) {
|
||||||
|
@ -100,7 +100,7 @@ define(function(require, exports, module) {
|
||||||
console.error("\nTry running with --verbose flag for more information");
|
console.error("\nTry running with --verbose flag for more information");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
else {
|
else if (!dryRun) {
|
||||||
console.log("Succesfully published version", data.version);
|
console.log("Succesfully published version", data.version);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,55 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cmd.addCommand({
|
||||||
|
name: "build",
|
||||||
|
info: " Builds development version of package to load in non-debug mode.",
|
||||||
|
usage: "[--devel]",
|
||||||
|
options: {
|
||||||
|
"devel" : {
|
||||||
|
"description": "",
|
||||||
|
"alias": "d",
|
||||||
|
"default": false,
|
||||||
|
"boolean": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
exec: function(argv) {
|
||||||
|
if (argv["devel"]) {
|
||||||
|
var code = function(argument) {
|
||||||
|
/* TODO explain */
|
||||||
|
define("plugins/PACKAGE_NAME/__installed__", [],[
|
||||||
|
"plugins/PACKAGE_NAME/__debug__"
|
||||||
|
]);
|
||||||
|
define("plugins/PACKAGE_NAME/__debug__",[], function(require, exports, module) {
|
||||||
|
main.consumes = ["plugin.debug"];
|
||||||
|
main.provides = [];
|
||||||
|
return main;
|
||||||
|
|
||||||
|
function main(options, imports, register) {
|
||||||
|
var debug = imports["plugin.debug"];
|
||||||
|
debug.loadPackage("PACKAGE_NAME");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}.toString();
|
||||||
|
var cwd = process.cwd();
|
||||||
|
var packageName = basename(cwd);
|
||||||
|
var indent = code.match(/\n\r?(\s*)/)[1].length;
|
||||||
|
code = code
|
||||||
|
.replace(/\r/g, "")
|
||||||
|
.replace(new RegExp("^ {" + indent + "}", "gm"), "")
|
||||||
|
.replace(/^.*?{|}$/g, "")
|
||||||
|
.trim()
|
||||||
|
.replace(/PACKAGE_NAME/g, packageName);
|
||||||
|
|
||||||
|
fs.writeFileSync(cwd + "/__installed__.js", code, "utf8")
|
||||||
|
} else {
|
||||||
|
dryRun = true
|
||||||
|
publish({local: true}, function(err, data){});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
cmd.addCommand({
|
cmd.addCommand({
|
||||||
name: "unpublish",
|
name: "unpublish",
|
||||||
info: "Disables a cloud9 package.",
|
info: "Disables a cloud9 package.",
|
||||||
|
@ -316,7 +365,11 @@ define(function(require, exports, module) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function publish(version, callback) {
|
function publish(options, callback) {
|
||||||
|
if (typeof options != "object")
|
||||||
|
options = {version: options};
|
||||||
|
|
||||||
|
var version = options.version;
|
||||||
var cwd = process.cwd();
|
var cwd = process.cwd();
|
||||||
var packagePath = cwd + "/package.json";
|
var packagePath = cwd + "/package.json";
|
||||||
fs.readFile(packagePath, function(err, data){
|
fs.readFile(packagePath, function(err, data){
|
||||||
|
@ -381,31 +434,35 @@ define(function(require, exports, module) {
|
||||||
if (failed)
|
if (failed)
|
||||||
return callback(new Error());
|
return callback(new Error());
|
||||||
|
|
||||||
if (warned && !force)
|
if (warned && !force && !dryRun)
|
||||||
return callback(new Error("Use --force to ignore these warnings."));
|
return callback(new Error("Use --force to ignore these warnings."));
|
||||||
|
|
||||||
var v = (json.version || "0.0.1").split(".");
|
if (!dryRun) {
|
||||||
|
var v = (json.version || "0.0.1").split(".");
|
||||||
|
// Update the version field in the package.json file
|
||||||
|
if (version == "major") {
|
||||||
|
v[0]++;
|
||||||
|
v[1] = 0;
|
||||||
|
v[2] = 0;
|
||||||
|
}
|
||||||
|
else if (version == "minor") {
|
||||||
|
v[1]++;
|
||||||
|
v[2] = 0;
|
||||||
|
}
|
||||||
|
else if (version == "patch" || version == "build") v[2]++;
|
||||||
|
else if (version.match(/^\d+\.\d+\.\d+$/))
|
||||||
|
v = version.split(".");
|
||||||
|
else
|
||||||
|
return callback(new Error("Invalid version. Semver required: " + version));
|
||||||
|
|
||||||
// Update the version field in the package.json file
|
json.version = v.join(".");
|
||||||
if (version == "major") {
|
|
||||||
v[0]++;
|
|
||||||
v[1] = 0;
|
|
||||||
v[2] = 0;
|
|
||||||
}
|
}
|
||||||
else if (version == "minor") {
|
|
||||||
v[1]++;
|
|
||||||
v[2] = 0;
|
|
||||||
}
|
|
||||||
else if (version == "patch" || version == "build") v[2]++;
|
|
||||||
else if (version.match(/^\d+\.\d+\.\d+$/))
|
|
||||||
v = version.split(".");
|
|
||||||
else
|
|
||||||
return callback(new Error("Invalid version. Semver required: " + version));
|
|
||||||
|
|
||||||
json.version = v.join(".");
|
if (dryRun)
|
||||||
|
return build();
|
||||||
|
|
||||||
// Write the package.json file
|
// Write the package.json file
|
||||||
fs.writeFile(packagePath, JSON.stringify(json, 1, " "), function(err){
|
fs.writeFile(packagePath, JSON.stringify(json, null, " "), function(err){
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
if (dryRun) return build();
|
if (dryRun) return build();
|
||||||
|
@ -414,6 +471,7 @@ define(function(require, exports, module) {
|
||||||
.replace(/\$1/, packagePath)
|
.replace(/\$1/, packagePath)
|
||||||
.replace(/\$2/, json.version);
|
.replace(/\$2/, json.version);
|
||||||
|
|
||||||
|
// commit
|
||||||
proc.spawn("bash", {
|
proc.spawn("bash", {
|
||||||
args: ["-c", SHELLSCRIPT]
|
args: ["-c", SHELLSCRIPT]
|
||||||
}, function(err, p){
|
}, function(err, p){
|
||||||
|
@ -550,6 +608,8 @@ define(function(require, exports, module) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packedFiles.push(cwd + "/__installed__.js");
|
||||||
|
|
||||||
if (json.installer) {
|
if (json.installer) {
|
||||||
var path = join(cwd, json.installer);
|
var path = join(cwd, json.installer);
|
||||||
var installerCode = fs.readFileSync(path, "utf8");
|
var installerCode = fs.readFileSync(path, "utf8");
|
||||||
|
@ -658,22 +718,19 @@ define(function(require, exports, module) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
fs.writeFile("__packed__.js", result.code, "utf8", next);
|
var filename = options.local ? "__installed__.js" : "__packed__.js";
|
||||||
|
fs.writeFile(filename, result.code, "utf8", next);
|
||||||
},
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
// console.log(packedFiles)
|
// console.log(packedFiles)
|
||||||
|
if (options.local)
|
||||||
|
return callback();
|
||||||
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", normalizePath(zipFilePath), "."];
|
var tarArgs = ["-zcvf", normalizePath(zipFilePath), "."];
|
||||||
|
@ -709,9 +766,10 @@ define(function(require, exports, module) {
|
||||||
if (code !== 0)
|
if (code !== 0)
|
||||||
return callback(new Error("ERROR: Could not package directory"));
|
return callback(new Error("ERROR: Could not package directory"));
|
||||||
|
|
||||||
console.log("Built package", json.name + "@" + json.version);
|
console.log("Built package", json.name + "@" + json.version +
|
||||||
|
(dryRun ? " at " + zipFilePath : ""));
|
||||||
|
|
||||||
if (dryRun) return callback(1);
|
if (dryRun) return callback();
|
||||||
|
|
||||||
upload();
|
upload();
|
||||||
});
|
});
|
||||||
|
@ -934,13 +992,15 @@ define(function(require, exports, module) {
|
||||||
request.on('response', function(res) {
|
request.on('response', function(res) {
|
||||||
if (res.statusCode != 200)
|
if (res.statusCode != 200)
|
||||||
return callback(new Error("Unknown Error:" + res.statusCode));
|
return callback(new Error("Unknown Error:" + res.statusCode));
|
||||||
|
});
|
||||||
|
|
||||||
|
file.on('finish', function(err) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
console.log("Unpacking", gzPath, "to", packagePath);
|
console.log("Unpacking", gzPath, "to", packagePath);
|
||||||
|
|
||||||
// Untargz package
|
// Untargz package
|
||||||
proc.spawn(TAR, {
|
proc.spawn(TAR, {
|
||||||
args: ["-C", packagePath, "-zxvf", gzPath]
|
args: ["-C", normalizePath(packagePath), "-zxvf", normalizePath(gzPath)]
|
||||||
}, function(err, p){
|
}, function(err, p){
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
|
@ -1109,6 +1169,12 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizePath(p) {
|
||||||
|
if (process.platform == "win32")
|
||||||
|
p = p.replace(/\\/g, "/").replace(/^(\w):/, "/$1");
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
/***** Lifecycle *****/
|
/***** Lifecycle *****/
|
||||||
|
|
||||||
plugin.on("load", function(){
|
plugin.on("load", function(){
|
||||||
|
|
Ładowanie…
Reference in New Issue