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

feat(cli): support reading auth token in CLI with --auth-token and in ENV with MERMAID_CHART_AUTH_TOKEN #22

Merged

Conversation

aloisklink
Copy link
Contributor

@aloisklink aloisklink commented Apr 11, 2024

Support loading the auth token and Mermaid Chart base URL from environment variables using MERMAID_CHART_AUTH_TOKEN and MERMAID_CHART_BASE_URL, and from the CLI using --auth-token <authToken> and --base-url <baseUrl>.

The order of priority is:

  1. CLI --options
  2. Environment variables
  3. Config file
  4. Default values

This is to make it easier for us to use the @mermaidchart/cli in CI providers, like in a GitHub Action workflow.

Notes to reviewers

I've used Commander.js to handle setting these variables, so run npx @mermaidchart/cli automatically prints documentation for this:

alois@pc:~/plugins/packages/cli (feat/support-loading-tokens-from-environment-variables)$ npx tsx src/cli.ts --help
Usage: mermaid-cli [options] [command]

CLI for interacting with https://MermaidChart.com, the platform that makes collaborating with Mermaid diagrams easy.

Options:
  -V, --version               output the version number
  -c, --config <config_file>  The path to the config file to use. (default: "/home/alois/.config/mermaid-chart.toml")
  --base-url <base_url>       The base URL of the Mermaid Chart instance to use. (default: "https://mermaidchart.com", env: MERMAID_CHART_BASE_URL)
  --auth-token <auth_token>   The Mermaid Chart API token to use. (env: MERMAID_CHART_AUTH_TOKEN)
  -h, --help                  display help for command

<---TRUNCATED TO MAKE THIS PR SMALLER -->

Also, I know this is a bit of a big PR, so it might be easier to review it commit-by-commit!

@aloisklink aloisklink added the enhancement New feature or request label Apr 11, 2024
Copy link

vercel bot commented Apr 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
office-plugin-site ⬜️ Ignored (Inspect) Visit Preview Apr 12, 2024 1:11pm

Support setting the mermaidchart baseURL by using `--base-url`, and
the auth token with `--auth-token`. The values will override the values
in the config file, if specified.
Support loading the auth token and Mermaid Chart base URL from
environment variables using `MERMAID_CHART_AUTH_TOKEN` and
`MERMAID_CHART_BASE_URL`.

The order of priority is:
  1. CLI --options
  2. Environment variables
  3. Config file
  4. Default values
@aloisklink aloisklink force-pushed the feat/support-loading-tokens-from-environment-variables branch from 0816b40 to e16a4b1 Compare April 12, 2024 13:11
Base automatically changed from feat/use-a-url-id-for-frontmatter to main April 22, 2024 04:07
@aloisklink aloisklink merged commit ce94af6 into main Apr 22, 2024
6 checks passed
@aloisklink aloisklink deleted the feat/support-loading-tokens-from-environment-variables branch April 22, 2024 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants