Skip to content

Commit

Permalink
feat: add notification about new version available (#2100)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVarchuk authored Aug 10, 2022
1 parent 250f6d1 commit d6ca8cc
Show file tree
Hide file tree
Showing 4 changed files with 1,503 additions and 33 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build-and-e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm run bundle
- run: npm run e2e
- uses: actions/checkout@v3
- run: npm ci && npm ci --prefix cli
- run: npm run bundle
- run: npm run e2e
16 changes: 16 additions & 0 deletions cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
/* tslint:disable:no-implicit-dependencies */
import * as React from 'react';
import * as updateNotifier from 'update-notifier';
import { renderToString } from 'react-dom/server';
import { ServerStyleSheet } from 'styled-components';

Expand Down Expand Up @@ -111,6 +112,7 @@ const handlerForBuildCommand = async (argv: any) => {
};

try {
notifyUpdateCliVersion();
await bundle(argv.spec, config);
} catch (e) {
handleError(e);
Expand Down Expand Up @@ -174,6 +176,7 @@ YargsParser.command(
};

try {
notifyUpdateCliVersion();
await serve(argv.host as string, argv.port as number, argv.spec as string, config);
} catch (e) {
handleError(e);
Expand Down Expand Up @@ -468,3 +471,16 @@ function getObjectOrJSON(options) {
return {};
}
}

function notifyUpdateCliVersion() {
const pkg = require('./package.json');
const notifier = updateNotifier({
pkg,
updateCheckInterval: 0,
shouldNotifyInNpmScript: true,
});
notifier.notify({
message:
'Run `{updateCommand}` to update.\nChangelog: https://github.com/Redocly/redoc/releases/tag/{latestVersion}',
});
}
Loading

0 comments on commit d6ca8cc

Please sign in to comment.