Skip to content

fix(vscode): honor SFCC_CONFIG for instance config resolution - #621

Open
clavery wants to merge 2 commits into
mainfrom
fix/vscode-sfcc-config-env
Open

fix(vscode): honor SFCC_CONFIG for instance config resolution#621
clavery wants to merge 2 commits into
mainfrom
fix/vscode-sfcc-config-env

Conversation

@clavery

@clavery clavery commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

The VS Code extension ignored the SFCC_CONFIG environment variable when resolving B2C instance configuration. SFCC_CONFIG points to a dw.json file (the same thing the CLI's --config flag sets), but the extension only ever looked for a dw.json in the workspace folder.

As a result, a project that has a .env (so the extension selects that workspace folder) but relies on a global dw.json via SFCC_CONFIG resolved to "No B2C Commerce instance configured" — the global config was never consulted.

Root cause

resolveConfig() was called with only {workingDirectory, sourcesBefore: [new EnvSource()]}. EnvSource maps SFCC_* vars to config fields (hostname, clientId, …) and has no entry for SFCC_CONFIG because it's a file path, not a field. With no configPath, DwJsonSource only checked <workingDirectory>/dw.json.

Fix

Read process.env.SFCC_CONFIG and thread it through as configPath, mirroring how the CLI wires its --config flag. Read after the .env load so a project .env can set/override it (matching CLI precedence). Falls back to workingDirectory/dw.json as before.

Toolchain

Also bumps @vscode/test-cli (0.0.12 → 0.0.15) and @vscode/test-electron (2.5.2 → 3.1.0). The old test-electron hardcoded the macOS test-host binary as Contents/MacOS/Electron; VS Code 1.110+ renamed it to Code, so the integration test host failed to launch (spawn .../MacOS/Electron ENOENT). 3.x reads CFBundleExecutable from Info.plist and launches correctly.

Testing

Manual verification: with SFCC_CONFIG set to a global dw.json and no dw.json in the workspace folder, the extension now resolves the instance from the global config instead of reporting "No B2C Commerce instance configured".

The extension previously only loaded a dw.json from the workspace folder
and ignored a global dw.json referenced by the SFCC_CONFIG env var, so
projects relying on that var (e.g. alongside a project .env) resolved to
"No B2C Commerce instance configured". Thread SFCC_CONFIG through as the
explicit configPath, matching the CLI's --config flag.

Also bump @vscode/test-cli and @vscode/test-electron so the integration
test host launches against VS Code 1.110+ (binary renamed Electron -> Code).
@clavery
clavery requested a review from wei-liu-sf as a code owner August 14, 2026 22:17
test-cli 0.0.15 depends on yargs@^18, which hoisted an unpatched yargs@18
to the workspace root. That reintroduced the 'require is not defined in ES
module scope' error the repo's yargs@17.7.2 patch fixes, breaking SDK/MCP/CLI
tests on node 26. The macOS binary-name fix lives in @vscode/test-electron@3.x
(reads CFBundleExecutable), which is retained; only test-cli is reverted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant