davidpcaldwell / slime

Mozilla Public License 2.0
2 stars 1 forks source link

Enable jsh to be executed via remote shell executed against GitHub #280

Closed davidpcaldwell closed 3 years ago

davidpcaldwell commented 3 years ago

Still need to:

  1. Set up requests after the jsh.bash request to use HTTPS, by changing PROTOCOL in jsh.jsh.js, setting up https.proxyHost and https.proxyPort correctly (and passing them through correctly; see http.proxyHost and http.proxyPort
  2. Make JSH_OPTIMIZE_REMOTE_SHELL optional when doing remote testing, and give it a better name
davidpcaldwell commented 3 years ago

May want to try the rhino/tools/github/authorize.js approach to disable HTTPS security for local usage; unclear whether that is the problem with the HTTPS setup but worth trying, should be quick.

davidpcaldwell commented 3 years ago

Fully-local simulator still not working, but attempting to run against real GitHub started fine and ended up hitting rate limit. So it may be that the code is now correct. May need to use GitHub Pages as an alternative way to serve these files.

davidpcaldwell commented 3 years ago

Given rate-limit issue, now implementing alternate version that uses available download. For this, should build an appropriate local mock for testing.

davidpcaldwell commented 3 years ago

Created code to produce mocked GitHub ZIP distribution for local testing. File looks to be correct but jsh plugins are not correctly loaded from it. Need to investigate further but attempting to push up changes as they are likely to pass existing tests.

davidpcaldwell commented 3 years ago

Lots of commits in adding type checking and clarity to the jrunscript bootstrap and jsh launcher code. Still have at least two areas to modify:

  1. Use new GithubArchive object, passed through $api somehow, to implement slime.js getSourceFilesUnder in the URL case (where currently we use raw.githubusercontent.com)
  2. In javac.js, need to check whether a source file URL is available via archive and create a different SourceFile implementation if it is.

That, along with a bit of scaffolding to provide GithubArchive access via $api, may be all that's left.

davidpcaldwell commented 3 years ago

Got it down to this for launching the sample script:

Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh.bash
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/rhino/jrunscript/api.js
Request: GET github.com davidpcaldwell/slime/archive/refs/heads/master.zip
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh/launcher/main.js
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh/launcher/slime.js
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh/launcher/launcher.js
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh/launcher/javac.js
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh/launcher/jsh.jar
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/local/jsh/lib
Request: GET github.com davidpcaldwell/slime/archive/refs/heads/master.zip
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh/test/jsh-data.jsh.js

Seems like it should be possible to short-circuit the load() calls (to jsh/launcher/main.js, etc.) and maybe the local/jsh/lib call as well. But the raw.githubusercontent.com calls are still possibly rate-limited (according to some cursory Googling), so it may make sense to switch to GitHub Pages for master or something to serve these?

Still, probably could run a single script successfully now.

davidpcaldwell commented 3 years ago

Script launched from GitHub still appears to provide no output; should maybe try a Hello, World rather than jsh-data.jsh.js.

davidpcaldwell commented 3 years ago

Removed jsh launcher accesses over HTTP, so all that seems to be left is in the loader:

Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh.bash
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/rhino/jrunscript/api.js
Request: GET github.com davidpcaldwell/slime/archive/refs/heads/master.zip
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh/launcher/jsh.jar
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/local/jsh/lib
Request: GET github.com davidpcaldwell/slime/archive/refs/heads/master.zip
Request: GET raw.githubusercontent.com davidpcaldwell/slime/master/jsh/test/jsh-data.jsh.js

The bottom four are believed to be within the loader; it'd be good to get rid of the requests for jsh.jar and local/jsh/lib if possible.

We'll close this ticket leaving the others in place, pending a possible move to GitHub Pages, which would only support serving a single directory (perhaps master or some kind of released branch).

davidpcaldwell commented 3 years ago

after the coming commit, the only remaining question is, does the code work? Why has it produced no output on the client?