mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-13 22:27:27 +00:00
genereate components config files
This commit is contained in:
parent
78775afd1c
commit
dd0cfbc2dc
@ -124,11 +124,13 @@ class IPFS {
|
||||
// TODO: should be done in embarkjs-ipfs
|
||||
// TODO: check config, etc..
|
||||
registerAndSetIpfs() {
|
||||
// TODO: this should be at the start
|
||||
const code = `
|
||||
const __embarkIPFS = require('embarkjs-ipfs');
|
||||
EmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS.default || __embarkIPFS);
|
||||
`;
|
||||
|
||||
// TODO: this should be done when a connection is detected
|
||||
this.events.request('runcode:eval', code, (err) => {
|
||||
let providerCode = `\nEmbarkJS.Storage.setProviders(${JSON.stringify(this.embark.config.storageConfig.dappConnection || [])}, {web3});`;
|
||||
this.events.request('runcode:eval', providerCode, (err) => {
|
||||
|
@ -4,31 +4,30 @@ import * as async from 'async';
|
||||
class Storage {
|
||||
constructor(embark, options){
|
||||
this.embark = embark;
|
||||
this.embarkConfig = embark.config.embarkConfig;
|
||||
this.events = this.embark.events;
|
||||
this.storageConfig = embark.config.storageConfig;
|
||||
this.plugins = options.plugins;
|
||||
this.ready = false;
|
||||
let plugin = this.plugins.createPlugin('storageplugin', {});
|
||||
|
||||
this.embark.events.setCommandHandler("module:storage:onReady", (cb) => {
|
||||
if (this.ready) {
|
||||
return cb();
|
||||
}
|
||||
this.embark.events.once("module:storage:ready", cb);
|
||||
});
|
||||
// this.handleUploadCommand();
|
||||
// this.addSetProviders(() => {});
|
||||
plugin.registerActionForEvent("pipeline:generateAll:before", this.addArtifactFile.bind(this));
|
||||
|
||||
this.embark.events.setCommandHandler("module:storageJS:reset", (cb) => {
|
||||
if (!this.isEnabled()) {
|
||||
return cb();
|
||||
}
|
||||
this.ready = false;
|
||||
this.addSetProviders(cb);
|
||||
});
|
||||
// TODO: register xyz (e.g ipfs) to check for dappConnectionConfig
|
||||
}
|
||||
|
||||
if (!this.isEnabled()) {
|
||||
this.ready = true;
|
||||
return;
|
||||
}
|
||||
addArtifactFile(_params, cb) {
|
||||
let config = {
|
||||
dappConnection: this.storageConfig.dappConnection
|
||||
};
|
||||
|
||||
this.handleUploadCommand();
|
||||
this.addSetProviders(() => {});
|
||||
this.events.request("pipeline:register", {
|
||||
path: [this.embarkConfig.generationDir, 'config'],
|
||||
file: 'communication.json',
|
||||
format: 'json',
|
||||
content: config
|
||||
}, cb);
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
|
@ -13,11 +13,13 @@ class Whisper {
|
||||
this.events = embark.events;
|
||||
this.fs = embark.fs;
|
||||
this.communicationConfig = embark.config.communicationConfig;
|
||||
this.embarkConfig = embark.config.embarkConfig;
|
||||
this.web3 = new Web3();
|
||||
this.embark = embark;
|
||||
this.web3Ready = false;
|
||||
this.webSocketsChannels = {};
|
||||
this.modulesPath = dappPath(embark.config.embarkConfig.generationDir, constants.dappArtifacts.symlinkDir);
|
||||
this.plugins = options.plugins;
|
||||
|
||||
if (embark.currentContext.includes('test') && options.node &&options.node === 'vm') {
|
||||
this.logger.info(__('Whisper disabled in the tests'));
|
||||
@ -48,6 +50,9 @@ class Whisper {
|
||||
this.registerAndSetWhisper();
|
||||
});
|
||||
|
||||
let plugin = this.plugins.createPlugin('whisperplugin', {});
|
||||
plugin.registerActionForEvent("pipeline:generateAll:before", this.addArtifactFile.bind(this));
|
||||
|
||||
// ===============================
|
||||
// this.connectToProvider();
|
||||
|
||||
@ -73,6 +78,21 @@ class Whisper {
|
||||
// this.events.request('processes:launch', 'whisper');
|
||||
}
|
||||
|
||||
// TODO: should load the latest config
|
||||
addArtifactFile(_params, cb) {
|
||||
let config = {
|
||||
// TODO: for consistency we should change this to be dappConnection or connection
|
||||
connection: this.communicationConfig.connection
|
||||
};
|
||||
|
||||
this.events.request("pipeline:register", {
|
||||
path: [this.embarkConfig.generationDir, 'config'],
|
||||
file: 'storage.json',
|
||||
format: 'json',
|
||||
content: config
|
||||
}, cb);
|
||||
}
|
||||
|
||||
connectToProvider() {
|
||||
let {host, port} = this.communicationConfig.connection;
|
||||
let web3Endpoint = 'ws://' + host + ':' + port;
|
||||
|
@ -277,9 +277,9 @@ class Engine {
|
||||
}
|
||||
|
||||
storageService(_options) {
|
||||
this.registerModulePackage('embark-storage', {plugins: this.plugins});
|
||||
this.registerModulePackage('embark-ipfs');
|
||||
// this.registerModulePackage('embark-swarm');
|
||||
// this.registerModulePackage('embark-storage', {plugins: this.plugins});
|
||||
|
||||
// this.events.setCommandHandler("module:storage:reset", (cb) => {
|
||||
// async.parallel([
|
||||
@ -298,6 +298,7 @@ class Engine {
|
||||
|
||||
web3Service(options) {
|
||||
this.registerModulePackage('embark-web3');
|
||||
this.registerModule('blockchain', { plugins: this.plugins });
|
||||
|
||||
this.registerModulePackage('embark-blockchain-process', {
|
||||
client: this.client,
|
||||
@ -314,7 +315,7 @@ class Engine {
|
||||
wait: options.wait
|
||||
});
|
||||
|
||||
this.registerModulePackage('embark-whisper');
|
||||
this.registerModulePackage('embark-whisper', { plugins: this.plugins });
|
||||
this.registerModule('web3', { plugins: this.plugins });
|
||||
}
|
||||
|
||||
|
36
packages/embark/src/lib/modules/blockchain/index.js
Normal file
36
packages/embark/src/lib/modules/blockchain/index.js
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
class Blockchain {
|
||||
|
||||
constructor(embark, options) {
|
||||
this.embarkConfig = embark.config.embarkConfig;
|
||||
this.logger = embark.logger;
|
||||
this.events = embark.events;
|
||||
this.blockchainConfig = embark.config.blockchainConfig;
|
||||
this.contractConfig = embark.config.contractConfig;
|
||||
this.plugins = options.plugins;
|
||||
let plugin = this.plugins.createPlugin('web3plugin', {});
|
||||
|
||||
plugin.registerActionForEvent("pipeline:generateAll:before", this.addArtifactFile.bind(this));
|
||||
}
|
||||
|
||||
addArtifactFile(_params, cb) {
|
||||
this.events.request("config:contractsConfig", (contractsConfig) => {
|
||||
let config = {
|
||||
dappConnection: contractsConfig.dappConnection,
|
||||
dappAutoEnable: contractsConfig.dappAutoEnable,
|
||||
warnIfMetamask: this.blockchainConfig.isDev,
|
||||
blockchainClient: this.blockchainConfig.client
|
||||
};
|
||||
|
||||
this.events.request("pipeline:register", {
|
||||
path: [this.embarkConfig.generationDir, 'config'],
|
||||
file: 'blockchain.json',
|
||||
format: 'json',
|
||||
content: config
|
||||
}, cb);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Blockchain;
|
Loading…
x
Reference in New Issue
Block a user