b2c-config

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

B2C Config Skill

B2C配置Skill

Use the
b2c setup inspect
command to view the resolved configuration and understand where each value comes from. Use the
b2c setup instance
commands to manage named instance configurations.
Tip:
b2c setup config
still works as an alias. If
b2c
is not installed globally, use
npx @salesforce/b2c-cli
instead (e.g.,
npx @salesforce/b2c-cli setup inspect
).
使用
b2c setup inspect
命令查看已解析的配置,并了解每个值的来源。使用
b2c setup instance
命令管理命名实例配置。
提示:
b2c setup config
仍可用作别名。如果未全局安装
b2c
,请改用
npx @salesforce/b2c-cli
(例如:
npx @salesforce/b2c-cli setup inspect
)。

When to Use

使用场景

Use
b2c setup inspect
when you need to:
  • Verify which configuration file is being used
  • Check if environment variables are being read correctly
  • Debug authentication failures by confirming credentials are loaded
  • Understand credential source priority (dw.json vs env vars vs plugins)
  • Identify hostname mismatch protection issues
  • Verify MRT API key is loaded from ~/.mobify
Use
b2c setup instance
commands when you need to:
  • List all configured instances
  • Create a new instance configuration
  • Switch between instances (set active)
  • Remove an instance configuration
当你需要以下操作时,使用
b2c setup inspect
  • 验证正在使用哪个配置文件
  • 检查环境变量是否被正确读取
  • 通过确认凭据已加载来调试身份验证失败问题
  • 了解凭据来源的优先级(dw.json vs 环境变量 vs 插件)
  • 识别主机名不匹配保护问题
  • 验证MRT API密钥是否从~/.mobify加载
当你需要以下操作时,使用
b2c setup instance
命令:
  • 列出所有已配置的实例
  • 创建新的实例配置
  • 在实例之间切换(设置为活动实例)
  • 删除实例配置

Inspecting Configuration

检查配置

View Current Configuration

查看当前配置

bash
undefined
bash
undefined

Display resolved configuration (sensitive values masked by default)

显示已解析的配置(默认会屏蔽敏感值)

b2c setup inspect
b2c setup inspect

View configuration for a specific instance from dw.json

查看dw.json中特定实例的配置

b2c setup inspect -i staging
b2c setup inspect -i staging

View configuration with a specific config file

使用指定的配置文件查看配置

b2c setup inspect --config /path/to/dw.json
undefined
b2c setup inspect --config /path/to/dw.json
undefined

Debug Sensitive Values

调试敏感值

bash
undefined
bash
undefined

Show actual passwords, secrets, and API keys (use with caution)

显示完整的密码、密钥和API密钥(谨慎使用)

b2c setup inspect --unmask
undefined
b2c setup inspect --unmask
undefined

JSON Output for Scripting

用于脚本的JSON输出

bash
undefined
bash
undefined

Output as JSON for parsing in scripts

以JSON格式输出,用于脚本解析

b2c setup inspect --json
b2c setup inspect --json

Pretty-print with jq

使用jq进行格式化输出

b2c setup inspect --json | jq '.config'
b2c setup inspect --json | jq '.config'

Check which sources are loaded

检查已加载的来源

b2c setup inspect --json | jq '.sources'
undefined
b2c setup inspect --json | jq '.sources'
undefined

IDE Integration (Prophet)

IDE集成(Prophet)

Use
b2c setup ide prophet
to generate a
dw.js
bridge script for the Prophet VS Code extension.
bash
undefined
使用
b2c setup ide prophet
为Prophet VS Code扩展生成
dw.js
桥接脚本。
bash
undefined

Generate ./dw.js in the current project

在当前项目中生成./dw.js

b2c setup ide prophet
b2c setup ide prophet

Overwrite existing file

覆盖现有文件

b2c setup ide prophet --force
b2c setup ide prophet --force

Custom path

指定自定义路径

b2c setup ide prophet --output .vscode/dw.js

The generated script runs `b2c setup inspect --json --unmask` at runtime, so Prophet sees the same resolved config as CLI commands, including configuration plugins. It maps values to `dw.json`-style keys and passes through Prophet fields like `cartridgesPath`, `siteID`, and `storefrontPassword` when present.
b2c setup ide prophet --output .vscode/dw.js

