|
| 1 | +import { |
| 2 | + loadSupportedVersions, |
| 3 | + type SupportedVersions, |
| 4 | +} from "./supported_versions.ts"; |
| 5 | + |
| 6 | +async function main(): Promise<void> { |
| 7 | + const supportedVersions = await loadSupportedVersions("main"); |
| 8 | + await updateREADME(supportedVersions); |
| 9 | + await updateGithubWorkflowsTest(supportedVersions); |
| 10 | +} |
| 11 | + |
| 12 | +async function updateREADME( |
| 13 | + supportedVersions: SupportedVersions, |
| 14 | +): Promise<void> { |
| 15 | + const url = new URL(import.meta.resolve("../README.md")); |
| 16 | + let text = await Deno.readTextFile(url); |
| 17 | + // Deno |
| 18 | + text = text.replace( |
| 19 | + /Deno\s+\d+\.\d+\.\d+/, |
| 20 | + `Deno ${supportedVersions.deno}`, |
| 21 | + ); |
| 22 | + text = text.replace( |
| 23 | + /Deno-Support%20\d+\.\d+\.\d+/, |
| 24 | + `Deno-Support%20${supportedVersions.deno}`, |
| 25 | + ); |
| 26 | + text = text.replace( |
| 27 | + /https:\/\/github\.com\/denoland\/deno\/tree\/v\d+\.\d+\.\d+/, |
| 28 | + `https://github.com/denoland/deno/tree/v${supportedVersions.deno}`, |
| 29 | + ); |
| 30 | + // Vim |
| 31 | + text = text.replace( |
| 32 | + /Vim\s+\d+\.\d+\.\d+/, |
| 33 | + `Vim ${supportedVersions.vim}`, |
| 34 | + ); |
| 35 | + text = text.replace( |
| 36 | + /Vim-Support%20\d+\.\d+\.\d+/, |
| 37 | + `Vim-Support%20${supportedVersions.vim}`, |
| 38 | + ); |
| 39 | + text = text.replace( |
| 40 | + /https:\/\/github\.com\/vim\/vim\/tree\/v\d+\.\d+\.\d+/, |
| 41 | + `https://github.com/vim/vim/tree/v${supportedVersions.vim}`, |
| 42 | + ); |
| 43 | + // Neovim |
| 44 | + text = text.replace( |
| 45 | + /Neovim\s+\d+\.\d+\.\d+/, |
| 46 | + `Neovim ${supportedVersions.neovim}`, |
| 47 | + ); |
| 48 | + text = text.replace( |
| 49 | + /Neovim-Support%20\d+\.\d+\.\d+/, |
| 50 | + `Neovim-Support%20${supportedVersions.neovim}`, |
| 51 | + ); |
| 52 | + text = text.replace( |
| 53 | + /https:\/\/github\.com\/neovim\/neovim\/tree\/v\d+\.\d+\.\d+/, |
| 54 | + `https://github.com/neovim/neovim/tree/v${supportedVersions.neovim}`, |
| 55 | + ); |
| 56 | + await Deno.writeTextFile(url, text); |
| 57 | +} |
| 58 | + |
| 59 | +async function updateGithubWorkflowsTest( |
| 60 | + supportedVersions: SupportedVersions, |
| 61 | +): Promise<void> { |
| 62 | + const url = new URL(import.meta.resolve("../.github/workflows/test.yml")); |
| 63 | + let text = await Deno.readTextFile(url); |
| 64 | + // Deno |
| 65 | + text = text.replace( |
| 66 | + /deno_version:(.*?)"\d+\.\d+\.\d+"/s, |
| 67 | + `deno_version:$1"${supportedVersions.deno}"`, |
| 68 | + ); |
| 69 | + // Vim |
| 70 | + text = text.replace( |
| 71 | + /vim:(.*?)"v\d+\.\d+\.\d+"/s, |
| 72 | + `vim:$1"v${supportedVersions.vim}"`, |
| 73 | + ); |
| 74 | + // Neovim |
| 75 | + text = text.replace( |
| 76 | + /nvim:(.*?)"v\d+\.\d+\.\d+"/s, |
| 77 | + `nvim:$1"v${supportedVersions.neovim}"`, |
| 78 | + ); |
| 79 | + await Deno.writeTextFile(url, text); |
| 80 | +} |
| 81 | + |
| 82 | +if (import.meta.main) { |
| 83 | + try { |
| 84 | + await main(); |
| 85 | + } catch (error) { |
| 86 | + console.error(error); |
| 87 | + Deno.exit(1); |
| 88 | + } |
| 89 | +} |
0 commit comments