Browse Source

Bug fixes, patch for `up kill-all`

pull/8/head
Muthu Kumar 7 years ago
parent
commit
7c315ecb8e
  1. 2
      README.md
  2. 11
      Roadmap.md
  3. 7
      actions/killALL.js
  4. 21
      index.js
  5. 2
      package-lock.json
  6. 2
      package.json
  7. 9
      utils/listFile.js
  8. 2
      utils/nginxReload.js

2
README.md

@ -8,7 +8,7 @@
# up # up
> Current version: `up v.0.2.0 (Alpha)` > Current version: `up v.0.2.1 (Alpha)`
> Notes: `up` is now in Alpha! 🎉 [(Changelog)](Changelog.md)\ > Notes: `up` is now in Alpha! 🎉 [(Changelog)](Changelog.md)\
> ⚠️ ❌ `up` is pretty useable so far. If you're testing `up` on a development server, do give us feedback. > ⚠️ ❌ `up` is pretty useable so far. If you're testing `up` on a development server, do give us feedback.

11
Roadmap.md

@ -8,12 +8,12 @@ This living document details our plans for `up`. If you would like to request fe
## The Roadmap ## The Roadmap
- [ ] MVP - Minimum Viable Product. - [x] MVP - Minimum Viable Product.
- [x] `up static` and `up proxy` MUST work. - [x] `up static` and `up proxy` MUST work.
- [ ] `up kill` MUST work. - [x] `up kill` MUST work.
- [ ]List servers option. - [x]List servers option.
- [ ] `up list` MUST provide list of servers running by parsing nginx's `sites-available` and `sites-enabled` folders. - [x] `up list` MUST provide list of servers running from `/etc/up-serve/servers.up` file.
- [ ] `up static` MUST have an option to specify path to root. Example: `up static example.com ./public`. - [x] `up static` MUST have an option to specify path to root. Example: `up static example.com ./public`.
- [ ] `up static` and `up proxy` MAY take a Git URL to deploy. Example: - [ ] `up static` and `up proxy` MAY take a Git URL to deploy. Example:
1. `up static example.com --git https://github.com/h5bp/html5-boilerplate /html` 1. `up static example.com --git https://github.com/h5bp/html5-boilerplate /html`
2. `up proxy example.com 5000 --git https://github.com/heroku/node-js-sample` 2. `up proxy example.com 5000 --git https://github.com/heroku/node-js-sample`
@ -21,7 +21,6 @@ This living document details our plans for `up`. If you would like to request fe
- [ ] MUST add a `-s` or `--secure` flag to enable automatic HTTPS config with HTTP/2 enabled by default. - [ ] MUST add a `-s` or `--secure` flag to enable automatic HTTPS config with HTTP/2 enabled by default.
- [ ] HSTS MAY be enabled with a `-s -h`, `-sh`, `-secure -hsts` or `--secure-hsts` flag. Will warn user to be sure of what they are doing. - [ ] HSTS MAY be enabled with a `-s -h`, `-sh`, `-secure -hsts` or `--secure-hsts` flag. Will warn user to be sure of what they are doing.
- [ ] MAY add a `-c` flag to use `certbot` to automatically generate certificates using letsencrypt. - [ ] MAY add a `-c` flag to use `certbot` to automatically generate certificates using letsencrypt.
- [ ] SHOULD work on a way to make `up` work on distros other than Deb/Ubuntu based.
- [ ] MAY make `up` work on Windows. - [ ] MAY make `up` work on Windows.
Want more features or prioritize something? Raise an [issue!](https://github.com/codefeathers/up-serve/issues) Want more features or prioritize something? Raise an [issue!](https://github.com/codefeathers/up-serve/issues)

7
actions/killALL.js

@ -7,6 +7,7 @@ const { EOL } = require('os');
const npath = require('../utils/nginxPath'); const npath = require('../utils/nginxPath');
const conf = require('../utils/nginxConf'); const conf = require('../utils/nginxConf');
const nginxReload = require('../utils/nginxReload');
function killALL () { function killALL () {
shell.rm('-Rf', npath.serversBakUp); shell.rm('-Rf', npath.serversBakUp);
@ -19,17 +20,15 @@ function killALL () {
shell.mkdir('-p', npath.enabledSites()); shell.mkdir('-p', npath.enabledSites());
shell.mkdir('-p', npath.webRoot()); shell.mkdir('-p', npath.webRoot());
shell.cp((path.join(__dirname, '/../build/defaultNginx.conf')), shell.cp((path.join(__dirname, '/../build/defaultNginx.conf')),
conf(npath.confD())); conf(npath.enabledSites()));
// Create the default.conf file // Create the default.conf file
shell.ln('-sf', npath.confD() + "default.conf",
npath.enabledSites() + "default.conf");
// Symlink the default.conf file from confD to sites-enabled
console.log("All servers were killed and reverted to default."); console.log("All servers were killed and reverted to default.");
console.log(EOL + [ console.log(EOL + [
"A backup of your old servers.up is " + "A backup of your old servers.up is " +
"saved in /etc/up-serve/servers.bak.up.", "saved in /etc/up-serve/servers.bak.up.",
"Check this if you need to." "Check this if you need to."
].join(EOL) + EOL); ].join(EOL) + EOL);
nginxReload();
} }
function noKill () { function noKill () {

21
index.js

@ -7,7 +7,6 @@ const { EOL } = require('os');
// Requiring npm modules // Requiring npm modules
const program = require('commander'); const program = require('commander');
const chalk = require('chalk'); const chalk = require('chalk');
//var fs = require('fs-extra');
// Requiring Actions // Requiring Actions
const createProxyServer = require('./actions/createProxyServer'); const createProxyServer = require('./actions/createProxyServer');
@ -28,7 +27,16 @@ requirements(); // Comment in development and uncomment this line in production.
// This should check whether the OS is compatible with this version of `up` // This should check whether the OS is compatible with this version of `up`
program program
.version('0.2.0'); .version('0.2.1');
let cmdValue;
program
.version('0.1.0')
.arguments('<cmd>')
.action(function (cmd) {
cmdValue = cmd;
});
program program
.command('static <domain> [outPort]') .command('static <domain> [outPort]')
@ -65,8 +73,7 @@ program
"Done! Your reverse proxy server has been set up!", "Done! Your reverse proxy server has been set up!",
"Point your domain to this server and check " + "Point your domain to this server and check " +
chalk.cyan(domain) + chalk.cyan(domain) +
" to verify!" " to verify!"].join(EOL));
].join(EOL));
}); });
program program
@ -93,6 +100,7 @@ program
killAllConfirm(); killAllConfirm();
}); });
program program
.command('*') // This should pick invalid commands, but it doesn't, yet. .command('*') // This should pick invalid commands, but it doesn't, yet.
.action(function () { .action(function () {
@ -121,3 +129,8 @@ program.on('--help', function () {
// Parses commands passed to `up` and chooses one of the above commands. // Parses commands passed to `up` and chooses one of the above commands.
program.parse(process.argv); program.parse(process.argv);
if (typeof cmdValue === 'undefined') {
console.log(EOL + "No command was given. `up --help` for help info.");
process.exit(1);
}

2
package-lock.json

@ -1,6 +1,6 @@
{ {
"name": "up-serve", "name": "up-serve",
"version": "0.2.0", "version": "0.2.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "up-serve", "name": "up-serve",
"version": "0.2.0", "version": "0.2.1",
"description": "A cli tool to quickly create and manage nginx server blocks.", "description": "A cli tool to quickly create and manage nginx server blocks.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

9
utils/listFile.js

@ -45,9 +45,14 @@ function removeFromList (domain, outPort) {
} }
function readServers () { function readServers () {
const serversList = JSON.parse(fs.readFileSync(listFilePath())); let serversList;
if (fs.existsSync(listFilePath())) {
serversList = JSON.parse(fs.readFileSync(listFilePath()));
if(!serversList.domains[0]) return undefined; if(!serversList.domains[0]) return undefined;
}
else {
return "Servers were not created";
}
return serversList; return serversList;
} }

2
utils/nginxReload.js

@ -8,7 +8,7 @@ function nginxReload() {
console.error("exec error: " + error); console.error("exec error: " + error);
console.log("stdout: " + stdout); console.log("stdout: " + stdout);
console.log("stderr: " + stderr); console.log("stderr: " + stderr);
return; process.exit(1);
} }
}); });
} }

Loading…
Cancel
Save