From 70f10b1d1588ece527b8450b194f01caf94138ed Mon Sep 17 00:00:00 2001
From: carsakiller <carsakiller@gmail.com>
Date: Fri, 27 Oct 2023 20:42:06 -0400
Subject: [PATCH] refactor: replace bee with LuaCATS submodule

---
 .gitmodules                             |   3 +
 meta/3rd/bee                            |   1 +
 meta/3rd/bee/config.json                |   4 -
 meta/3rd/bee/library/bee/filesystem.lua | 240 ------------------------
 meta/3rd/bee/library/bee/platform.lua   |  62 ------
 meta/3rd/bee/library/bee/subprocess.lua |  99 ----------
 meta/3rd/bee/library/bee/thread.lua     |  62 ------
 7 files changed, 4 insertions(+), 467 deletions(-)
 create mode 160000 meta/3rd/bee
 delete mode 100644 meta/3rd/bee/config.json
 delete mode 100644 meta/3rd/bee/library/bee/filesystem.lua
 delete mode 100644 meta/3rd/bee/library/bee/platform.lua
 delete mode 100644 meta/3rd/bee/library/bee/subprocess.lua
 delete mode 100644 meta/3rd/bee/library/bee/thread.lua

diff --git a/.gitmodules b/.gitmodules
index 074b2def6..60b6cdddd 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -22,3 +22,6 @@
 [submodule "meta/3rd/OpenResty"]
 	path = meta/3rd/OpenResty
 	url = https://github.com/LuaCATS/openresty.git
