Skip to content

Commit bcc2c4d

Browse files
authored
fix: better output for mystery component (#1018)
1 parent ec76bdc commit bcc2c4d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/resolve/connectionResolver.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import { PollingClient, StatusResult, Connection, Logger } from '@salesforce/core';
8+
import { PollingClient, StatusResult, Connection, Logger, SfError, Messages } from '@salesforce/core';
99
import { Duration, ensureArray } from '@salesforce/kit';
1010
import { retry, NotRetryableError, RetryError } from 'ts-retry-promise';
1111
import { ensurePlainObject, ensureString, isPlainObject } from '@salesforce/ts-types';
@@ -14,6 +14,10 @@ import { standardValueSet } from '../registry/standardvalueset';
1414
import { FileProperties, StdValueSetRecord, ListMetadataQuery } from '../client/types';
1515
import { extName } from '../utils';
1616
import { MetadataComponent } from './types';
17+
18+
Messages.importMessagesDirectory(__dirname);
19+
const messages = Messages.loadMessages('@salesforce/source-deploy-retrieve', 'sdr');
20+
1721
export interface ResolveConnectionResult {
1822
components: MetadataComponent[];
1923
apiVersion: string;
@@ -49,14 +53,22 @@ export class ConnectionResolver {
4953
let componentType: MetadataType;
5054
if (typeof component.type === 'string' && component.type.length) {
5155
componentType = this.registry.getTypeByName(component.type);
52-
} else {
56+
} else if (typeof component.fileName === 'string' && component.fileName.length) {
5357
// fix { type: { "$": { "xsi:nil": "true" } } }
5458
componentType = ensurePlainObject(
5559
this.registry.getTypeBySuffix(extName(component.fileName)),
5660
`No type found for ${component.fileName} when matching by suffix. Check the file extension.`
5761
);
5862
component.type = componentType.name;
63+
} else {
64+
// has no type and has no filename!
65+
throw new SfError(
66+
messages.getMessage('error_could_not_infer_type', [component.fullName]),
67+
'TypeInferenceError',
68+
[messages.getMessage('suggest_type_more_suggestions')]
69+
);
5970
}
71+
6072
Aggregator.push(component);
6173
componentTypes.add(componentType);
6274
const folderContentType = componentType.folderContentType;

0 commit comments

Comments
 (0)