-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the proxy-host and proxy-port, introduce proxy-url instead #567
Conversation
One thing I am wondering though is that I was tempted to use it as:
Which wouldn't work as Proxy will still kick off if I skip the protocol but later result in error, while trying to proxy:
is valid usage. |
Jep you should append Sry for closing and reopening this. I've hit the button accidentally. |
@@ -10,8 +10,7 @@ module.exports = Command.extend({ | |||
availableOptions: [ | |||
{ name: 'port', type: Number, default: 4200 }, | |||
{ name: 'host', type: String, default: '0.0.0.0' }, | |||
{ name: 'proxy-port', type: Number }, | |||
{ name: 'proxy-host', type: String }, | |||
{ name: 'proxy-url', type: String }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just --proxy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although --proxy
works, too (because nopt expands it), I also think we could just call it --proxy
. It's simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sounds good.
i like this approach, can you add some tests, and an entry in the changelog? |
@MajorBreakfast im not concerned about length, this will most commonly be driven from the dotfile |
To me
itself does feel wrong. I've asked node.js team about it (nodejs/node-v0.x-archive#7547). Eventually if |
@stefanpenner Yeah couldn't find any proxy related tests so can add some. I am not too familiar with the codebase though. To what level (integration/unit) you want to test it? |
@stefanpenner I think calling if (/^\d*$/.test(options.proxy)) { proxy = 'http://localhost:' + proxy }
if (!/^https?:\/\//.test(options.proxy)) { proxy = 'http://' + proxy } |
@MajorBreakfast Yeah, that would certainly work. Alternative approach might be to expect the So yeah, solution injecting defaults or better error feedback both look good to me. If going for defaults, should it be somewhere explicitly mentioned or we expect 'http://localhost:' as implicit "reasonable" default? |
@petrjanda status? Would love to get this in for this weekends release. |
@stefanpenner couldn't figure out nice way to test it. Suggestions? What about the defaults (protocol / domain)? Shall we add them as well? |
I would prefer we only allowed the fully qualified uri for now. No short cuts |
@petrjanda like a test in: https://github.com/stefanpenner/ember-cli/blob/master/tests/unit/cli/cli-test.js to ensure the param gets passed through. And another test to ensure the serve task when given the URI passes it through to the server |
@@ -125,6 +125,17 @@ describe('Unit: CLI', function() { | |||
|
|||
describe('server', function() { | |||
['server','s'].forEach(function(command) { | |||
it('expects version in UI output', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored this to separate test. I wanted to increase output.length
in assert as proxy does write extra line to the output but because of stub the server command is actually never called in this spec so was rather confusing. Afaik only output it handles is before command.validateAndRun
is triggered.
it('should start proxy if ```proxy``` URI is given', function() { | ||
expressServer.ui = new MockUI(); | ||
return expressServer.start({proxy: 'http://localhost:3000/'}).then(function() { | ||
var output = expressServer.ui.output.trim().split('\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really best test. I cant use stub
test helper for constructors, right? I think stubbing and testing the call to proxy
would be ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also match against the output make sure it contains the proxy URI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
this is looking pretty good, let me know when its ready. (it will also need a rebase) |
|
||
assert.equal(serveRun.called, 1, 'expected run to be called once'); | ||
|
||
assert.equal(options.proxy, 'http://localhost:3000/', 'has correct port'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has correct proxy
?
merged manually f672ede |
this is great. thanks, a lot better than launching chrome without web security |
Simplified proxy setup, fixes #465.