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] [name] [options]

[module] is optional:

ModuleDescription
(none)Detect project resources and generate a complete configuration
fnGenerate a function configuration template
integrationGenerate an integration configuration template; [name] is the integration instance name

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
[name]NoFunction name (fn) or integration instance name (integration), prompts when omitted—
--keyid <keyId>NoIntegration instance identifier, integration module only. Generated from [name] when omittedGenerated
--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 stripe-test

# Specify the integration type
tcb config init integration stripe-test --type stripe-pay

# Set the keyId yourself
tcb config init integration stripe-test --keyid stripe-test-a1b2c3d4

# Custom output path
tcb config init integration stripe-test --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, leaves sensitive values as ****** to fill in manually, and writes the generated keyId plus system callback URLs

Existing files are never overwritten.