feat: add notification about new version available (#2100)

This commit is contained in:
Alex Varchuk 2022-08-10 10:55:26 +03:00 committed by GitHub
parent 250f6d12b2
commit d6ca8cc53b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1478 additions and 8 deletions

View File

@ -6,7 +6,7 @@ jobs:
build-and-e2e: build-and-e2e:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: npm ci - run: npm ci && npm ci --prefix cli
- run: npm run bundle - run: npm run bundle
- run: npm run e2e - run: npm run e2e

View File

@ -1,6 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
/* tslint:disable:no-implicit-dependencies */ /* tslint:disable:no-implicit-dependencies */
import * as React from 'react'; import * as React from 'react';
import * as updateNotifier from 'update-notifier';
import { renderToString } from 'react-dom/server'; import { renderToString } from 'react-dom/server';
import { ServerStyleSheet } from 'styled-components'; import { ServerStyleSheet } from 'styled-components';
@ -111,6 +112,7 @@ const handlerForBuildCommand = async (argv: any) => {
}; };
try { try {
notifyUpdateCliVersion();
await bundle(argv.spec, config); await bundle(argv.spec, config);
} catch (e) { } catch (e) {
handleError(e); handleError(e);
@ -174,6 +176,7 @@ YargsParser.command(
}; };
try { try {
notifyUpdateCliVersion();
await serve(argv.host as string, argv.port as number, argv.spec as string, config); await serve(argv.host as string, argv.port as number, argv.spec as string, config);
} catch (e) { } catch (e) {
handleError(e); handleError(e);
@ -468,3 +471,16 @@ function getObjectOrJSON(options) {
return {}; 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}',
});
}

1461
cli/npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,7 @@
"react-dom": "^17.0.1", "react-dom": "^17.0.1",
"redoc": "2.0.0-rc.74", "redoc": "2.0.0-rc.74",
"styled-components": "^5.3.0", "styled-components": "^5.3.0",
"update-notifier": "^5.0.1",
"yargs": "^17.3.1" "yargs": "^17.3.1"
}, },
"publishConfig": { "publishConfig": {