Skip to content

Commit 3dedc05

Browse files
authored
docs(skills): config-first idiomatic usage in CLI skill examples (#355)
* docs(skills): refactor skill examples for config-first idiomatic usage Update b2c CLI skills so command examples assume configured values (tenantId, shortCode, slasClientId, clientId, server) resolve from dw.json / SFCC_* env vars, with flags shown only as overrides. This prevents coding agents from prompting users for values that are already present in their configuration. Affected skills: scapi-schemas, scapi-custom, slas, ecdn (+ references), cip, users-roles. * feat(setup:skills): prompt to overwrite existing skills When running interactively, detect already-installed skills and prompt the user to overwrite them rather than requiring the --update flag up front. Non-interactive behavior (--force, --update, --json) is preserved. Widen isSkillInstalled options to include the optional directory override so the target-path check matches the installer's resolution when --directory is provided.
1 parent 691f96f commit 3dedc05

12 files changed

Lines changed: 237 additions & 158 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@salesforce/b2c-cli': patch
3+
'@salesforce/b2c-tooling-sdk': patch
4+
---
5+
6+
`b2c setup skills` now prompts to overwrite already-installed skills in interactive mode instead of silently skipping them with a "use --update to overwrite" message. The existing `--update` and `--force` flags still work non-interactively.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@salesforce/b2c-cli': patch
3+
---
4+
5+
Refine b2c CLI skills (`scapi-schemas`, `scapi-custom`, `slas`, `ecdn`, `cip`, `users-roles`) to show config-first idiomatic usage. Examples now assume values like `tenantId`, `shortCode`, and `clientId` are resolved from `dw.json` / `SFCC_*` env vars, with flags shown only as overrides. This prevents coding agents from prompting users for values that are already configured.

packages/b2c-cli/src/commands/setup/skills.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
downloadSkillsArtifact,
1717
scanSkills,
1818
installSkills,
19+
isSkillInstalled,
1920
getIdeDisplayName,
2021
getIdeDocsUrl,
2122
findSkillsByName,
@@ -305,6 +306,34 @@ export default class SetupSkills extends BaseCommand<typeof SetupSkills> {
305306
}
306307
}
307308

