kopia lustrzana https://github.com/c9/core
Change to , fix fs module and fix issue with flow. Also now installed is written properly
rodzic
7dd8b141ae
commit
b42d7a62f2
|
@ -1,6 +1,11 @@
|
||||||
module.exports = function(options) {
|
module.exports = function(options) {
|
||||||
|
|
||||||
var EventEmitter = require("events").EventEmitter;
|
var EventEmitter = require("events").EventEmitter;
|
||||||
|
EventEmitter.prototype.emit = new Function("type",
|
||||||
|
EventEmitter.prototype.emit.toString()
|
||||||
|
.replace(/return false/g, "return")
|
||||||
|
.replace(/^.*\n/, "")
|
||||||
|
.replace(/\}$/, ""));
|
||||||
|
|
||||||
var PID = process.env.C9_PID || 526;
|
var PID = process.env.C9_PID || 526;
|
||||||
var APIHOST = process.env.C9_APIHOST || "api.c9.io"; // "api.c9.io";
|
var APIHOST = process.env.C9_APIHOST || "api.c9.io"; // "api.c9.io";
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
"c9.ide.help.support": "#60e88f5680",
|
"c9.ide.help.support": "#60e88f5680",
|
||||||
"c9.ide.imgeditor": "#08bbc53578",
|
"c9.ide.imgeditor": "#08bbc53578",
|
||||||
"c9.ide.immediate": "#6845a93705",
|
"c9.ide.immediate": "#6845a93705",
|
||||||
"c9.ide.installer": "#63c3c021e3",
|
"c9.ide.installer": "#fd20938443",
|
||||||
"c9.ide.mount": "#32e79866ee",
|
"c9.ide.mount": "#32e79866ee",
|
||||||
"c9.ide.navigate": "#64156c7f4a",
|
"c9.ide.navigate": "#64156c7f4a",
|
||||||
"c9.ide.newresource": "#f1f0624768",
|
"c9.ide.newresource": "#f1f0624768",
|
||||||
|
@ -95,6 +95,7 @@
|
||||||
"c9.ide.readonly": "#f6f07bbe42",
|
"c9.ide.readonly": "#f6f07bbe42",
|
||||||
"c9.ide.recentfiles": "#7c099abf40",
|
"c9.ide.recentfiles": "#7c099abf40",
|
||||||
"c9.ide.remote": "#cd45e81d2f",
|
"c9.ide.remote": "#cd45e81d2f",
|
||||||
|
"c9.ide.processlist": "#bc11818bb5",
|
||||||
"c9.ide.run": "#71c5562e42",
|
"c9.ide.run": "#71c5562e42",
|
||||||
"c9.ide.run.build": "#ad45874c88",
|
"c9.ide.run.build": "#ad45874c88",
|
||||||
"c9.ide.run.debug.xdebug": "#b91d23f48b",
|
"c9.ide.run.debug.xdebug": "#b91d23f48b",
|
||||||
|
|
|
@ -59,7 +59,7 @@ define(function(require, exports, module) {
|
||||||
cmd.addCommand({
|
cmd.addCommand({
|
||||||
name: "install",
|
name: "install",
|
||||||
info: " Installs a cloud9 package.",
|
info: " Installs a cloud9 package.",
|
||||||
usage: "[--verbose] [--force] [--global] [--local] [--debug] [--dry-run] <package>[@<version>]",
|
usage: "[--verbose] [--force] [--global] [--local] [--debug] [<package>[@<version>] | . ]",
|
||||||
options: {
|
options: {
|
||||||
"local": {
|
"local": {
|
||||||
description: "",
|
description: "",
|
||||||
|
@ -86,11 +86,6 @@ define(function(require, exports, module) {
|
||||||
"default": false,
|
"default": false,
|
||||||
"boolean": true
|
"boolean": true
|
||||||
},
|
},
|
||||||
"dry-run" : {
|
|
||||||
"description": "Installs current directory as a package",
|
|
||||||
"default": false,
|
|
||||||
"boolean": true
|
|
||||||
},
|
|
||||||
"force" : {
|
"force" : {
|
||||||
"description": "Ignore warnings",
|
"description": "Ignore warnings",
|
||||||
"alias": "f",
|
"alias": "f",
|
||||||
|
@ -117,13 +112,17 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var name = argv._[1];
|
var name = argv._[1];
|
||||||
|
var test = name == ".";
|
||||||
|
if (test)
|
||||||
|
name = require("path").basename(process.cwd());
|
||||||
|
|
||||||
install(
|
install(
|
||||||
name,
|
name,
|
||||||
{
|
{
|
||||||
global: argv.global,
|
global: argv.global,
|
||||||
local: argv.local,
|
local: argv.local,
|
||||||
debug: argv.debug,
|
debug: argv.debug,
|
||||||
dryRun: argv["dry-run"]
|
test: test
|
||||||
},
|
},
|
||||||
function(err, data){
|
function(err, data){
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -203,7 +202,7 @@ define(function(require, exports, module) {
|
||||||
var version = parts[1];
|
var version = parts[1];
|
||||||
var repository;
|
var repository;
|
||||||
|
|
||||||
if ((!version || options.debug) && !options.dryRun) {
|
if ((!version || options.debug) && !options.test) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
console.log("Retrieving package info");
|
console.log("Retrieving package info");
|
||||||
|
|
||||||
|
@ -226,9 +225,14 @@ define(function(require, exports, module) {
|
||||||
function prepareDirectory(callback){
|
function prepareDirectory(callback){
|
||||||
// Create package dir
|
// Create package dir
|
||||||
var packagePath = process.env.HOME + "/.c9/plugins/" + name;
|
var packagePath = process.env.HOME + "/.c9/plugins/" + name;
|
||||||
var exists = fs.existsSync(packagePath) ;
|
var exists = fs.existsSync(packagePath);
|
||||||
|
|
||||||
|
// Ignore when testing and in the same dir
|
||||||
|
if (options.test && process.cwd() == packagePath)
|
||||||
|
exists = false;
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
if (!force)
|
if (!force && !options.test)
|
||||||
return callback(new Error("WARNING: Directory not empty: " + packagePath
|
return callback(new Error("WARNING: Directory not empty: " + packagePath
|
||||||
+ ". Use --force to overwrite."));
|
+ ". Use --force to overwrite."));
|
||||||
|
|
||||||
|
@ -246,7 +250,7 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function installPackage(){
|
function installPackage(){
|
||||||
if (!version && !options.dryRun)
|
if (!version && !options.test)
|
||||||
return callback(new Error("No version found for this package"));
|
return callback(new Error("No version found for this package"));
|
||||||
|
|
||||||
if (options.local) {
|
if (options.local) {
|
||||||
|
@ -292,7 +296,7 @@ define(function(require, exports, module) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.dryRun) {
|
if (options.test) {
|
||||||
try {
|
try {
|
||||||
var json = JSON.parse(fs.readFileSync(join(process.cwd(), "package.json")));
|
var json = JSON.parse(fs.readFileSync(join(process.cwd(), "package.json")));
|
||||||
if (json.private)
|
if (json.private)
|
||||||
|
@ -302,11 +306,20 @@ define(function(require, exports, module) {
|
||||||
return callback(new Error("ERROR: Invalid package: " + e.message));
|
return callback(new Error("ERROR: Invalid package: " + e.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
proc.execFile("bash", { args: ["-c", "cp -a " + join(process.cwd(), "/*") + " " + packagePath] }, function(err){
|
if (process.cwd() == packagePath)
|
||||||
|
installNPM();
|
||||||
|
else {
|
||||||
|
proc.execFile("bash", {
|
||||||
|
args: [
|
||||||
|
"-c", "cp -a " + join(process.cwd(), "/*")
|
||||||
|
+ " " + packagePath
|
||||||
|
]
|
||||||
|
}, function(err){
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
installNPM();
|
installNPM();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -376,7 +389,7 @@ define(function(require, exports, module) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
console.log("Installing debug version of package");
|
console.log("Installing debug version of package");
|
||||||
|
|
||||||
if (!options.dryRun)
|
if (!options.test)
|
||||||
return callback(new Error("Dry run is not supported for debug installations"));
|
return callback(new Error("Dry run is not supported for debug installations"));
|
||||||
|
|
||||||
prepareDirectory(function(err, packagePath){
|
prepareDirectory(function(err, packagePath){
|
||||||
|
@ -434,10 +447,10 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
if (installPath) {
|
if (installPath) {
|
||||||
installerCLI.verbose = verbose;
|
installerCLI.verbose = verbose;
|
||||||
installer.createSession(name, version, require(path + "/" + installPath), function(err){
|
installer.createSession(name, version || "", require(path + "/" + installPath), function(err){
|
||||||
if (err) return callback(new Error("Error Installing Package " + name + "@" + version));
|
if (err) return callback(new Error("Error Installing Package " + name + "@" + version));
|
||||||
installToDatabase();
|
installToDatabase();
|
||||||
});
|
}, force || options.test);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
installToDatabase();
|
installToDatabase();
|
||||||
|
@ -445,8 +458,8 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
||||||
function installToDatabase(){
|
function installToDatabase(){
|
||||||
if (options.dryRun)
|
if (options.test)
|
||||||
return callback(null, { version: "dry-run" });
|
return callback(null, { version: "test" });
|
||||||
|
|
||||||
var endpoint = options.global ? api.user : api.project;
|
var endpoint = options.global ? api.user : api.project;
|
||||||
var url = "install/" + packageName + "/" + version + "?mode=silent";
|
var url = "install/" + packageName + "/" + version + "?mode=silent";
|
||||||
|
|
|
@ -18,7 +18,7 @@ define(function(require, exports, module) {
|
||||||
var vfs = imports.vfs;
|
var vfs = imports.vfs;
|
||||||
var Plugin = imports.Plugin;
|
var Plugin = imports.Plugin;
|
||||||
|
|
||||||
var stream = require("./fs.streams")(vfs, options.base, options.baseProc);
|
var stream = require("./fs.streams")(vfs, options.base, options.baseProc, options.cli);
|
||||||
var xhr = options.cli ? stream : require("./fs.xhr")(vfs.rest);
|
var xhr = options.cli ? stream : require("./fs.xhr")(vfs.rest);
|
||||||
var uCaseFirst = require("c9/string").uCaseFirst;
|
var uCaseFirst = require("c9/string").uCaseFirst;
|
||||||
|
|
||||||
|
@ -54,6 +54,8 @@ define(function(require, exports, module) {
|
||||||
if (loaded) return false;
|
if (loaded) return false;
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
|
if (options.cli)
|
||||||
|
plugin.on("error", function(e){ console.error(e.error); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrap(name, fn) {
|
function wrap(name, fn) {
|
||||||
|
@ -104,6 +106,7 @@ define(function(require, exports, module) {
|
||||||
original_callback.__cb__ = cb;
|
original_callback.__cb__ = cb;
|
||||||
|
|
||||||
var event = { path: path, args: args, fn: fn };
|
var event = { path: path, args: args, fn: fn };
|
||||||
|
|
||||||
if (emit("before" + uCaseFirst(name), event) === false)
|
if (emit("before" + uCaseFirst(name), event) === false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,14 @@ define(function(require, exports, module) {
|
||||||
var Stream = require("stream").Stream;
|
var Stream = require("stream").Stream;
|
||||||
var PATH = require("path");
|
var PATH = require("path");
|
||||||
|
|
||||||
return function(vfs, base, baseProc) {
|
return function(vfs, base, baseProc, cli) {
|
||||||
|
|
||||||
var resolvePath = function(path, basePath) {
|
var resolvePath = function(path, basePath) {
|
||||||
if (path.charAt(0) == "~") return path;
|
if (path.charAt(0) == "~") {
|
||||||
|
if (cli)
|
||||||
|
return process.env.HOME + "/" + path.substr(1);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
if (!basePath)
|
if (!basePath)
|
||||||
basePath = base;
|
basePath = base;
|
||||||
|
@ -20,7 +24,7 @@ return function(vfs, base, baseProc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function readFile(path, encoding, callback) {
|
function readFile(path, encoding, callback) {
|
||||||
if (!callback) {
|
if (!callback || typeof encoding == "function") {
|
||||||
callback = encoding;
|
callback = encoding;
|
||||||
encoding = null;
|
encoding = null;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +58,7 @@ return function(vfs, base, baseProc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeFile(path, data, encoding, callback) {
|
function writeFile(path, data, encoding, callback) {
|
||||||
if (!callback) {
|
if (!callback || typeof encoding == "function") {
|
||||||
callback = encoding;
|
callback = encoding;
|
||||||
encoding = null;
|
encoding = null;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue