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

Allow emulators to work offline (MOTD fail) #4998

Merged
merged 6 commits into from Sep 30, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 22 additions & 5 deletions src/fetchMOTD.ts
Expand Up @@ -5,6 +5,7 @@ import { Client } from "./apiv2";
import { configstore } from "./configstore";
import { realtimeOrigin } from "./api";
import * as utils from "./utils";
import { FirebaseError } from "./error";

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

Expand Down Expand Up @@ -43,10 +44,26 @@ export function fetchMOTD(): void {
} else {
const origin = utils.addSubdomain(realtimeOrigin, "firebase-public");
const c = new Client({ urlPrefix: origin, auth: false });
c.get("/cli.json").then((res) => {
motd = Object.assign({}, res.body);
configstore.set("motd", motd);
configstore.set("motd.fetched", Date.now());
});
c.get("/cli.json")
.then((res) => {
motd = Object.assign({}, res.body);
configstore.set("motd", motd);
configstore.set("motd.fetched", Date.now());
})
.catch((err) => {
const args = process.argv.slice(2);

if (args.findIndex((arg) => arg.startsWith("emulators:")) === -1) {
throw new FirebaseError(
"Unable to fetch the CLI version check configuration. Make sure that you are online and try again.",
{ original: err }
);
}

utils.logLabeledWarning(
"emulators",
"Unable to fetch the CLI version check configuration, emulator functionality may be incorrect."
);
ericvera marked this conversation as resolved.
Show resolved Hide resolved
});
}
}