fix(vscode): honor SFCC_CONFIG for instance config resolution - #621
Open
clavery wants to merge 2 commits into
Open
fix(vscode): honor SFCC_CONFIG for instance config resolution#621clavery wants to merge 2 commits into
clavery wants to merge 2 commits into
Conversation
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).
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The VS Code extension ignored the
SFCC_CONFIGenvironment variable when resolving B2C instance configuration.SFCC_CONFIGpoints to adw.jsonfile (the same thing the CLI's--configflag sets), but the extension only ever looked for adw.jsonin the workspace folder.As a result, a project that has a
.env(so the extension selects that workspace folder) but relies on a globaldw.jsonviaSFCC_CONFIGresolved to "No B2C Commerce instance configured" — the global config was never consulted.Root cause
resolveConfig()was called with only{workingDirectory, sourcesBefore: [new EnvSource()]}.EnvSourcemapsSFCC_*vars to config fields (hostname, clientId, …) and has no entry forSFCC_CONFIGbecause it's a file path, not a field. With noconfigPath,DwJsonSourceonly checked<workingDirectory>/dw.json.Fix
Read
process.env.SFCC_CONFIGand thread it through asconfigPath, mirroring how the CLI wires its--configflag. Read after the.envload so a project.envcan set/override it (matching CLI precedence). Falls back toworkingDirectory/dw.jsonas before.Toolchain
Also bumps
@vscode/test-cli(0.0.12 → 0.0.15) and@vscode/test-electron(2.5.2 → 3.1.0). The oldtest-electronhardcoded the macOS test-host binary asContents/MacOS/Electron; VS Code 1.110+ renamed it toCode, so the integration test host failed to launch (spawn .../MacOS/Electron ENOENT). 3.x readsCFBundleExecutablefromInfo.plistand launches correctly.Testing
Manual verification: with
SFCC_CONFIGset to a globaldw.jsonand nodw.jsonin the workspace folder, the extension now resolves the instance from the global config instead of reporting "No B2C Commerce instance configured".