Browse Source

Bump to v. 0.2.5

* Deprecated up static in favour of up serve
* Updated README, changelog and version number to 0.2.5
pull/10/head
Muthu Kumar 7 years ago
parent
commit
95145966fd
  1. 1
      .eslintrc.json
  2. 28
      README.md
  3. 6
      actions/createNewServer.js
  4. 1
      actions/killALL.js
  5. 2
      assets/tlds.txt
  6. 25
      cli.js
  7. 7
      docs/Changelog.md
  8. 13
      lib.js
  9. 5
      package.json
  10. 4
      utils/listFile.js
  11. 4
      utils/nginxReload.js

1
.eslintrc.json

@ -3,7 +3,6 @@
"node": true,
"es6": true
},
"parserOptions": { "ecmaVersion": 2017 },
"extends": "eslint:recommended",
"rules": {
"no-console": "off",

28
README.md

@ -8,10 +8,10 @@
# up
> Current version: `up v.0.2.1 (Alpha)`
> Current version: `up v.0.2.5 (Alpha)`
> Notes: `up` is now in Alpha! 🎉 [(Changelog)](/docs/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.
**`up`** is a command line application that creates nginx server blocks quickly with a single command.
@ -32,7 +32,8 @@ Install `up` from npm:
Format: `up command <required> [optional]`
- `up static <domain> [outbound port]` - Create new static server at current folder.
- `up serve <domain> [outbound port]` - Create new static server at current folder.
- `up static` is deprecated from `v. 0.2.5` (see [changelog](/docs/CHANGELOG.md))
- `up proxy <domain> <inbound port> [outbound port]` - Create new proxy server listening at said port.
- `up list` - List currently available servers.
- `up kill <domain>` - Kill the server for this domain.
@ -41,10 +42,29 @@ Format: `up command <required> [optional]`
- `up static example.com` will serve a static website from current folder.
- `up proxy example.com 8081` will create a reverse proxy listening at port 8081.
- `up kill example.com`
- `up kill example.com` will kill the server named example.com.
- `up list` will fetch a list of servers created with `up`.
## API
```JavaScript
const up = require('up-serve')
console.log(up.version()) // up v. 0.2.5
let result = up.server("example.com", "path/to/project", "80")
console.log(result) // Will log success or throw if error
let result = up.kill("example.com", "80")
console.log(result) // Will log success or throw if error
```
More detailed API documentation coming soon.
---
<h2 align="center">Meta</h2>
<h4 align="center"><a href="/docs/Roadmap.MD">Roadmap</a></h4>
<h4 align="center"><a href="Contributing.MD">Contribution Guidelines</a></h4>

6
actions/createStaticServer.js → actions/createNewServer.js

@ -2,17 +2,15 @@
const fs = require('fs-extra');
const shell = require('shelljs');
const path = require('path');
const npath = require('../utils/nginxPath');
const conf = require('../utils/nginxConf');
const nginxReload = require('../utils/nginxReload');
const { appendToList } = require('../utils/listFile');
const currentPath = path.normalize(process.cwd());
const { EOL } = require('os'); // \n if used on Linux, \r\n if used on Windows.
function createStaticServer(domain, outPort) {
function createStaticServer(domain, path, outPort) {
outPort = outPort || 80;
shell.mkdir('-p', npath.enabledSites());
@ -37,7 +35,7 @@ function createStaticServer(domain, outPort) {
// Removes domain from webroot if exists
shell.mkdir('-p', npath.webRoot());
// Creating the nginx www path if it doesn't exist so symlink doesn't fail
shell.ln('-sf', currentPath, npath.webRootDomain(domain, outPort));
shell.ln('-sf', path, npath.webRootDomain(domain, outPort));
// Symlink current directory to nginx's web root
appendToList(domain, outPort);

1
actions/killALL.js

@ -2,7 +2,6 @@
const shell = require('shelljs');
const path = require('path');
const fs = require('fs');
const { EOL } = require('os');

2
assets/tlds.txt

@ -1,4 +1,4 @@
# Version 2017111900, Last Updated Sun Nov 19 07:07:01 2017 UTC
# Version 2017112900, Last Updated Wed Nov 29 07:07:01 2017 UTC
AAA
AARP
ABARTH

25
cli.js

@ -3,6 +3,7 @@
'use strict';
const { EOL } = require('os');
const path = require('path');
// Requiring npm modules
const program = require('commander');
@ -15,12 +16,20 @@ const killAllConfirm = require('./actions/killAllConfirm');
// Requiring utils
const requirements = require('./utils/requirements');
const currentPath = path.normalize(process.cwd());
let cmdValue = '';
// Check for requirements such as OS version and nginx install.
// #Roadmap: Add ability to satisfy any possible requirements.
requirements();
// Comment in development and uncomment this line in production.
program
.version(up.version())
.arguments('<cmd>')
.action((cmd) => cmdValue = cmd);
const tryCatch = ((test, name) => {
try {
const msg = test();
@ -32,19 +41,21 @@ const tryCatch = ((test, name) => {
}
});
let cmdValue = '';
program
.version('0.2.5')
.arguments('<cmd>')
.action((cmd) => cmdValue = cmd);
.command('serve <domain> [outPort]')
.description('Create a server at this folder.')
.action((domain, outPort) =>
tryCatch(
() => up.server(domain, currentPath, outPort),
'new-server'
));
program
.command('static <domain> [outPort]')
.description('Create a static server at this folder.')
.description('DEPRECATED! Create a static server at this folder.')
.action((domain, outPort) =>
tryCatch(
() => up.server(domain, outPort),
() => up.server(domain, currentPath, outPort),
'new-server'
));

7
docs/Changelog.md

@ -1,5 +1,12 @@
# Changelog / Version history
## `up` v. 0.2.5
- `up static` is DEPRECATED. Use `up serve` instead.
- Major refactor of code, and splitting of `index.js` to `lib.js` and `cli.js`.
- Basic API now available.
- Usage of `conf.d` is DEPRECATED. `up-serve` now only uses `sites-enabled`. Since everything is abstracted at a higher level, the need for maintaining two directories (Read sites-available here) is non-existent.
## `up` v. 0.2.1
- Bug fix and patch for `up kill-all` breaking unexpectedly due to undefined default config file.

13
lib.js

@ -6,20 +6,26 @@ const { EOL } = require('os');
const chalk = require('chalk');
// Requiring Actions
const createNewServer = require('./actions/createNewServer');
const createProxyServer = require('./actions/createProxyServer');
const createStaticServer = require('./actions/createStaticServer');
const killServer = require('./actions/killServer');
const listServers = require('./actions/listServers');
// Requiring utils
const validate = require('./utils/validate');
function server (domain, outPort = "80") {
const pacversion = 'up-serve v. ' + require('./package.json').version;
function version () {
return pacversion;
}
function server (domain, path, outPort = "80") {
// If outport is not given, 80 is set as default.
outPort = String(outPort);
validate(domain, outPort);
// Validates domain and outport, and if invalid, throws and returns.
createStaticServer(domain, outPort);
createNewServer(domain, path, outPort);
if (outPort != "80" || "443") domain = domain + ":" + outPort;
return (EOL + [
"Done! Your static server has been set up!",
@ -56,6 +62,7 @@ function kill (domain, outPort = "80") {
}
module.exports = {
version,
server,
proxy,
list,

5
package.json

@ -1,6 +1,6 @@
{
"name": "up-serve",
"version": "0.2.1",
"version": "0.2.5",
"description": "A cli tool to quickly create and manage nginx server blocks.",
"main": "lib.js",
"scripts": {
@ -21,6 +21,9 @@
"bin": {
"up": "./cli.js"
},
"pkg": {
"assets": "assets/*"
},
"author": "Muthu Kumar (@MKRhere)",
"license": "MIT",
"bugs": {

4
utils/listFile.js

@ -15,9 +15,9 @@ function appendToList(domain, outPort, inPort) {
};
if (!inPort) {
domBlock.type = "static";
domBlock.type = "static/server";
} else {
domBlock.type = "proxy";
domBlock.type = "proxy server";
domBlock.inPort = inPort;
}

4
utils/nginxReload.js

@ -3,7 +3,7 @@
const { execSync } = require('child_process');
function nginxReload() {
/*try {
try {
execSync('service nginx reload', {
stdio: 'ignore'
});
@ -13,7 +13,7 @@ function nginxReload() {
} catch (err) {
throw new Error('nginx failed to load');
}
return;*/
return;
}
module.exports = nginxReload;

Loading…
Cancel
Save