[Experimental] Added script capability to Optic #323
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@LouManglass -- as discussed, in this PR I've implemented the
scripts
command to back up the demand-gen project.Scripts are registered similarly to how you setup a task.
The most basic script looks like this:
^ But a naked command like this is hard to share with your team. Unlike an npm script there's no affordances in bash to require certain dependencies to be on your /bin. This means you also need to tell your teammates or CI pipeline to install these manually.
To address this, you can also use the expanded syntax (this is what I imagine we'd share in our blog posts to make things work automagically).
Add this to your
optic.yml
and runapidev scripts publish-redoc
The check for
redoc-cli
fails and asks you to run the command again with the--install
flag. This won't catch everything (if npm isn't installed you're still screwed), but it should help most teams get aligned. You can always see the failures and fallback to manual dependency resolution.Presto! Script executed -- static docs built
Note
All scripts get
OPENAPI_JSON
andOPENAPI_YAML
. These are paths to their respective files and are injected as env variables.