Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add notification about available new version #2100

Merged
merged 4 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
25 changes: 0 additions & 25 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,6 @@ jobs:
name: bundles
path: bundles
- run: npm run e2e
# disable this for now
# deploy-demo:
# needs: [bundle, unit-tests, e2e-tests]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1
# - name: Install dependencies
# run: npm ci
# - name: Download bundled artifacts
# uses: actions/download-artifact@v3
# with:
# name: bundles
# path: bundles
# - name: Build package
# run: npm run build:demo
# - name: Deploy to S3 bucket
# run: npm run deploy:demo
# - name: Invalidate
# run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DEMO_DISTRIBUTION_ID }} --paths "/*"
publish:
name: Publish to NPM
needs: [bundle, unit-tests, e2e-tests]
Expand Down
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