| 56 | export const tempDirName = "next-forge-update"; |
| 57 | |
| 58 | export const getAvailableVersions = async (): Promise<string[]> => { |
| 59 | const changelog = await readFile("CHANGELOG.md", "utf-8"); |
| 60 | const versionRegex = /# v(\d+\.\d+\.\d+)/g; |
| 61 | const matches = [...changelog.matchAll(versionRegex)]; |
| 62 | |
| 63 | return matches |
| 64 | .map((match) => match[1]) |
| 65 | .sort((a, b) => { |
| 66 | const [aMajor, aMinor, aPatch] = a.split(".").map(Number); |
| 67 | const [bMajor, bMinor, bPatch] = b.split(".").map(Number); |
| 68 | if (aMajor !== bMajor) { |
| 69 | return bMajor - aMajor; |
| 70 | } |
| 71 | if (aMinor !== bMinor) { |
| 72 | return bMinor - aMinor; |
| 73 | } |
| 74 | return bPatch - aPatch; |
| 75 | }); |
| 76 | }; |