fixes for the test_dapp to work

This commit is contained in:
Jonathan Rainville 2019-02-20 15:57:12 -05:00 committed by Iuri Matias
parent e049b459c8
commit d33425fb4c
5 changed files with 58 additions and 44 deletions

View File

@ -383,24 +383,48 @@ class CodeGenerator {
} }
generateSymlink(target, name, callback) { generateSymlink(target, name, callback) {
const symlinkDir = this.fs.dappPath(this.embarkConfig.generationDir, constants.dappArtifacts.symlinkDir); async.waterfall([
this.fs.mkdirp(symlinkDir, (err) => { // Make directory
if (err) { next => {
return callback(err); const symlinkDir = this.fs.dappPath(this.embarkConfig.generationDir, constants.dappArtifacts.symlinkDir);
} this.fs.mkdirp(symlinkDir, (err) => {
const symlinkDest = utils.joinPath(symlinkDir, name).replace(/\\/g, '/');
this.fs.remove(symlinkDest, (err) => {
if (err) {
return callback(err);
}
this.fs.symlink(path.dirname(target), symlinkDest, 'junction', (err) => {
if (err) { if (err) {
return callback(err); return next(err);
} }
callback(null, symlinkDest); next(null, utils.joinPath(symlinkDir, name).replace(/\\/g, '/'));
}); });
}); },
}); // Remove old symlink because they are not overwritable
(symlinkDest, next) => {
this.fs.remove(symlinkDest, (err) => {
if (err) {
return next(err);
}
next(null, symlinkDest);
});
},
// Make target a directory as files don't work on Windows
(symlinkDest, next) => {
this.fs.stat(target, (err, stats) => {
if (err) {
return next(err);
}
let finalTarget = target;
if (stats.isFile()) {
finalTarget = path.dirname(target);
}
next(null, symlinkDest, finalTarget);
});
},
(symlinkDest, finalTarget, next) => {
this.fs.symlink(finalTarget, symlinkDest, 'junction', (err) => {
if (err) {
return next(err);
}
next(null, symlinkDest);
});
}
], callback);
} }
} }

View File

@ -356,12 +356,11 @@ class Pipeline {
importsList["Embark/contracts/" + contract.className] = contractPath; importsList["Embark/contracts/" + contract.className] = contractPath;
// add the contract to the exports list to support alternate import syntax // add the contract to the exports list to support alternate import syntax
importsHelperFile.write(`"${contract.className}": require('./${contract.className}').default`); importsHelperFile.write(`"${contract.className}": require('./${contract.className}').default,\n`);
if (idx < contracts.length - 1) importsHelperFile.write(',\n'); // add a comma if we have more contracts to add
eachCb(); eachCb();
}); });
}, () => { }, () => {
importsHelperFile.write('\n}'); // close the module.exports = {} importsHelperFile.write('\n};'); // close the module.exports = {}
importsHelperFile.close(next); // close the write stream importsHelperFile.close(next); // close the write stream
}); });
}); });

View File

@ -1,13 +1,13 @@
import { Component } from 'react'; import { Component } from 'react';
import SimpleStorage from 'Embark/contracts/SimpleStorage'; import SimpleStorage from '../../embarkArtifacts/contracts/SimpleStorage';
window.SimpleStorage = SimpleStorage; window.SimpleStorage = SimpleStorage;
class App extends Component { class App extends Component {
action() { action() {
console.log("calling...") console.log("calling...");
SimpleStorage.methods.get().call(function(err, value) { SimpleStorage.methods.get().call(function(err, value) {
alert(value); alert(value);
}) });
} }
render() { render() {

View File

@ -1,28 +1,18 @@
/*globals $, SimpleStorage, document*/ /*global web3*/
import React from 'react';
import React, { Component } from 'react';
import EmbarkJS from 'Embark/EmbarkJS'; import EmbarkJS from 'Embark/EmbarkJS';
import SimpleStorage from 'Embark/contracts/SimpleStorage'; import {SimpleStorage, Test, SimpleStorageTest} from '../../embarkArtifacts/contracts';
import Test from 'Embark/contracts/Test'; import config from '../../embarkArtifacts/config/blockchain';
//import Assert from 'Embark/contracts/Assert';
import SimpleStorageTest from 'Embark/contracts/SimpleStorageTest'; window.SimpleStorageTest = SimpleStorageTest;
window.SimpleStorageTest = SimpleStorageTest
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
//import $ from './_vendor/jquery.min';
import $ from 'jquery'; import $ from 'jquery';
//import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.css'; import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css'; import 'bootstrap/dist/css/bootstrap-theme.css';
//import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap/dist/js/bootstrap.min.js'; import 'bootstrap/dist/js/bootstrap.min.js';
//import 'react-bootstrap/dist/react-bootstrap.min.js';
import { Navbar, Jumbotron, Button } from 'react-bootstrap';
window.EmbarkJS = EmbarkJS; window.EmbarkJS = EmbarkJS;
window.SimpleStorage = SimpleStorage; window.SimpleStorage = SimpleStorage;
window.Test = Test; window.Test = Test;
@ -44,6 +34,12 @@ var addToLog = function(id, txt) {
// Blockchain example // Blockchain example
// =========================== // ===========================
$(document).ready(function() { $(document).ready(function() {
EmbarkJS.Blockchain.connect(config, (err) => {
if (err) {
console.error(err);
}
});
console.log([1,2,3].map(v => v + 1)); console.log([1,2,3].map(v => v + 1));
$("#blockchain button.set").click(function() { $("#blockchain button.set").click(function() {
@ -144,7 +140,7 @@ $(document).ready(function() {
$("#communication .error").hide(); $("#communication .error").hide();
$("#communication .errorVersion").hide(); $("#communication .errorVersion").hide();
if (EmbarkJS.Messages.providerName === 'whisper') { if (EmbarkJS.Messages.providerName === 'whisper') {
EmbarkJS.Messages.getWhisperVersion(function(err, version) { EmbarkJS.Messages.getWhisperVersion(function(err, _version) {
if (err) { if (err) {
$("#communication .error").show(); $("#communication .error").show();
$("#communication-controls").hide(); $("#communication-controls").hide();

View File

@ -1,12 +1,7 @@
import $ from 'jquery'; import $ from 'jquery';
import AlreadyDeployedToken from 'Embark/contracts/AlreadyDeployedToken';
import AnotherStorage from 'Embark/contracts/AnotherStorage';
import async from 'async';
import MyToken from 'Embark/contracts/MyToken';
import MyToken2 from 'Embark/contracts/MyToken2';
import SimpleStorage from 'Embark/contracts/SimpleStorage';
import Token from 'Embark/contracts/Token';
import {AlreadyDeployedToken, AnotherStorage, MyToken, MyToken2, SimpleStorage, Token} from '../../embarkArtifacts/contracts';
import async from 'async';
$(document).ready(function() { $(document).ready(function() {