mirror of https://github.com/embarklabs/embark.git
support versioning ipfs-api
This commit is contained in:
parent
59642b4160
commit
82681fec8f
|
@ -115,6 +115,9 @@ Config.prototype.loadContractsConfigFile = function() {
|
|||
Config.prototype.loadStorageConfigFile = function() {
|
||||
var configObject = {
|
||||
"default": {
|
||||
"versions": {
|
||||
"ipfs-api": "17.2.4"
|
||||
},
|
||||
"enabled": true,
|
||||
"available_providers": ["ipfs"],
|
||||
"ipfs_bin": "ipfs",
|
||||
|
|
|
@ -21,6 +21,7 @@ var Plugin = function(options) {
|
|||
this.serviceChecks = [];
|
||||
this.pluginTypes = [];
|
||||
this.uploadCmds = [];
|
||||
this.imports = [];
|
||||
this.embarkjs_code = [];
|
||||
this.embarkjs_init_code = {};
|
||||
this.logger = options.logger;
|
||||
|
@ -158,6 +159,11 @@ Plugin.prototype.addProviderInit = function(providerType, code, initCondition) {
|
|||
this.pluginTypes.push('initCode');
|
||||
};
|
||||
|
||||
Plugin.prototype.registerImportFile = function(importName, importLocation) {
|
||||
this.imports.push([importName, importLocation]);
|
||||
this.pluginTypes.push('imports');
|
||||
};
|
||||
|
||||
Plugin.prototype.runFilePipeline = function() {
|
||||
var self = this;
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class IPFS {
|
|||
}
|
||||
|
||||
addIPFSToEmbarkJS() {
|
||||
const self = this;
|
||||
// TODO: make this a shouldAdd condition
|
||||
if (this.storageConfig === {}) {
|
||||
return;
|
||||
|
@ -75,6 +76,15 @@ class IPFS {
|
|||
return;
|
||||
}
|
||||
|
||||
self.events.request("version:get:ipfs-api", function(ipfsApiVersion) {
|
||||
let currentIpfsApiVersion = require('../../../package.json').dependencies["ipfs-api"];
|
||||
if (ipfsApiVersion !== currentIpfsApiVersion) {
|
||||
self.events.request("version:getPackageLocation", "ipfs-api", ipfsApiVersion, function(err, location) {
|
||||
self.embark.registerImportFile("ipfs-api", utils.joinPath(process.env.PWD, location));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let code = "";
|
||||
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
|
||||
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS);";
|
||||
|
|
|
@ -39,9 +39,10 @@ class Pipeline {
|
|||
importsList["Embark/EmbarkJS"] = utils.joinPath(fs.dappPath(), ".embark", 'embark.js');
|
||||
importsList["Embark/web3"] = utils.joinPath(fs.dappPath(), ".embark", 'web3_instance.js');
|
||||
|
||||
//importsList["ipfs-api"] = utils.joinPath(fs.dappPath(), ".embark", 'ipfs_api.js');
|
||||
|
||||
//importsList["Embark/libs/IpfsApi"] = fs.embarkPath('js/ipfs.js');
|
||||
self.plugins.getPluginsProperty('imports', 'imports').forEach(function (importObject) {
|
||||
let [importName, importLocation] = importObject;
|
||||
importsList[importName] = importLocation;
|
||||
});
|
||||
|
||||
async.waterfall([
|
||||
function findImports(next) {
|
||||
|
|
|
@ -6,6 +6,7 @@ class LibraryManager {
|
|||
this.plugins = options.plugins;
|
||||
this.config = options.config;
|
||||
this.contractsConfig = this.config.contractsConfig;
|
||||
this.storageConfig = this.config.storageConfig;
|
||||
|
||||
this.embark = this.plugins.createPlugin('libraryManager', {});
|
||||
|
||||
|
@ -21,7 +22,7 @@ class LibraryManager {
|
|||
|
||||
let solcVersionInConfig = this.contractsConfig.versions.solc;
|
||||
let web3VersionInConfig = this.contractsConfig.versions["web3.js"];
|
||||
let ipfsApiVersion = require('../../package.json').dependencies["ipfs-api"];
|
||||
let ipfsApiVersion = this.storageConfig.versions["ipfs-api"];
|
||||
|
||||
this.versions['solc'] = solcVersionInConfig;
|
||||
this.versions['web3'] = web3VersionInConfig;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"default": {
|
||||
"versions": {
|
||||
"ipfs-api": "17.2.6"
|
||||
},
|
||||
"enabled": true,
|
||||
"available_providers": ["ipfs"],
|
||||
"ipfs_bin": "ipfs",
|
||||
|
|
Loading…
Reference in New Issue