Skip to main content

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:

ModuleDescription
(none)Detect project resources and generate a complete configuration
fnGenerate a function configuration template
integrationGenerate an integration configuration template

Parameters​

Full initialisation:

ParameterRequiredDescriptionDefault
--no-directoryNoWrite the configuration only, skip the directory skeletonfalse
-o, --output <output>NoOutput path, relative paths resolve against the current directorycloudbaserc.json

Module initialisation (fn / integration):

ParameterRequiredDescriptionDefault
[keyId]NoFunction name (fn) or integration keyId (integration), prompts when omitted—
--type <type>NoIntegration type, integration module only, for example weixinpaydcPrompts
-o, --output <output>NoOutput path, relative paths resolve against the current directorycloudbaserc.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_bootstrap is recognised as an HTTP function
  • Framework: detects Vite, Next.js, Nuxt, Angular, Vue CLI and others from config files such as vite.config.js and next.config.js plus package.json dependencies
  • Static directories: recognises dist/, build/, web/, public/, preferring the framework output directory
  • Autofill: fills the default environment ID when logged in, and copies scripts.build from package.json into buildCommand

A summary appears for confirmation first; after confirmation the CLI writes the configuration and creates the directory skeleton.

Behaviour​

ScenarioBehaviour
Full initialisationWrites the complete configuration with outputDir / buildCommand / installCommand; creates functions/ and web/ skeletons unless --no-directory is passed
Function configurationWrites a template with name, timeout, runtime, envVariables, and related fields
Integration configurationPulls 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.