Skip to content

refactor: source EXTENSION_ID/ENV_VARS/OUTPUT_CHANNEL_NAME from constants#4

Merged
MelbourneDeveloper merged 2 commits into
mainfrom
salvage/centralize-brand-name
May 30, 2026
Merged

refactor: source EXTENSION_ID/ENV_VARS/OUTPUT_CHANNEL_NAME from constants#4
MelbourneDeveloper merged 2 commits into
mainfrom
salvage/centralize-brand-name

Conversation

@MelbourneDeveloper
Copy link
Copy Markdown
Collaborator

TLDR

Wire the already-defined EXTENSION_ID, ENV_VARS, and OUTPUT_CHANNEL_NAME constants 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.ts already derived EXTENSION_ID, ENV_VARS, and OUTPUT_CHANNEL_NAME from the single BRAND_ID/BRAND_NAME/PUBLISHER roots, but the call sites still hardcoded the resulting strings. This replaces those literals with imports:

  • src/logger.ts — drops the local const ENV_LOG_LEVEL_VAR = "DIFFR_LOG_LEVEL"; reads process.env[ENV_VARS.logLevel] instead.
  • src/test/runTests.tsDIFFR_E2E env key → [ENV_VARS.e2e]; launch-arg "nimblesite.diffr"EXTENSION_ID.
  • src/commands/flow.ts — error toast Output → DiffrOutput → ${OUTPUT_CHANNEL_NAME}.
  • src/test/suite/{activation,commands,contentProvider}.test.ts — delete the three duplicated const EXTENSION_ID = "nimblesite.diffr" literals; import EXTENSION_ID from ../../constants.

No new files, no new dependencies, no behavioural change — the derived strings are byte-identical to the literals they replace. Net +10 / −15 across 6 files.

How Do The Automated Tests Prove It Works?

make ci passes end-to-end on this branch:

  • E2E (@vscode/test-electron, real VSCode): activation.test.ts resolves the extension via the now-imported EXTENSION_ID and asserts every COMMAND_IDS value is registered; contentProvider.test.ts resolves diffr:// URIs against the seeded repo using the same imported id — proving the derived EXTENSION_ID matches the manifest's published id, otherwise getExtension(EXTENSION_ID) would return undefined and these suites would fail.
  • runTests.ts launches the host with EXTENSION_ID and sets [ENV_VARS.e2e]; the suites only run because that wiring resolves correctly.
  • Coverage gate held: Statements 95.09% (2153/2264), Functions 97.84%, Lines 95.09%, above the coverage-thresholds.json floor. tsc -p ., eslint src, and shipwright:validate all clean.

Breaking Changes

None. Internal refactor only; the env-var names, extension id, and channel label are unchanged.

MelbourneDeveloper and others added 2 commits May 30, 2026 10:13
… 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>
@MelbourneDeveloper MelbourneDeveloper merged commit 1178245 into main May 30, 2026
1 check passed
@MelbourneDeveloper MelbourneDeveloper deleted the salvage/centralize-brand-name branch May 30, 2026 04:11
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