Skip to content
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

[Experimental] Added script capability to Optic #323

Merged
merged 2 commits into from
Aug 26, 2020

Conversation

acunniffe
Copy link
Member

@acunniffe acunniffe commented Aug 22, 2020

@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:

scripts:
  do-thing: rdme push $OPENAPI_YAML --id xyz

^ 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).

scripts:
  publish-redoc:
    command: redoc-cli bundle $OPENAPI_YAML
    dependsOn: redoc-cli
    install: npm install redoc-cli -g

Add this to your optic.yml and run apidev scripts publish-redoc

Screen Shot 2020-08-22 at 10 18 05 AM

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

Screen Shot 2020-08-22 at 10 19 43 AM

Note
All scripts get OPENAPI_JSON and OPENAPI_YAML. These are paths to their respective files and are injected as env variables.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request has been automatically deployed to FeaturePeek. 👩‍🎤
Your deployment will be kept up-to-date with this pull request's latest changes.

https://peek.run/g5whmp6d


Please read our docs for more configuration details.

@acunniffe acunniffe merged commit 48b2159 into develop Aug 26, 2020
@acunniffe acunniffe deleted the scripts-experiment branch August 26, 2020 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant