MCPcopy
hub / github.com/t3-oss/create-t3-app / checkForLatestVersion

Function checkForLatestVersion

cli/src/utils/renderVersionWarning.ts:45–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43}
44
45function checkForLatestVersion(): Promise<string> {
46 return new Promise((resolve, reject) => {
47 https
48 .get(
49 "https://registry.npmjs.org/-/package/create-t3-app/dist-tags",
50 (res) => {
51 if (res.statusCode === 200) {
52 let body = "";
53 res.on("data", (data) => (body += data));
54 res.on("end", () => {
55 resolve((JSON.parse(body) as DistTagsBody).latest);
56 });
57 } else {
58 // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
59 reject();
60 }
61 }
62 )
63 .on("error", () => {
64 // logger.error("Unable to check for latest version.");
65 // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
66 reject();
67 });
68 });
69}
70
71export const getNpmVersion = () =>
72 // `fetch` to the registry is faster than `npm view` so we try that first

Callers 1

getNpmVersionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected