diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-07 16:12:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-07 16:12:25 +0800 |
commit | 799927b8b97429a29455713564fafcbf43f277c8 (patch) | |
tree | 8fcf6abf9d5da206a4b4a9880d32b428ff564cc2 | |
parent | bcaf47b66a81e56f85e8fa48021da10062899425 (diff) | |
download | lua-language-server-799927b8b97429a29455713564fafcbf43f277c8.zip |
telemetry version
-rw-r--r-- | script/service/telemetry.lua | 10 | ||||
-rw-r--r-- | script/version.lua | 30 |
2 files changed, 40 insertions, 0 deletions
diff --git a/script/service/telemetry.lua b/script/service/telemetry.lua index 419589e7..978adee4 100644 --- a/script/service/telemetry.lua +++ b/script/service/telemetry.lua @@ -9,6 +9,7 @@ local proto = require 'proto.proto' local lang = require 'language' local define = require 'proto.define' local await = require 'await' +local version = require 'version' local tokenPath = (ROOT / 'log' / 'token'):string() local token = util.loadFile(tokenPath) @@ -49,6 +50,14 @@ local function pushPlatformInfo(link) )) end +local function pushVersion(link) + send(link, string.pack('zzz' + , 'version' + , token + , version.getVersion() + )) +end + local function pushErrorLog(link) if not log.firstError then return @@ -78,6 +87,7 @@ timer.wait(5, function () function link:on_connect() pushClientInfo(link) pushPlatformInfo(link) + pushVersion(link) pushErrorLog(link) self:close() end diff --git a/script/version.lua b/script/version.lua new file mode 100644 index 00000000..fa178564 --- /dev/null +++ b/script/version.lua @@ -0,0 +1,30 @@ +local fsu = require 'fs-utility' + +local function loadVersion() + local changelog = fsu.loadFile(ROOT / 'changelog.md') + if not changelog then + return + end + + local version, pos = changelog:match '%#%# (%d+%.%d+%.%d+)()' + if not version then + return + end + + if not changelog:find('^[\r\n]+`', pos) then + version = version .. '-dev' + end + return version +end + +local m = {} + +function m.getVersion() + if not m.version then + m.version = loadVersion() or '<Unknown>' + end + + return m.version +end + +return m |