生成的脚本会在运行时执行`b2c setup inspect --json --unmask`,因此Prophet会看到与CLI命令相同的已解析配置,包括配置插件。它会将值映射为dw.json风格的键,并在存在时传递Prophet字段,如`cartridgesPath`、`siteID`和`storefrontPassword`。

Managing Instances

管理实例

List Configured Instances

列出已配置的实例

bash
undefined
bash
undefined

Show all instances from dw.json

显示dw.json中的所有实例

b2c setup instance list
b2c setup instance list

Output as JSON

以JSON格式输出

b2c setup instance list --json
undefined
b2c setup instance list --json
undefined

Create a New Instance

创建新实例

bash
undefined
bash
undefined

Interactive mode - prompts for all values

交互模式 - 提示输入所有值

b2c setup instance create staging
b2c setup instance create staging

With hostname

指定主机名

b2c setup instance create staging --hostname staging.example.com
b2c setup instance create staging --hostname staging.example.com

Create and set as active

创建并设置为活动实例

b2c setup instance create staging --hostname staging.example.com --active
b2c setup instance create staging --hostname staging.example.com --active

Non-interactive mode (for scripts)

非交互模式(适用于脚本)

b2c setup instance create staging
--hostname staging.example.com
--username admin
--password secret
--force
undefined
b2c setup instance create staging
--hostname staging.example.com
--username admin
--password secret
--force
undefined

Switch Active Instance

切换活动实例

bash
undefined
bash
undefined

Set staging as the default instance

将staging设置为默认实例

b2c setup instance set-active staging
b2c setup instance set-active staging

Now commands use staging by default

现在命令默认使用staging实例

b2c code list # Uses staging
undefined
b2c code list # 使用staging实例
undefined

Remove an Instance

删除实例

bash
undefined
bash
undefined

Remove with confirmation prompt

删除(带确认提示)

b2c setup instance remove staging
b2c setup instance remove staging

Remove without confirmation

直接删除(无确认提示)

b2c setup instance remove staging --force
undefined
b2c setup instance remove staging --force
undefined

Understanding the Output

理解输出内容

The
setup inspect
command displays configuration organized by category:
  • Instance: hostname, webdavHostname, codeVersion
  • Authentication (Basic): username, password (for WebDAV)
  • Authentication (OAuth): clientId, clientSecret, scopes, authMethods
  • TLS/mTLS: certificate, certificatePassphrase, selfSigned (for two-factor auth)
  • SCAPI: shortCode
  • Managed Runtime (MRT): mrtProject, mrtEnvironment, mrtApiKey
  • Metadata: instanceName (from multi-instance configs)
  • Sources: List of all configuration sources that were loaded
Each value shows its source in brackets:
  • [DwJsonSource]
    - Value from dw.json file
  • [MobifySource]
    - Value from ~/.mobify file
  • [SFCC_*]
    - Value from environment variable
  • [password-store]
    - Value from a credential plugin
setup inspect
命令会按类别显示配置:
  • Instance:hostname、webdavHostname、codeVersion
  • Authentication (Basic):username、password(用于WebDAV)
  • Authentication (OAuth):clientId、clientSecret、scopes、authMethods
  • TLS/mTLS:certificate、certificatePassphrase、selfSigned(用于双因素认证)
  • SCAPI:shortCode
  • Managed Runtime (MRT):mrtProject、mrtEnvironment、mrtApiKey
  • Metadata:instanceName(来自多实例配置)
  • Sources:所有已加载的配置来源列表
每个值都会在括号中显示其来源:
  • [DwJsonSource]
    - 来自dw.json文件的值
  • [MobifySource]
    - 来自~/.mobify文件的值
  • [SFCC_*]
    - 来自环境变量的值
  • [password-store]
    - 来自凭据插件的值

Configuration Priority

配置优先级

Values are resolved with this priority (highest to lowest):
  1. CLI flags and environment variables
  2. Plugin sources (high priority)
  3. dw.json file
  4. ~/.mobify file (MRT API key only)
  5. Plugin sources (low priority)
  6. package.json b2c key
