kopia lustrzana https://github.com/c9/core
fix loading plugins from datebase
rodzic
37894f155c
commit
f331ae568b
|
@ -70,7 +70,7 @@ define(function(require, exports, module) {
|
||||||
}, function(err, packages) {
|
}, function(err, packages) {
|
||||||
if (err && err.code === "EDISCONNECT") {
|
if (err && err.code === "EDISCONNECT") {
|
||||||
c9.once("connect", function() {
|
c9.once("connect", function() {
|
||||||
loadPluginsFromDisk(callback);
|
listAllPackages(callback);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,6 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
async.map(stats, function(stat, done) {
|
async.map(stats, function(stat, done) {
|
||||||
// check for folder or symlink with folder target
|
// check for folder or symlink with folder target
|
||||||
|
|
||||||
if (stat.mime !== "inode/directory"
|
if (stat.mime !== "inode/directory"
|
||||||
&& (stat.mime === "inode/symlink" && stat.linkStat.mime !== "inode/directory")
|
&& (stat.mime === "inode/symlink" && stat.linkStat.mime !== "inode/directory")
|
||||||
) {
|
) {
|
||||||
|
@ -128,13 +127,11 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check folers not prefixed with [._]
|
// check folers not prefixed with [._]
|
||||||
|
|
||||||
if (stat.name[0] === "." || stat.name[0] === "_") {
|
if (stat.name[0] === "." || stat.name[0] === "_") {
|
||||||
return done();
|
return done();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check and load package.json
|
// check and load package.json
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
name: stat.name,
|
name: stat.name,
|
||||||
path: absolutePath([ dirPath, stat.name ].join("/")),
|
path: absolutePath([ dirPath, stat.name ].join("/")),
|
||||||
|
@ -216,17 +213,14 @@ define(function(require, exports, module) {
|
||||||
*/
|
*/
|
||||||
function loadPackage(config, callback) {
|
function loadPackage(config, callback) {
|
||||||
loadPackageInstalledJs(config, function(err, installed) {
|
loadPackageInstalledJs(config, function(err, installed) {
|
||||||
var plugins;
|
var plugins = installed;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
plugins = _.map(config.metadata.plugins, function(value, key) {
|
plugins = _.map(config.metadata.plugins, function(value, key) {
|
||||||
return [ "plugins", config.name, key ].join("/");
|
return [ "plugins", config.name, key ].join("/");
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
plugins = installed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var architectConfig = installed.map(function(plugin) {
|
var architectConfig = plugins.map(function(plugin) {
|
||||||
if (typeof plugin == "string")
|
if (typeof plugin == "string")
|
||||||
plugin = { packagePath: plugin };
|
plugin = { packagePath: plugin };
|
||||||
|
|
||||||
|
@ -256,36 +250,41 @@ define(function(require, exports, module) {
|
||||||
listAllPackages(function(err, resolved) {
|
listAllPackages(function(err, resolved) {
|
||||||
if (err) return console.error(err);
|
if (err) return console.error(err);
|
||||||
|
|
||||||
|
var extraPackages = {};
|
||||||
|
// convert old format from db to the new one
|
||||||
|
loaderConfig.forEach(function(p) {
|
||||||
|
if (!extraPackages[p.packageName]) {
|
||||||
|
var path = "plugins/" + p.packageName;
|
||||||
|
extraPackages[path] = {
|
||||||
|
apiKey: p.apiKey,
|
||||||
|
packagePath: path,
|
||||||
|
version: p.version,
|
||||||
|
name: p.packageName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
if (!loadFromDisk) {
|
if (!loadFromDisk) {
|
||||||
// filter packages by config instead of loading
|
// filter packages by config instead of loading
|
||||||
// everything from disk
|
// everything from disk
|
||||||
|
|
||||||
resolved = resolved.filter(function(config) {
|
resolved = resolved.filter(function(config) {
|
||||||
var extraConfig = _.find(loaderConfig, { packagePath: config.packagePath });
|
if (extraPackages[config.packagePath])
|
||||||
|
return true;
|
||||||
if (!extraConfig) {
|
|
||||||
console.warn("[c9.ide.loader] Not loading package "
|
console.warn("[c9.ide.loader] Not loading package "
|
||||||
+ config.path + " because it is not installed, "
|
+ config.path + " because it is not installed, "
|
||||||
+ "according to the database");
|
+ "according to the database");
|
||||||
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
config.apiKey = extraConfig.apiKey;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
resolved.filter(function(config) {
|
||||||
loaderConfig.forEach(function(extraConfig) {
|
if (extraPackages[config.packagePath])
|
||||||
// warn about missing packages which are supposed to be installed
|
delete extraPackages[config.packagePath];
|
||||||
|
});
|
||||||
if (!_.find(resolved, { packagePath: extraConfig.packagePath })) {
|
Object.keys(extraPackages).forEach(function(extraConfig) {
|
||||||
console.warn("[c9.ide.loader] Package "
|
console.warn("[c9.ide.loader] Package "
|
||||||
+ extraConfig.packagePath + " should be installed, according "
|
+ extraConfig.packagePath + " should be installed, according "
|
||||||
+ "to the database, but was not found on the filesystem. "
|
+ "to the database, but was not found on the filesystem. "
|
||||||
+ "Try reinstalling it.");
|
+ "Try reinstalling it.");
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
names = _.pluck(resolved, "name");
|
names = _.pluck(resolved, "name");
|
||||||
|
@ -307,7 +306,6 @@ define(function(require, exports, module) {
|
||||||
load();
|
load();
|
||||||
});
|
});
|
||||||
plugin.on("unload", function() {
|
plugin.on("unload", function() {
|
||||||
loaded = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/***** Register and define API *****/
|
/***** Register and define API *****/
|
||||||
|
|
Ładowanie…
Reference in New Issue