+[submodule "meta/3rd/bee"]
+	path = meta/3rd/bee
+	url = https://github.com/LuaCATS/bee.git
diff --git a/meta/3rd/bee b/meta/3rd/bee
new file mode 160000
index 000000000..c0bc5349e
--- /dev/null
+++ b/meta/3rd/bee
@@ -0,0 +1 @@
+Subproject commit c0bc5349e5fa741d7ad8d6d5c7624a54dcfd9ebe
diff --git a/meta/3rd/bee/config.json b/meta/3rd/bee/config.json
deleted file mode 100644
index 0dce58173..000000000
--- a/meta/3rd/bee/config.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
-    "name" : "bee",
-    "words" : [ "require[%s%(\"']+bee%.%w+[%)\"']" ]
-}
diff --git a/meta/3rd/bee/library/bee/filesystem.lua b/meta/3rd/bee/library/bee/filesystem.lua
deleted file mode 100644
index 7cd4dcbb9..000000000
--- a/meta/3rd/bee/library/bee/filesystem.lua
+++ /dev/null
@@ -1,240 +0,0 @@
----@meta
-
-local m = {}
-
----@enum bee.filesystem.copy_options
-local copy_options = {
-    none = 0,
-    skip_existing = 1,
-    overwrite_existing = 2,
-    update_existing = 4,
-    recursive = 8,
-    copy_symlinks = 16,
-    skip_symlinks = 32,
-    directories_only = 64,
-    create_symlinks = 128,
-    create_hard_links = 256,
-    __in_recursive_copy = 512,
-}
-
----@alias bee.filesystem.path_arg string|bee.filesystem.path
-
----@class bee.filesystem.path
----@operator div(any):bee.filesystem.path
----@operator concat(any):bee.filesystem.path
-local path = {}
-
----@return string
-function path:string()
-end
-
----@return bee.filesystem.path
-function path:filename()
-end
-
----@return bee.filesystem.path
-function path:parent_path()
-end
-
----@return bee.filesystem.path
-function path:stem()
-end
-
----@return bee.filesystem.path
-function path:extension()
-end
-
----@return boolean
-function path:is_absolute()
-end
-
----@return boolean
-function path:is_relative()
-end
-
----@return bee.filesystem.path
-function path:remove_filename()
-end
-
----@param filename bee.filesystem.path_arg
----@return bee.filesystem.path
-function path:replace_filename(filename)
-end
-
----@param extension bee.filesystem.path_arg
----@return bee.filesystem.path
-function path:replace_extension(extension)
-end
-
----@param path bee.filesystem.path_arg
----@return boolean
-function path:equal_extension(path)
-end
-
----@return bee.filesystem.path
-function path:lexically_normal()
-end
-
----@class bee.filesystem.file_status
-local file_status = {}
-
----@alias bee.filesystem.file_type
----| "'none'"
----| "'not_found'"
----| "'regular'"
----| "'directory'"
----| "'symlink'"
----| "'block'"
----| "'character'"
----| "'fifo'"
----| "'socket'"
----| "'junction'"
----| "'unknown'"
-
----@return bee.filesystem.file_type
-function file_status:type()
-end
-
----@return boolean
-function file_status:exists()
-end
-
----@return boolean
-function file_status:is_directory()
-end
-
----@return boolean
-function file_status:is_regular_file()
-end
-
----@class bee.filesystem.directory_entry
-local directory_entry = {}
-
----@return bee.filesystem.path
-function directory_entry:path()
-end
-
----@return bee.filesystem.file_status
-function directory_entry:status()
-end
-
----@return bee.filesystem.file_status
-function directory_entry:symlink_status()
-end
-
----@return bee.filesystem.file_type
-function directory_entry:type()
-end
-
----@return boolean
-function directory_entry:exists()
-end
-
----@return boolean
-function directory_entry:is_directory()
-end
-
----@return boolean
-function directory_entry:is_regular_file()
-end
-
----@return bee.filesystem.path
-function m.path(path)
-end
-
----@return bee.filesystem.file_status
-function m.status(path)
-end
-
----@return bee.filesystem.file_status
-function m.symlink_status(path)
-end
-
----@return boolean
-function m.exists(path)
-end
-
----@return boolean
-function m.is_directory(path)
-end
-
----@return boolean
-function m.is_regular_file(path)
-end
-
-function m.create_directory(path)
-end
-
-function m.create_directories(path)
-end
-
-function m.rename(from, to)
-end
-
-function m.remove(path)
-end
-
-function m.remove_all(path)
-end
-
----@return bee.filesystem.path
-function m.current_path()
-end
-
----@param options bee.filesystem.copy_options
-function m.copy(from, to, options)
-end
-
----@param options bee.filesystem.copy_options
-function m.copy_file(from, to, options)
-end
-
-function m.absolute(path)
-end
-
-function m.canonical(path)
-end
-
-function m.relative(path)
-end
-
-function m.last_write_time(path)
-end
-
-function m.permissions(path)
-end
-
-function m.create_symlink(target, link)
-end
-
-function m.create_directory_symlink(target, link)
-end
-
-function m.create_hard_link(target, link)
-end
-
----@return bee.filesystem.path
-function m.temp_directory_path()
-end
-
----@return fun(table: bee.filesystem.path[]): bee.filesystem.path
-function m.pairs(path)
-end
-
----@return bee.filesystem.path
-function m.exe_path()
-end
-
----@return bee.filesystem.path
-function m.dll_path()
-end
-
----@return bee.file
-function m.filelock(path)
-end
-
----@return bee.filesystem.path
-function m.fullpath(path)
-end
-
-return m
diff --git a/meta/3rd/bee/library/bee/platform.lua b/meta/3rd/bee/library/bee/platform.lua
deleted file mode 100644
index f380a9bf4..000000000
--- a/meta/3rd/bee/library/bee/platform.lua
+++ /dev/null
@@ -1,62 +0,0 @@
----@meta
-
----@alias bee.platform.os
----| '"windows"'
----| '"android"'
----| '"linux"'
----| '"netbsd"'
----| '"freebsd"'
----| '"openbsd"'
----| '"ios"'
----| '"macos"'
----| '"unknown"'
-
----@alias bee.platform.OS
----| '"Windows"'
----| '"Android"'
----| '"Linux"'
----| '"NetBSD"'
----| '"FreeBSD"'
----| '"OpenBSD"'
----| '"iOS"'
----| '"macOS"'
----| '"unknown"'
-
----@alias bee.platform.arch
----| '"x86"'
----| '"x86_64"'
----| '"arm"'
----| '"arm64"'
----| '"riscv"'
----| '"unknown"'
-
----@alias bee.platform.compiler
----| '"clang"'
----| '"gcc"'
----| '"msvc"'
----| '"unknown"'
-
----@alias bee.platform.crt
----| '"msvc"'
----| '"bionic"'
----| '"libstdc++"'
----| '"libc++"'
----| '"unknown"'
-
-local m = {
-    ---@type bee.platform.os
-    os = "unknown",
-    ---@type bee.platform.OS
-    OS = "unknown",
-    ---@type bee.platform.compiler
-    Compiler = "clang",
-    CompilerVersion = "",
-    CRTVersion = "",
-    ---@type bee.platform.crt
-    CRT = "msvc",
-    ---@type bee.platform.arch
-    Arch = "x86",
-    DEBUG = false,
-}
-
-return m
diff --git a/meta/3rd/bee/library/bee/subprocess.lua b/meta/3rd/bee/library/bee/subprocess.lua
deleted file mode 100644
index 0c979729e..000000000
--- a/meta/3rd/bee/library/bee/subprocess.lua
+++ /dev/null
@@ -1,99 +0,0 @@
----@meta
-
----@class bee.file:lightuserdata
-local file = {}
-
----@alias bee.file.readmode integer|"'a'"
-
----@param mode bee.file.readmode
----@return string
-function file:read(mode)
-end
-
----@param buf number|integer|string
-function file:write(buf)
-end
-
----@return fun():string
-function file:lines()
-end
-
-function file:flush()
-end
-
-function file:close()
-end
-
----@param mode "'no'"|"'full'"|"'line'"
-function file:setvbuf(mode)
-end
-
----@class bee.process
----@field stderr bee.file?
----@field stdout bee.file?
----@field stdin bee.file?
-local process = {}
-
----@return integer exit_code
-function process:wait()
-end
-
----@return boolean success
-function process:kill()
-end
-
----@return integer process_id
-function process:get_id()
-end
-
----@return boolean is_running
-function process:is_running()
-end
-
----@return boolean success
-function process:resume()
-end
-
----@return any native_handle
-function process:native_handle()
-end
-
----@class bee.subprocess
-local m = {}
-
----@alias bee.bee.subprocess.spawn_io_arg boolean|file*|bee.file|"'stderr'"|"'stdout'"
-
----@class bee.subprocess.spawn.options : string[]
----@field stdin bee.bee.subprocess.spawn_io_arg?
----@field stdout bee.bee.subprocess.spawn_io_arg?
----@field stderr bee.bee.subprocess.spawn_io_arg?
----@field env table<string,string>?
----@field suspended boolean?
----@field detached boolean?
-
----@param options bee.subprocess.spawn.options
----@return bee.process process
-function m.spawn(options)
-end
-
----@param file file*|bee.file
----@return integer offset
----@return string? error_message
-function m.peek(file)
-end
-
-function m.filemode()
-end
-
----@param name string
----@param value string
----@return boolean success
----@return string? error_message
-function m.setenv(name, value)
-end
-
----@return integer current_process_id
-function m.get_id()
-end
-
-return m
diff --git a/meta/3rd/bee/library/bee/thread.lua b/meta/3rd/bee/library/bee/thread.lua
deleted file mode 100644
index 9e005ea45..000000000
--- a/meta/3rd/bee/library/bee/thread.lua
+++ /dev/null
@@ -1,62 +0,0 @@
----@meta
-
----@class bee.rpc:lightuserdata
-
----@class bee.thread_obj:lightuserdata
-
----@class bee.channel
-local channel = {}
-
-function channel:push(...)
-end
-
----@return boolean ok
----@return ...
-function channel:pop()
-end
-
----@return ...
-function channel:bpop()
-end
-
----@class bee.thread
-local m = {}
-
-function m.sleep(sec)
-end
-
----@return bee.thread_obj
-function m.thread(source, params)
-end
-
-function m.newchannel(name)
-end
-
----@return bee.channel
-function m.channel(name)
-end
-
-function m.reset()
-end
-
----@param th bee.thread_obj
-function m.wait(th)
-end
-
-function m.setname(name)
-end
-
----@return bee.rpc
-function m.rpc_create()
-end
-
-function m.rpc_wait(rpc)
-end
-
-function m.rpc_return(rpc)
-end
-
-function m.preload_module()
-end
-
-return m
-- 
GitLab