Skip to content

Commit 532e47b

Browse files
authored
Merge branch 'main' into W-21461342-Configurable-safety-levels
2 parents bb11e5d + fe25ae6 commit 532e47b

96 files changed

Lines changed: 1954 additions & 2402 deletions

File tree

Some content is hidden

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

.claude/skills/testing/SKILL.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,29 @@ const customAuth = new MockAuthStrategy('custom-token');
324324

325325
## Silencing Test Output
326326

327-
Commands may produce console output (tables, formatted displays) even in tests. Use these helpers to keep test output clean.
327+
Commands produce console output (tables, formatted displays) during tests. **All test helpers are designed to keep test output clean by default** — no extra work needed in most cases.
328328

329-
### Using runSilent for Output Capture
329+
### stubCommandConfigAndLogger Silences Output Automatically
330330

331-
The `runSilent` helper uses oclif's `captureOutput` to suppress stdout/stderr:
331+
The `stubCommandConfigAndLogger` helper (used by AM and sandbox command tests) automatically stubs `command.log`, `command.logToStderr`, and `ux.stdout` so no output leaks to the console:
332+
333+
```typescript
334+
import { stubCommandConfigAndLogger } from '../../../helpers/test-setup.js';
335+
336+
it('displays client details in non-JSON mode', async () => {
337+
const command = new ClientGet([], {} as any);
338+
stubCommandConfigAndLogger(command); // stdout is silenced automatically
339+
stubJsonEnabled(command, false);
340+
// ... setup ...
341+
342+
const result = await command.run(); // No console noise
343+
expect(result.id).to.equal('client-123');
344+
});
345+
```
346+
347+
### Using runSilent for Other Cases
348+
349+
For commands that don't use `stubCommandConfigAndLogger`, use `runSilent` to capture stdout/stderr:
332350

333351
```typescript
334352
import { runSilent } from '../../helpers/test-setup.js';
@@ -344,24 +362,22 @@ it('returns data in non-JSON mode', async () => {
344362
});
345363
```
346364

347-
Use `runSilent` when:
348-
- Testing non-JSON output modes (tables, formatted displays)
349-
- The test doesn't need to verify console output content
350-
- You want clean test output with only pass/fail summary
351-
352365
### When Output Verification is Needed
353366

354-
If you need to verify console output, stub `ux.stdout` directly:
367+
If you need to verify console output content, stub `ux.stdout` directly **before** calling `stubCommandConfigAndLogger` (which checks if the stub already exists):
355368

356369
```typescript
357370
import { ux } from '@oclif/core';
358371

359372
it('prints table in non-JSON mode', async () => {
360373
const stdoutStub = sinon.stub(ux, 'stdout');
374+
stubCommandConfigAndLogger(command); // won't double-stub ux.stdout
361375

362376
await command.run();
363377

364378
expect(stdoutStub.called).to.be.true;
379+
const text = stdoutStub.firstCall.args[0];
380+
expect(text).to.include('expected content');
365381
});
366382
```
367383

.github/workflows/changesets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
2323

2424
- name: Setup pnpm
25-
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
25+
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
2626

2727
- name: Setup Node.js
2828
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ jobs:
6060
- name: Build packages
6161
run: pnpm -r run build
6262

