tcb config init
Generate cloudbaserc.json interactively. Without a module argument the command detects functions, frontend frameworks, and static directories to build a complete configuration; with a module argument it writes only that module's template.
Usage
tcb config init [module] [options]
[module] is optional:
| Module | Description |
|---|---|
| (none) | Detect project resources and generate a complete configuration |
fn | Generate a function configuration template |
integration | Generate an integration configuration template |
Parameters
Full initialisation:
| Parameter | Required | Description | Default |
|---|---|---|---|
--no-directory | No | Write the configuration only, skip the directory skeleton | false |
-o, --output <output> | No | Output path, relative paths resolve against the current directory | cloudbaserc.json |
Module initialisation (fn / integration):
| Parameter | Required | Description | Default |
|---|---|---|---|
[keyId] | No | Function name (fn) or integration keyId (integration), prompts when omitted | — |
--type <type> | No | Integration type, integration module only, for example weixinpaydc | Prompts |
-o, --output <output> | No | Output path, relative paths resolve against the current directory | cloudbaserc.json |
Examples
# Detect project resources and generate a complete configuration
tcb config init
# Write the configuration only, no directory skeleton
tcb config init --no-directory
# Custom output path
tcb config init -o ./config/cloudbaserc.json
# Create a function configuration interactively
tcb config init fn
# Create a function configuration for a named function
tcb config init fn myFunc
# Pick an integration type interactively
tcb config init integration
# Specify the integration type and keyId
tcb config init integration myPayment --type weixinpaydc -o ./config/cloudbaserc.json
Sample output:
{
"$schema": "https://static.cloudbase.net/cli/cloudbaserc.schema.json",
"envId": "env-xxx",
"functionRoot": "./functions",
"functions": [
{
"name": "myPythonFn",
"handler": "main.main",
"runtime": "Python3.11",
"timeout": 3,
"memorySize": 256
}
],
"hosting": [
{
"name": "web",
"root": "web",
"framework": "vite",
"outputDir": "dist",
"buildCommand": "npm run build",
"installCommand": "npm install"
}
]
}
Detection
Without a module argument the CLI inspects the project:
- Functions: scans
functions/, infers each function's runtime, handler, and type (Event / HTTP);scf_bootstrapis recognised as an HTTP function - Framework: detects Vite, Next.js, Nuxt, Angular, Vue CLI and others from config files such as
vite.config.jsandnext.config.jspluspackage.jsondependencies - Static directories: recognises
dist/,build/,web/,public/, preferring the framework output directory - Autofill: fills the default environment ID when logged in, and copies
scripts.buildfrompackage.jsonintobuildCommand
A summary appears for confirmation first; after confirmation the CLI writes the configuration and creates the directory skeleton.
Behaviour
| Scenario | Behaviour |
|---|---|
| Full initialisation | Writes the complete configuration with outputDir / buildCommand / installCommand; creates functions/ and web/ skeletons unless --no-directory is passed |
| Function configuration | Writes a template with name, timeout, runtime, envVariables, and related fields |
| Integration configuration | Pulls the field definition of the integration type from the cloud, marks required and optional fields, and leaves sensitive values as ****** to fill in manually |
Existing files are never overwritten.
Related Commands
- Configuration file: field reference and complete examples
- Declarative deployment: deploy everything at once
- Validate before deploy: check the configuration first