feat: 增加独立构建工作区、服务端ADB与私有文件清单
支持Git提交导入及未提交源码叠加,APK原名下载和完成通知。新增服务端设备安装与按工程维护的私有文件清单,修复Wrapper预检查、布局及IDE读锁和保存状态问题。更新协议、测试和部署记录;服务端0.7.0,插件0.7.1。
This commit is contained in:
1 parent
87652364bc
commit
6f9cc7e7ea
44 files changed
+2742
-87
No files matched your search
+67
-5
@@ -45,6 +45,7 @@ type Artifact struct {
|
||||
Hash string `json:"hash"`
|
||||
Size int64 `json:"size"`
|
||||
SourcePath string `json:"sourcePath,omitempty"`
|
||||
FileName string `json:"fileName,omitempty"`
|
||||
}
|
||||
type Build struct {
|
||||
JavaHome string `json:"javaHome,omitempty"`
|
||||
@@ -64,6 +65,10 @@ type Build struct {
|
||||
cancelled bool
|
||||
}
|
||||
type Project struct {
|
||||
PrivateFiles map[string]File `json:"privateFiles,omitempty"`
|
||||
LegacyProject string `json:"legacyProject,omitempty"`
|
||||
Dedicated bool `json:"dedicated,omitempty"`
|
||||
Pending *PendingSync `json:"pending,omitempty"`
|
||||
WorkspacePath string `json:"workspacePath,omitempty"`
|
||||
Git *GitSnapshot `json:"git,omitempty"`
|
||||
Revision string `json:"revision"`
|
||||
@@ -139,7 +144,7 @@ func decode(w http.ResponseWriter, r *http.Request, v any) error {
|
||||
return d.Decode(v)
|
||||
}
|
||||
func (s *Server) work(p string) string {
|
||||
if pr := s.projects[p]; pr != nil && pr.WorkspacePath != "" {
|
||||
if pr := s.projects[p]; pr != nil && pr.WorkspacePath != "" && !pr.Dedicated {
|
||||
return pr.WorkspacePath
|
||||
}
|
||||
return filepath.Join(s.root, "projects", p, "work")
|
||||
@@ -164,6 +169,10 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
s.streamLogs(w, r)
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(r.URL.Path, "/api/v1/adb/") {
|
||||
s.serveADB(w, r)
|
||||
return
|
||||
}
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if e := s.reloadAccessPolicy(); e != nil {
|
||||
@@ -173,7 +182,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
parts := strings.Split(strings.Trim(r.URL.Path, "/"), "/")
|
||||
fail := func(e error) { http.Error(w, e.Error(), 400) }
|
||||
if r.URL.Path == "/api/v1/health" {
|
||||
jsonOut(w, map[string]any{"version": "0.4.9", "adminCLI": true, "preflight": true, "textComparison": true, "jdkSelection": true, "workspaceSelection": true, "os": runtime.GOOS, "sync": "http-manifest", "recovery": true})
|
||||
jsonOut(w, map[string]any{"version": "0.7.0", "privateFileList": true, "remoteADB": true, "syncPreflight": true, "dedicatedGit": true, "adminCLI": true, "preflight": true, "textComparison": true, "jdkSelection": true, "workspaceSelection": true, "os": runtime.GOOS, "sync": "http-manifest", "recovery": true})
|
||||
return
|
||||
}
|
||||
if r.URL.Path == "/api/v1/environment" && r.Method == "GET" {
|
||||
@@ -189,6 +198,10 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
s.jdks(w, r)
|
||||
return
|
||||
}
|
||||
if r.URL.Path == "/api/v1/private-files" {
|
||||
s.servePrivateFiles(w, r)
|
||||
return
|
||||
}
|
||||
if r.URL.Path == "/api/v1/directories" && r.Method == "GET" {
|
||||
s.browseDirectories(w, r)
|
||||
return
|
||||
@@ -223,6 +236,10 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if parts[4] == "git" && r.Method == "POST" {
|
||||
s.importBundle(w, r, p)
|
||||
return
|
||||
}
|
||||
if parts[4] == "manifest" && r.Method == "GET" {
|
||||
jsonOut(w, s.manifest(p))
|
||||
return
|
||||
@@ -230,7 +247,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if parts[4] == "builds" && r.Method == "GET" {
|
||||
items := []*Build{}
|
||||
for _, b := range s.builds {
|
||||
if b.Project == p && (r.URL.Query().Get("clientRequestId") == "" || b.RequestID == r.URL.Query().Get("clientRequestId")) {
|
||||
if (b.Project == p || pr.LegacyProject != "" && b.Project == pr.LegacyProject) && (r.URL.Query().Get("clientRequestId") == "" || b.RequestID == r.URL.Query().Get("clientRequestId")) {
|
||||
items = append(items, b)
|
||||
}
|
||||
}
|
||||
@@ -255,6 +272,25 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
fail(errors.New("revision and files required"))
|
||||
return
|
||||
}
|
||||
if pr.Dedicated {
|
||||
names, err := s.privateNames(p)
|
||||
if err != nil {
|
||||
fail(err)
|
||||
return
|
||||
}
|
||||
for _, name := range names {
|
||||
if privateConflict(req.Files, name) {
|
||||
fail(fmt.Errorf("私有文件与普通源码同步冲突:%s;请在本机忽略该文件", name))
|
||||
return
|
||||
}
|
||||
}
|
||||
for name := range pr.PrivateFiles {
|
||||
if privateConflict(req.Files, name) {
|
||||
fail(fmt.Errorf("私有文件仍在工作区:%s;请先完成清单移除后的构建清理", name))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if e := s.checkGit(p, req.Git); e != nil {
|
||||
http.Error(w, e.Error(), 409)
|
||||
return
|
||||
@@ -315,10 +351,23 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// Validate the entire request before touching the working tree. Invalidate first:
|
||||
// an interrupted commit must never permit building a mixed source revision.
|
||||
pr.Revision = ""
|
||||
if pr.Dedicated {
|
||||
journal := map[string]File{}
|
||||
for path, f := range req.Files {
|
||||
journal[path] = File{Hash: f.Hash}
|
||||
}
|
||||
pr.Pending = &PendingSync{Files: journal}
|
||||
}
|
||||
if e := s.save(p); e != nil {
|
||||
fail(e)
|
||||
return
|
||||
}
|
||||
if pr.Dedicated {
|
||||
if e := s.advanceDedicated(p, req.Git); e != nil {
|
||||
fail(e)
|
||||
return
|
||||
}
|
||||
}
|
||||
for path := range previousFiles {
|
||||
if _, ok := req.Files[path]; !ok && validPath(path) {
|
||||
if e := os.Remove(filepath.Join(s.work(p), filepath.FromSlash(path))); e != nil && !os.IsNotExist(e) {
|
||||
@@ -349,6 +398,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
pr.Revision = req.Revision
|
||||
pr.Git = req.Git
|
||||
pr.Pending = nil
|
||||
if e := s.save(p); e != nil {
|
||||
pr.Revision = ""
|
||||
fail(e)
|
||||
@@ -401,7 +451,13 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, e.Error(), 409)
|
||||
return
|
||||
}
|
||||
actual, e := sourceInventory(s.work(p))
|
||||
var actual map[string]File
|
||||
var e error
|
||||
if pr.Dedicated {
|
||||
actual, e = s.projectInventory(p)
|
||||
} else {
|
||||
actual, e = sourceInventory(s.work(p))
|
||||
}
|
||||
if e != nil {
|
||||
fail(e)
|
||||
return
|
||||
@@ -544,6 +600,7 @@ func (s *Server) run(b *Build) {
|
||||
return
|
||||
}
|
||||
b.Status = "running"
|
||||
source := s.projects[b.Project].WorkspacePath
|
||||
b.Progress = Progress{Phase: "preparing", Message: "正在检测工具版本、缓存及系统代理", Percent: -1}
|
||||
_ = s.persistBuild(b)
|
||||
s.mu.Unlock()
|
||||
@@ -556,7 +613,12 @@ func (s *Server) run(b *Build) {
|
||||
if b.JavaHome != "" {
|
||||
cfg.JavaHome = b.JavaHome
|
||||
}
|
||||
if e := s.prepareWorkspaceFiles(b.Project, cfg); e != nil {
|
||||
s.finishFailed(b, e)
|
||||
return
|
||||
}
|
||||
report := s.preflight(work, cfg)
|
||||
s.explainWrapper(&report, work, source, false)
|
||||
for _, item := range report.Items {
|
||||
buildWriter{s, b}.Write([]byte(fmt.Sprintf("环境检查 [%s] %s:%s [%s]\n", item.Status, item.Name, item.Message, item.Path)))
|
||||
}
|
||||
@@ -643,7 +705,7 @@ func (s *Server) run(b *Build) {
|
||||
if e = os.WriteFile(filepath.Join(dest, name), data, 0600); e != nil {
|
||||
return e
|
||||
}
|
||||
artifacts = append(artifacts, Artifact{Name: name, Hash: digest(data), Size: int64(len(data)), SourcePath: artifactSourcePath(work, p)})
|
||||
artifacts = append(artifacts, Artifact{Name: name, Hash: digest(data), Size: int64(len(data)), SourcePath: artifactSourcePath(work, p), FileName: filepath.Base(p)})
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user