Repository: Redocly/redocly-cli
Pull request #1425 (2024-02-01 16:06:43)

fix: update `push-status` messages
## What/Why/How?

Fix the wording and eliminate uppercase for messages in both the `push-status` and `push` commands.

## Reference

## Testing

## Screenshots (optional)

## Has code been changed?

- [ ] Tested with redoc/reference-docs/workflows (internal)
- [ ] All new/updated code is covered with tests

## Security

- [x] Security impact of change has been considered
- [x] Code follows company security practices and guidelines


changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: d8c22a9fc60966368ff7b000ae1406d703bc973a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/Redocly/redocly-cli/new/fix/push-messages?filename=.changeset/empty-cameras-clean.md&value=---%0A%22%40redocly%2Fcli%22%3A%20patch%0A---%0A%0Afix%3A%20update%20%60push-status%60%20messages%0A)


github-actions[bot]: | Command | Mean [s] | Min [s] | Max [s] | Relative |
|:---|---:|---:|---:|---:|
| `redocly lint packages/core/src/benchmark/benches/rebilly.yaml` | 1.060 ± 0.024 | 1.042 | 1.124 | 1.00 |
| `redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml` | 1.066 ± 0.020 | 1.030 | 1.097 | 1.00 ± 0.03 |

<!-- thollander/actions-comment-pull-request "hyperfine-comparison" -->
github-actions[bot]: <!-- jest coverage report action for options with hash 3339ae53a38c44382c0fb4491bdb282d -->

## Coverage report 

