Skip to content

Commit 06f471f

Browse files
authored
Merge pull request #396 from vim-denops/check-support-version
☕ Add `denops/supported-versions.json` and check if all information is updated
2 parents 0608102 + de48a62 commit 06f471f

File tree

5 files changed

+154
-35
lines changed

5 files changed

+154
-35
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
run: deno fmt --check
4040
- name: Type check
4141
run: deno task check
42+
- name: Supported version inconsistency check
43+
run: |
44+
deno task apply:supported-versions
45+
git diff --exit-code
4246
4347
test:
4448
needs: check
@@ -50,8 +54,8 @@ jobs:
5054
- windows-latest
5155
- macos-latest
5256
- ubuntu-latest
53-
version:
54-
- "1.45.x"
57+
deno_version:
58+
- "1.45.0"
5559
- "1.x"
5660
host_version:
5761
- vim: "v9.1.0448"
@@ -67,7 +71,7 @@ jobs:
6771

6872
- uses: denoland/setup-deno@v1.1.4
6973
with:
70-
deno-version: "${{ matrix.version }}"
74+
deno-version: "${{ matrix.deno_version }}"
7175

7276
- uses: rhysd/action-setup-vim@v1
7377
id: vim

.scripts/apply_supported_versions.ts

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

autoload/health/denops.vim

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
const s:DENO_VERSION = '1.45.0'
2-
const s:VIM_VERSION = '9.1.0448'
3-
const s:NEOVIM_VERSION = '0.10.0'
1+
const s:root = resolve(expand('<sfile>:p:h:h:h'))
42

53
function! s:compare_version(v1, v2) abort
6-
let l:v1 = map(split(a:v1, '\.'), { _, v -> v + 0 })
7-
let l:v2 = map(split(a:v2, '\.'), { _, v -> v + 0 })
4+
const l:v1 = map(split(a:v1, '\.'), { _, v -> v + 0 })
5+
const l:v2 = map(split(a:v2, '\.'), { _, v -> v + 0 })
86
for l:i in range(max([len(l:v1), len(l:v2)]))
97
let l:t1 = get(l:v1, l:i, 0)
108
let l:t2 = get(l:v2, l:i, 0)
@@ -15,8 +13,16 @@ function! s:compare_version(v1, v2) abort
1513
return 0
1614
endfunction
1715

16+
function! s:load_supported_versions() abort
17+
const l:jsonfile = denops#_internal#path#join([s:root, 'denops', 'supported_versions.json'])
18+
if !filereadable(l:jsonfile)
19+
throw 'Failed to read <runtimepath>/denops/supported_versions.json'
20+
endif
21+
return json_decode(join(readfile(l:jsonfile), "\n"))
22+
endfunction
23+
1824
function! s:get_deno_version(deno) abort
19-
let l:output = system(printf('%s --version', a:deno))
25+
const l:output = system(printf('%s --version', a:deno))
2026
return matchstr(l:output, 'deno \zs[0-9.]\+')
2127
endfunction
2228

@@ -42,61 +48,49 @@ function! s:check_deno_executable() abort
4248
call s:report_ok('Deno executable check: passed')
4349
endfunction
4450

45-
function! s:check_deno_version() abort
46-
let l:deno_version = s:get_deno_version(g:denops#deno)
47-
call s:report_info(printf(
48-
\ 'Supported Deno version: `%s`',
49-
\ s:DENO_VERSION,
50-
\))
51+
function! s:check_deno_version(supported_version) abort
52+
const l:deno_version = s:get_deno_version(g:denops#deno)
5153
call s:report_info(printf(
5254
\ 'Detected Deno version: `%s`',
5355
\ l:deno_version,
5456
\))
5557
if empty(l:deno_version)
5658
call s:report_error('Unable to detect version of deno, make sure your deno runtime is correct.')
5759
return
58-
elseif s:compare_version(l:deno_version, s:DENO_VERSION) < 0
60+
elseif s:compare_version(l:deno_version, a:supported_version) < 0
5961
call s:report_error(printf(
6062
\ 'Unsupported Deno version is detected. You need to upgrade it to `%s` or later.',
61-
\ s:DENO_VERSION,
63+
\ a:supported_version,
6264
\))
6365
return
6466
endif
6567
call s:report_ok('Deno version check: passed')
6668
endfunction
6769

68-
function! s:check_vim_version() abort
69-
call s:report_info(printf(
70-
\ 'Supported Vim version: `%s`',
71-
\ s:VIM_VERSION,
72-
\))
70+
function! s:check_vim_version(supported_version) abort
7371
call s:report_info(printf(
7472
\ 'Detected Vim version: `%s`',
7573
\ denops#_internal#meta#get().version,
7674
\))
77-
if !has(printf('patch-%s', s:VIM_VERSION))
75+
if !has(printf('patch-%s', a:supported_version))
7876
call s:report_error(printf(
7977
\ 'Unsupported Vim version is detected. You need to upgrade it to `%s` or later.',
80-
\ s:VIM_VERSION,
78+
\ a:supported_version,
8179
\))
8280
return
8381
endif
8482
call s:report_ok('Vim version check: passed')
8583
endfunction
8684

87-
function! s:check_neovim_version() abort
88-
call s:report_info(printf(
89-
\ 'Supported Neovim version: `%s`',
90-
\ s:NEOVIM_VERSION,
91-
\))
85+
function! s:check_neovim_version(supported_version) abort
9286
call s:report_info(printf(
9387
\ 'Detected Neovim version: `%s`',
9488
\ denops#_internal#meta#get().version,
9589
\))
96-
if !has(printf('nvim-%s', s:NEOVIM_VERSION))
90+
if !has(printf('nvim-%s', a:supported_version))
9791
call s:report_error(printf(
9892
\ 'Unsupported Neovim version is detected. You need to upgrade it to `%s` or later.',
99-
\ s:NEOVIM_VERSION,
93+
\ a:supported_version,
10094
\))
10195
return
10296
endif
@@ -157,11 +151,24 @@ else
157151
endif
158152

159153
function! health#denops#check() abort
160-
call s:check_deno_version()
154+
const l:supported_versions = s:load_supported_versions()
155+
call s:report_info(printf(
156+
\ 'Supported Deno version: `%s`',
157+
\ l:supported_versions.deno,
158+
\))
159+
call s:report_info(printf(
160+
\ 'Supported Vim version: `%s`',
161+
\ l:supported_versions.vim,
162+
\))
163+
call s:report_info(printf(
164+
\ 'Supported Neovim version: `%s`',
165+
\ l:supported_versions.neovim,
166+
\))
167+
call s:check_deno_version(l:supported_versions.deno)
161168
if !has('nvim')
162-
call s:check_vim_version()
169+
call s:check_vim_version(l:supported_versions.vim)
163170
else
164-
call s:check_neovim_version()
171+
call s:check_neovim_version(l:supported_versions.neovim)
165172
endif
166173
call s:check_denops()
167174
call s:check_denops_status()

deno.jsonc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"coverage": "deno coverage --exclude=\"test[.]ts(#.*)?$\" .coverage",
77
"update": "deno run --allow-env --allow-read --allow-write --allow-run=git,deno --allow-net=jsr.io,registry.npmjs.org jsr:@molt/cli **/*.ts",
88
"update:write": "deno task -q update --write",
9-
"update:commit": "deno task -q update --commit --prefix :package: --pre-commit=fmt,lint"
9+
"update:commit": "deno task -q update --commit --prefix :package: --pre-commit=fmt,lint",
10+
"apply:supported-versions": "deno run --allow-read --allow-write .scripts/apply_supported_versions.ts"
1011
},
1112
"exclude": [
1213
".coverage/"

denops/supported_versions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"deno": "1.45.0",
3+
"vim": "9.1.0448",
4+
"neovim": "0.10.0"
5+
}

0 commit comments

Comments
 (0)