MCPcopy Create free account
hub / github.com/firebase/firebase-tools / fetchMOTD

Function fetchMOTD

src/fetchMOTD.ts:17–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15 * Fetches the message of the day.
16 */
17export function fetchMOTD(): void {
18 let motd = configstore.get("motd");
19 const motdFetched = configstore.get("motd.fetched") || 0;
20
21 if (motd && motdFetched > Date.now() - ONE_DAY_MS) {
22 if (motd.minVersion && semver.gt(motd.minVersion, pkg.version)) {
23 console.error(
24 clc.red("Error:"),
25 "CLI is out of date (on",
26 clc.bold(pkg.version),
27 ", need at least",
28 clc.bold(motd.minVersion) + ")\n\nRun",
29 clc.bold("npm install -g firebase-tools"),
30 "to upgrade.",
31 );
32 process.exit(1);
33 }
34
35 if (motd.message && process.stdout.isTTY) {
36 const lastMessage = configstore.get("motd.lastMessage");
37 if (lastMessage !== motd.message) {
38 console.log();
39 console.log(motd.message);
40 console.log();
41 configstore.set("motd.lastMessage", motd.message);
42 }
43 }
44 } else {
45 const origin = utils.addSubdomain(realtimeOrigin(), "firebase-public");
46 const c = new Client({ urlPrefix: origin, auth: false });
47 c.get("/cli.json")
48 .then((res) => {
49 motd = Object.assign({}, res.body);
50 configstore.set("motd", motd);
51 configstore.set("motd.fetched", Date.now());
52 })
53 .catch((err) => {
54 utils.logWarning(
55 "Unable to fetch the CLI MOTD and remote config. This is not a fatal error, but may indicate an issue with your network connection.",
56 );
57 logger.debug(`Failed to fetch MOTD ${err}`);
58 });
59 }
60}

Callers 1

cliFunction · 0.90

Calls 6

getMethod · 0.95
realtimeOriginFunction · 0.90
getMethod · 0.65
exitMethod · 0.45
logMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…