Skip to content

Commit 8961f33

Browse files
committed
Merge main into t/commerce/W-20599053-readme
Resolved conflict in packages/b2c-dx-mcp/README.md by keeping the streamlined version from HEAD, avoiding duplicate Configuration documentation that was already covered in the Usage section.
2 parents f734e87 + dbb0981 commit 8961f33

File tree

221 files changed

+5513
-1050
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+5513
-1050
lines changed

.changeset/code-bugfix.md

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+
bugfix code deploy to not require oauth unless needed

.changeset/doc-improvements.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@salesforce/b2c-cli': minor
3+
---
4+
5+
consistent command doc structure; better auth page; online links in examples for all topics/cmds

.changeset/log-tailing-feature.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@salesforce/b2c-cli': minor
3+
'@salesforce/b2c-tooling-sdk': minor
4+
---
5+
6+
Add log tailing, listing, and retrieval commands for viewing B2C Commerce instance logs. See `b2c logs` topic.

.changeset/mrt-warnings.md

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+
mrt bundle commands now relay warnings from the bundle such as out of date node versions

.claude/skills/testing/SKILL.md

Lines changed: 99 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ This skill covers project-specific testing patterns for the B2C CLI project.
1818

1919
## Running Tests
2020

21+
For coding agents (minimal output - only failures shown):
22+
23+
```bash
24+
# Run tests - only failures + summary
25+
pnpm run test:agent
26+
27+
# Run tests for specific package
28+
pnpm --filter @salesforce/b2c-tooling-sdk run test:agent
29+
pnpm --filter @salesforce/b2c-cli run test:agent
30+
```
31+
32+
For debugging (full output with coverage):
33+
2134
```bash
2235
# Run all tests with coverage
2336
pnpm run test
@@ -307,6 +320,59 @@ const client = new WebDavClient(TEST_HOST, mockAuth);
307320
const customAuth = new MockAuthStrategy('custom-token');
308321
```
309322

323+
## Silencing Test Output
324+
325+
Commands may produce console output (tables, formatted displays) even in tests. Use these helpers to keep test output clean.
326+
327+
### Using runSilent for Output Capture
328+
329+
The `runSilent` helper uses oclif's `captureOutput` to suppress stdout/stderr:
330+
331+
```typescript
332+
import { runSilent } from '../../helpers/test-setup.js';
333+
334+
it('returns data in non-JSON mode', async () => {
335+
const command = new MyCommand([], {} as any);
336+
// ... setup ...
337+
338+
// Silences any console output from the command
339+
const result = await runSilent(() => command.run());
340+
341+
expect(result.data).to.exist;
342+
});
343+
```
344+
345+
Use `runSilent` when:
346+
- Testing non-JSON output modes (tables, formatted displays)
347+
- The test doesn't need to verify console output content
348+
- You want clean test output with only pass/fail summary
349+
350+
### When Output Verification is Needed
351+
352+
If you need to verify console output, stub `ux.stdout` directly:
353+
354+
```typescript
355+
import { ux } from '@oclif/core';
356+
357+
it('prints table in non-JSON mode', async () => {
358+
const stdoutStub = sinon.stub(ux, 'stdout');
359+
360+
await command.run();
361+
362+
expect(stdoutStub.called).to.be.true;
363+
});
364+
```
365+
366+
### stubParse Sets Silent Logging
367+
368+
The `stubParse` helper automatically sets `'log-level': 'silent'` to reduce pino logger output:
369+
370+
```typescript
371+
// stubParse includes silent log level by default
372+
stubParse(command, {server: 'test.demandware.net'});
373+
// Equivalent to: {server: 'test.demandware.net', 'log-level': 'silent'}
374+
```
375+
310376
## Command Test Guidelines
311377

