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

Better error message when failing to fetch MOTD #6556

Merged
merged 4 commits into from
Nov 29, 2023
Merged
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
4 changes: 3 additions & 1 deletion src/fetchMOTD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { realtimeOrigin } from "./api";
import * as utils from "./utils";

const pkg = require("../package.json"); // eslint-disable-line @typescript-eslint/no-var-requires

Check warning on line 10 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe assignment of an `any` value

const ONE_DAY_MS = 1000 * 60 * 60 * 24;

Expand All @@ -15,15 +15,15 @@
* Fetches the message of the day.
*/
export function fetchMOTD(): void {
let motd = configstore.get("motd");

Check warning on line 18 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe assignment of an `any` value
const motdFetched = configstore.get("motd.fetched") || 0;

Check warning on line 19 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe assignment of an `any` value

if (motd && motdFetched > Date.now() - ONE_DAY_MS) {
if (motd.minVersion && semver.gt(motd.minVersion, pkg.version)) {

Check warning on line 22 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe member access .minVersion on an `any` value

Check warning on line 22 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe argument of type `any` assigned to a parameter of type `string | SemVer`

Check warning on line 22 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe member access .minVersion on an `any` value

Check warning on line 22 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe argument of type `any` assigned to a parameter of type `string | SemVer`

Check warning on line 22 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe member access .version on an `any` value
console.error(
clc.red("Error:"),
"CLI is out of date (on",
clc.bold(pkg.version),

Check warning on line 26 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe argument of type `any` assigned to a parameter of type `string | number`

Check warning on line 26 in src/fetchMOTD.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe member access .version on an `any` value
", need at least",
clc.bold(motd.minVersion) + ")\n\nRun",
clc.bold("npm install -g firebase-tools"),
Expand Down Expand Up @@ -51,7 +51,9 @@
configstore.set("motd.fetched", Date.now());
})
.catch((err) => {
utils.logWarning("Unable to fetch the CLI MOTD and remote config.");
utils.logWarning(
"Unable to fetch the CLI MOTD and remote config. This is not a fatal error, but may indicate an issue with your network connection."
);
logger.debug(`Failed to fetch MOTD ${err}`);
});
}
Expand Down
Loading