@oclif/multi-stage-output 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  const getSideDividerWidth = (width, titleWidth) => (width - titleWidth) / 2;
4
4
  const getNumberOfCharsPerWidth = (char, width) => width / char.length;
5
5
  const PAD = ' ';
6
- export function Divider({ dividerChar = '─', dividerColor = 'dim', padding = 1, textColor = 'white', textPadding: titlePadding = 1, title = '', width = 50, }) {
6
+ export function Divider({ dividerChar = '─', dividerColor = 'dim', padding = 1, textColor, textPadding: titlePadding = 1, title = '', width = 50, }) {
7
7
  const titleString = title ? `${PAD.repeat(titlePadding) + title + PAD.repeat(titlePadding)}` : '';
8
8
  const titleWidth = titleString.length;
9
9
  const terminalWidth = process.stdout.columns ?? 80;
package/lib/design.d.ts CHANGED
@@ -43,7 +43,7 @@ export type Design = {
43
43
  */
44
44
  padding?: number;
45
45
  /**
46
- * Color of the title. Defaults to 'white'
46
+ * Color of the title
47
47
  */
48
48
  textColor?: string;
49
49
  /**
package/lib/design.js CHANGED
@@ -54,7 +54,7 @@ export function constructDesignParams(design) {
54
54
  dividerChar: '─',
55
55
  dividerColor: 'dim',
56
56
  padding: 1,
57
- textColor: 'white',
57
+ textColor: 'reset',
58
58
  textPadding: 1,
59
59
  width: 50,
60
60
  ...design?.title,
@@ -45,6 +45,10 @@ export type MultiStageOutputOptions<T extends Record<string, unknown>> = {
45
45
  * Design options to customize the output.
46
46
  */
47
47
  readonly design?: Design;
48
+ /**
49
+ * Set to true when --json flag is passed to the command. This will prevent any output to the console. Defaults to false
50
+ */
51
+ readonly jsonEnabled: boolean;
48
52
  };
49
53
  export declare class MultiStageOutput<T extends Record<string, unknown>> implements Disposable {
50
54
  private ciInstance;
@@ -61,7 +65,7 @@ export declare class MultiStageOutput<T extends Record<string, unknown>> impleme
61
65
  private stopped;
62
66
  private readonly timerUnit?;
63
67
  private readonly title?;
64
- constructor({ data, design, postStagesBlock, preStagesBlock, showElapsedTime, showStageTime, stageSpecificBlock, stages, timerUnit, title, }: MultiStageOutputOptions<T>);
68
+ constructor({ data, design, jsonEnabled, postStagesBlock, preStagesBlock, showElapsedTime, showStageTime, stageSpecificBlock, stages, timerUnit, title, }: MultiStageOutputOptions<T>);
65
69
  goto(stage: string, data?: Partial<T>): void;
66
70
  next(data?: Partial<T>): void;
67
71
  stop(error?: Error): void;
@@ -144,7 +144,7 @@ export class MultiStageOutput {
144
144
  stopped = false;
145
145
  timerUnit;
146
146
  title;
147
- constructor({ data, design, postStagesBlock, preStagesBlock, showElapsedTime, showStageTime, stageSpecificBlock, stages, timerUnit, title, }) {
147
+ constructor({ data, design, jsonEnabled = false, postStagesBlock, preStagesBlock, showElapsedTime, showStageTime, stageSpecificBlock, stages, timerUnit, title, }) {
148
148
  this.data = data;
149
149
  this.design = constructDesignParams(design);
150
150
  this.stages = stages;
@@ -156,10 +156,13 @@ export class MultiStageOutput {
156
156
  this.timerUnit = timerUnit ?? 'ms';
157
157
  this.stageTracker = new StageTracker(stages);
158
158
  this.stageSpecificBlock = stageSpecificBlock;
159
+ if (jsonEnabled)
160
+ return;
159
161
  if (isInCi) {
160
162
  this.ciInstance = new CIMultiStageOutput({
161
163
  data,
162
164
  design,
165
+ jsonEnabled,
163
166
  postStagesBlock,
164
167
  preStagesBlock,
165
168
  showElapsedTime,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/multi-stage-output",
3
3
  "description": "Terminal output for oclif commands with multiple stages",
4
- "version": "0.2.2",
4
+ "version": "0.3.1",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/multi-stage-output/issues",
7
7
  "dependencies": {
@@ -33,7 +33,7 @@
33
33
  "husky": "^9.1.3",
34
34
  "ink-testing-library": "^4.0.0",
35
35
  "lint-staged": "^15",
36
- "mocha": "^10.7.0",
36
+ "mocha": "^10.7.3",
37
37
  "prettier": "^3.3.3",
38
38
  "shx": "^0.3.4",
39
39
  "sinon": "^18",