309+
// Detect already-installed skills and prompt to upgrade (unless --update or --force set)
310+
let update = this.flags.update;
311+
if (!update && !this.flags.force) {
312+
const existingCount = skillsToInstall.reduce((count, skill) => {
313+
return (
314+
count +
315+
targetIdes.filter((ide) =>
316+
isSkillInstalled(skill.name, ide, {
317+
global: this.flags.global,
318+
projectRoot: process.cwd(),
319+
directory,
320+
}),
321+
).length
322+
);
323+
}, 0);
324+
325+
if (existingCount > 0) {
326+
update = await confirm({
327+
message: t(
328+
'commands.setup.skills.confirmUpgrade',
329+
'{{count}} skill(s) are already installed. Overwrite with the new version?',
330+
{count: existingCount},
331+
),
332+
default: true,
333+
});
334+
}
335+
}
336+
308337
// Install skills for all skillsets in parallel
309338
const installPromises = skillsets
310339
.map((skillset) => {
@@ -313,7 +342,7 @@ export default class SetupSkills extends BaseCommand<typeof SetupSkills> {
313342
return installSkills(skillsForSet, skillsDirs[skillset], {
314343
ides: targetIdes,
315344
global: this.flags.global,
316-
update: this.flags.update,
345+
update,
317346
projectRoot: process.cwd(),
318347
directory,
319348
});

packages/b2c-tooling-sdk/src/skills/installer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async function copyDirectory(source: string, target: string): Promise<number> {
8888
export function isSkillInstalled(
8989
skillName: string,
9090
ide: IdeType,
91-
options: {global: boolean; projectRoot?: string},
91+
options: {global: boolean; projectRoot?: string; directory?: string},
9292
): boolean {
9393
const installPath = getSkillInstallPath(ide, skillName, options);
9494
return fs.existsSync(installPath);

skills/b2c-cli/skills/b2c-cip/SKILL.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,22 @@ cip
2929
└── top-referrers
3030
```
3131

32-
## Requirements
32+
## Configuration
3333

34-
- OAuth client credentials (resolved from CLI configuration, or override with `--client-id` / `--client-secret`)
35-
- CIP tenant: `--tenant-id` (or `--tenant`)
36-
- API client has `Salesforce Commerce API` role with tenant filter for your instance
34+
Values like `tenantId`, `clientId`, and `clientSecret` resolve from `dw.json` / `SFCC_*` env vars / the active instance. Examples below show minimal usage; add flags only to override configured values. If a required value is missing, the CLI emits an actionable error pointing at the flag, env var, and config key. See the `b2c-config` skill for precedence details.
3735

38-
Optional:
36+
Relevant overrides:
3937

40-
- `--cip-host` (or `SFCC_CIP_HOST`) to override the default host
41-
- `--staging` (or `SFCC_CIP_STAGING`) to force staging analytics host
38+
- `--tenant-id` (alias `--tenant`) / `SFCC_TENANT_ID` / `tenantId`
39+
- `--client-id` / `SFCC_CLIENT_ID` / `clientId`
40+
- `--client-secret` / `SFCC_CLIENT_SECRET` / `clientSecret`
41+
- `--cip-host` / `SFCC_CIP_HOST` to override the default host
42+
- `--staging` / `SFCC_CIP_STAGING` to force staging analytics host
43+
44+
## Requirements
45+
46+
- OAuth client credentials (CIP supports client credentials only; `--user-auth` is not supported)
47+
- API client has `Salesforce Commerce API` role with tenant filter for your instance
4248

4349
::: warning Availability
4450
This feature is typically used with production analytics tenants (for example `abcd_prd`).
@@ -58,14 +64,17 @@ Reports & Dashboards non-production URL: `https://ccac.stg.analytics.commerceclo
5864
## Metadata Discovery Examples
5965

6066
```bash
61-
# List warehouse tables
62-
b2c cip tables --tenant-id abcd_prd
67+
# List warehouse tables (uses configured tenant)
68+
b2c cip tables
6369

6470
# Filter table names
65-
b2c cip tables --tenant-id abcd_prd --pattern "ccdw_aggr_%"
71+
b2c cip tables --pattern "ccdw_aggr_%"
6672

6773
# Describe table columns
68-
b2c cip describe ccdw_aggr_ocapi_request --tenant-id abcd_prd
74+
b2c cip describe ccdw_aggr_ocapi_request
75+
76+
# Target a different tenant than the active config
77+
b2c cip tables --tenant-id abcd_prd
6978
```
7079

7180
## Known Tables
@@ -86,9 +95,8 @@ The list is derived from official JDBC documentation and intended as a quick dis
8695
# Show report commands
8796
b2c cip report --help
8897

89-
# Run a report
98+
# Run a report (tenant resolves from config)
9099
b2c cip report sales-analytics \
91-
--tenant-id abcd_prd \
92100
--site-id Sites-RefArch-Site \
93101
--from 2025-01-01 \
94102
--to 2025-01-31
@@ -107,15 +115,13 @@ b2c cip report top-referrers --site-id Sites-RefArch-Site --limit 25 --staging -
107115

108116
```bash
109117
b2c cip report sales-analytics --site-id Sites-RefArch-Site --sql \
110-
| b2c cip query --tenant-id abcd_prd
118+
| b2c cip query
111119
```
112120

113121
## Raw SQL Query Examples
114122

115123
```bash
116-
b2c cip query \
117-
--tenant-id abcd_prd \
118-
"SELECT * FROM ccdw_aggr_sales_summary LIMIT 10"
124+
b2c cip query "SELECT * FROM ccdw_aggr_sales_summary LIMIT 10"
119125
```
120126

121127
You can also use:

skills/b2c-cli/skills/b2c-ecdn/SKILL.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,72 +9,79 @@ Use the `b2c` CLI plugin to manage eCDN (embedded Content Delivery Network) zone
99

1010
> **Tip:** If `b2c` is not installed globally, use `npx @salesforce/b2c-cli` instead (e.g., `npx @salesforce/b2c-cli ecdn zones list`).
1111
12+
## Configuration
13+
14+
Values like `tenantId` resolve from `dw.json` / `SFCC_*` env vars / the active instance. Examples below show minimal usage; add flags only to override configured values. If a required value is missing, the CLI emits an actionable error pointing at the flag, env var, and config key. See the `b2c-config` skill for precedence details.
15+
1216
## Prerequisites
1317

1418
- OAuth credentials with `sfcc.cdn-zones` scope (read operations)
1519
- OAuth credentials with `sfcc.cdn-zones.rw` scope (write operations)
16-
- Tenant ID for your B2C Commerce organization
20+
- Tenant ID for your B2C Commerce organization (from config or `--tenant-id`)
1721

1822
## Examples
1923

2024
### List CDN Zones
2125

2226
```bash
23-
# list all CDN zones for a tenant
24-
b2c ecdn zones list --tenant-id zzxy_prd
27+
# list all CDN zones for the configured tenant
28+
b2c ecdn zones list
29+
30+
# JSON output
31+
b2c ecdn zones list --json
2532

26-
# list with JSON output
27-
b2c ecdn zones list --tenant-id zzxy_prd --json
33+
# target a different tenant than the active config
34+
b2c ecdn zones list --tenant-id zzxy_prd
2835
```
2936

3037
### Create a Storefront Zone
3138

3239
```bash
3340
# create a new storefront zone
34-
b2c ecdn zones create --tenant-id zzxy_prd --domain-name example.com
41+
b2c ecdn zones create --domain-name example.com
3542
```
3643

3744
### Purge Cache
3845

3946
```bash
4047
# purge cache for specific paths
41-
b2c ecdn cache purge --tenant-id zzxy_prd --zone my-zone --path /products --path /categories
48+
b2c ecdn cache purge --zone my-zone --path /products --path /categories
4249

4350
# purge by cache tags
44-
b2c ecdn cache purge --tenant-id zzxy_prd --zone my-zone --tag product-123 --tag category-456
51+
b2c ecdn cache purge --zone my-zone --tag product-123 --tag category-456
4552
```
4653

4754
### Manage Certificates
4855

4956
```bash
5057
# list certificates for a zone
51-
b2c ecdn certificates list --tenant-id zzxy_prd --zone my-zone
58+
b2c ecdn certificates list --zone my-zone
5259

5360
# add a new certificate
54-
b2c ecdn certificates add --tenant-id zzxy_prd --zone my-zone --hostname www.example.com --certificate-file ./cert.pem --private-key-file ./key.pem
61+
b2c ecdn certificates add --zone my-zone --hostname www.example.com --certificate-file ./cert.pem --private-key-file ./key.pem
5562

5663
# validate a custom hostname
57-
b2c ecdn certificates validate --tenant-id zzxy_prd --zone my-zone --certificate-id abc123
64+
b2c ecdn certificates validate --zone my-zone --certificate-id abc123
5865
```
5966

6067
### Security Settings
6168

6269
```bash
6370
# get security settings
64-
b2c ecdn security get --tenant-id zzxy_prd --zone my-zone
71+
b2c ecdn security get --zone my-zone
6572

6673
# update security settings
67-
b2c ecdn security update --tenant-id zzxy_prd --zone my-zone --ssl-mode full --min-tls-version 1.2 --always-use-https
74+
b2c ecdn security update --zone my-zone --ssl-mode full --min-tls-version 1.2 --always-use-https
6875
```
6976

7077
### Speed Settings
7178

7279
```bash
7380
# get speed optimization settings
74-
b2c ecdn speed get --tenant-id zzxy_prd --zone my-zone
81+
b2c ecdn speed get --zone my-zone
7582

7683
# update speed settings
77-
b2c ecdn speed update --tenant-id zzxy_prd --zone my-zone --browser-cache-ttl 14400 --auto-minify-html --auto-minify-css
84+
b2c ecdn speed update --zone my-zone --browser-cache-ttl 14400 --auto-minify-html --auto-minify-css
7885
```
7986

8087
## Additional Topics
@@ -84,12 +91,14 @@ For less commonly used eCDN features, see the reference files:
8491
- **[SECURITY.md](references/SECURITY.md)** — WAF (v1 and v2), custom firewall rules, rate limiting, and Page Shield (CSP policies, script detection, notification webhooks)
8592
- **[ADVANCED.md](references/ADVANCED.md)** — Logpush jobs, MRT routing rules, mTLS certificates, cipher suite configuration, and origin header modification
8693

87-
## Configuration
94+
## Configuration Overrides
8895

89-
The tenant ID can be set via environment variable:
90-
- `SFCC_TENANT_ID`: B2C Commerce tenant ID
96+
The tenant ID can be overridden via flag or environment variable:
97+
98+
- `--tenant-id` / `SFCC_TENANT_ID` / `tenantId` in dw.json
9199

92100
The `--zone` flag accepts either:
101+
93102
- Zone ID (32-character hex string)
94103
- Zone name (human-readable, case-insensitive lookup)
95104

skills/b2c-cli/skills/b2c-ecdn/references/ADVANCED.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,81 @@
22

33
Logpush, MRT rules, mTLS, cipher suites, and origin header commands for B2C eCDN.
44

5+
> `tenantId` resolves from `dw.json` / `SFCC_TENANT_ID`. Add `--tenant-id` only to override the active config.
6+
57
## Logpush
68

79
```bash
810
# create ownership challenge for S3 destination
9-
b2c ecdn logpush ownership --tenant-id zzxy_prd --zone my-zone --destination-path 's3://my-bucket/logs?region=us-east-1'
11+
b2c ecdn logpush ownership --zone my-zone --destination-path 's3://my-bucket/logs?region=us-east-1'
1012

1113
# list logpush jobs
12-
b2c ecdn logpush jobs list --tenant-id zzxy_prd --zone my-zone
14+
b2c ecdn logpush jobs list --zone my-zone
1315

1416
# create a logpush job
15-
b2c ecdn logpush jobs create --tenant-id zzxy_prd --zone my-zone --name "HTTP logs" --destination-path 's3://my-bucket/logs?region=us-east-1' --log-type http_requests
17+
b2c ecdn logpush jobs create --zone my-zone --name "HTTP logs" --destination-path 's3://my-bucket/logs?region=us-east-1' --log-type http_requests
1618

1719
# update a logpush job (enable/disable)
18-
b2c ecdn logpush jobs update --tenant-id zzxy_prd --zone my-zone --job-id 123456 --enabled
20+
b2c ecdn logpush jobs update --zone my-zone --job-id 123456 --enabled
1921

2022
# delete a logpush job
21-
b2c ecdn logpush jobs delete --tenant-id zzxy_prd --zone my-zone --job-id 123456
23+
b2c ecdn logpush jobs delete --zone my-zone --job-id 123456
2224
```
2325

2426
## MRT Rules
2527

2628
```bash
2729
# get MRT ruleset for a zone
28-
b2c ecdn mrt-rules get --tenant-id zzxy_prd --zone my-zone
30+
b2c ecdn mrt-rules get --zone my-zone
2931

3032
# create MRT rules to route to a Managed Runtime environment
31-
b2c ecdn mrt-rules create --tenant-id zzxy_prd --zone my-zone --mrt-hostname customer-pwa.mobify-storefront.com --expressions '(http.host eq "example.com")'
33+
b2c ecdn mrt-rules create --zone my-zone --mrt-hostname customer-pwa.mobify-storefront.com --expressions '(http.host eq "example.com")'
3234

3335
# update MRT ruleset hostname
34-
b2c ecdn mrt-rules update --tenant-id zzxy_prd --zone my-zone --mrt-hostname new-customer-pwa.mobify-storefront.com
36+
b2c ecdn mrt-rules update --zone my-zone --mrt-hostname new-customer-pwa.mobify-storefront.com
3537

3638
# delete MRT ruleset
37-
b2c ecdn mrt-rules delete --tenant-id zzxy_prd --zone my-zone
39+
b2c ecdn mrt-rules delete --zone my-zone
3840
```
3941

4042
## mTLS Certificates
4143

4244
```bash
4345
# list mTLS certificates (organization level)
44-
b2c ecdn mtls list --tenant-id zzxy_prd
46+
b2c ecdn mtls list
4547

4648
# create mTLS certificate for code upload authentication
47-
b2c ecdn mtls create --tenant-id zzxy_prd --name "Build Server" --ca-certificate-file ./ca.pem --leaf-certificate-file ./leaf.pem
49+
b2c ecdn mtls create --name "Build Server" --ca-certificate-file ./ca.pem --leaf-certificate-file ./leaf.pem
4850

4951
# get mTLS certificate details
50-
b2c ecdn mtls get --tenant-id zzxy_prd --certificate-id abc123
52+
b2c ecdn mtls get --certificate-id abc123
5153

5254
# delete mTLS certificate
53-
b2c ecdn mtls delete --tenant-id zzxy_prd --certificate-id abc123
55+
b2c ecdn mtls delete --certificate-id abc123
5456
```
5557

5658
## Cipher Suites
5759

5860
```bash
5961
# get cipher suites configuration
60-
b2c ecdn cipher-suites get --tenant-id zzxy_prd --zone my-zone
62+
b2c ecdn cipher-suites get --zone my-zone
6163

6264
# update to Modern cipher suite
63-
b2c ecdn cipher-suites update --tenant-id zzxy_prd --zone my-zone --suite-type Modern
65+
b2c ecdn cipher-suites update --zone my-zone --suite-type Modern
6466

6567
# update to Custom cipher suite with specific ciphers
66-
b2c ecdn cipher-suites update --tenant-id zzxy_prd --zone my-zone --suite-type Custom --ciphers "ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256"
68+
b2c ecdn cipher-suites update --zone my-zone --suite-type Custom --ciphers "ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256"
6769
```
6870

6971
## Origin Headers
7072

7173
```bash
7274
# get origin header modification
73-
b2c ecdn origin-headers get --tenant-id zzxy_prd --zone my-zone
75+
b2c ecdn origin-headers get --zone my-zone
7476

7577
# set origin header modification (for MRT)
76-
b2c ecdn origin-headers set --tenant-id zzxy_prd --zone my-zone --header-value my-secret-value
78+
b2c ecdn origin-headers set --zone my-zone --header-value my-secret-value
7779

7880
# delete origin header modification
79-
b2c ecdn origin-headers delete --tenant-id zzxy_prd --zone my-zone
81+
b2c ecdn origin-headers delete --zone my-zone
8082
```

0 commit comments

Comments
 (0)