kopia lustrzana https://github.com/c9/core
commit
9fea731052
|
@ -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(/^[^{]*{/, "")
|
||||||
|
.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";
|
||||||
|
|
|
@ -157,8 +157,9 @@ function build(base, args, cb) {
|
||||||
plugin.packagePath_orig = plugin.packagePath;
|
plugin.packagePath_orig = plugin.packagePath;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
server(args, null, function(err, config) {
|
server(args, null, function(err, config, configPath) {
|
||||||
addModule("server.js");
|
addModule("server.js");
|
||||||
|
addModule(configPath);
|
||||||
config.forEach(function(plugin) {
|
config.forEach(function(plugin) {
|
||||||
if (plugin.packagePath)
|
if (plugin.packagePath)
|
||||||
addModule(relPath(plugin.packagePath));
|
addModule(relPath(plugin.packagePath));
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"acorn": ">=0.11.0",
|
"acorn": ">=0.11.0",
|
||||||
"amd-loader": "~0.0.5",
|
"amd-loader": "",
|
||||||
"async": "^0.9.0",
|
"async": "^0.9.0",
|
||||||
"base64id": "~0.1.0",
|
"base64id": "~0.1.0",
|
||||||
"c9": "",
|
"c9": "",
|
||||||
|
@ -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": "#0b915c68e9",
|
"c9.ide.installer": "#80d050b6de",
|
||||||
"c9.ide.mount": "#32e79866ee",
|
"c9.ide.mount": "#32e79866ee",
|
||||||
"c9.ide.navigate": "#64156c7f4a",
|
"c9.ide.navigate": "#64156c7f4a",
|
||||||
"c9.ide.newresource": "#f1f0624768",
|
"c9.ide.newresource": "#f1f0624768",
|
||||||
|
|
|
@ -15,8 +15,9 @@ define(function(require, exports, module) {
|
||||||
var installer = imports.installer;
|
var installer = imports.installer;
|
||||||
var installerCLI = imports["installer.cli"];
|
var installerCLI = imports["installer.cli"];
|
||||||
|
|
||||||
|
var dirname = require("path").dirname;
|
||||||
|
|
||||||
var TEST_MODE = !!process.env.C9_TEST_MODE;
|
var TEST_MODE = !!process.env.C9_TEST_MODE;
|
||||||
var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh").toString("utf8");
|
|
||||||
var TAR = "tar";
|
var TAR = "tar";
|
||||||
var APIHOST = options.apiHost;
|
var APIHOST = options.apiHost;
|
||||||
var BASICAUTH = process.env.C9_TEST_AUTH;
|
var BASICAUTH = process.env.C9_TEST_AUTH;
|
||||||
|
@ -59,7 +60,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 +87,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 +113,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 +203,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 +226,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 +251,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 +297,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 +307,17 @@ 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)
|
||||||
if (err) return callback(err);
|
|
||||||
|
|
||||||
installNPM();
|
installNPM();
|
||||||
});
|
else {
|
||||||
|
proc.execFile("cp", {
|
||||||
|
args: ["-R", process.cwd(), dirname(packagePath)]
|
||||||
|
}, function(err){
|
||||||
|
if (err) return callback(err);
|
||||||
|
|
||||||
|
installNPM();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -376,7 +387,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){
|
||||||
|
@ -414,18 +425,15 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function installFull(){
|
function installFull(){
|
||||||
if (verbose)
|
|
||||||
console.log("Notifying c9.io that packages needs to be installed");
|
|
||||||
|
|
||||||
// Install Locally
|
// Install Locally
|
||||||
options.local = true;
|
options.local = true;
|
||||||
install(name + "@" + version, options, function(err){
|
install(name + "@" + version, options, function(err){
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
var path = process.env.HOME + "/.c9/plugins/" + name;
|
var path = process.env.HOME + "/.c9/plugins/" + name;
|
||||||
fs.readFile(path + "/package.json", "utf8", function(err, data){
|
fs.readFile(path + "/package.json", "utf8", function(err, data){
|
||||||
if (err) return callback(new Error("Package.json not found in " + path));
|
if (err) return callback(new Error("Package.json not found in " + path));
|
||||||
|
|
||||||
var installPath;
|
var installPath;
|
||||||
try { installPath = JSON.parse(data).installer; }
|
try { installPath = JSON.parse(data).installer; }
|
||||||
catch(e){
|
catch(e){
|
||||||
|
@ -434,10 +442,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 +453,11 @@ 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" });
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
console.log("Notifying c9.io that packages needs to be installed");
|
||||||
|
|
||||||
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";
|
||||||
|
|
|
@ -11,7 +11,7 @@ define(function(require, exports, module) {
|
||||||
var api = imports.api;
|
var api = imports.api;
|
||||||
|
|
||||||
var TEST_MODE = !!process.env.C9_TEST_MODE;
|
var TEST_MODE = !!process.env.C9_TEST_MODE;
|
||||||
var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh").toString("utf8");
|
var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh");
|
||||||
var TAR = "tar";
|
var TAR = "tar";
|
||||||
var APIHOST = options.apiHost;
|
var APIHOST = options.apiHost;
|
||||||
var BASICAUTH = process.env.C9_TEST_AUTH;
|
var BASICAUTH = process.env.C9_TEST_AUTH;
|
||||||
|
@ -312,7 +312,7 @@ define(function(require, exports, module) {
|
||||||
// Write the package.json file
|
// Write the package.json file
|
||||||
var indent = data.match(/{\n\r?^ {4}"/) ? 4 : 2;
|
var indent = data.match(/{\n\r?^ {4}"/) ? 4 : 2;
|
||||||
var newData = JSON.stringify(json, null, indent);
|
var newData = JSON.stringify(json, null, indent);
|
||||||
fs.writeFile(cwd + "/.c9/.build/pacage.json", newData, function(){
|
fs.writeFile(cwd + "/.c9/.build/package.json", newData, function(){
|
||||||
if (dryRun)
|
if (dryRun)
|
||||||
return next(); // if dry-run is passed only update path in .build
|
return next(); // if dry-run is passed only update path in .build
|
||||||
fs.writeFile(packagePath, newData, function(err){
|
fs.writeFile(packagePath, newData, function(err){
|
||||||
|
@ -446,7 +446,7 @@ define(function(require, exports, module) {
|
||||||
extraCode.push({
|
extraCode.push({
|
||||||
type: "installer",
|
type: "installer",
|
||||||
filename: json.installer,
|
filename: json.installer,
|
||||||
data: version
|
data: installerVersion
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,7 +820,7 @@ define(function(require, exports, module) {
|
||||||
force = false;
|
force = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
/***** Register and definfe API *****/
|
/***** Register and define API *****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -29,11 +29,6 @@ define(function(require, exports, module) {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!commands[module] && process.argv.length > 2 && process.argv.every(function(n){ return !n.match(/^--/)})) {
|
|
||||||
process.argv.splice(2, 0, "open");
|
|
||||||
module = "open";
|
|
||||||
}
|
|
||||||
|
|
||||||
optimist = require('optimist');
|
optimist = require('optimist');
|
||||||
|
|
||||||
if (!module || !commands[module]) {
|
if (!module || !commands[module]) {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +32,7 @@ return function(vfs, base, baseProc) {
|
||||||
var options = {};
|
var options = {};
|
||||||
if (encoding)
|
if (encoding)
|
||||||
options.encoding = encoding;
|
options.encoding = encoding;
|
||||||
|
|
||||||
vfs.readfile(resolvePath(path), options, function(err, meta) {
|
vfs.readfile(resolvePath(path), options, function(err, meta) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ function start(configName, options, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv._getConfig)
|
if (argv._getConfig)
|
||||||
return callback && callback(null, config);
|
return callback && callback(null, config, configPath);
|
||||||
|
|
||||||
var app = architect.createApp(config, function (err, app) {
|
var app = architect.createApp(config, function (err, app) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Ładowanie…
Reference in New Issue