Azure / Azure/data-api-builder
[Enh]: Enhance Command Line & Console Output
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 370
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 8
Description
## What is it?
* Update `dab init` to create a `.env` file when a connection string is supplied.
* Update `dab start` to output a summary table after starting.
* Add `dab validate -output: test-result.xml` for CICD automation.
* Make progress on `dab configure` to edit everything from the command line.
## Automatic .env file
1. Create the `.env` file
* If `dab init` is passing an `@env()` value, then do not continue with this.
* If a `.env` file already exists, modify it.
3. Use a default environment variable name `my-connection-string`
Simple `.env` file contents:
```bash
my-connection-string=whatever-the-user-provided
```
4. Reference the environment variable name in the `dab-config.json` file.
Using variables in the JSON:
```json
{
"$schema": "...",
"data-source": {
"database-type": "mssql",
"connection-string": "@env('my-connection-string')"
}
}
```
## dab start Summary table
Today, it's just console logs. This is not new information, just easier to use.
||Http Endpoint|Https Endpoint|
|-|-|-|
|OpenAPI|http://localhost/API/OpenAPI|https://localhost/API/OpenAPI
|Swagger|http://localhost/swagger|https://localhost/swagger
|GraphQL|http://localhost/graphql|https://localhost/graphql
|Health|http://localhost/|https://localhost/
When production
||Http Endpoint|Https Endpoint|
|-|-|-|
|OpenAPI|http://localhost/API/OpenAPI|https://localhost/API/OpenAPI
|Swagger|mode=Production|mode=Production
|GraphQL|mode=Production|mode=Production
|Health|http://localhost/|https://localhost/
When no HTTPS
||Http Endpoint|Https Endpoint|
|-|-|-|
|OpenAPI|http://localhost/API/OpenAPI|Not Configured
|Swagger|http://localhost/swagger|Not Configured
|GraphQL|http://localhost/graphql|Not Configured
|Health|http://localhost/|Not Configured
## dab validate Output File
The flag `dab validate -output:results.xml` extends `dab validate` to support outputting the validation results in a **machine-readable XML format** useful for CI/CD pipelines. This allows for automated validation of configuration files, where any validation errors will be written to the specified XML file for further processing or reporting just like unit test. It's okay to still output to the console.
**Sample file**
The **JUnit XML** format is widely used for reporting test results and is supported by most CI/CD tools (Jenkins, GitLab CI, Azure DevOps, etc.). You can find the JUnit XML schema reference and examples at the following link: [JUnit XML Format](https://llg.cubic.org/docs/junit/).
```xml
The data-source section is missing the required 'connection-string' field.
The entities array in the configuration is empty. Please define at least one entity.
The value 'abc' for runtime/host/mode is invalid. Expected values are 'development', 'production', or 'staging'.
```
## Related issues to potentially close
* #2296
* #2295
* #2251
* #2000
* #1924
* #1861
* #1781
* #1477
* #2276
* #1796
* *2168
Contributor guide
Assessment
This issue has not been assessed yet.