From fffaea96f8d8dffbd4f3d752caff57c86aac9a00 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Thu, 1 Aug 2024 16:14:47 -0500 Subject: [PATCH] fix: allow more undefined from adapters --- src/resolve/adapters/baseSourceAdapter.ts | 13 ++++++------- .../adapters/digitalExperienceSourceAdapter.ts | 2 +- .../adapters/matchingContentSourceAdapter.ts | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/resolve/adapters/baseSourceAdapter.ts b/src/resolve/adapters/baseSourceAdapter.ts index 99d617c64..d4c7b031e 100644 --- a/src/resolve/adapters/baseSourceAdapter.ts +++ b/src/resolve/adapters/baseSourceAdapter.ts @@ -5,7 +5,7 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ import { basename, dirname, sep } from 'node:path'; -import { Messages, SfError } from '@salesforce/core'; +import { Lifecycle, Messages, SfError } from '@salesforce/core'; import { ensureString } from '@salesforce/ts-types'; import { MetadataXml } from '../types'; import { parseMetadataXml, parseNestedFullName } from '../../utils/path'; @@ -13,7 +13,7 @@ import { SourceComponent } from '../sourceComponent'; import { SourcePath } from '../../common/types'; import { MetadataType } from '../../registry/types'; import { RegistryAccess, typeAllowsMetadataWithContent } from '../../registry/registryAccess'; -import { FindRootMetadata, GetComponent } from './types'; +import { FindRootMetadata, MaybeGetComponent } from './types'; Messages.importMessagesDirectory(__dirname); const messages = Messages.loadMessages('@salesforce/source-deploy-retrieve', 'sdr'); @@ -76,17 +76,16 @@ export const trimPathToContent = return pathParts.slice(0, typeFolderIndex + offset).join(sep); }; -export const getComponent: GetComponent = +export const getComponent: MaybeGetComponent = (context) => ({ type, path, metadataXml: findRootMetadata = defaultFindRootMetadata }) => { // find rootMetadata const metadataXml = typeof findRootMetadata === 'function' ? findRootMetadata(type, path) : findRootMetadata; if (!metadataXml) { - throw SfError.create({ - message: messages.getMessage('error_parsing_xml', [path, type.name]), - name: 'MissingXml', - }); + void Lifecycle.getInstance().emitWarning(messages.getMessage('error_parsing_xml', [path, type.name])); + return; } + if (context.forceIgnore?.denies(metadataXml.path)) { throw SfError.create({ message: messages.getMessage('error_no_metadata_xml_ignore', [metadataXml.path, path]), diff --git a/src/resolve/adapters/digitalExperienceSourceAdapter.ts b/src/resolve/adapters/digitalExperienceSourceAdapter.ts index 681b36269..851182485 100644 --- a/src/resolve/adapters/digitalExperienceSourceAdapter.ts +++ b/src/resolve/adapters/digitalExperienceSourceAdapter.ts @@ -81,7 +81,7 @@ export const getDigitalExperienceComponent: MaybeGetComponent = ? ensure(parseMetadataXmlForDEB(context.registry)(type)(metaFilePath)) : ({ path: metaFilePath, fullName: 'foo' } satisfies MetadataXml); const sourceComponent = getComponent(context)({ type, path, metadataXml: rootMetaXml }); - return populate(context)(type)(path, sourceComponent); + return sourceComponent ? populate(context)(type)(path, sourceComponent) : undefined; }; const getNonDEBRoot = (type: MetadataType, path: SourcePath): SourcePath => { diff --git a/src/resolve/adapters/matchingContentSourceAdapter.ts b/src/resolve/adapters/matchingContentSourceAdapter.ts index fd67492a7..b8b20d10b 100644 --- a/src/resolve/adapters/matchingContentSourceAdapter.ts +++ b/src/resolve/adapters/matchingContentSourceAdapter.ts @@ -38,7 +38,7 @@ const removeMetaXmlSuffix = (fsPath: SourcePath): SourcePath => fsPath.slice(0, export const getMatchingContentComponent: GetComponent = (context) => ({ type, path }) => { - const sourceComponent = getComponent(context)({ type, path, metadataXml: findRootMetadata }); + const sourceComponent = ensure(getComponent(context)({ type, path, metadataXml: findRootMetadata })); return populate(context)(type)(path, sourceComponent); };