kopia lustrzana https://github.com/c9/core
Loads the package browser in the IDE and many tweaks
rodzic
9264fd8310
commit
1a5dbfb5ec
|
@ -13,6 +13,8 @@ define(function(require, exports, module) {
|
||||||
var auth = imports.auth;
|
var auth = imports.auth;
|
||||||
var pubsub = imports.pubsub;
|
var pubsub = imports.pubsub;
|
||||||
|
|
||||||
|
var async = require("async");
|
||||||
|
|
||||||
var escapeShell = util.escapeShell;
|
var escapeShell = util.escapeShell;
|
||||||
var updates = options.updates;
|
var updates = options.updates;
|
||||||
var architect;
|
var architect;
|
||||||
|
@ -20,11 +22,10 @@ define(function(require, exports, module) {
|
||||||
/***** Initialization *****/
|
/***** Initialization *****/
|
||||||
|
|
||||||
var plugin = new Plugin("Ajax.org", main.consumes);
|
var plugin = new Plugin("Ajax.org", main.consumes);
|
||||||
// var emit = plugin.getEmitter();
|
var emit = plugin.getEmitter();
|
||||||
|
|
||||||
var HASSDK = c9.location.indexOf("sdk=0") === -1;
|
var HASSDK = c9.location.indexOf("sdk=0") === -1;
|
||||||
|
|
||||||
var queue = [];
|
|
||||||
var installing;
|
var installing;
|
||||||
|
|
||||||
var loaded = false;
|
var loaded = false;
|
||||||
|
@ -69,38 +70,40 @@ define(function(require, exports, module) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!config.length) return;
|
if (!config.length)
|
||||||
|
return callback && callback();
|
||||||
|
|
||||||
var found = {};
|
// Only run one installer at a time
|
||||||
config.forEach(function(item){
|
if (installing) {
|
||||||
if (!found[item.packageName])
|
return plugin.once("finished", function(){
|
||||||
found[item.packageName] = true;
|
installPlugins(config, callback);
|
||||||
else return;
|
});
|
||||||
|
|
||||||
queue.push({ name: item.packageName, version: item.version });
|
|
||||||
|
|
||||||
if (installing)
|
|
||||||
installing.push(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (installing) return;
|
|
||||||
installing = config;
|
|
||||||
|
|
||||||
var i = 0;
|
|
||||||
function next(err){
|
|
||||||
if (err) console.log(err);
|
|
||||||
|
|
||||||
if (!queue[i]) {
|
|
||||||
installing = false; queue = [];
|
|
||||||
architect.loadAdditionalPlugins(config, callback);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
installPlugin(queue[i].name, queue[i].version, next);
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
installing = true;
|
||||||
|
|
||||||
|
var found = {}, packages = [];
|
||||||
|
config.forEach(function(item){
|
||||||
|
if (!found[item.name])
|
||||||
|
found[item.name] = true;
|
||||||
|
else return;
|
||||||
|
|
||||||
|
packages.push({ name: item.name, version: item.version });
|
||||||
|
});
|
||||||
|
|
||||||
|
async.eachSeries(packages, function(pkg, next){
|
||||||
|
installPlugin(pkg.name, pkg.version, next);
|
||||||
|
}, function(err){
|
||||||
|
installing = false;
|
||||||
|
emit("finished");
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
console.error(err.message);
|
||||||
|
return callback && callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
architect.loadAdditionalPlugins(config, callback);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function installPlugin(name, version, callback){
|
function installPlugin(name, version, callback){
|
||||||
|
@ -109,16 +112,17 @@ define(function(require, exports, module) {
|
||||||
}, function(err, process){
|
}, function(err, process){
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
|
var output = "";
|
||||||
process.stdout.on("data", function(c){
|
process.stdout.on("data", function(c){
|
||||||
console.log(c);
|
output += c;
|
||||||
});
|
});
|
||||||
process.stderr.on("data", function(c){
|
process.stderr.on("data", function(c){
|
||||||
console.error(c);
|
output += c;
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on("exit", function(code){
|
process.on("exit", function(code){
|
||||||
if (code) {
|
if (code) {
|
||||||
var error = new Error(err);
|
var error = new Error(output);
|
||||||
error.code = code;
|
error.code = code;
|
||||||
return callback(error);
|
return callback(error);
|
||||||
}
|
}
|
||||||
|
@ -160,7 +164,6 @@ define(function(require, exports, module) {
|
||||||
plugin.on("unload", function() {
|
plugin.on("unload", function() {
|
||||||
loaded = false;
|
loaded = false;
|
||||||
installing = false;
|
installing = false;
|
||||||
queue = [];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/***** Register and define API *****/
|
/***** Register and define API *****/
|
||||||
|
|
|
@ -137,15 +137,15 @@ define(function(require, exports, module) {
|
||||||
tab = e.tab;
|
tab = e.tab;
|
||||||
var htmlNode = e.htmlNode;
|
var htmlNode = e.htmlNode;
|
||||||
|
|
||||||
|
htmlNode.style.paddingTop = 0;
|
||||||
|
|
||||||
iframe = htmlNode.appendChild(document.createElement("iframe"));
|
iframe = htmlNode.appendChild(document.createElement("iframe"));
|
||||||
iframe.style.position = "absolute";
|
|
||||||
iframe.style.top = 0;
|
|
||||||
iframe.style.left = 0;
|
|
||||||
iframe.style.width = "100%";
|
iframe.style.width = "100%";
|
||||||
iframe.style.height = "100%";
|
iframe.style.height = "100%";
|
||||||
iframe.style.border = 0;
|
iframe.style.border = 0;
|
||||||
|
iframe.style.backgroundColor = "#fbfbfb";
|
||||||
|
|
||||||
iframe.src = location.origin + "/profile/packages?nobar=1&pid=" + c9.projectId;
|
iframe.src = location.origin.replace("ide.", "") + "/profile/packages?nobar=1&pid=" + c9.projectId;
|
||||||
});
|
});
|
||||||
|
|
||||||
plugin.on("getState", function(e) {
|
plugin.on("getState", function(e) {
|
||||||
|
@ -160,7 +160,7 @@ define(function(require, exports, module) {
|
||||||
doc.title = "Package Browser";
|
doc.title = "Package Browser";
|
||||||
|
|
||||||
function setTheme(){
|
function setTheme(){
|
||||||
var bg = "#ededed";
|
var bg = "#fbfbfb";
|
||||||
doc.tab.backgroundColor = bg;
|
doc.tab.backgroundColor = bg;
|
||||||
|
|
||||||
if (util.shadeColor(bg, 1).isLight)
|
if (util.shadeColor(bg, 1).isLight)
|
||||||
|
@ -174,14 +174,7 @@ define(function(require, exports, module) {
|
||||||
});
|
});
|
||||||
|
|
||||||
plugin.on("documentActivate", function(e) {
|
plugin.on("documentActivate", function(e) {
|
||||||
e.doc.tab.on("unload", function(){
|
|
||||||
if (parent.parentNode == tab)
|
|
||||||
tab.removeChild(parent);
|
|
||||||
});
|
|
||||||
|
|
||||||
tab.appendChild(parent);
|
|
||||||
|
|
||||||
emit("show");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/***** Register and define API *****/
|
/***** Register and define API *****/
|
||||||
|
|
Ładowanie…
Reference in New Issue