❌ An unexpected error occurred. For more details, [check console](https://github.com/Redocly/redocly-cli/actions/runs/7744150421) 
```
Error: The process '/opt/hostedtoolcache/node/18.19.0/x64/bin/npm' failed with exit code 1
```

| <div title="Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold">St.<sup>:grey_question:</sup></div> | Category   | Percentage | Covered / Total |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
|                                                                           🟡                                                                           | Statements | 76.1%      |    4306/5658    |
|                                                                           🟡                                                                           | Branches   | 65.79%     |    2240/3405    |
|                                                                           🟡                                                                           | Functions  | 68.74%     |     695/1011    |
|                                                                           🟡                                                                           | Lines      | 76.31%     |    4049/5306    |


## Test suite run failed

<details><summary>Failed tests: 4/701. Failed suites: 1/101.</summary>
<br/>

```
  ● handlePushStatus() › should return success push status for preview-build

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: "🚀 PREVIEW deployment succeeded.
    Preview URL: https://test-url
    "
    Received: "🚀 PREVIEW deploy success.
    Preview URL: https://test-url
    "

    Number of calls: 1

      90 |     );
      91 |     expect(process.stdout.write).toHaveBeenCalledTimes(1);
    > 92 |     expect(process.stdout.write).toHaveBeenCalledWith(
         |                                  ^
      93 |       '🚀 PREVIEW deployment succeeded.\nPreview URL: https://test-url\n'
      94 |     );
      95 |   });

      at packages/cli/src/cms/commands/__tests__/push-status.test.ts:92:34
      at fulfilled (packages/cli/src/cms/commands/__tests__/push-status.test.ts:5:58)

  ● handlePushStatus() › should return success push status for preview and production builds

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: "🚀 PREVIEW deployment succeeded.
    Preview URL: https://test-url
    "
    Received
           1: "🚀 PREVIEW deploy success.
    Preview URL: https://test-url
    "
           2: "🚀 PRODUCTION deploy success.
    Preview URL: https://test-url
    "

    Number of calls: 2

      110 |     );
      111 |     expect(process.stdout.write).toHaveBeenCalledTimes(2);
    > 112 |     expect(process.stdout.write).toHaveBeenCalledWith(
          |                                  ^
      113 |       '🚀 PREVIEW deployment succeeded.\nPreview URL: https://test-url\n'
      114 |     );
      115 |     expect(process.stdout.write).toHaveBeenCalledWith(

      at packages/cli/src/cms/commands/__tests__/push-status.test.ts:112:34
      at fulfilled (packages/cli/src/cms/commands/__tests__/push-status.test.ts:5:58)

  ● handlePushStatus() › should return failed push status for preview build

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: "❌ PREVIEW deployment failed.
    Preview URL: https://test-url"
    Received: "❌ PREVIEW deploy fail.
    Preview URL: https://test-url"

    Number of calls: 1

      139 |       mockConfig
      140 |     );
    > 141 |     expect(exitWithError).toHaveBeenCalledWith(
          |                           ^
      142 |       '❌ PREVIEW deployment failed.\nPreview URL: https://test-url'
      143 |     );
      144 |   });

      at packages/cli/src/cms/commands/__tests__/push-status.test.ts:141:27
      at fulfilled (packages/cli/src/cms/commands/__tests__/push-status.test.ts:5:58)

  ● handlePushStatus() › should return success push status for preview build and print scorecards

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: "🚀 PREVIEW deployment succeeded.
    Preview URL: https://test-url
    "
    Received
           1: "🚀 PREVIEW deploy success.
    Preview URL: https://test-url
    "
           2: "
    Scorecard:"
           3: "
        Name: test-name
        Status: success
        URL: test-url
        Description: test-description
    "

    Number of calls: 4

      176 |     );
      177 |     expect(process.stdout.write).toHaveBeenCalledTimes(4);
    > 178 |     expect(process.stdout.write).toHaveBeenCalledWith(
          |                                  ^
      179 |       '🚀 PREVIEW deployment succeeded.\nPreview URL: https://test-url\n'
      180 |     );
      181 |     expect(process.stdout.write).toHaveBeenCalledWith('\nScorecard:');

      at packages/cli/src/cms/commands/__tests__/push-status.test.ts:178:34
      at fulfilled (packages/cli/src/cms/commands/__tests__/push-status.test.ts:5:58)

```

</details>


<p align="right">Report generated by <a href="https://github.com/ArtiomTr/jest-coverage-report-action">🧪jest coverage report action</a> from d8c22a9fc60966368ff7b000ae1406d703bc973a</p>


Patch:
diff --git a/packages/cli/src/cms/commands/push-status.ts b/packages/cli/src/cms/commands/push-status.ts
index f072974e..60c41cf4 100644
--- a/packages/cli/src/cms/commands/push-status.ts
+++ b/packages/cli/src/cms/commands/push-status.ts
@@ -5,6 +5,7 @@ import { Spinner } from '../../utils/spinner';
 import { DeploymentError } from '../utils';
 import { yellow } from 'colorette';
 import { ReuniteApiClient, getApiKeys, getDomain } from '../api';
+import { capitalize } from '../../utils/js-utils';
 
 import type { DeploymentStatus, PushResponse, ScorecardItem } from '../api/types';
 
@@ -177,15 +178,15 @@ function displayDeploymentAndBuildStatus({
     case 'success':
       spinner.stop();
       return process.stdout.write(
-        `${colors.green(
-          `🚀 ${buildType.toLocaleUpperCase()} deployment succeeded.`
-        )}\n${colors.magenta('Preview URL')}: ${colors.cyan(previewUrl!)}\n`
+        `${colors.green(`🚀 ${capitalize(buildType)} deploy success.`)}\n${colors.magenta(
+          `${capitalize(buildType)} URL`
+        )}: ${colors.cyan(previewUrl!)}\n`
       );
     case 'failed':
       spinner.stop();
       throw new DeploymentError(
-        `${colors.red(`❌ ${buildType.toLocaleUpperCase()} deployment failed.`)}\n${colors.magenta(
-          'Preview URL'
+        `${colors.red(`❌ ${capitalize(buildType)} deploy fail.`)}\n${colors.magenta(
+          `${capitalize(buildType)} URL`
         )}: ${colors.cyan(previewUrl!)}`
       );
     case 'pending':
diff --git a/packages/cli/src/utils/js-utils.ts b/packages/cli/src/utils/js-utils.ts
index 1f4f42cb..41946c64 100644
--- a/packages/cli/src/utils/js-utils.ts
+++ b/packages/cli/src/utils/js-utils.ts
@@ -15,3 +15,10 @@ export function keysOf<T>(obj: T) {
   if (!obj) return [];
   return Object.keys(obj) as (keyof T)[];
 }
+
+export function capitalize(s: string) {
+  if (s?.length > 0) {
+    return s[0].toUpperCase() + s.slice(1);
+  }
+  return s;
+}


Test patch:
diff --git a/packages/cli/src/cms/commands/__tests__/push-status.test.ts b/packages/cli/src/cms/commands/__tests__/push-status.test.ts
index e2b8e350..c15a4558 100644
--- a/packages/cli/src/cms/commands/__tests__/push-status.test.ts
+++ b/packages/cli/src/cms/commands/__tests__/push-status.test.ts
@@ -90,7 +90,7 @@ describe('handlePushStatus()', () => {
     );
     expect(process.stdout.write).toHaveBeenCalledTimes(1);
     expect(process.stdout.write).toHaveBeenCalledWith(
-      '🚀 PREVIEW deployment succeeded.\nPreview URL: https://test-url\n'
+      '🚀 Preview deploy success.\nPreview URL: https://test-url\n'
     );
   });
 
@@ -110,10 +110,10 @@ describe('handlePushStatus()', () => {
     );
     expect(process.stdout.write).toHaveBeenCalledTimes(2);
     expect(process.stdout.write).toHaveBeenCalledWith(
-      '🚀 PREVIEW deployment succeeded.\nPreview URL: https://test-url\n'
+      '🚀 Preview deploy success.\nPreview URL: https://test-url\n'
     );
     expect(process.stdout.write).toHaveBeenCalledWith(
-      '🚀 PRODUCTION deployment succeeded.\nPreview URL: https://test-url\n'
+      '🚀 Production deploy success.\nProduction URL: https://test-url\n'
     );
   });
 
@@ -139,7 +139,7 @@ describe('handlePushStatus()', () => {
       mockConfig
     );
     expect(exitWithError).toHaveBeenCalledWith(
-      '❌ PREVIEW deployment failed.\nPreview URL: https://test-url'
+      '❌ Preview deploy fail.\nPreview URL: https://test-url'
     );
   });
 
@@ -176,7 +176,7 @@ describe('handlePushStatus()', () => {
     );
     expect(process.stdout.write).toHaveBeenCalledTimes(4);
     expect(process.stdout.write).toHaveBeenCalledWith(
-      '🚀 PREVIEW deployment succeeded.\nPreview URL: https://test-url\n'
+      '🚀 Preview deploy success.\nPreview URL: https://test-url\n'
     );
     expect(process.stdout.write).toHaveBeenCalledWith('\nScorecard:');
     expect(process.stdout.write).toHaveBeenCalledWith(