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() {
|
Config.prototype.loadStorageConfigFile = function() {
|
||||||
var configObject = {
|
var configObject = {
|
||||||
"default": {
|
"default": {
|
||||||
|
"versions": {
|
||||||
|
"ipfs-api": "17.2.4"
|
||||||
|
},
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"available_providers": ["ipfs"],
|
"available_providers": ["ipfs"],
|
||||||
"ipfs_bin": "ipfs",
|
"ipfs_bin": "ipfs",
|
||||||
|
|
|
@ -21,6 +21,7 @@ var Plugin = function(options) {
|
||||||
this.serviceChecks = [];
|
this.serviceChecks = [];
|
||||||
this.pluginTypes = [];
|
this.pluginTypes = [];
|
||||||
this.uploadCmds = [];
|
this.uploadCmds = [];
|
||||||
|
this.imports = [];
|
||||||
this.embarkjs_code = [];
|
this.embarkjs_code = [];
|
||||||
this.embarkjs_init_code = {};
|
this.embarkjs_init_code = {};
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
|
@ -158,6 +159,11 @@ Plugin.prototype.addProviderInit = function(providerType, code, initCondition) {
|
||||||
this.pluginTypes.push('initCode');
|
this.pluginTypes.push('initCode');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Plugin.prototype.registerImportFile = function(importName, importLocation) {
|
||||||
|
this.imports.push([importName, importLocation]);
|
||||||
|
this.pluginTypes.push('imports');
|
||||||
|
};
|
||||||
|
|
||||||
Plugin.prototype.runFilePipeline = function() {
|
Plugin.prototype.runFilePipeline = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ class IPFS {
|
||||||
}
|
}
|
||||||
|
|
||||||
addIPFSToEmbarkJS() {
|
addIPFSToEmbarkJS() {
|
||||||
|
const self = this;
|
||||||
// TODO: make this a shouldAdd condition
|
// TODO: make this a shouldAdd condition
|
||||||
if (this.storageConfig === {}) {
|
if (this.storageConfig === {}) {
|
||||||
return;
|
return;
|
||||||
|
@ -75,6 +76,15 @@ class IPFS {
|
||||||
return;
|
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 = "";
|
let code = "";
|
||||||
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
|
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
|
||||||
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS);";
|
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS);";
|
||||||
|
|
|
@ -39,9 +39,10 @@ class Pipeline {
|
||||||
importsList["Embark/EmbarkJS"] = utils.joinPath(fs.dappPath(), ".embark", 'embark.js');
|
importsList["Embark/EmbarkJS"] = utils.joinPath(fs.dappPath(), ".embark", 'embark.js');
|
||||||
importsList["Embark/web3"] = utils.joinPath(fs.dappPath(), ".embark", 'web3_instance.js');
|
importsList["Embark/web3"] = utils.joinPath(fs.dappPath(), ".embark", 'web3_instance.js');
|
||||||
|
|
||||||
//importsList["ipfs-api"] = utils.joinPath(fs.dappPath(), ".embark", 'ipfs_api.js');
|
self.plugins.getPluginsProperty('imports', 'imports').forEach(function (importObject) {
|
||||||
|
let [importName, importLocation] = importObject;
|
||||||
//importsList["Embark/libs/IpfsApi"] = fs.embarkPath('js/ipfs.js');
|
importsList[importName] = importLocation;
|
||||||
|
});
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function findImports(next) {
|
function findImports(next) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ class LibraryManager {
|
||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
this.contractsConfig = this.config.contractsConfig;
|
this.contractsConfig = this.config.contractsConfig;
|
||||||
|
this.storageConfig = this.config.storageConfig;
|
||||||
|
|
||||||
this.embark = this.plugins.createPlugin('libraryManager', {});
|
this.embark = this.plugins.createPlugin('libraryManager', {});
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ class LibraryManager {
|
||||||
|
|
||||||
let solcVersionInConfig = this.contractsConfig.versions.solc;
|
let solcVersionInConfig = this.contractsConfig.versions.solc;
|
||||||
let web3VersionInConfig = this.contractsConfig.versions["web3.js"];
|
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['solc'] = solcVersionInConfig;
|
||||||
this.versions['web3'] = web3VersionInConfig;
|
this.versions['web3'] = web3VersionInConfig;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
{
|
{
|
||||||
"default": {
|
"default": {
|
||||||
|
"versions": {
|
||||||
|
"ipfs-api": "17.2.6"
|
||||||
|
},
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"available_providers": ["ipfs"],
|
"available_providers": ["ipfs"],
|
||||||
"ipfs_bin": "ipfs",
|
"ipfs_bin": "ipfs",
|
||||||
|
|
Loading…
Reference in New Issue