mirror of https://github.com/embarklabs/embark.git
feature(@embark/embarkjs-ipfs: make embarkjs ipfs plugin a module on its own
This commit is contained in:
parent
d71352b781
commit
c87284f72a
|
@ -96,6 +96,7 @@
|
|||
"embark-utils": "^4.0.0",
|
||||
"embark-webserver": "^4.0.0",
|
||||
"embarkjs": "^4.0.0",
|
||||
"embarkjs-ipfs": "^4.0.0",
|
||||
"eth-ens-namehash": "2.0.8",
|
||||
"ethereumjs-tx": "1.3.7",
|
||||
"ethereumjs-util": "6.0.0",
|
||||
|
|
|
@ -42,6 +42,8 @@ class VM {
|
|||
"eth-ens-namehash",
|
||||
"swarm-api",
|
||||
"embarkjs-whisper",
|
||||
"ipfs-api",
|
||||
"embarkjs-ipfs",
|
||||
"rxjs",
|
||||
"rxjs/operators",
|
||||
],
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const UploadIPFS = require('./upload.js');
|
||||
const utils = require('../../utils/utils.js');
|
||||
import {joinPath} from 'embark-utils';
|
||||
const IpfsApi = require('ipfs-api');
|
||||
// TODO: not great, breaks module isolation
|
||||
const StorageProcessesLauncher = require('../storage/storageProcessesLauncher');
|
||||
|
@ -105,16 +104,16 @@ class IPFS {
|
|||
return this.logger.error(err.message || err);
|
||||
}
|
||||
this.events.request('code-generator:ready', () => {
|
||||
this.events.request('code-generator:symlink:generate', location, 'ipfs-api', (err, symlinkDest) => {
|
||||
this.events.request('code-generator:symlink:generate', location, 'ipfs-api', (err, _symlinkDest) => {
|
||||
if (err) {
|
||||
this.logger.error(__('Error creating a symlink to IPFS API'));
|
||||
return this.logger.error(err.message || err);
|
||||
}
|
||||
|
||||
this.events.emit('runcode:register', 'IpfsApi', require('ipfs-api'), () => {
|
||||
let code = `\nconst IpfsApi = global.IpfsApi || require('${symlinkDest}');`;
|
||||
code += "\n" + this.fs.readFileSync(joinPath(__dirname, 'embarkjs.js')).toString();
|
||||
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS);";
|
||||
let code = "";
|
||||
code += "\nconst __embarkIPFS = require('embarkjs-ipfs')";
|
||||
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS.default || __embarkIPFS);";
|
||||
|
||||
this.embark.addCodeToEmbarkJS(code);
|
||||
this.embark.addConsoleProviderInit("storage", code, (storageConfig) => storageConfig.enabled);
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/* global module require */
|
||||
|
||||
const cloneDeep = require('lodash.clonedeep');
|
||||
|
||||
module.exports = (api) => {
|
||||
const env = api.env();
|
||||
|
||||
const base = {};
|
||||
|
||||
const browser = cloneDeep(base);
|
||||
Object.assign(browser, {
|
||||
ignore: [
|
||||
'src/embarkjs.js',
|
||||
'src/node/index.js'
|
||||
]
|
||||
});
|
||||
|
||||
const node = cloneDeep(base);
|
||||
Object.assign(node, {
|
||||
ignore: [
|
||||
'src/browser.js'
|
||||
]
|
||||
});
|
||||
|
||||
const nodeAsync = cloneDeep(base);
|
||||
Object.assign(nodeAsync, {
|
||||
ignore: [
|
||||
'src/node/index.js'
|
||||
]
|
||||
});
|
||||
|
||||
const nodeTest = cloneDeep(base);
|
||||
|
||||
switch (env) {
|
||||
case 'browser':
|
||||
return browser;
|
||||
case 'node':
|
||||
return node;
|
||||
case 'node:async':
|
||||
return nodeAsync;
|
||||
case 'node:test':
|
||||
return nodeTest;
|
||||
default:
|
||||
return base;
|
||||
}
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
build-test
|
|
@ -0,0 +1,4 @@
|
|||
engine-strict = true
|
||||
package-lock = false
|
||||
save-exact = true
|
||||
scripts-prepend-node-path = true
|
|
@ -0,0 +1,6 @@
|
|||
# `embarkjs-ipfs`
|
||||
|
||||
embarkjs plugin to interact with ipfs
|
||||
|
||||
Visit [embark.status.im](https://embark.status.im/) to get started with
|
||||
[Embark](https://github.com/embark-framework/embark).
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"name": "embarkjs-ipfs",
|
||||
"version": "4.0.0",
|
||||
"author": "Iuri Matias <iuri.matias@gmail.com>",
|
||||
"contributors": [],
|
||||
"description": "Ipfs plugin for embarkjs",
|
||||
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/embarkjs-ipfs#readme",
|
||||
"bugs": "https://github.com/embark-framework/embark/issues",
|
||||
"keywords": [
|
||||
"blockchain",
|
||||
"dapps",
|
||||
"ethereum",
|
||||
"ipfs",
|
||||
"serverless",
|
||||
"solc",
|
||||
"solidity"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"directory": "packages/embarkjs-ipfs",
|
||||
"type": "git",
|
||||
"url": "https://github.com/embark-framework/embark.git"
|
||||
},
|
||||
"main": "dist/node/index.js",
|
||||
"browser": {
|
||||
"./dist/node/index.js": "./dist/browser/index.js"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 version",
|
||||
"not dead",
|
||||
"> 0.2%"
|
||||
],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "npm-run-all build:**",
|
||||
"build:browser": "cross-env BABEL_ENV=browser babel src --out-dir dist/browser --root-mode upward",
|
||||
"build:node": "cross-env BABEL_ENV=node babel src --out-dir dist --root-mode upward --source-maps",
|
||||
"build:node:async": "cross-env BABEL_ENV=node:async babel src/node --out-dir dist --root-mode upward --source-maps",
|
||||
"// build:node:test": "cross-env BABEL_ENV=node:test babel test --out-dir build-test --root-mode upward --source-maps",
|
||||
"ci": "npm run qa",
|
||||
"clean": "npm run reset",
|
||||
"package": "npm pack",
|
||||
"// qa": "npm-run-all build test package",
|
||||
"qa": "npm-run-all build package",
|
||||
"reset": "npx rimraf build-test dist embarkjs-*.tgz package",
|
||||
"start": "npm run watch",
|
||||
"test": "mocha \"build-test/**/*.js\" --exit --no-timeouts --require source-map-support/register",
|
||||
"watch": "run-p \"build:** -- --verbose --watch\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime-corejs2": "7.3.1",
|
||||
"ipfs-api": "17.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.2.3",
|
||||
"@babel/core": "7.2.2",
|
||||
"ajv": "6.5.2",
|
||||
"chai": "4.2.0",
|
||||
"cross-env": "5.2.0",
|
||||
"lodash.clonedeep": "4.5.0",
|
||||
"mocha": "5.2.0",
|
||||
"npm-run-all": "4.1.5",
|
||||
"rimraf": "2.6.3",
|
||||
"source-map-support": "0.5.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.12.0",
|
||||
"npm": ">=6.4.1",
|
||||
"yarn": ">=1.12.3"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export {default} from './index';
|
|
@ -1,4 +1,4 @@
|
|||
/*global IpfsApi*/
|
||||
const IpfsApi = require('ipfs-api');
|
||||
|
||||
const __embarkIPFS = {};
|
||||
|
||||
|
@ -146,3 +146,5 @@ __embarkIPFS.register = function(addr, callback) {
|
|||
callback(addr + " could not be registered");
|
||||
});
|
||||
};
|
||||
|
||||
export default __embarkIPFS;
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('../embarkjs').default;
|
Loading…
Reference in New Issue