-
Notifications
You must be signed in to change notification settings - Fork 743
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
[RFC] [WIP] Tool registry #197
base: master
Are you sure you want to change the base?
Conversation
... with the hope that it allows us to do better error reporting.
I was recently thinking about this problem too, but instead of custom tool builder I rather thought about using wzrd.in which will do bundling & caching for us. |
This is looking good to me. I wanted to take a peek locally (to preview the changes), but I keep seeing "build timeouts". I'm definitely not doing something right. I'll try to take a look at the |
@RReverser: Maybe wzrd.in can be used for dependencies required from transformers, on the fly. I don't think it would give us enough flexibilities for the existing parsers and transforms. Just look the special treatments we have to do for the some of the parsers/transforms in the webpack config. @skratchdot: Thanks! Sorry, I didn't really provide any instructions for how to run it. You need to have redis installed. Then the following commands should do it (in three different windows)
|
@fkling - That's basically what I tried, although this time, I'm getting slightly different errors. I know at one point I had to run In my current setup, I'll run the commands you pasted. Everything starts without error. I hit Then in my
And in my
I've tried yarn adding missing modules at different times but currently, I've tried |
Oh I see. You can only build what is available in the |
I just didn't understand why hitting |
Oh, that's probably because As I said, it's very much WIP 😉 |
Nice!! That fixed the I had to make 1 small change b/c I was running into a I changed:
To:
|
Note: The code is pretty raw and will change a lot. I'm primarily looking for feedback/questions on the idea, but I also appreciate feedback on parts of the code.
Problems
There are a couple of problems with the current way of how astexplorer makes different parsers and transformers available:
This proposal would solve all of these issues.
Proposed solution: A tool registry and unified interface
The registry is basically a separate endpoint that builds parsers (more generally: tools) on demand, independently of the website itself and other tools. For example,
/api/v1/tools/acorn/4.0.11
would return version 4.0.11 of acorn.The tools are stored in
registry/tools/<toolname>/
and pretty much use the same interface as the current parsers/transformers inwebsite/src/parsers/
. They are still associated with a category (i.e. JavaScript, CSS) but not grouped by it anymore (only in the UI).In addition to the wrapper/interface files,
package.js
contains meta and build information for a tool, for example:The field
versions
contains information about which versions are available (taken from the semver range in thedependencies
entry), which entry file to use for a specific version, and which build configuration (if adjustments are needed) to use.Given a specific version, the build script finds the entry that satisfies the requested version, generates a
package.json
file and copies the source files into a temporary folder. In there it installs the specified dependencies, the requested tool version and runs webpack. Webpack will generate an AMD bundle.Unified interface
One big difference is that transformers also have to provide a
parse()
method (instead of specifying the ID of a parser to use). This method is supposed to delegate to the parser the transform is using. That means, whether a tool is a transformer only depends on whether or not it implements atransform
method.Overall this should simplify the store logic and other places on the website.
Another positive side effect of this: The "parser settings" logic can now be reused for transformer settings.
Building versions on demand
If a bundle isn't available for the requested version, the webserver creates a new build job. The job is processed by another process. On my machine, building acorn took ~2s, building jscodeshift took ~13s. I'll have to see how the build times are on the server.
Automatically build the latest version
A cron job can run to periodically check all tools for new available versions and build the latest version automatically.
Automatically build inventory
Another cron job will take the information of all the
package.js
files and generate an inventory that lists all the available tools and versions. This information is used on the website to let the visitor choose a tool (see previous screenshot).More ideas
Current limitations of the solution
package.js
should be structured for non-npm tools.ToDo
... and probably more