From 04d04607eaabdd60ca7b6d8988e20ad23ad99c7e Mon Sep 17 00:00:00 2001 From: Deepu Mungamuri Date: Tue, 31 Mar 2026 10:33:17 +0530 Subject: [PATCH] refactor: rename webapp references to uiBundle across src and test files - Rename webappDiscovery.ts -> uiBundleDiscovery.ts - Rename webappProjectUtils.ts -> uiBundleProjectUtils.ts - Rename webappDiscovery.test.ts -> uiBundleDiscovery.test.ts - Update all import paths to reference renamed files - Rename WEBAPPLICATIONS_RELATIVE_PATH -> UI_BUNDLES_RELATIVE_PATH - Rename WEBAPP_META_XML_PATTERN -> UIBUNDLE_META_XML_PATTERN - Rename param webAppNames -> uiBundleNames in createProjectWithMultipleUiBundles - Fix proxy health check header: X-Salesforce-UiBundle-Proxy -> X-Salesforce-UIBundle-Proxy - Update stale comments referencing WebAppProxyHandler and webapp terminology @W21818614 Made-with: Cursor --- src/commands/ui-bundle/dev.ts | 4 ++-- .../{webappDiscovery.ts => uiBundleDiscovery.ts} | 12 ++++++------ test/commands/ui-bundle/dev.nut.ts | 2 +- test/commands/ui-bundle/devPort.nut.ts | 2 +- test/commands/ui-bundle/devWithUrl.nut.ts | 2 +- test/commands/ui-bundle/helpers/devServerUtils.ts | 6 +++--- ...webappProjectUtils.ts => uiBundleProjectUtils.ts} | 6 +++--- ...ppDiscovery.test.ts => uiBundleDiscovery.test.ts} | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) rename src/config/{webappDiscovery.ts => uiBundleDiscovery.ts} (98%) rename test/commands/ui-bundle/helpers/{webappProjectUtils.ts => uiBundleProjectUtils.ts} (97%) rename test/config/{webappDiscovery.test.ts => uiBundleDiscovery.test.ts} (99%) diff --git a/src/commands/ui-bundle/dev.ts b/src/commands/ui-bundle/dev.ts index 3a97d2c..b8d4ec1 100644 --- a/src/commands/ui-bundle/dev.ts +++ b/src/commands/ui-bundle/dev.ts @@ -23,7 +23,7 @@ import type { UiBundleManifest } from '../../config/manifest.js'; import { ManifestWatcher } from '../../config/ManifestWatcher.js'; import { DevServerManager } from '../../server/DevServerManager.js'; import { ProxyServer } from '../../proxy/ProxyServer.js'; -import { discoverUiBundle, DEFAULT_DEV_COMMAND, type DiscoveredUiBundle } from '../../config/webappDiscovery.js'; +import { discoverUiBundle, DEFAULT_DEV_COMMAND, type DiscoveredUiBundle } from '../../config/uiBundleDiscovery.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-ui-bundle-dev', 'ui-bundle.dev'); @@ -160,7 +160,7 @@ export default class UiBundleDev extends SfCommand { method: 'GET', signal: AbortSignal.timeout(3000), // 3 second timeout }); - return response.headers.get('X-Salesforce-UiBundle-Proxy') === 'true'; + return response.headers.get('X-Salesforce-UIBundle-Proxy') === 'true'; } catch { // Health check failed - Vite proxy not active return false; diff --git a/src/config/webappDiscovery.ts b/src/config/uiBundleDiscovery.ts similarity index 98% rename from src/config/webappDiscovery.ts rename to src/config/uiBundleDiscovery.ts index 4e86ac5..27ed74c 100644 --- a/src/config/webappDiscovery.ts +++ b/src/config/uiBundleDiscovery.ts @@ -30,12 +30,12 @@ export const DEFAULT_DEV_COMMAND = 'npm run dev'; * Standard metadata path segment for uiBundles (relative to package directory). * Consistent with other metadata types: packagePath/main/default/uiBundles */ -const WEBAPPLICATIONS_RELATIVE_PATH = 'main/default/uiBundles'; +const UI_BUNDLES_RELATIVE_PATH = 'main/default/uiBundles'; /** * Pattern to match uibundle metadata XML files */ -const WEBAPP_META_XML_PATTERN = /^(.+)\.uibundle-meta\.xml$/; +const UIBUNDLE_META_XML_PATTERN = /^(.+)\.uibundle-meta\.xml$/; /** * Discovered uiBundle with its directory path and optional manifest @@ -47,7 +47,7 @@ export type DiscoveredUiBundle = { relativePath: string; /** Parsed manifest content (null if no ui-bundle.json found) */ manifest: UiBundleManifest | null; - /** Webapp name (from .uibundle-meta.xml or folder name) */ + /** uiBundle name (from .uibundle-meta.xml or folder name) */ name: string; /** Whether this uiBundle has a ui-bundle.json manifest file */ hasManifest: boolean; @@ -91,7 +91,7 @@ async function findUiBundleMetaXml(dirPath: string): Promise { const matches: string[] = []; for (const entry of entries) { - const match = WEBAPP_META_XML_PATTERN.exec(entry); + const match = UIBUNDLE_META_XML_PATTERN.exec(entry); if (match) { matches.push(match[1]); } @@ -187,7 +187,7 @@ async function getUiBundlesPathsFromProject(projectRoot: string): Promise { - const uiBundlesPath = join(projectRoot, pkg.path, WEBAPPLICATIONS_RELATIVE_PATH); + const uiBundlesPath = join(projectRoot, pkg.path, UI_BUNDLES_RELATIVE_PATH); return (await pathExists(uiBundlesPath)) ? uiBundlesPath : null; }) ); @@ -444,7 +444,7 @@ export type DiscoverUiBundleResult = { * * Discovery use cases: * 1. SFDX Project Root: Search uiBundles in all package directories - * - Webapps identified by {name}.uibundle-meta.xml + * - uiBundles identified by {name}.uibundle-meta.xml * - Always prompt for selection (even if only 1 uiBundle) * * 2. Inside uiBundles/ directory: diff --git a/test/commands/ui-bundle/dev.nut.ts b/test/commands/ui-bundle/dev.nut.ts index ffcab42..721d054 100644 --- a/test/commands/ui-bundle/dev.nut.ts +++ b/test/commands/ui-bundle/dev.nut.ts @@ -30,7 +30,7 @@ import { ensureSfCli, authOrgViaUrl, REAL_HOME, -} from './helpers/webappProjectUtils.js'; +} from './helpers/uiBundleProjectUtils.js'; /* ------------------------------------------------------------------ * * Tier 1 — No Auth * diff --git a/test/commands/ui-bundle/devPort.nut.ts b/test/commands/ui-bundle/devPort.nut.ts index c4fa667..163ccde 100644 --- a/test/commands/ui-bundle/devPort.nut.ts +++ b/test/commands/ui-bundle/devPort.nut.ts @@ -17,7 +17,7 @@ import type { Server } from 'node:net'; import { TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; -import { createProjectWithDevServer, ensureSfCli, authOrgViaUrl } from './helpers/webappProjectUtils.js'; +import { createProjectWithDevServer, ensureSfCli, authOrgViaUrl } from './helpers/uiBundleProjectUtils.js'; import { occupyPort, spawnUiBundleDev, diff --git a/test/commands/ui-bundle/devWithUrl.nut.ts b/test/commands/ui-bundle/devWithUrl.nut.ts index b976b76..70e71a5 100644 --- a/test/commands/ui-bundle/devWithUrl.nut.ts +++ b/test/commands/ui-bundle/devWithUrl.nut.ts @@ -23,7 +23,7 @@ import { writeManifest, ensureSfCli, authOrgViaUrl, -} from './helpers/webappProjectUtils.js'; +} from './helpers/uiBundleProjectUtils.js'; import { spawnUiBundleDev, startTestHttpServer, diff --git a/test/commands/ui-bundle/helpers/devServerUtils.ts b/test/commands/ui-bundle/helpers/devServerUtils.ts index cc5246c..a2a2e11 100644 --- a/test/commands/ui-bundle/helpers/devServerUtils.ts +++ b/test/commands/ui-bundle/helpers/devServerUtils.ts @@ -29,7 +29,7 @@ import { createServer, type Server } from 'node:net'; * parallelism is enabled later, overlapping ranges would cause EADDRINUSE. */ -/** Mocha suite-level timeout for describe blocks that spawn webapp dev. */ +/** Mocha suite-level timeout for describe blocks that spawn ui-bundle dev. */ export const SUITE_TIMEOUT = 180_000; /** Timeout for spawnUiBundleDev when the command is expected to start successfully. */ @@ -178,8 +178,8 @@ export function startTestHttpServer(port: number): Promise { /** * Start an HTTP server that mimics a Vite dev server with the - * WebAppProxyHandler plugin active. Responds to health check requests - * (`?sfProxyHealthCheck=true`) with `X-Salesforce-UiBundle-Proxy: true`. + * UIBundleProxyHandler plugin active. Responds to health check requests + * (`?sfProxyHealthCheck=true`) with `X-Salesforce-UIBundle-Proxy: true`. */ export function startViteProxyServer(port: number): Promise { return new Promise((resolve, reject) => { diff --git a/test/commands/ui-bundle/helpers/webappProjectUtils.ts b/test/commands/ui-bundle/helpers/uiBundleProjectUtils.ts similarity index 97% rename from test/commands/ui-bundle/helpers/webappProjectUtils.ts rename to test/commands/ui-bundle/helpers/uiBundleProjectUtils.ts index f52af2b..8423f1a 100644 --- a/test/commands/ui-bundle/helpers/webappProjectUtils.ts +++ b/test/commands/ui-bundle/helpers/uiBundleProjectUtils.ts @@ -19,7 +19,7 @@ import { mkdirSync, rmSync, writeFileSync } from 'node:fs'; import { homedir, tmpdir } from 'node:os'; import { join } from 'node:path'; import type { TestSession } from '@salesforce/cli-plugins-testkit'; -import { UI_BUNDLES_FOLDER } from '../../../../src/config/webappDiscovery.js'; +import { UI_BUNDLES_FOLDER } from '../../../../src/config/uiBundleDiscovery.js'; /** * Real home directory captured at module load, before TestSession overrides process.env.HOME. @@ -118,10 +118,10 @@ export function createProjectWithUiBundle(session: TestSession, projectName: str export function createProjectWithMultipleUiBundles( session: TestSession, projectName: string, - webAppNames: string[] + uiBundleNames: string[] ): string { const projectDir = createProject(session, projectName); - for (const name of webAppNames) { + for (const name of uiBundleNames) { execSync(`sf ui-bundle generate --name ${name}`, { cwd: projectDir, stdio: 'pipe', diff --git a/test/config/webappDiscovery.test.ts b/test/config/uiBundleDiscovery.test.ts similarity index 99% rename from test/config/webappDiscovery.test.ts rename to test/config/uiBundleDiscovery.test.ts index 985f437..3f8b87e 100644 --- a/test/config/webappDiscovery.test.ts +++ b/test/config/uiBundleDiscovery.test.ts @@ -18,9 +18,9 @@ import { mkdirSync, rmSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; import { expect } from 'chai'; import { SfError, SfProject } from '@salesforce/core'; -import { DEFAULT_DEV_COMMAND, discoverUiBundle, UI_BUNDLES_FOLDER } from '../../src/config/webappDiscovery.js'; +import { DEFAULT_DEV_COMMAND, discoverUiBundle, UI_BUNDLES_FOLDER } from '../../src/config/uiBundleDiscovery.js'; -describe('webappDiscovery', () => { +describe('uiBundleDiscovery', () => { const testDir = join(process.cwd(), '.test-uiBundle-discovery'); // Standard SFDX uiBundles path