kopia lustrzana https://github.com/c9/core
Have Cloud9 Bundles show up in the plugin manager
rodzic
03ef8db11a
commit
4ec0548696
|
@ -124,87 +124,105 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var resourceHolder = new Plugin();
|
var resourceHolder = new Plugin();
|
||||||
// Fetch package.json
|
var resourceVersion = "";
|
||||||
async.parallel([
|
|
||||||
function(next){
|
resourceHolder.freezePublicAPI({
|
||||||
fs.readFile("~/.c9/plugins/" + name + "/package.json", function(err, data){
|
get version(){ return resourceVersion },
|
||||||
if (err)
|
set version(v){ resourceVersion = v; }
|
||||||
return next(err);
|
});
|
||||||
|
|
||||||
try {
|
var inited = false;
|
||||||
var options = JSON.parse(data);
|
resourceHolder.on("load", function(){
|
||||||
if (!options.plugins)
|
async.parallel([
|
||||||
throw new Error("Missing plugins property in package.json of " + name);
|
function(next){
|
||||||
}
|
// Fetch package.json
|
||||||
catch(e){
|
fs.readFile("~/.c9/plugins/" + name + "/package.json", function(err, data){
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
var host = vfs.baseUrl + "/";
|
|
||||||
var base = join(String(c9.projectId),
|
|
||||||
"plugins", auth.accessToken);
|
|
||||||
|
|
||||||
var pathConfig = {};
|
|
||||||
|
|
||||||
pathConfig["plugins/" + name] = host + join(base, name);
|
|
||||||
// Add the plugin to the config
|
|
||||||
Object.keys(options.plugins).forEach(function(path){
|
|
||||||
var pluginPath = name + "/" + path;
|
|
||||||
|
|
||||||
// Watch project path
|
|
||||||
watch("~/.c9/plugins/" + pluginPath);
|
|
||||||
var cfg = options.plugins[path];
|
|
||||||
cfg.packagePath = "plugins/" + name + "/" + path;
|
|
||||||
cfg.staticPrefix = host + join(base, name);
|
|
||||||
cfg.apikey = "0000000000000000000000000000=";
|
|
||||||
|
|
||||||
config.push(cfg);
|
|
||||||
});
|
|
||||||
|
|
||||||
requirejs.config({paths: pathConfig});
|
|
||||||
|
|
||||||
// Start the installer if one is included
|
|
||||||
if (options.installer) {
|
|
||||||
addStaticPlugin("installer", name, options.installer,
|
|
||||||
null, resourceHolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function(next){
|
|
||||||
var path = join(c9.home, "plugins", name);
|
|
||||||
var rePath = new RegExp("^" + util.escapeRegExp(path), "g");
|
|
||||||
find.getFileList({
|
|
||||||
path: path,
|
|
||||||
nocache: true,
|
|
||||||
buffer: true
|
|
||||||
}, function(err, data){
|
|
||||||
if (err)
|
|
||||||
return next(err);
|
|
||||||
|
|
||||||
|
|
||||||
// Remove the base path
|
|
||||||
data = data.replace(rePath, "");
|
|
||||||
|
|
||||||
if (data.indexOf("/__installed__.js") !== -1)
|
|
||||||
return next("installed");
|
|
||||||
|
|
||||||
// Process all the submodules
|
|
||||||
var parallel = processModules(path, data, resourceHolder);
|
|
||||||
async.parallel(parallel, function(err, data){
|
|
||||||
if (err)
|
if (err)
|
||||||
return next(err);
|
return next(err);
|
||||||
|
|
||||||
// Done
|
try {
|
||||||
|
var options = JSON.parse(data);
|
||||||
|
if (!options.plugins)
|
||||||
|
throw new Error("Missing plugins property in package.json of " + name);
|
||||||
|
}
|
||||||
|
catch(e){
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
var host = vfs.baseUrl + "/";
|
||||||
|
var base = join(String(c9.projectId),
|
||||||
|
"plugins", auth.accessToken);
|
||||||
|
|
||||||
|
var pathConfig = {};
|
||||||
|
|
||||||
|
pathConfig["plugins/" + name] = host + join(base, name);
|
||||||
|
// Add the plugin to the config
|
||||||
|
Object.keys(options.plugins).forEach(function(path){
|
||||||
|
var pluginPath = name + "/" + path;
|
||||||
|
|
||||||
|
// Watch project path
|
||||||
|
watch("~/.c9/plugins/" + pluginPath);
|
||||||
|
var cfg = options.plugins[path];
|
||||||
|
cfg.packagePath = "plugins/" + name + "/" + path;
|
||||||
|
cfg.staticPrefix = host + join(base, name);
|
||||||
|
cfg.apikey = "0000000000000000000000000000=";
|
||||||
|
|
||||||
|
config.push(cfg);
|
||||||
|
});
|
||||||
|
|
||||||
|
requirejs.config({paths: pathConfig});
|
||||||
|
|
||||||
|
resourceHolder.version = options.version;
|
||||||
|
|
||||||
|
// Start the installer if one is included
|
||||||
|
if (options.installer) {
|
||||||
|
addStaticPlugin("installer", name, options.installer,
|
||||||
|
null, resourceHolder);
|
||||||
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
}
|
function(next){
|
||||||
], function(err, results){
|
var path = join(c9.home, "plugins", name);
|
||||||
if (err) console.error(err);
|
var rePath = new RegExp("^" + util.escapeRegExp(path), "g");
|
||||||
next();
|
find.getFileList({
|
||||||
|
path: path,
|
||||||
|
nocache: true,
|
||||||
|
buffer: true
|
||||||
|
}, function(err, data){
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
|
|
||||||
|
// Remove the base path
|
||||||
|
data = data.replace(rePath, "");
|
||||||
|
|
||||||
|
if (data.indexOf("/__installed__.js") !== -1)
|
||||||
|
return next("installed");
|
||||||
|
|
||||||
|
// Process all the submodules
|
||||||
|
var parallel = processModules(path, data, resourceHolder);
|
||||||
|
async.parallel(parallel, function(err, data){
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
|
// Done
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
], function(err, results){
|
||||||
|
if (err) console.error(err);
|
||||||
|
|
||||||
|
if (!inited) {
|
||||||
|
next();
|
||||||
|
inited = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
resourceHolder.load("Cloud9 Bundle");
|
||||||
}
|
}
|
||||||
|
|
||||||
function finish(){
|
function finish(){
|
||||||
|
@ -260,7 +278,26 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
function addStaticPlugin(type, pluginName, filename, data, plugin) {
|
function addStaticPlugin(type, pluginName, filename, data, plugin) {
|
||||||
var services = architect.services;
|
var services = architect.services;
|
||||||
var path = "plugins/" + pluginName + "/" + type + "/" + filename.replace(/\.js$/, "");
|
var path = "plugins/" + pluginName + "/"
|
||||||
|
+ (type == "installer" ? "" : type + "/")
|
||||||
|
+ filename.replace(/\.js$/, "");
|
||||||
|
|
||||||
|
if (!services[plugin.name] && type !== "installer") {
|
||||||
|
services[plugin.name] = plugin;
|
||||||
|
architect.lut["~/.c9/plugins/" + pluginName] = {
|
||||||
|
provides: []
|
||||||
|
};
|
||||||
|
architect.pluginToPackage[plugin.name] = {
|
||||||
|
path: plugin.packagePath,
|
||||||
|
package: pluginName,
|
||||||
|
version: plugin.version,
|
||||||
|
isAdditionalMode: true
|
||||||
|
};
|
||||||
|
if (!architect.packages[pluginName])
|
||||||
|
architect.packages[pluginName] = [];
|
||||||
|
architect.packages[pluginName].push(name);
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "builders":
|
case "builders":
|
||||||
data = util.safeParseJson(data, function() {});
|
data = util.safeParseJson(data, function() {});
|
||||||
|
|
|
@ -134,6 +134,10 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
}), 210, plugin);
|
}), 210, plugin);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ext.on("register", function(){
|
||||||
|
reloadModel();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,7 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "http://github.com/c9/newclient.git"
|
"url": "http://github.com/c9/newclient.git"
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {},
|
||||||
"example": {}
|
|
||||||
},
|
|
||||||
"installer": "install.js",
|
"installer": "install.js",
|
||||||
"categories": [
|
"categories": [
|
||||||
"misc"
|
"misc"
|
||||||
|
|
Ładowanie…
Reference in New Issue