-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* swith from .dev to .localhost (changing app name to LocalhostD) * rewrite using create-react-app * show console on application domain
- Loading branch information
Showing
65 changed files
with
12,013 additions
and
14,478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
static/vendor | ||
dist | ||
/node_modules | ||
/dist | ||
/ui_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
"node": true, | ||
"browser": false | ||
}, | ||
"extends": ["eslint:recommended", "prettier"], | ||
"parserOptions": { "ecmaVersion": 9 }, | ||
"extends": ["eslint:recommended", "react-app", "prettier"], | ||
"rules": { | ||
"no-console": 0, | ||
"no-unused-vars": 0, | ||
"linebreak-style": ["error", "unix"], | ||
"semi": ["error", "always"] | ||
"semi": ["error", "always"], | ||
"no-var": ["error"], | ||
"prefer-const": ["error"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/node_modules | ||
/dist | ||
/ui_build | ||
|
||
*.log | ||
node_modules | ||
dist | ||
.npmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/dist | ||
/src | ||
|
||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env node | ||
|
||
const Path = require("path"); | ||
const Commander = require("commander"); | ||
const Server = require("../lib/server.js"); | ||
const UpdateNotifier = require("update-notifier"); | ||
const pkg = require("../package.json"); | ||
const waitDeath = require("../lib/wait_death.js"); | ||
|
||
UpdateNotifier({ | ||
pkg | ||
}).notify(); | ||
|
||
Commander.version(pkg.version) | ||
.option("-d --debug", "enable debug") | ||
.option( | ||
" --state-file [string]", | ||
"state file, default: ~/.localhostd.json", | ||
Path.join(process.env["HOME"] || process.env["HOMEPATH"], ".localhostd.json") | ||
); | ||
|
||
Commander.command("server") | ||
.option( | ||
"-p, --port [integer]", | ||
"HTTP port, default: 2999", | ||
(i, d) => parseInt(i || d), | ||
2999 | ||
) | ||
.option("-b, --bind [string]", "HTTP bind, default: 127.0.0.1", "127.0.0.1") | ||
.action(options => | ||
Promise.resolve() | ||
.then(async () => { | ||
const server = new Server(Commander); | ||
await server.listen(options); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(server.getUsageMessage()); | ||
|
||
const signal = await waitDeath(); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(`received ${signal}`); | ||
|
||
process.exit(0); | ||
}) | ||
.catch(error => { | ||
// eslint-disable-next-line no-console | ||
console.error( | ||
Commander.debug | ||
? error.stack | ||
: `LocalhostD has encountered an error: \n${error.message}` | ||
); | ||
process.exit(1); | ||
}) | ||
); | ||
|
||
Commander.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
process.env.NODE_ENV = "production"; | ||
process.env.BABEL_ENV = "production"; | ||
|
||
require("react-scripts/config/env"); | ||
|
||
const fs = require("fs-extra"); | ||
const path = require("path"); | ||
const paths = require("react-scripts/config/paths"); | ||
|
||
paths.appBuild = path.join(__dirname, "../ui_build"); | ||
paths.servedPath = "./"; | ||
|
||
const webpack = require("webpack"); | ||
const config = require("react-scripts/config/webpack.config.prod.js"); | ||
|
||
// removes react-dev-utils/webpackHotDevClient.js at first in the array | ||
// config.entry.shift(); | ||
|
||
const webpackConfigured = webpack(config); | ||
|
||
function callback(err, stats) { | ||
if (err) { | ||
// eslint-disable-next-line no-console | ||
console.error(err); | ||
} else { | ||
copyPublicFolder(); | ||
} | ||
if (stats) | ||
// eslint-disable-next-line no-console | ||
console.error( | ||
stats.toString({ | ||
chunks: false, | ||
colors: true | ||
}) | ||
); | ||
} | ||
|
||
function copyPublicFolder() { | ||
fs.copySync(paths.appPublic, paths.appBuild, { | ||
dereference: true, | ||
filter: file => file !== paths.appHtml | ||
}); | ||
} | ||
|
||
if (process.env.LOCALHOSTD_DEV_WATCH) webpackConfigured.watch({}, callback); | ||
else webpackConfigured.run(callback); |
Oops, something went wrong.