Socket
Socket
Sign inDemoInstall

hotel

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotel - npm Package Compare versions

Comparing version 0.6.1 to 0.7.0

lib/cli/run.js

10

CHANGELOG.md
# Change Log
## Unreleased
* Add `run` command
* Add `http-proxy-env` flag to `hotel add`
* Drop Node `0.12` support
__Breaking__
* By default no `HTTP_PROXY` env will be passed to servers. To pass `HTTP_PROXY` you need to set it in your server configuration or use the flag `http-proxy-env` when adding your server.
## 0.6.1

@@ -4,0 +14,0 @@

73

lib/cli/index.js
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var yargs = require('yargs');
var servers = require('./servers');
var run = require('./run');
var daemon = require('./daemon');
var pkg = require('../../package.json');
var addOptions = {
name: {
alias: 'n',
describe: 'Server name'
},
port: {
alias: 'p',
describe: 'Set PORT environment variable',
number: true
},
out: {
alias: 'o',
describe: 'Output file'
},
env: {
alias: 'e',
describe: 'Additional environment variables',
array: true
},
xfwd: {
alias: 'x',
describe: 'Adds x-forward headers',
default: false,
boolean: true
},
'change-origin': {
alias: 'co',
describe: 'Changes the origin of the host header to the target URL',
default: false,
boolean: true
},
'http-proxy-env': {
describe: 'Adds HTTP_PROXY environment variable',
default: false,
boolean: true
}
};
module.exports = function (processArgv) {
yargs(processArgv.slice(2)).version(pkg.version).alias('v', 'version').help('h').alias('h', 'help').command('add <cmd_or_url> [options]', 'Add server or proxy', function (yargs) {
return yargs.option('name', {
alias: 'n',
describe: 'Server name'
}).option('port', {
alias: 'p',
describe: 'Set PORT environment variable',
number: true
}).option('out', {
alias: 'o',
describe: 'Output file'
}).option('env', {
alias: 'e',
describe: 'Additional environment variables',
array: true
}).option('xfwd', {
alias: 'x',
describe: 'Adds x-forward headers',
default: false,
boolean: true
}).option('change-origin', {
alias: 'co',
describe: 'Changes the origin of the host header to the target URL',
default: false,
boolean: true
}).demand(1);
return yargs.options(addOptions).demand(1);
}, function (argv) {
return servers.add(argv['cmd_or_url'], argv);
}).command('run <cmd> [options]', 'Run server and get a temporary local domain', function (yargs) {
var runOptions = _extends({}, addOptions);
delete runOptions['out'];
return yargs.options(addOptions).demand(1);
}, function (argv) {
return run.spawn(argv['cmd'], argv);
}).command('rm [options]', 'Remove server or proxy', function (yargs) {

@@ -38,0 +61,0 @@ yargs.option('name', {

@@ -62,2 +62,6 @@ 'use strict';

if (opts.httpProxyEnv) {
conf.httpProxyEnv = opts.httpProxyEnv;
}
if (isUrl(param)) {

@@ -64,0 +68,0 @@ conf = _extends({

'use strict';
var path = require('path');
var homedir = /0.1/.test(process.version) ? require('os-homedir')() // Node 0.12
: require('os').homedir(); // Node 4+
var homedir = require('os').homedir();

@@ -7,0 +6,0 @@ var hotelDir = path.join(homedir, '.hotel');

@@ -25,6 +25,3 @@ 'use strict';

// For example, if you're behind a corporate proxy
proxy: false,
// Set it to false if you don't want hotel to pass HTTP_PROXY and HTTPS_PROXY
// to your servers
http_proxy: true
proxy: false
};

@@ -31,0 +28,0 @@

@@ -15,3 +15,2 @@ 'use strict';

var os = require('os');
var fs = require('fs');

@@ -25,3 +24,2 @@ var path = require('path');

var matcher = require('matcher');
var unquote = require('unquote');
var respawn = require('respawn');

@@ -31,6 +29,6 @@ var afterAll = require('after-all');

var serverReady = require('server-ready');
var arrayFind = require('array-find');
var errorMsg = require('./views/error-msg');
var tcpProxy = require('./tcp-proxy');
var daemonConf = require('../conf');
var getCmd = require('../get-cmd');

@@ -111,3 +109,3 @@ module.exports = function () {

if (daemonConf.http_proxy) {
if (conf.httpProxyEnv) {
conf.env = _extends({

@@ -126,3 +124,3 @@ HTTP_PROXY: HTTP_PROXY,

var command = os.platform() === 'win32' ? ['cmd', '/c'].concat(conf.cmd.split(' ')) : ['sh', '-c'].concat(unquote(conf.cmd));
var command = getCmd(conf.cmd);

@@ -265,6 +263,6 @@ var mon = respawn(command, _extends({}, conf, {

var strictMatch = arrayFind(arr, function (h) {
var strictMatch = arr.find(function (h) {
return h.isStrictMatch;
});
var wildcardMatch = arrayFind(arr, function (h) {
var wildcardMatch = arr.find(function (h) {
return h.isWildcardMatch;

@@ -271,0 +269,0 @@ });

{
"name": "hotel",
"version": "0.6.1",
"version": "0.7.0",
"description": "Local domains for everyone and more! ",

@@ -9,3 +9,3 @@ "main": "lib",

"engines": {
"node": ">= 0.12"
"node": ">= 4"
},

@@ -17,3 +17,3 @@ "scripts": {

"start:nodemon": "nodemon -- src/daemon",
"prepublish": "npm run build",
"prepublish": "npm run build && pkg-ok",
"uninstall": "node bin/uninstall.js",

@@ -23,3 +23,3 @@ "precommit": "npm test",

"build:babel": "rimraf lib && babel src -d lib --copy-files --ignore src/front",
"build:webpack": "rimraf dist && webpack -p"
"build:webpack": "rimraf dist && cross-env NODE_ENV=production webpack -p"
},

@@ -49,3 +49,2 @@ "repository": {

"ansi2html": "0.0.1",
"array-find": "^1.0.0",
"chalk": "^1.1.3",

@@ -61,3 +60,2 @@ "chokidar": "^1.2.0",

"once": "^1.3.2",
"os-homedir": "^1.0.1",
"respawn": "^2.4.1",

@@ -76,3 +74,3 @@ "server-ready": "^0.3.1",

"devDependencies": {
"ava": "^0.16.0",
"ava": "^0.18.2",
"babel-cli": "^6.1.2",

@@ -87,2 +85,3 @@ "babel-core": "^6.7.4",

"babel-runtime": "^6.6.1",
"cross-env": "^3.1.4",
"css-loader": "^0.25.0",

@@ -96,13 +95,12 @@ "escape-html": "^1.0.3",

"npm-run-all": "^3.1.0",
"pkg-ok": "^1.0.1",
"rimraf": "^2.5.2",
"sinon": "^1.17.3",
"sinon": "^1.17.7",
"standard": "^8.5.0",
"supertest": "^2.0.1",
"uid": "0.0.2",
"vue": "^2.0.3",
"vue-hot-reload-api": "^2.0.6",
"vue-html-loader": "^1.2.3",
"vue-loader": "^9.7.0",
"vue-style-loader": "^1.0.0",
"webpack": "^1.12.13",
"vue": "^2.1.0",
"vue-loader": "^10.0.0",
"vue-template-compiler": "^2.1.10",
"webpack": "^2.2.1",
"whatwg-fetch": "^1.0.0"

@@ -109,0 +107,0 @@ },

@@ -46,3 +46,3 @@ # hotel [![Mac/Linux Build Status](https://img.shields.io/travis/typicode/hotel/master.svg?label=Mac%20OSX%20%26%20Linux)](https://travis-ci.org/typicode/hotel) [![Windows Build status](https://img.shields.io/appveyor/ci/typicode/hotel/master.svg?label=Windows)](https://ci.appveyor.com/project/typicode/hotel/branch/master) [![](https://badge.fury.io/js/hotel.svg)](https://www.npmjs.com/package/hotel)

```sh
# http://brew.sh
# https://brew.sh
brew install node

@@ -92,2 +92,4 @@

__Tip__ you can also use `hotel run <cmd>` to start your server in the terminal and get a temporary local domain.
#### Popular servers examples

@@ -128,4 +130,6 @@

hotel add <cmd|url> [opts]
hotel run <cmd> [opts]
# Examples:
# Examples
hotel add 'nodemon app.js' --out dev.log # Set output file (default: none)

@@ -137,3 +141,6 @@ hotel add 'nodemon app.js' --name name # Set custom name (default: current dir name)

hotel run 'nodemon app.js' # Run server and get a temporary local domain
# Other commands
hotel ls # List servers

@@ -186,5 +193,12 @@ hotel rm # Remove server

* [HotelX](https://github.com/djyde/HotelX) Another OS X menubar (only 1.6MB)
* [alfred-hotel](https://github.com/exah/alfred-hotel) Alfred 3 workflow
## FAQ
#### Seting a fixed port
```sh
hotel add --port 3000 'server-cmd $PORT'
```
#### Adding `X-Forwarded-*` headers to requests

@@ -196,14 +210,12 @@

Alias `-x`
#### Setting `HTTP_PROXY` env
#### Seting a fixed port
Use `--http-proxy-env` flag when adding your server or edit your server configuration in `~/.hotel/servers`
```sh
hotel add --port 3000 'server-cmd $PORT'
hotel add --http-proxy-env 'server-cmd'
```
Alias `-p`
#### Proxying requests to a remote `https` server
### Proxying requests to a remote `https` server
```sh

@@ -213,4 +225,2 @@ hotel add --change-origin 'https://jsonplaceholder.typicode.com'

Alias `--co`
_When proxying to a `https` server, you may get an error because your local `.dev` domain doesn't match the host defined in the server certificate. With this flag, `host` header is changed to match the target URL._

@@ -217,0 +227,0 @@

@@ -81,3 +81,4 @@ const fs = require('fs')

'-x',
'--co'
'--co',
'--http-proxy-env'
])

@@ -97,3 +98,4 @@

xfwd: true,
changeOrigin: true
changeOrigin: true,
httpProxyEnv: true
}

@@ -100,0 +102,0 @@

@@ -63,3 +63,4 @@ const fs = require('fs')

out: '/tmp/logs/app.log',
env: ['FOO']
env: ['FOO'],
httpProxyEnv: true
})

@@ -123,3 +124,11 @@

.expect(/host: node.dev/)
.expect(200, /Hello World/, t.end)
.expect(200, /Hello World/, (err, res) => {
if (err) return t.end(err)
t.notRegex(
res.body,
/http:\/\/127.0.0.1:2000\/proxy.pac/,
`shouldn't be started with HTTP_PROXY env set`
)
return t.end()
})
}

@@ -126,0 +135,0 @@ )

@@ -15,2 +15,2 @@ var http = require('http')

console.log('Server running on port', process.env.PORT)
console.log('Server listening on port', process.env.PORT)

@@ -17,11 +17,11 @@ module.exports = {

exclude: /node_modules/,
loader: 'babel'
loader: 'babel-loader'
},
{
test: /\.json$/,
loader: 'json'
loader: 'json-loader'
},
{
test: /\.vue$/, // a regex for matching all files that end in `.vue`
loader: 'vue' // loader to use for matched files
loader: 'vue-loader' // loader to use for matched files
}

@@ -32,4 +32,6 @@ ]

resolve: {
alias: {vue: 'vue/dist/vue.js'}
alias: {
vue: 'vue/dist/vue.js'
}
}
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc