From d7340b4f5a3b8337e27410abc44cc2374d42ed5d Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Jul 2018 18:55:17 +0300 Subject: [PATCH] move storage processes to their own modules --- lib/modules/ipfs/index.js | 3 ++- .../storageProcesses/ipfs.js => modules/ipfs/process.js} | 2 +- .../storage}/storageProcessesLauncher.js | 4 ++-- lib/modules/swarm/index.js | 3 ++- .../storageProcesses/swarm.js => modules/swarm/process.js} | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) rename lib/{processes/storageProcesses/ipfs.js => modules/ipfs/process.js} (98%) rename lib/{processes/storageProcesses => modules/storage}/storageProcessesLauncher.js (97%) rename lib/{processes/storageProcesses/swarm.js => modules/swarm/process.js} (97%) diff --git a/lib/modules/ipfs/index.js b/lib/modules/ipfs/index.js index 190888d8d..7d36d5e0d 100644 --- a/lib/modules/ipfs/index.js +++ b/lib/modules/ipfs/index.js @@ -2,7 +2,8 @@ const UploadIPFS = require('./upload.js'); const utils = require('../../utils/utils.js'); const fs = require('../../core/fs.js'); const IpfsApi = require('ipfs-api'); -const StorageProcessesLauncher = require('../../processes/storageProcesses/storageProcessesLauncher'); +// TODO: not great, breaks module isolation +const StorageProcessesLauncher = require('../storage/storageProcessesLauncher'); class IPFS { diff --git a/lib/processes/storageProcesses/ipfs.js b/lib/modules/ipfs/process.js similarity index 98% rename from lib/processes/storageProcesses/ipfs.js rename to lib/modules/ipfs/process.js index 724a47724..b64f9fa95 100644 --- a/lib/processes/storageProcesses/ipfs.js +++ b/lib/modules/ipfs/process.js @@ -1,5 +1,5 @@ const child_process = require('child_process'); -const ProcessWrapper = require('../processWrapper'); +const ProcessWrapper = require('../../processes/processWrapper'); const constants = require('../../constants'); let ipfsProcess; // eslint-disable-line no-unused-vars diff --git a/lib/processes/storageProcesses/storageProcessesLauncher.js b/lib/modules/storage/storageProcessesLauncher.js similarity index 97% rename from lib/processes/storageProcesses/storageProcessesLauncher.js rename to lib/modules/storage/storageProcessesLauncher.js index 6e7b23593..cac28f57c 100644 --- a/lib/processes/storageProcesses/storageProcessesLauncher.js +++ b/lib/modules/storage/storageProcessesLauncher.js @@ -1,7 +1,7 @@ const fs = require('../../core/fs'); const shellJs = require('shelljs'); const utils = require('../../utils/utils'); -const ProcessLauncher = require('../processLauncher'); +const ProcessLauncher = require('../../processes/processLauncher'); const constants = require('../../constants'); const {canonicalHost} = require('../../utils/host'); @@ -87,7 +87,7 @@ class StorageProcessesLauncher { if (self.processes[storageName]) { return callback(__('Storage process already started')); } - const filePath = utils.joinPath(__dirname, `./${storageName}.js`); + const filePath = utils.joinPath(__dirname, `../${storageName}/process.js`); fs.access(filePath, (err) => { if (err) { return callback(__('No process file for this storage type (%s) exists. Please start the process locally.', storageName)); diff --git a/lib/modules/swarm/index.js b/lib/modules/swarm/index.js index 8c3531706..c479a1008 100644 --- a/lib/modules/swarm/index.js +++ b/lib/modules/swarm/index.js @@ -2,7 +2,8 @@ const UploadSwarm = require('./upload.js'); const utils = require('../../utils/utils.js'); const fs = require('../../core/fs.js'); const Web3Bzz = require('web3-bzz'); -const StorageProcessesLauncher = require('../../processes/storageProcesses/storageProcessesLauncher'); +// TODO: not great, breaks module isolation +const StorageProcessesLauncher = require('../storage/storageProcessesLauncher'); class Swarm { diff --git a/lib/processes/storageProcesses/swarm.js b/lib/modules/swarm/process.js similarity index 97% rename from lib/processes/storageProcesses/swarm.js rename to lib/modules/swarm/process.js index ac0ca9bb9..5278fa196 100644 --- a/lib/processes/storageProcesses/swarm.js +++ b/lib/modules/swarm/process.js @@ -1,5 +1,5 @@ const child_process = require('child_process'); -const ProcessWrapper = require('../processWrapper'); +const ProcessWrapper = require('../../processes/processWrapper'); const constants = require('../../constants'); const fs = require('../../core/fs');