312378
Command tests should focus on **command-specific logic**, not trivial flag verification.
@@ -445,15 +511,43 @@ pnpm run test
445511
open coverage/index.html
446512
```
447513

514+
## Test Helpers Reference
515+
516+
### CLI Package (`packages/b2c-cli/test/helpers/`)
517+
518+
| Helper | Purpose |
519+
|--------|---------|
520+
| `runSilent(fn)` | Capture and suppress stdout/stderr from command execution |
521+
| `stubParse(command, flags, args)` | Stub oclif's parse method with flags (includes silent log level) |
522+
| `createTestCommand(CommandClass, config, flags, args)` | Create command instance with stubbed parse |
523+
| `createIsolatedConfigHooks()` | Mocha hooks for config isolation |
524+
| `createIsolatedEnvHooks()` | Mocha hooks for env var isolation |
525+
526+
### SDK Package (`packages/b2c-tooling-sdk/test/helpers/`)
527+
528+
| Helper | Purpose |
529+
|--------|---------|
530+
| `MockAuthStrategy` | Mock authentication for API clients |
531+
| `stubParse(command, flags, args)` | Stub oclif's parse method (includes silent log level) |
532+
| `createNullStream()` | Create a writable stream that discards output |
533+
| `CapturingStream` | Writable stream that captures output for assertions |
534+
535+
### SDK Test Utils (exported from package)
536+
537+
```typescript
538+
import { isolateConfig, restoreConfig } from '@salesforce/b2c-tooling-sdk/test-utils';
539+
```
540+
448541
## Writing Tests Checklist
449542

450543
1. Create test file in `test/` mirroring source structure
451544
2. Use `.test.ts` suffix
452545
3. Import from package names, not relative paths
453546
4. Set up MSW server for HTTP tests (avoid fake timers)
454547
5. Use `isolateConfig()`/`restoreConfig()` for config-dependent tests
455-
6. Use `pollInterval` option for polling operations
456-
7. Use MockAuthStrategy for authenticated clients
457-
8. Test both success and error paths
458-
9. Focus on command-specific logic, not trivial delegation
459-
10. Run tests: `pnpm --filter <package> run test`
548+
6. Use `runSilent()` for commands that produce console output
549+
7. Use `pollInterval` option for polling operations
550+
8. Use MockAuthStrategy for authenticated clients
551+
9. Test both success and error paths
552+
10. Focus on command-specific logic, not trivial delegation
553+
11. Run tests: `pnpm --filter <package> run test`

AGENTS.md

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,41 @@ pnpm run build
1818
pnpm --filter @salesforce/b2c-cli run build
1919
pnpm --filter @salesforce/b2c-tooling-sdk run build
2020

21-
# Run tests (includes linting)
22-
pnpm run test
23-
2421
# Dev mode for CLI (uses source files directly)
2522
pnpm --filter @salesforce/b2c-cli run dev
2623
# or using convenience script
2724
./cli
25+
```
26+
27+
## Commands for Coding Agents
28+
29+
These commands produce condensed output optimized for AI coding agents:
30+
31+
```bash
32+
# Run tests (minimal output - only failures + summary)
33+
pnpm run test:agent
34+
35+
# Run tests for specific package
36+
pnpm --filter @salesforce/b2c-cli run test:agent
37+
pnpm --filter @salesforce/b2c-tooling-sdk run test:agent
38+
39+
# Lint (errors only, no warnings)
40+
pnpm run lint:agent
41+
42+
# Type-check (single-line errors, no color)
43+
pnpm run typecheck:agent
44+
45+
# Format check (lists only files needing formatting)
46+
pnpm run -r format:check
47+
```
48+
49+
## Verbose Commands (Debugging/CI)
50+
51+
Use these for detailed output during debugging or in CI pipelines:
52+
53+
```bash
54+
# Run tests with full output and coverage
55+
pnpm run test
2856

2957
# Run tests for specific package
3058
pnpm --filter @salesforce/b2c-cli run test
@@ -33,7 +61,7 @@ pnpm --filter @salesforce/b2c-tooling-sdk run test
3361
# Format code with prettier
3462
pnpm run -r format
3563

36-
# Lint only (without tests)
64+
# Lint with full output
3765
pnpm run -r lint
3866
```
3967

