ci: remove update-lockfile shell script

This commit is contained in:
Christian Clason 2023-05-29 16:52:20 +02:00
parent 73ddd80069
commit 7681249bbd
4 changed files with 13 additions and 39 deletions

View file

@ -28,10 +28,7 @@ jobs:
SKIP_LOCKFILE_UPDATE_FOR_LANGS: ""
run: |
cp lockfile.json /tmp/old_lockfile.json
nvim -l scripts/write-lockfile.lua
# Pretty print
cp lockfile.json /tmp/lockfile.json
cat /tmp/lockfile.json | jq --sort-keys > lockfile.json
nvim -l ./scripts/update-lockfile.lua
- name: Commit changes
run: |

View file

@ -1,18 +1,18 @@
#!/usr/bin/env -S nvim -l
vim.opt.runtimepath:append('.')
local util = require('nvim-treesitter.util')
-- Load previous lockfile
local filename = require('nvim-treesitter.install').get_package_path('lockfile.json')
local lockfile = vim.json.decode(require('nvim-treesitter.util').read_file(filename))
local lockfile = vim.json.decode(util.read_file(filename))
---@type string?
local skip_lang_string = os.getenv('SKIP_LOCKFILE_UPDATE_FOR_LANGS')
local skip_lang_string = os.getenv('LOCKFILE_SKIP')
local skip_langs = skip_lang_string and vim.split(skip_lang_string, ',') or {}
vim.print('Skipping languages: ', skip_langs)
local sorted_parsers = {}
local configs = require('nvim-treesitter.parsers').configs
for k, v in pairs(configs) do
for k, v in pairs(require('nvim-treesitter.parsers').configs) do
table.insert(sorted_parsers, { name = k, parser = v })
end
table.sort(sorted_parsers, function(a, b)
@ -42,7 +42,6 @@ for _, v in ipairs(sorted_parsers) do
print('Skipping ' .. v.name)
end
end
vim.print(lockfile)
-- write new lockfile
require('nvim-treesitter.util').write_file(filename, vim.json.encode(lockfile))
lockfile = vim.fn.system('jq --sort-keys', vim.json.encode(lockfile))
util.write_file(filename, lockfile)

View file

@ -1,20 +0,0 @@
#!/usr/bin/env bash
make_ignored() {
if [ -n "$1" ]
then
while read -r lang; do
if [ "$lang" != "$1" ]
then
printf "%s," "$lang"
fi
done < <(jq 'keys|@sh' -c lockfile.json)
fi
}
TO_IGNORE=$(make_ignored $1)
SKIP_LOCKFILE_UPDATE_FOR_LANGS="$TO_IGNORE" nvim -l ./scripts/write-lockfile.lua
# Pretty print
cp lockfile.json /tmp/lockfile.json
cat /tmp/lockfile.json | jq --sort-keys > lockfile.json

View file

@ -1,21 +1,19 @@
#!/usr/bin/env -S nvim -l
vim.opt.runtimepath:append('.')
local util = require('nvim-treesitter.util')
local parsers = require('nvim-treesitter.parsers')
---@class Parser
---@field name string
---@field parser ParserInfo
local parsers = require('nvim-treesitter.parsers').configs
local sorted_parsers = {}
for k, v in pairs(parsers) do
for k, v in pairs(parsers.configs) do
table.insert(sorted_parsers, { name = k, parser = v })
end
table.sort(sorted_parsers, function(a, b)
return a.name < b.name
end)
local tiers = require('nvim-treesitter.parsers').tiers
local generated_text = [[
Language | Tier | Queries | CLI | NPM | Maintainer
-------- |:----:|:-------:|:---:|:---:| ----------
@ -38,7 +36,7 @@ for _, v in ipairs(sorted_parsers) do
end
-- tier
generated_text = generated_text .. (p.tier and tiers[p.tier] or '') .. ' | '
generated_text = generated_text .. (p.tier and parsers.tiers[p.tier] or '') .. ' | '
-- queries
generated_text = generated_text
@ -66,7 +64,7 @@ end
generated_text = generated_text .. footnotes
local readme = 'SUPPORTED_LANGUAGES.md'
local readme_text = require('nvim-treesitter.util').read_file(readme)
local readme_text = util.read_file(readme)
local new_readme_text = string.gsub(
readme_text,
@ -74,7 +72,7 @@ local new_readme_text = string.gsub(
'<!--parserinfo-->\n' .. generated_text .. '<!--parserinfo-->'
)
require('nvim-treesitter.util').write_file(readme, new_readme_text)
util.write_file(readme, new_readme_text)
if string.find(readme_text, generated_text, 1, true) then
print(readme .. ' is up-to-date\n')