| 43 | } |
| 44 | |
| 45 | function 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 | |
| 71 | export const getNpmVersion = () => |
| 72 | // `fetch` to the registry is faster than `npm view` so we try that first |