@@ -60,6 +88,8 @@ The header is enforced by eslint via `eslint-plugin-header`. The canonical defin
6088

6189
## Documentation
6290

91+
- Update docs in `./docs/` folder and relevant skills in `./plugins/b2c-cli/skills/` when updating or adding CLI commands.
92+
6393
See [documentation skill](./.claude/skills/documentation/SKILL.md) for details on updating user guides, CLI reference, and API docs.
6494

6595
```bash
@@ -76,9 +106,9 @@ pnpm run docs:build
76106
- CLI commands have access to this logger via `this.log` method from oclif Command class
77107
- CLI commands can write directly to stdout/stderr if their primary purpose is to output or stream data
78108

79-
## Table Output
109+
## CLI Command Development
80110

81-
Use `createTable` from `@salesforce/b2c-tooling-sdk/cli` for tabular output. See [CLI command development skill](./.claude/skills/cli-command-development/SKILL.md) for patterns.
111+
See [CLI command development skill](./.claude/skills/cli-command-development/SKILL.md) for patterns.
82112

83113
## Claude Code Skills
84114

@@ -95,27 +125,20 @@ Use `createTable` from `@salesforce/b2c-tooling-sdk/cli` for tabular output. See
95125

96126
See [testing skill](./.claude/skills/testing/SKILL.md) for patterns on writing tests with Mocha, Chai, and MSW.
97127

98-
Quick commands:
99-
```bash
100-
pnpm run test # Run all tests
101-
pnpm --filter @salesforce/b2c-tooling-sdk run test # Test specific package
102-
pnpm mocha "test/clients/webdav.test.ts" # Single file (no coverage)
103-
```
104-
105128
## Changesets
106129

107130
This project uses [Changesets](https://github.com/changesets/changesets) for version management. When making changes that affect users, create a changeset:
108131

109132
Changeset guidelines:
110133
- Create a changeset for any user-facing changes (features, bug fixes); typically in new pull requests;
111-
- a pull request can have multiple changesets
134+
- a pull request can have multiple changesets; separate files for separate changes
112135
- Select the appropriate semver bump: `patch` (bug fixes) or `minor` (new features)
113136
- This is a pre-1.0 preview release, so there are no `major` breaking change bumps yet
114137
- Good changesets explain:
115138
- WHAT the change is
116139
- WHY the change was made
117140
- HOW a consumer should update their code
118-
- Good changesets are brief and user-focused (not contributor); they are generally 1 line or a short paragraph for detailed changes; The content of the changeset is used in CHANGELOG and release notes.
141+
- Good changesets are brief and user-focused (not contributor); they are generally 1 line or two; The content of the changeset is used in CHANGELOG and release notes. You do not need to list internal implementation details or all details of commands; just the high level summary for users.
119142

120143
create a changeset file directly in `.changeset/` with a unique filename (e.g., `descriptive-change-name.md`):
121144

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const guideSidebar = [
3131
{ text: 'Overview', link: '/cli/' },
3232
{ text: 'Code Commands', link: '/cli/code' },
3333
{ text: 'Job Commands', link: '/cli/jobs' },
34+
{ text: 'Logs Commands', link: '/cli/logs' },
3435
{ text: 'Sites Commands', link: '/cli/sites' },
3536
{ text: 'WebDAV Commands', link: '/cli/webdav' },
3637
{ text: 'ODS Commands', link: '/cli/ods' },

docs/cli/auth.md

Lines changed: 13 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -88,85 +88,20 @@ b2c auth token | pbcopy # macOS: copy to clipboard
8888

8989
## Authentication Overview
9090

91-
The CLI supports multiple authentication methods depending on the operation.
91+
For complete authentication setup instructions, see the [Authentication Setup Guide](/guide/authentication).
9292

93-
### Account Manager API Client (OAuth)
93+
### Quick Reference
9494

95-
Most instance operations require an Account Manager API Client. The CLI supports two authentication methods:
95+
| Operation | Auth Required |
96+
|-----------|--------------|
97+
| [Code](/cli/code) deploy/watch | WebDAV credentials |
98+
| [Code](/cli/code) list/activate/delete, [Jobs](/cli/jobs), [Sites](/cli/sites) | OAuth + OCAPI configuration |
99+
| SCAPI commands ([eCDN](/cli/ecdn), [schemas](/cli/scapi-schemas), [custom-apis](/cli/custom-apis)) | OAuth + SCAPI scopes |
100+
| [ODS](/cli/ods), [SLAS](/cli/slas) | OAuth + appropriate roles |
101+
| [MRT](/cli/mrt) | API Key |
96102

97-
| Auth Method | When Used | Role Configuration |
98-
|-------------|-----------|-------------------|
99-
| User Authentication | Only `--client-id` provided | Roles on your **user account** |
100-
| Client Credentials | Both `--client-id` and `--client-secret` provided | Roles on the **API client** |
103+
See [Configuration](/guide/configuration) for setting up credentials via environment variables or config files.
101104

102-
```bash
103-
# User Authentication (opens browser for login)
104-
b2c ods list --client-id xxx
105-
106-
# Client Credentials
107-
export SFCC_CLIENT_ID=my-client
108-
export SFCC_CLIENT_SECRET=my-secret
109-
b2c ods list
110-
```
111-
112-
Used by:
113-
- Code management (`code list`, `code activate`, `code delete`)
114-
- Job operations (`job run`, `job search`, `job import`, `job export`)
115-
- Site operations (`sites list`)
116-
- ODS operations (requires `Sandbox API User` role)
117-
- SLAS operations (requires `SLAS Organization Administrator` or `Sandbox API User` role depending on auth method)
118-
119-
### Basic Auth (WebDAV)
120-
121-
WebDAV operations support Basic Auth using your Business Manager username and WebDAV access key:
122-
123-
```bash
124-
export SFCC_USERNAME=my-user
125-
export SFCC_PASSWORD=my-webdav-access-key
126-
```
127-
128-
Used by:
129-
- `code deploy` (file upload)
130-
- `code watch` (file upload)
131-
- `webdav` commands
132-
133-
### MRT API Key
134-
135-
Managed Runtime commands use a separate API key obtained from the MRT dashboard:
136-
137-
```bash
138-
export SFCC_MRT_API_KEY=your-mrt-api-key
139-
```
140-
141-
See [MRT Commands](./mrt#authentication) for details.
142-
143-
### Mixed Authentication
144-
145-
Some commands (like `code deploy` with `--reload`) require both OAuth and WebDAV access:
146-
147-
```bash
148-
export SFCC_CLIENT_ID=my-client
149-
export SFCC_CLIENT_SECRET=my-secret
150-
export SFCC_USERNAME=my-user
151-
export SFCC_PASSWORD=my-access-key
152-
b2c code deploy --reload
153-
```
154-
155-
### Configuration File
156-
157-
Credentials can be stored in a `dw.json` file:
158-
159-
```json
160-
{
161-
"client-id": "my-client",
162-
"client-secret": "my-secret",
163-
"username": "my-user",
164-
"password": "my-access-key"
165-
}
166-
```
167-
168-
Use `--config` to specify a custom config file path, or `--instance` to select a named instance configuration.
169-
170-
### Tenant Scope
171-
172-
For ODS and SLAS operations, your API client must have tenant scope configured for the realm/organization you wish to manage. This is set up in Account Manager when creating or editing the API client.
105+
::: tip
106+
Each command page below documents its specific authentication requirements including required scopes.
107+
:::

0 commit comments

Comments
 (0)