Skip to content

Commit

Permalink
fix: better output for mystery component (#1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc authored Jun 19, 2023
1 parent ec76bdc commit bcc2c4d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/resolve/connectionResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { PollingClient, StatusResult, Connection, Logger } from '@salesforce/core';
import { PollingClient, StatusResult, Connection, Logger, SfError, Messages } from '@salesforce/core';
import { Duration, ensureArray } from '@salesforce/kit';
import { retry, NotRetryableError, RetryError } from 'ts-retry-promise';
import { ensurePlainObject, ensureString, isPlainObject } from '@salesforce/ts-types';
Expand All @@ -14,6 +14,10 @@ import { standardValueSet } from '../registry/standardvalueset';
import { FileProperties, StdValueSetRecord, ListMetadataQuery } from '../client/types';
import { extName } from '../utils';
import { MetadataComponent } from './types';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/source-deploy-retrieve', 'sdr');

export interface ResolveConnectionResult {
components: MetadataComponent[];
apiVersion: string;
Expand Down Expand Up @@ -49,14 +53,22 @@ export class ConnectionResolver {
let componentType: MetadataType;
if (typeof component.type === 'string' && component.type.length) {
componentType = this.registry.getTypeByName(component.type);
} else {
} else if (typeof component.fileName === 'string' && component.fileName.length) {
// fix { type: { "$": { "xsi:nil": "true" } } }
componentType = ensurePlainObject(
this.registry.getTypeBySuffix(extName(component.fileName)),
`No type found for ${component.fileName} when matching by suffix. Check the file extension.`
);
component.type = componentType.name;
} else {
// has no type and has no filename!
throw new SfError(
messages.getMessage('error_could_not_infer_type', [component.fullName]),
'TypeInferenceError',
[messages.getMessage('suggest_type_more_suggestions')]
);
}

Aggregator.push(component);
componentTypes.add(componentType);
const folderContentType = componentType.folderContentType;
Expand Down

0 comments on commit bcc2c4d

Please sign in to comment.