open-index/open-npm huggingface dataset:
npm package: @cbs-consulting/generate-default-env
Description: Generate default-env.json from .cdsrc-private.json CF bindings
Latest version: 1.0.0

# @cbs-consulting/generate-default-env

Generate `default-env.json` from `.cdsrc-private.json` Cloud Foundry bindings.

This utility automatically fetches Cloud Foundry service credentials and generates a `default-env.json` file that can be used for local development or in CI/CD pipelines.

## Installation

```bash
npm install @cbs-consulting/generate-default-env
```

## Usage

### Command Line

After installation, you can use the CLI command:

```bash
# Generate default-env.json using the 'hybrid' profile
generate-default-env hybrid

# Specify output file
generate-default-env hybrid default-env.json

# Specify workspace root directory
generate-default-env ownHDI gen/db/default-env.json /path/to/workspace
```

#### Parameters

1. **profile** (optional, default: `hybrid`): The profile name from `.cdsrc-private.json` (without brackets)
2. **outputFile** (optional, default: `default-env.json`): Path where the output file will be written
3. **workspaceRoot** (optional, default: current directory): Directory containing `.cdsrc-private.json`

## Configuration

The tool reads from `.cdsrc-private.json` in your workspace root. Example structure:

```json
{
  "requires": {
    "[hybrid]": {
      "db": {
        "kind": "hana",
        "binding": {
          "apiEndpoint": "https://api.cf.example.com",
          "org": "my-org",
          "space": "dev",
          "instance": "my-hdi-container",
          "key": "my-service-key"
        },
        "vcap": {
          "name": "my-hdi-db"
        }
      },
      "xsuaa": {
        "kind": "xsuaa",
        "binding": {
          "apiEndpoint": "https://api.cf.example.com",
          "org": "my-org",
          "space": "dev",
          "instance": "my-xsuaa",
          "key": "my-xsuaa-key"
        }
      }
    }
  }
}
```

## Output

The tool generates a `default-env.json` file with the following structure:

```json
{
  "VCAP_SERVICES": {
    "hana": [
      {
        "name": "my-hdi-db",
        "instance_name": "my-hdi-container",
        "label": "hana",
        "tags": ["hana"],
        "plan": "standard",
        "credentials": {
          "host": "...",
          "port": "...",
          "user": "...",
          "password": "...",
          "schema": "..."
        }
      }
    ]
  },
  "TARGET_CONTAINER": "my-hdi-db"
}
```