refactor(@embark/embark-webserver): move webserver module

This commit is contained in:
Iuri Matias 2019-03-28 16:44:11 -04:00
parent 542809cd9f
commit b792b3fc78
10 changed files with 98 additions and 10 deletions

View File

@ -0,0 +1,4 @@
engine-strict = true
package-lock = false
save-exact = true
scripts-prepend-node-path = true

View File

@ -0,0 +1,6 @@
# `embark-webserver`
Development Webserver for Embark
Visit [embark.status.im](https://embark.status.im/) to get started with
[Embark](https://github.com/embark-framework/embark).

View File

@ -0,0 +1,73 @@
{
"name": "embark-webserver",
"version": "4.0.0",
"author": "Iuri Matias <iuri.matias@gmail.com>",
"contributors": [],
"description": "Webserver for Embark",
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/embark-webserver#readme",
"bugs": "https://github.com/embark-framework/embark/issues",
"keywords": [
"blockchain",
"dapps",
"ethereum",
"ipfs",
"serverless",
"solc",
"solidity"
],
"files": [
"dist"
],
"license": "MIT",
"repository": {
"directory": "packages/embark-webserver",
"type": "git",
"url": "https://github.com/embark-framework/embark.git"
},
"main": "./dist/index.js",
"scripts": {
"build": "cross-env BABEL_ENV=node babel src --copy-files --extensions \".js,.ts\" --out-dir dist --root-mode upward --source-maps",
"ci": "npm run qa",
"clean": "npm run reset",
"lint": "npm-run-all lint:*",
"lint:js": "eslint src/",
"// lint:ts": "tslint -c tslint.json \"src/**/*.ts\"",
"package": "npm pack",
"// qa": "npm-run-all lint typecheck build package",
"qa": "npm-run-all lint build package",
"reset": "npx rimraf dist embark-*.tgz package",
"start": "npm run watch",
"// typecheck": "tsc",
"watch": "run-p watch:*",
"watch:build": "npm run build -- --verbose --watch",
"// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch"
},
"eslintConfig": {
"extends": "../../.eslintrc.json"
},
"dependencies": {
"@babel/runtime-corejs2": "7.3.1",
"async": "2.6.1",
"embark-utils": "^4.0.0",
"express": "4.16.3",
"express-http-proxy": "1.5.1",
"express-ws": "4.0.0",
"opn": "5.3.0",
"serve-static": "1.13.2"
},
"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"cross-env": "5.2.0",
"eslint": "5.7.0",
"npm-run-all": "4.1.5",
"rimraf": "2.6.3",
"tslint": "5.11.0",
"typescript": "3.3.1"
},
"engines": {
"node": ">=8.12.0",
"npm": ">=6.4.1",
"yarn": ">=1.12.3"
}
}

View File

@ -38,6 +38,7 @@ class WebServer {
events: this.events,
host: this.host,
port: this.port,
fs: this.fs,
openBrowser: this.webServerConfig.openBrowser,
protocol: this.webServerConfig.protocol,
certOptions : this.webServerConfig.certOptions

View File

@ -3,7 +3,6 @@ let serveStatic = require('serve-static');
import {canonicalHost, defaultHost, dockerHostSwap} from 'embark-utils';
const expressWebSocket = require('express-ws');
const express = require('express');
const fs = require('../../core/fs');
const https = require('https');
let path = require('path');
@ -17,6 +16,7 @@ class Server {
this.hostname = dockerHostSwap(options.host) || defaultHost;
this.isFirstStart = true;
this.opened = false;
this.fs = options.fs;
this.openBrowser = options.openBrowser;
this.logging = false;
this.enableCatchAll = options.enableCatchAll;
@ -49,8 +49,8 @@ class Server {
return callback(null, message);
}
const coverage = serveStatic(fs.dappPath('coverage/__root__/'), {'index': ['index.html', 'index.htm']});
const coverageStyle = serveStatic(fs.dappPath('coverage/'));
const coverage = serveStatic(this.fs.dappPath('coverage/__root__/'), {'index': ['index.html', 'index.htm']});
const coverageStyle = serveStatic(this.fs.dappPath('coverage/'));
const main = serveStatic(this.buildDir, {'index': ['index.html', 'index.htm']});
this.app = express();
@ -71,7 +71,7 @@ class Server {
this.app.use('/coverage', coverage);
this.app.use(coverageStyle);
this.app.use(express.static(path.join(fs.dappPath(this.dist)), {'index': ['index.html', 'index.htm']}));
this.app.use(express.static(path.join(this.fs.dappPath(this.dist)), {'index': ['index.html', 'index.htm']}));
this.app.ws('/', () => {});
const wss = expressWs.getWss('/');
@ -91,7 +91,7 @@ class Server {
if (this.enableCatchAll === true) {
this.app.get('/*', function(req, res) {
self.logger.trace('webserver> GET ' + req.path);
res.sendFile(path.join(fs.dappPath(self.dist, 'index.html')));
res.sendFile(path.join(self.fs.dappPath(self.dist, 'index.html')));
});
}

View File

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"]
}

View File

@ -0,0 +1,3 @@
{
"extends": "../../tslint.json"
}

View File

@ -94,14 +94,12 @@
"embark-profiler": "^4.0.0",
"embark-specialconfigs": "^4.0.0",
"embark-utils": "^4.0.0",
"embark-webserver": "^4.0.0",
"embarkjs": "^4.0.0",
"eth-ens-namehash": "2.0.8",
"ethereumjs-tx": "1.3.7",
"ethereumjs-util": "6.0.0",
"ethereumjs-wallet": "0.6.0",
"express": "4.16.3",
"express-http-proxy": "1.5.1",
"express-ws": "4.0.0",
"file-loader": "2.0.0",
"find-up": "2.1.0",
"flatted": "0.2.3",
@ -146,7 +144,6 @@
"request": "2.88.0",
"sass-loader": "7.1.0",
"semver": "5.6.0",
"serve-static": "1.13.2",
"shelljs": "0.5.3",
"simples": "0.8.8",
"solc": "0.5.0",

View File

@ -269,7 +269,7 @@ class Engine {
}
webServerService() {
this.registerModule('webserver');
this.registerModulePackage('embark-webserver');
}
storageService(_options) {