When troubleshooting, check the source column to understand which configuration is taking precedence.
值的解析优先级从高到低如下:
  1. CLI标志和环境变量
  2. 插件来源(高优先级)
  3. dw.json文件
  4. ~/.mobify文件(仅MRT API密钥)
  5. 插件来源(低优先级)
  6. package.json中的b2c键
排查问题时,请查看来源列以了解哪个配置具有更高的优先级。

Common Issues

常见问题

Missing Values

缺失值

If a value shows
-
, it means no source provided that configuration. Check:
  • Is the field spelled correctly in dw.json?
  • Is the environment variable set?
  • Does the plugin provide that value?
如果某个值显示为
-
,表示没有来源提供该配置。请检查:
  • dw.json中的字段拼写是否正确?
  • 环境变量是否已设置?
  • 插件是否提供了该值?

Wrong Source Taking Precedence

错误的来源优先级

If a value comes from an unexpected source:
  • Higher priority sources override lower ones
  • Credential groups (username+password, clientId+clientSecret) are atomic
  • Hostname mismatch protection may discard values
如果值来自意外的来源:
  • 高优先级来源会覆盖低优先级来源
  • 凭据组(username+password、clientId+clientSecret)是原子性的
  • 主机名不匹配保护可能会丢弃值

Sensitive Values Masked

敏感值被屏蔽

By default, passwords and secrets show partial values like
admi...REDACTED
. Use
--unmask
to see full values when debugging authentication issues.
默认情况下,密码和密钥会显示为部分值,例如
admi...REDACTED
。调试身份验证问题时,请使用
--unmask
查看完整值。

Getting Admin OAuth Tokens

获取管理员OAuth令牌

Use
b2c auth token
to get an admin OAuth access token for Account Manager credentials (OCAPI and Admin APIs). This is useful for testing APIs, scripting, or CI/CD pipelines.
bash
undefined
使用
b2c auth token
命令获取用于Account Manager凭据的管理员OAuth访问令牌(适用于OCAPI和Admin API)。这在测试API、编写脚本或CI/CD流水线中非常有用。
bash
undefined

Get access token (outputs raw token to stdout)

获取访问令牌(将原始令牌输出到标准输出)

b2c auth token
b2c auth token

Get token with specific scopes

获取具有特定权限范围的令牌

b2c auth token --auth-scope sfcc.orders --auth-scope sfcc.products
b2c auth token --auth-scope sfcc.orders --auth-scope sfcc.products

Get token as JSON (includes expiration and scopes)

以JSON格式获取令牌(包含过期时间和权限范围)

b2c auth token --json
b2c auth token --json

Use in curl for OCAPI calls

在curl中使用令牌调用OCAPI

curl -H "Authorization: Bearer $(b2c auth token)"
"https://your-instance.dx.commercecloud.salesforce.com/s/-/dw/data/v24_1/sites"

The token is obtained using the `clientId` and `clientSecret` from your configuration (dw.json or environment variables). If only `clientId` is configured, an implicit OAuth flow is used (browser-based).

**Note:** This command returns **admin** tokens for OCAPI/Admin APIs. For **shopper** tokens (SLAS), see the [b2c-slas skill](../b2c-slas/SKILL.md).
curl -H "Authorization: Bearer $(b2c auth token)"
"https://your-instance.dx.commercecloud.salesforce.com/s/-/dw/data/v24_1/sites"

令牌是使用配置中的`clientId`和`clientSecret`(来自dw.json或环境变量)获取的。如果仅配置了`clientId`,则会使用隐式OAuth流(基于浏览器)。

**注意:** 此命令返回的是用于OCAPI/Admin API的**管理员**令牌。如需**购物者**令牌(SLAS),请查看[b2c-slas skill](../b2c-slas/SKILL.md)。

More Commands

更多命令

See
b2c setup --help
for other setup commands including
b2c setup skills
for AI agent skill installation.
请查看
b2c setup --help
获取其他设置命令,包括用于AI agent skill安装的
b2c setup skills