bjoluc/jspsych-builder

Allow for us to change the port

jmuchovej opened this issue ยท 6 comments

I have a few webservers I leave running (locally) to avoid needing to remember to restart them, one of them runs on :3000. I was sad to find that the port is hard-coded to :3000, as per

port: 3000,

I'm willing to submit a PR to allow this to be dynamic (with a default of :3000), but wanted to gauge whether it would be an "acceptable" change (as I'm not maintaining this ๐Ÿ˜…).

No idea how hard this would be, but it could also make sense to let this "walk the ports" like Jupyter and Docker do when opening ports?

Thanks @jmuchovej,

I fully agree, including the "walk the ports" part. It turns out webpack-dev-server has that already, so we can just rely on it by default! ๐ŸŽ‰
PRs are always welcome! If you decide to create one though, you might want to wait until tomorrow as I'm currently migrating the project to TypeScript and didn't yet commit anything of that. Otherwise, I think I'll get to this in the next couple of days ๐Ÿ™‚

Oooh. I see. Didn't know webpack-dev-server did that. ๐Ÿ‘€

Should the behavior, then, be use the user's port OR "walk the ports"? It seems that webpack-dev-server doesn't support it as a fallback option?

Also, re:TS migration โ€“ awesome! ๐Ÿ™‚
Is it a full-on TS migration, or just for the "core CLI"? (i.e., will folks need to use TS for their experiments?)

Should the behavior, then be use the user's port OR "walk the ports"? It seems that webpack-dev-server doesn't support it as a fallback option?

Good point. I do think so, i.e. I think it's a good idea to fail when the user provides a port which is not available, and only walk the ports when none was set. A user who passes a port most likely wants the server to run on that exact port and not just any other port nearby...

Is it a full-on TS migration, or just for the "core CLI"? (i.e., will folks need to use TS for their experiments?)

No worries, it's just the CLI ๐Ÿ˜„ User-side TS is supported since v4.1.0 though ๐Ÿ‘

Cool.

Do you think setting an environment variable like... JSPSYCH_PORT should be a default/supported mode? If so, should dotenv be supported?

(I'm happy to make these changes, just thinking about to what degree of supporting this you'd be interested in doing. ๐Ÿ˜… I'll, of course, hold-off until the TS migration is complete. Just planning ahead.)

Do you think setting an environment variable like... JSPSYCH_PORT should be a default/supported mode? If so, should dotenv be supported?

Since the run command is the only one that would use it, and it is only intended for development, I don't think environment variable support is worth the overhead. One could as well insert the environment variable's value into the run command using bash or the like.

The TS code is on the develop branch now โ€“ good enough for now, I think, though typing can be improved here and there. Feel free to check it out and author a PR against develop if you feel like it!

๐ŸŽ‰ This issue has been resolved in version 4.2.0 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€