my first question here :)
Iam trying to develop a Brackets Extension that would sync all installed extensions across other PCs. Point is, that I can't get info like version, url of the origin repo etc.
I was using ExtensionManager api, but extension field provides only info like following(ex. data for "JSLint" extension:
{"installInfo":
{"metadata":
{"name":"JSLint",
"title":"JSLint"},
"path":"C:/(...)/default/JSLint",
"locationType":"default",
"status":"enabled"}
}
I guess that there must be some model extending function, that would attach information I seek.(Brackets for sure has it hidden somewhere, cause native extension manager has all this crucial data - debugging didn't help too much :( )
Ok, I found out a solution.
ExtensionsManager.downloadRegistry().done(function () {
for (var k in ExtensionsManager.extensions) {
if (ExtensionsManager.extensions[k].installInfo && ExtensionsManager.extensions[k].registryInfo) {
FileSystem.resolve(ExtensionsManager.extensions[k].installInfo.path + "/package.json",
function (err, data) {
if (!err) {
FileUtils.readAsText(data).done(function (dt) {
var lt = JSON.parse(dt);
/** -----> **lt** <--------- **/
// all info about extension is in lt variable
});
}
});
}
}
})
some explanations:
ExtensionManager is responsible for extensions and information about them, it has a method called downloadRegistry. This method simply populates registry info - intalled addons, addons available to download, native extensions etc.
Method returns a promise, which after resolving, fills extensions attribute of ExtensionsManager, with data required to next step, including names and paths to extensions.
Important part here is, that we have to check if installInfo and registryInfo attributes are present. Install info extists if addon is installed, registryInfo if its not a native, but downloaded module.
Under installInfo.path we can find path to extension folder, by adding "/package.json", we can get main manifest file, with all the extension information - version, repository etc.