63-
- name: Build documentation
64-
run: pnpm run docs:build
65-
6663
- name: Run SDK tests
6764
id: sdk-test
6865
working-directory: packages/b2c-tooling-sdk

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Docs Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'docs/**'
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- 'docs/**'
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
build-docs:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 22.x
29+
30+
- name: Setup pnpm
31+
uses: pnpm/action-setup@v4
32+
with:
33+
version: 10.17.1
34+
35+
- name: Get pnpm store directory
36+
shell: bash
37+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
38+
39+
- name: Setup pnpm cache
40+
uses: actions/cache@v4
41+
with:
42+
path: ${{ env.STORE_PATH }}
43+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
44+
restore-keys: |
45+
${{ runner.os }}-pnpm-store-
46+
47+
- name: Install dependencies
48+
run: pnpm install --frozen-lockfile
49+
50+
- name: Build packages
51+
run: pnpm -r run build
52+
53+
- name: Build documentation
54+
run: pnpm run docs:build

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
106106
- name: Setup pnpm
107107
if: steps.release-type.outputs.type == 'nightly' || (steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true')
108-
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
108+
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
109109

110110
- name: Setup Node.js
111111
if: steps.release-type.outputs.type == 'nightly' || (steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true')

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ This catches prettier formatting, import ordering, class member ordering (`perfe
161161

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

164+
**Stdout in tests**: Command tests must not leak output to the console. `stubCommandConfigAndLogger()` silences `command.log`, `command.logToStderr`, and `ux.stdout` automatically. For other cases, use `runSilent()` from `test/helpers/test-setup.ts`.
165+
164166
## Changesets
165167

166168
This project uses [Changesets](https://github.com/changesets/changesets) for version management with **independent per-package versioning**. Each package versions independently based on its own changesets.

packages/b2c-cli/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @salesforce/b2c-cli
22

3+
## 0.7.4
4+
5+
### Patch Changes
6+
7+
- [`4cf7249`](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/commit/4cf72497f5e01d627de7aae80290d072f4c914f6) - Add `cartridges` config option to specify which cartridges to deploy/watch. Supports comma or colon-separated strings, or arrays in dw.json. Also accepts `cartridgesPath` as an alias. The `-c` flag still takes precedence when provided. (Thanks [@clavery](https://github.com/clavery)!)
8+
9+
- [#264](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/pull/264) [`9996eba`](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/commit/9996eba2a8fe53a27bf52fb208eb722d618cd282) - Fix multiple issues with the hook scaffold (#247): (Thanks [@clavery](https://github.com/clavery)!)
10+
11+
- Updated dependencies [[`16bd9d6`](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/commit/16bd9d6a1c658d6ba3de04fa3acf89295e1e5e06), [`4cf7249`](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/commit/4cf72497f5e01d627de7aae80290d072f4c914f6), [`9996eba`](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/commit/9996eba2a8fe53a27bf52fb208eb722d618cd282), [`d50bf6b`](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/commit/d50bf6b91dcd40314f10c8c97a28805039161213)]:
12+
- @salesforce/b2c-tooling-sdk@0.9.0
13+
314
## 0.7.3
415

516
### Patch Changes

packages/b2c-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@salesforce/b2c-cli",
33
"description": "A Salesforce B2C Commerce CLI",
4-
"version": "0.7.3",
4+
"version": "0.7.4",
55
"author": "Charles Lavery",
66
"bin": {
77
"b2c": "./bin/run.js"

packages/b2c-cli/src/commands/code/deploy.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ export default class CodeDeploy extends CartridgeCommand<typeof CodeDeploy> {
134134
this.error(t('commands.code.deploy.noCartridges', 'No cartridges found in {{path}}', {path: this.cartridgePath}));
135135
}
136136

137-
this.logger?.info(
138-
{path: this.cartridgePath, server: hostname, codeVersion: version},
139-
t('commands.code.deploy.deploying', 'Deploying {{path}} to {{hostname}} ({{version}})', {
137+
this.log(
138+
t('commands.code.deploy.deploying', 'Deploying {{path}} to {{hostname}} ({{version}})...', {
140139
path: this.cartridgePath,
141140
hostname,
142141
version,
@@ -145,12 +144,13 @@ export default class CodeDeploy extends CartridgeCommand<typeof CodeDeploy> {
145144

146145
// Log found cartridges
147146
for (const c of cartridges) {
148-
this.logger?.debug({cartridgeName: c.name, path: c.src}, ` ${c.name}`);
147+
this.log(` ${c.name} (${c.src})`);
149148
}
150149

151150
try {
152151
// Optionally delete existing cartridges first
153152
if (this.flags.delete) {
153+
this.log(t('commands.code.deploy.deleting', 'Deleting existing cartridges...'));
154154
await this.operations.deleteCartridges(this.instance, cartridges);
155155
}
156156

@@ -174,12 +174,15 @@ export default class CodeDeploy extends CartridgeCommand<typeof CodeDeploy> {
174174
reloaded,
175175
};
176176

177-
this.logger?.info(
178-
{codeVersion: result.codeVersion, cartridgeCount: result.cartridges.length},
179-
t('commands.code.deploy.summary', 'Deployed {{count}} cartridge(s) to {{codeVersion}}', {
180-
count: result.cartridges.length,
181-
codeVersion: result.codeVersion,
182-
}),
177+
this.log(
178+
t(
179+
'commands.code.deploy.summary',
180+
'Deployed {{count}} cartridge(s) to version "{{codeVersion}}" successfully!',
181+
{
182+
count: result.cartridges.length,
183+
codeVersion: result.codeVersion,
184+
},
185+
),
183186
);
184187

185188
if (result.reloaded) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default class SetupInspect extends BaseCommand<typeof SetupInspect> {
8989

9090
static hiddenAliases = ['config:show', 'config:inspect'];
9191

92-
protected override loadConfiguration(): ResolvedB2CConfig {
92+
protected override async loadConfiguration(): Promise<ResolvedB2CConfig> {
9393
// Include EnvSource so that SFCC_* environment variables are visible in inspect output.
9494
// Other commands handle env vars via oclif flag mappings, but inspect needs to show them
9595
// as a config source since it doesn't have those flags.

0 commit comments

Comments
 (0)