Skip to content

Commit 69a623b

Browse files
authored
Merge pull request #1665 from forcedotcom/d/W-17052870
CHANGE @W-17052870@ Polished config output
2 parents bfd3124 + cbcf4a6 commit 69a623b

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

messages/action-summary-viewer.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ Summary
66

77
Additional log information written to:
88

9-
# config-action.no-outfiles
10-
11-
No output file was specified.
12-
139
# config-action.outfile-location
1410

1511
Configuration written to:

src/lib/actions/ConfigAction.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,13 @@ export class ConfigAction {
121121
};
122122
const configModel: ConfigModel = this.dependencies.modelGenerator(relevantEngines, userConfigContext, defaultConfigContext);
123123

124-
this.dependencies.viewer.view(configModel);
125124
const fileWritten: boolean = this.dependencies.writer
126125
? await this.dependencies.writer.write(configModel)
127126
: false;
127+
if (!fileWritten) {
128+
this.dependencies.viewer.view(configModel);
129+
}
130+
128131
this.dependencies.actionSummaryViewer.view(logFileWriter.getLogDestination(), fileWritten ? input['output-file'] : undefined);
129132
return Promise.resolve();
130133
}

src/lib/viewers/ActionSummaryViewer.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ export class ConfigActionSummaryViewer extends AbstractActionSummaryViewer {
3434

3535
if (outfile) {
3636
this.displayOutfile(outfile);
37-
} else {
38-
this.display.displayLog(getMessage(BundleName.ActionSummaryViewer, 'config-action.no-outfiles'));
37+
this.displayLineSeparator();
3938
}
40-
this.displayLineSeparator();
4139

4240
this.displayLogFileInfo(logFile);
4341
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
=== Summary
22

3-
No output file was specified.
4-
53
Additional log information written to:

test/lib/actions/ConfigAction.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {ConfigStyledYamlViewer} from '../../../src/lib/viewers/ConfigViewer';
1313
import {ConfigActionSummaryViewer} from '../../../src/lib/viewers/ActionSummaryViewer';
1414

1515
import {SpyConfigWriter} from '../../stubs/SpyConfigWriter';
16+
import {SpyConfigViewer} from '../../stubs/SpyConfigViewer';
1617
import {DisplayEventType, SpyDisplay} from '../../stubs/SpyDisplay';
1718

1819
const PATH_TO_FIXTURES = path.join(__dirname, '..', '..', 'fixtures');
@@ -403,17 +404,38 @@ describe('ConfigAction tests', () => {
403404
};
404405
});
405406

406-
it('If a ConfigWriter is provided, it is used along with the ConfigViewer', async () => {
407+
it('If a file is created, then the ConfigViewer is unused', async () => {
407408
// ==== SETUP ====
408409
// We need to add a Writer to the dependencies.
409410
const spyWriter = new SpyConfigWriter();
410411
dependencies.writer = spyWriter;
412+
// Replace the viewer with a Spy.
413+
const spyViewer = new SpyConfigViewer();
414+
dependencies.viewer = spyViewer;
411415

412416
// ==== TESTED BEHAVIOR ====
413417
await runActionAndGetDisplayedConfig(dependencies, ['all']);
414418

415419
// ==== ASSERTIONS ====
416420
expect(spyWriter.getCallHistory()).toHaveLength(1);
421+
expect(spyViewer.getCallHistory()).toHaveLength(0);
422+
});
423+
424+
it('If a file is specified by not created, then the ConfigViewer is used', async () => {
425+
// ==== SETUP ====
426+
// We need to add a Writer to the dependencies.
427+
const spyWriter = new SpyConfigWriter(false);
428+
dependencies.writer = spyWriter;
429+
// Replace the viewer with a Spy.
430+
const spyViewer = new SpyConfigViewer();
431+
dependencies.viewer = spyViewer;
432+
433+
// ==== TESTED BEHAVIOR ====
434+
await runActionAndGetDisplayedConfig(dependencies, ['all']);
435+
436+
// ==== ASSERTIONS ====
437+
expect(spyWriter.getCallHistory()).toHaveLength(1);
438+
expect(spyViewer.getCallHistory()).toHaveLength(1);
417439
});
418440
});
419441

0 commit comments

Comments
 (0)