Skip to content

Commit

Permalink
Merge pull request #653 from salesforcecli/sh/omit-large-fields-from-…
Browse files Browse the repository at this point in the history
…doctor

fix: omit _commandIDs and rootPlugin from doctor diagnosis
  • Loading branch information
mdonnalley authored Feb 14, 2024
2 parents b42f07f + a77b536 commit 0d31d4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface SfDoctorDiagnosis {
logFilePaths: string[];
}

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-info', 'doctor');

const PINNED_SUGGESTIONS = [
Expand Down Expand Up @@ -76,7 +76,14 @@ export class Doctor implements SfDoctor {
__cliConfig = config;
const sfdxEnvVars = new Env().entries().filter((e) => e[0].startsWith('SFDX_'));
const sfEnvVars = new Env().entries().filter((e) => e[0].startsWith('SF_'));
const cliConfig = omit(config, ['plugins', 'pjson', 'userPJSON', 'options']) as CliConfig;
const cliConfig = omit(config, [
'plugins',
'pjson',
'userPJSON',
'options',
'_commandIDs',
'rootPlugin',
]) as CliConfig;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
cliConfig.nodeEngine = config.pjson.engines.node as string;

Expand Down
7 changes: 6 additions & 1 deletion test/doctor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ describe('Doctor Class', () => {
},
plugins: [{ name: '@salesforce/plugin-org' }, { name: '@salesforce/plugin-source' }, { name: 'salesforce-alm' }],
versionDetails: getVersionDetailStub(),
_commandIDs: ['first', 'second'], // this should not be included in the diagnosis
rootPlugin: { foo: 'bar' }, // this should not be included in the diagnosis
} as unknown as Config;

afterEach(() => {
Expand Down Expand Up @@ -85,7 +87,10 @@ describe('Doctor Class', () => {
expect(dr.getDiagnosis().pluginSpecificData).to.deep.equal(expectedEntry);
dr.addPluginData(pluginName, dataEntries[1]);
expectedEntry[pluginName] = [dataEntries[0], dataEntries[1]];
expect(dr.getDiagnosis().pluginSpecificData).to.deep.equal(expectedEntry);
const diagnosis = dr.getDiagnosis();
expect(diagnosis.pluginSpecificData).to.deep.equal(expectedEntry);
expect(diagnosis.cliConfig).to.not.have.property('_commandIDs');
expect(diagnosis.cliConfig).to.not.have.property('rootPlugin');
});

it('writes file names with doctor ID', async () => {
Expand Down

0 comments on commit 0d31d4e

Please sign in to comment.