Skip to main content

tcb validate

Validate that the project cloudbaserc.json is well formed, that resource directories exist, and that resource references are consistent, surfacing configuration problems before deployment.

v3.8.0+

tcb validate has been available since v3.8.0.

Usage​

tcb validate [options]

Parameters​

ParameterRequiredDescriptionDefault
--config-file <path>NoPath to the configuration filecloudbaserc.json in the project root
--mode <mode>NoValidate after applying envOverrides.<mode>—

Examples​

# Validate cloudbaserc.json in the current directory
tcb validate

# Custom configuration file
tcb validate --config-file ./config/prod.json

# Validate a specific mode
tcb validate --mode dev

A passing run prints a resource summary and exits with 0:

[PASS] 项目校验通过
资源概览:云函数 1 个,静态托管 1 个,数据库 0 个,网关路由 2 条

Checks​

CheckDescriptionExample
Configuration structureMatches the cloudbaserc schema, valid fields, no additional propertiesgateway.routes rejects cdnType and other unknown fields
envIdThe configuration must contain envId—
Resource directoriesFunction directories, hosting roots, and so on existA missing functions/pay-common/ is reported
ConsistencyFunction or hosting referenced by a gateway target is declaredtarget: "function:pay-common" without that function

Output and exit codes​

ResultOutputExit code
PassedResource summary0
FailedError list with field and fix suggestion1
错误(2)
- gateway.routes.0: 配置不符合 cloudbaserc schema:should NOT have additional properties
修复建议:请检查 gateway.routes.0 字段
- gateway.routes.1: 配置不符合 cloudbaserc schema:should NOT have additional properties
修复建议:请检查 gateway.routes.1 字段

Relation to tcb deploy​

  • tcb deploy also guards the configuration lightly (envId present, configuration valid)
  • Run tcb validate before tcb deploy in CI so problems surface early
  • The full check (structure / directories / consistency) is the job of tcb validate