summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-13 11:17:23 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-13 11:17:23 +0800
commit1a49fa6c05d4131bd697d9f273ee9c10358f5bf6 (patch)
tree1414904274fed2820fc14b57a9c72a8cd8744024
parent6ac49a2eed8563c26d46456ab97952afad809d1d (diff)
downloadlua-language-server-1a49fa6c05d4131bd697d9f273ee9c10358f5bf6.zip
发布脚本
-rw-r--r--.gitignore1
-rw-r--r--.vscode/launch.json18
-rw-r--r--package.json3
-rw-r--r--server/publish.lua141
4 files changed, 159 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index d38ba5dd..bb2757bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ node_modules
client/server
.vscode-test
/server/log
+/publish
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 9870ccda..4997324c 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -12,7 +12,6 @@
"env": {
"PATH": "${workspaceRoot}\\server\\bin\\"
},
- "luaRuntime": "5.4 32bit",
"luaexe": "${workspaceRoot}\\server\\bin\\lua.exe",
"luadll": "${workspaceRoot}\\server\\bin\\lua54.dll",
"path": "${workspaceRoot}/server/bin/?.lua",
@@ -39,7 +38,6 @@
"stopOnEntry": false,
"program": "${workspaceRoot}/server/compile.lua",
"cwd": "${workspaceRoot}/server",
- "luaRuntime": "5.4 32bit",
"luaexe": "${workspaceRoot}/server/bee.lua/make/luamake.exe",
"luadll": "${workspaceRoot}/server/bee.lua/make/lua54.dll",
"path": "${workspaceRoot}/server/bee.lua/make/?.lua",
@@ -50,6 +48,22 @@
"sourceCoding": "utf8"
},
{
+ "name": "发布",
+ "type": "lua",
+ "request": "launch",
+ "stopOnEntry": false,
+ "program": "${workspaceRoot}/server/publish.lua",
+ "cwd": "${workspaceRoot}/server",
+ "luaexe": "${workspaceRoot}\\server\\bin\\lua.exe",
+ "luadll": "${workspaceRoot}\\server\\bin\\lua54.dll",
+ "path": "${workspaceRoot}/server/bin/?.lua",
+ "cpath": "${workspaceRoot}/server/bin/?.dll;",
+ "arg": [
+ ],
+ "consoleCoding": "utf8",
+ "sourceCoding": "utf8"
+ },
+ {
"type": "extensionHost",
"request": "launch",
"name": "Launch Client",
diff --git a/package.json b/package.json
index 8de7a68c..12e2a860 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,6 @@
"vscode:prepublish": "cd client && npm run update-vscode && cd ..",
"compile": "tsc -b",
"watch": "tsc -b -w",
- "postinstall": "cd client && npm install && cd ..",
- "test": "sh ./scripts/e2e.sh"
+ "postinstall": "cd client && npm install && cd .."
}
}
diff --git a/server/publish.lua b/server/publish.lua
new file mode 100644
index 00000000..0ccc5e18
--- /dev/null
+++ b/server/publish.lua
@@ -0,0 +1,141 @@
+local fs = require 'bee.filesystem'
+local subprocess = require 'bee.subprocess'
+
+ROOT = fs.current_path()
+EXTENSION = ROOT:parent_path()
+package.path = (ROOT / 'src' / '?.lua'):string()
+ .. ';' .. (ROOT / 'src' / '?' / 'init.lua'):string()
+
+require 'utility'
+local json = require 'json'
+
+local function loadVersion()
+ local buf = io.load(EXTENSION / 'package.json')
+ local package = json.decode(buf)
+ return package.version
+end
+
+local function createDirectory(version)
+ local out = EXTENSION / 'publish' / version / 'lua-language-server'
+ fs.create_directories(out)
+ return out
+end
+
+local function copyFiles(out)
+ return function (dirs)
+ local function copy(relative, mode)
+ local source = EXTENSION / relative
+ local target = out / relative
+ assert(fs.exists(source))
+ if fs.is_directory(source) then
+ fs.create_directory(target)
+ if mode == true then
+ for path in source:list_directory() do
+ copy(relative / path:filename(), true)
+ end
+ else
+ for name, v in pairs(mode) do
+ copy(relative / name, v)
+ end
+ end
+ else
+ fs.copy_file(source, target)
+ end
+ end
+
+ copy(fs.path '', dirs)
+ end
+end
+
+local function runTest(root)
+ local exe = root / 'bin' / 'lua.exe'
+ local test = root / 'test' / 'main.lua'
+ local lua = subprocess.spawn {
+ exe,
+ test,
+ '-E',
+ stdout = true,
+ stderr = true,
+ }
+ while true do
+ print(lua.stdout:read 'l')
+ end
+ lua:wait()
+ local err = lua.stderr:read 'a'
+ if err ~= '' then
+ error(err)
+ end
+end
+
+local function removeFiles(out)
+ return function (dirs)
+ if not fs.exists(out) then
+ return
+ end
+
+ local function remove(relative, mode)
+ local target = out / relative
+ assert(fs.exists(target))
+ if fs.is_directory(target) then
+ if mode == true then
+ for path in target:list_directory() do
+ remove(relative / path:filename(), true)
+ end
+ else
+ for name, v in pairs(mode) do
+ remove(relative / name, v)
+ end
+ end
+ fs.remove(target)
+ else
+ fs.remove(target)
+ end
+ end
+
+ remove(fs.path '', dirs)
+ end
+end
+
+local version = loadVersion()
+print('版本号为:' .. version)
+
+local out = createDirectory(version)
+
+print('清理目录...')
+removeFiles(out)(true)
+
+print('开始复制文件...')
+copyFiles(out) {
+ ['client'] = {
+ ['node_modules'] = true,
+ ['out'] = true,
+ ['package-lock.json'] = true,
+ ['package.json'] = true,
+ ['tsconfig.json'] = true,
+ },
+ ['server'] = {
+ ['bin'] = true,
+ ['libs'] = true,
+ ['locale'] = true,
+ ['src'] = true,
+ ['test'] = true,
+ ['main.lua'] = true,
+ },
+ ['package-lock.json'] = true,
+ ['package.json'] = true,
+ ['README.md'] = true,
+ ['tsconfig.json'] = true,
+}
+
+print('开始测试...')
+runTest(out / 'server')
+
+print('删除测试文件...')
+removeFiles(out) {
+ ['server'] = {
+ ['log'] = true,
+ ['test'] = true,
+ },
+}
+
+print('完成')