refactor: source EXTENSION_ID/ENV_VARS/OUTPUT_CHANNEL_NAME from constants#4
Merged
Merged
Conversation
… sites
main defined these constants in src/constants.ts but the call sites still
hardcoded the derived strings. Source them from constants so the brand
name lives in exactly one place:
- logger.ts: DIFFR_LOG_LEVEL literal -> ENV_VARS.logLevel
- runTests.ts: DIFFR_E2E + "nimblesite.diffr" -> ENV_VARS.e2e + EXTENSION_ID
- flow.ts: "Output -> Diffr" -> OUTPUT_CHANNEL_NAME
- {activation,commands,contentProvider}.test.ts: drop local
EXTENSION_ID literal, import from constants
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CI runs 'make fmt CHECK=1' before lint/test/build; the extended import exceeded prettier's print width. Reflow to satisfy the format check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
TLDR
Wire the already-defined
EXTENSION_ID,ENV_VARS, andOUTPUT_CHANNEL_NAMEconstants through their call sites so the brand name lives in exactly one place —src/constants.ts— instead of being re-hardcoded in six files.Details
src/constants.tsalready derivedEXTENSION_ID,ENV_VARS, andOUTPUT_CHANNEL_NAMEfrom the singleBRAND_ID/BRAND_NAME/PUBLISHERroots, but the call sites still hardcoded the resulting strings. This replaces those literals with imports:src/logger.ts— drops the localconst ENV_LOG_LEVEL_VAR = "DIFFR_LOG_LEVEL"; readsprocess.env[ENV_VARS.logLevel]instead.src/test/runTests.ts—DIFFR_E2Eenv key →[ENV_VARS.e2e]; launch-arg"nimblesite.diffr"→EXTENSION_ID.src/commands/flow.ts— error toastOutput → Diffr→Output → ${OUTPUT_CHANNEL_NAME}.src/test/suite/{activation,commands,contentProvider}.test.ts— delete the three duplicatedconst EXTENSION_ID = "nimblesite.diffr"literals; importEXTENSION_IDfrom../../constants.No new files, no new dependencies, no behavioural change — the derived strings are byte-identical to the literals they replace. Net
+10 / −15across 6 files.How Do The Automated Tests Prove It Works?
make cipasses end-to-end on this branch:@vscode/test-electron, real VSCode):activation.test.tsresolves the extension via the now-importedEXTENSION_IDand asserts everyCOMMAND_IDSvalue is registered;contentProvider.test.tsresolvesdiffr://URIs against the seeded repo using the same imported id — proving the derivedEXTENSION_IDmatches the manifest's published id, otherwisegetExtension(EXTENSION_ID)would return undefined and these suites would fail.runTests.tslaunches the host withEXTENSION_IDand sets[ENV_VARS.e2e]; the suites only run because that wiring resolves correctly.coverage-thresholds.jsonfloor.tsc -p .,eslint src, andshipwright:validateall clean.Breaking Changes
None. Internal refactor only; the env-var names, extension id, and channel label are unchanged.