b2c-config by salesforcecommercecloud/b2c-developer-tooling
npx skills add https://github.com/salesforcecommercecloud/b2c-developer-tooling --skill b2c-configB2C CLI (@salesforce/b2c-cli) 是一个用于 Salesforce B2C Commerce 开发的命令行工具。它提供了按主题组织的命令:auth、code、webdav、sandbox、mrt、scapi、slas、ecdn、job、logs、、、、 等。使用 或 查看完整列表。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
sitescontentcipsetupb2c --helpb2c <topic> --help提示: 如果
b2c未全局安装,请使用npx @salesforce/b2c-cli代替(例如npx @salesforce/b2c-cli setup inspect)。
大多数与 B2C Commerce 实例交互的命令都需要身份验证。CLI 支持多种方法:
clientId 和 clientSecret。这是自动化/CI 使用的默认方式。--user-auth,通过浏览器进行交互式身份验证。这将在您的默认浏览器中打开 Account Manager 进行登录。username 和 password。b2c auth login 进行持久的基于浏览器的登录会话。--user-auth 标志许多命令支持 --user-auth,以使用基于浏览器的隐式 OAuth 而不是客户端凭证。这在以下情况下很有用:
您没有配置 clientSecret
您需要用户级权限(例如,Account Manager 管理员角色)
您正在进行交互式工作
# 任何 OAuth 命令的交互式浏览器身份验证
b2c sandbox list --user-auth
b2c scapi schemas list --user-auth
b2c auth token --user-auth
编码代理也可以使用 --user-auth —— 浏览器流程在任何可以打开浏览器的环境中都有效。该标志与 --auth-methods 互斥。
在代理后运行: 如果浏览器无法访问 localhost:8080(例如,在容器中运行或在反向代理之后),请将 SFCC_REDIRECT_URI 设置为代理 URL。本地 OAuth 服务器仍然在默认端口(或 SFCC_OAUTH_LOCAL_PORT)上监听,但发送到 Account Manager 的重定向 URI 将使用您的代理 URL。请将代理 URL 添加到 Account Manager 中 API 客户端的重定向 URL 列表中。
B2C Commerce 使用两个相关的标识符:
zzxy_prd 或 zzxy-prd)f_ecom_ 前缀的 SCAPI 形式(例如 f_ecom_zzxy_prd)CLI 会自动在这些格式之间进行规范化和转换。您可以在配置或标志中提供任一形式 —— CLI 会处理转换。它还会从主机名中提取租户 ID(例如,zzxy-prd.dx.commercecloud.salesforce.com 解析为 zzxy_prd)。
在 dw.json 或环境变量中,使用 tenantId 配置键。CLI 在进行 SCAPI 调用时会添加 f_ecom_ 前缀。
使用 b2c setup inspect 查看已解析的配置并了解每个值的来源。使用 b2c setup instance 命令来管理命名的实例配置。
注意:
b2c setup config作为b2c setup inspect的别名使用。
在以下情况下使用 b2c setup inspect:
# 显示已解析的配置(默认情况下敏感值被屏蔽)
b2c setup inspect
# 查看 dw.json 中特定实例的配置
b2c setup inspect -i staging
# 使用特定配置文件查看配置
b2c setup inspect --config /path/to/dw.json
# 显示实际的密码、密钥和 API 密钥(谨慎使用)
b2c setup inspect --unmask
# 以 JSON 格式输出,供脚本解析
b2c setup inspect --json
# 使用 jq 进行格式化输出
b2c setup inspect --json | jq '.config'
# 检查加载了哪些源
b2c setup inspect --json | jq '.sources'
使用 b2c setup ide prophet 为 Prophet VS Code 扩展生成 dw.js 桥接脚本。
# 在当前项目中生成 ./dw.js
b2c setup ide prophet
# 覆盖现有文件
b2c setup ide prophet --force
# 自定义路径
b2c setup ide prophet --output .vscode/dw.js
生成的脚本在运行时执行 b2c setup inspect --json --unmask,因此 Prophet 看到的已解析配置与 CLI 命令相同,包括配置插件。它将值映射到 dw.json 风格的键,并在存在时传递 Prophet 字段,如 cartridgesPath、siteID 和 storefrontPassword。
# 显示 dw.json 中的所有实例
b2c setup instance list
# 以 JSON 格式输出
b2c setup instance list --json
# 交互模式 - 提示输入所有值
b2c setup instance create staging
# 指定主机名
b2c setup instance create staging --hostname staging.example.com
# 创建并设置为活动实例
b2c setup instance create staging --hostname staging.example.com --active
# 非交互模式(用于脚本)
b2c setup instance create staging \
--hostname staging.example.com \
--username admin \
--password secret \
--force
# 将 staging 设置为默认实例
b2c setup instance set-active staging
# 现在命令默认使用 staging
b2c code list # 使用 staging
# 移除并显示确认提示
b2c setup instance remove staging
# 移除而不确认
b2c setup instance remove staging --force
setup inspect 命令按类别显示配置:
每个值在方括号中显示其来源:
[DwJsonSource] — 来自 dw.json 文件的值[EnvSource] — 来自 SFCC_* 环境变量的值[MobifySource] — 来自 ~/.mobify 文件的值[PackageJsonSource] — 来自 package.json b2c 键的值值按以下优先级(从高到低)解析:
b2c 键故障排除时,请检查来源列以了解哪个配置具有优先权。
如果某个值显示为 -,则表示没有来源提供该配置。请检查:
如果某个值来自意外的来源:
默认情况下,密码和密钥会显示部分值,如 admi...REDACTED。调试身份验证问题时,使用 --unmask 查看完整值。
使用 b2c auth token 获取用于 Account Manager 凭据(OCAPI 和管理员 API)的管理员 OAuth 访问令牌。这对于测试 API、编写脚本或 CI/CD 流水线很有用。
# 获取访问令牌(将原始令牌输出到 stdout)
b2c auth token
# 使用基于浏览器的身份验证获取令牌
b2c auth token --user-auth
# 获取具有特定作用域的令牌
b2c auth token --auth-scope sfcc.orders --auth-scope sfcc.products
# 以 JSON 格式获取令牌(包括过期时间和作用域)
b2c auth token --json
# 在 curl 中用于 OCAPI 调用
curl -H "Authorization: Bearer $(b2c auth token)" \
"https://your-instance.dx.commercecloud.salesforce.com/s/-/dw/data/v24_1/sites"
该令牌是使用您的配置(dw.json 或环境变量)中的 clientId 和 clientSecret 获取的。如果只配置了 clientId,或者使用了 --user-auth,则使用隐式 OAuth 流程(基于浏览器)。
注意: 此命令返回用于 OCAPI/管理员 API 的管理员令牌。对于购物者令牌(SLAS),请参阅 b2c-slas 技能。
有关其他设置命令,请参阅 b2c setup --help,包括用于 AI 代理技能安装的 b2c setup skills。
每周安装次数
77
仓库
GitHub 星标数
33
首次出现
2026 年 2 月 11 日
安全审计
安装于
github-copilot72
codex69
cursor68
opencode68
amp67
kimi-cli67
The B2C CLI (@salesforce/b2c-cli) is a command-line tool for Salesforce B2C Commerce development. It provides commands organized by topic: auth, code, webdav, sandbox, mrt, scapi, slas, ecdn, job, logs, sites, content, cip, setup, and more. Use b2c --help or b2c <topic> --help for a full list.
Tip: If
b2cis not installed globally, usenpx @salesforce/b2c-cliinstead (e.g.,npx @salesforce/b2c-cli setup inspect).
Most commands that interact with a B2C Commerce instance require authentication. The CLI supports several methods:
clientId and clientSecret in dw.json or environment variables. This is the default for automated/CI use.--user-auth on any OAuth-enabled command to authenticate interactively via the browser. This opens Account Manager in your default browser for login.username and password for WebDAV operations.b2c auth login for persistent browser-based login sessions.--user-auth FlagMany commands support --user-auth to use browser-based implicit OAuth instead of client credentials. This is useful when:
You don't have a clientSecret configured
You need user-level permissions (e.g., Account Manager admin roles)
You're working interactively
b2c sandbox list --user-auth b2c scapi schemas list --user-auth b2c auth token --user-auth
Coding agents can also use --user-auth — the browser flow works in any environment where a browser can be opened. The flag is exclusive with --auth-methods.
Running behind a proxy: If localhost:8080 isn't reachable by the browser (e.g., running in a container or behind a reverse proxy), set SFCC_REDIRECT_URI to the proxy URL. The local OAuth server still listens on the default port (or SFCC_OAUTH_LOCAL_PORT), but the redirect URI sent to Account Manager will use your proxy URL. Add the proxy URL to the API client's redirect URLs in Account Manager.
B2C Commerce uses two related identifiers:
zzxy_prd or zzxy-prd)f_ecom_ prefix (e.g., f_ecom_zzxy_prd)The CLI automatically normalizes and translates between these formats. You can provide either form in configuration or flags — the CLI handles the conversion. It also extracts tenant IDs from hostnames (e.g., zzxy-prd.dx.commercecloud.salesforce.com resolves to zzxy_prd).
In dw.json or environment variables, use the tenantId config key. The CLI will add the f_ecom_ prefix when making SCAPI calls.
Use b2c setup inspect to view the resolved configuration and understand where each value comes from. Use b2c setup instance commands to manage named instance configurations.
Note:
b2c setup configworks as an alias forb2c setup inspect.
Use b2c setup inspect when you need to:
# Display resolved configuration (sensitive values masked by default)
b2c setup inspect
# View configuration for a specific instance from dw.json
b2c setup inspect -i staging
# View configuration with a specific config file
b2c setup inspect --config /path/to/dw.json
# Show actual passwords, secrets, and API keys (use with caution)
b2c setup inspect --unmask
# Output as JSON for parsing in scripts
b2c setup inspect --json
# Pretty-print with jq
b2c setup inspect --json | jq '.config'
# Check which sources are loaded
b2c setup inspect --json | jq '.sources'
Use b2c setup ide prophet to generate a dw.js bridge script for the Prophet VS Code extension.
# Generate ./dw.js in the current project
b2c setup ide prophet
# Overwrite existing file
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.
# Show all instances from dw.json
b2c setup instance list
# Output as JSON
b2c setup instance list --json
# Interactive mode - prompts for all values
b2c setup instance create staging
# With hostname
b2c setup instance create staging --hostname staging.example.com
# Create and set as 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
# Set staging as the default instance
b2c setup instance set-active staging
# Now commands use staging by default
b2c code list # Uses staging
# Remove with confirmation prompt
b2c setup instance remove staging
# Remove without confirmation
b2c setup instance remove staging --force
The setup inspect command displays configuration organized by category:
Each value shows its source in brackets:
[DwJsonSource] — Value from dw.json file[EnvSource] — Value from an SFCC_* environment variable[MobifySource] — Value from ~/.mobify file[PackageJsonSource] — Value from package.json b2c keyValues are resolved with this priority (highest to lowest):
b2c keyWhen troubleshooting, check the source column to understand which configuration is taking precedence.
If a value shows -, it means no source provided that configuration. Check:
If a value comes from an unexpected source:
By default, passwords and secrets show partial values like admi...REDACTED. Use --unmask to see full values when debugging authentication issues.
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.
# Get access token (outputs raw token to stdout)
b2c auth token
# Get token with browser-based auth
b2c auth token --user-auth
# Get token with specific scopes
b2c auth token --auth-scope sfcc.orders --auth-scope sfcc.products
# Get token as JSON (includes expiration and scopes)
b2c auth token --json
# Use in curl for OCAPI calls
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, or --user-auth is used, 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.
See b2c setup --help for other setup commands including b2c setup skills for AI agent skill installation.
Weekly Installs
77
Repository
GitHub Stars
33
First Seen
Feb 11, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
github-copilot72
codex69
cursor68
opencode68
amp67
kimi-cli67
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
104,900 周安装
Java开发专家技能:Spring Boot、Quarkus、企业级设计模式与性能优化指南
130 周安装
Python虚拟环境管理器:一键设置venv/virtualenv/conda,确保项目依赖隔离与版本正确
76 周安装
Salesforce DX 开发专家指南:Apex代码规范、LWC组件与SFDX CLI最佳实践
131 周安装
高管仪表板生成器 - AI驱动商业智能工具,一键将数据转化为可视化洞察与建议
127 周安装
前端设计技能:告别AI生成美学,打造独特生产级界面 | 创意前端开发指南
76 周安装
DigitalOcean管理技能:监控、告警、项目组织与正常运行时间检查
133 周安装