diff --git a/src/convert/transformers/staticResourceMetadataTransformer.ts b/src/convert/transformers/staticResourceMetadataTransformer.ts index 330f4f749..668a1eeb7 100644 --- a/src/convert/transformers/staticResourceMetadataTransformer.ts +++ b/src/convert/transformers/staticResourceMetadataTransformer.ts @@ -52,7 +52,6 @@ export class StaticResourceMetadataTransformer extends BaseMetadataTransformer { // Zip the static resource from disk to a stream, compressing at level 9. const zipIt = (): Readable => { - // static resource should always have content prop getLogger().debug(`zipping static resource: ${content}`); const zip = JSZip(); @@ -198,7 +197,7 @@ const getContentType = async (component: SourceComponent): Promise => { if (typeof output !== 'string') { throw new SfError( - `Expected a string for contentType in ${component.name} (${component.xml ?? ''}) but got ${JSON.stringify( + `Expected a string for contentType in ${component.name} (${component.xml ?? ''}) but got ${JSON.stringify( output )}` ); @@ -214,7 +213,7 @@ const getBaseContentPath = (component: SourceComponent, mergeWith?: SourceCompon const baseContentPath = component.getPackageRelativePath(component.content, 'source'); return join(dirname(baseContentPath), baseName(baseContentPath)); } - throw new SfError(`Expected a content path for ${component.name} (${component.xml ?? ''})`); + throw new SfError(`Expected a content path for ${component.name} (${component.xml ?? ''})`); }; const getExtensionFromType = (contentType: string): string => @@ -242,7 +241,7 @@ async function getStaticResourceZip(component: SourceComponent, content: string) return await JSZip.loadAsync(staticResourceZip, { createFolders: true }); } catch (e) { throw new SfError( - `Unable to open zip file ${content} for ${component.name} (${component.xml ?? ''})`, + `Unable to open zip file ${content} for ${component.name} (${component.xml ?? ''})`, 'BadZipFile', ['Check that your file really is a valid zip archive'] ); diff --git a/src/resolve/connectionResolver.ts b/src/resolve/connectionResolver.ts index be1d6456d..3109b5880 100644 --- a/src/resolve/connectionResolver.ts +++ b/src/resolve/connectionResolver.ts @@ -180,8 +180,8 @@ const listMembers = const inferFilenamesFromType = (metadataType: MetadataType) => (member: RelevantFileProperties): RelevantFileProperties => - typeof member.fileName === 'object' - ? { ...member, fileName: `${metadataType.directoryName}/${member.fullName}.${metadataType.suffix ?? ''}` } + typeof member.fileName === 'object' && metadataType.suffix + ? { ...member, fileName: `${metadataType.directoryName}/${member.fullName}.${metadataType.suffix}` } : member; const isNonEmptyString = (value: string | undefined): boolean => typeof value === 'string' && value.length > 0; diff --git a/src/resolve/sourceComponent.ts b/src/resolve/sourceComponent.ts index f14786430..791b15a94 100644 --- a/src/resolve/sourceComponent.ts +++ b/src/resolve/sourceComponent.ts @@ -75,7 +75,7 @@ export class SourceComponent implements MetadataComponent { } if (this.parent && this.type.ignoreParentName) { if (!this.name) { - throw new SfError(`Component was initialized without a name: ${this.xml ?? ''} (${this.type.name})`); + throw new SfError(`Component was initialized without a name: ${this.xml ?? ''} (${this.type.name})`); } return this.name; } else { @@ -350,17 +350,17 @@ export class SourceComponent implements MetadataComponent { } return Object.values(this.type.children.types).flatMap((childType) => { - const uniqueIdElement = childType.uniqueIdElement; + const { uniqueIdElement, xmlElementName } = childType; - if (!uniqueIdElement) { + if (!uniqueIdElement || !xmlElementName) { return []; } - const xmlPathToChildren = `${this.type.name}.${childType.xmlElementName ?? ''}`; + const xmlPathToChildren = `${this.type.name}.${xmlElementName}`; const elements = ensureArray(get(parsed, xmlPathToChildren, [])); return elements.map((element) => { const name = getString(element, uniqueIdElement); if (!name) { - throw new SfError(`Missing ${uniqueIdElement} on ${childType.name} in ${this.xml ?? ''}`); + throw new SfError(`Missing ${uniqueIdElement} on ${childType.name} in ${this.xml ?? ''}`); } return new SourceComponent( {