Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
JavaReleaseMenu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
朱鹏程
JavaReleaseMenu
Commits
c86ed293
Commit
c86ed293
authored
Nov 18, 2026
by
zpc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish release interface and expose locked batch progress and outcomes
parent
cd3a975e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
586 additions
and
139 deletions
+586
-139
Info.plist
Info.plist
+2
-2
ProjectSettings.swift
Sources/JavaReleaseMenu/ProjectSettings.swift
+6
-1
ReleaseStyle.swift
Sources/JavaReleaseMenu/ReleaseStyle.swift
+40
-1
SplitReleaseModel.swift
Sources/JavaReleaseMenu/SplitReleaseModel.swift
+73
-2
SplitReleasePanel.swift
Sources/JavaReleaseMenu/SplitReleasePanel.swift
+358
-133
ReleaseRunnerTests.swift
Tests/ReleaseCoreTests/ReleaseRunnerTests.swift
+107
-0
No files found.
Info.plist
View file @
c86ed293
...
...
@@ -19,9 +19,9 @@
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
APPL
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
1.4.
1
<
/string
>
<
string
>
1.4.
2
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
<
string
>
1
1
<
/string
>
<
string
>
1
2
<
/string
>
<
k
e
y
>
LSMinimumSystemVersion
<
/k
e
y
>
<
string
>
14.0
<
/string
>
<
k
e
y
>
LSUIElement
<
/k
e
y
>
...
...
Sources/JavaReleaseMenu/ProjectSettings.swift
View file @
c86ed293
...
...
@@ -21,6 +21,7 @@ struct ProjectSettings: View {
Label
(
"新建项目"
,
systemImage
:
"plus"
)
}
.
buttonStyle
(
SettingsButtonStyle
())
.
help
(
"创建新的本地项目配置"
)
}
.
padding
(
.
horizontal
,
22
)
.
padding
(
.
vertical
,
17
)
...
...
@@ -38,6 +39,7 @@ struct ProjectSettings: View {
.
menuStyle
(
.
borderlessButton
)
.
menuIndicator
(
.
hidden
)
.
accessibilityLabel
(
"已保存的项目"
)
.
help
(
"选择一个项目来查看和编辑设置"
)
}
section
(
"项目"
,
icon
:
"folder"
)
{
...
...
@@ -96,6 +98,7 @@ struct ProjectSettings: View {
}
}
.
labelsHidden
()
.
help
(
"默认优先 mvnd,未安装时使用 mvn;也可明确选择 mvn"
)
}
mavenField
(
"mvn"
,
path
:
$
draft
.
mavenPath
)
mavenField
(
"mvnd"
,
path
:
$
draft
.
mvndPath
)
...
...
@@ -128,6 +131,7 @@ struct ProjectSettings: View {
Button
(
"保存"
,
action
:
save
)
.
buttonStyle
(
SettingsButtonStyle
(
prominent
:
true
))
.
keyboardShortcut
(
.
defaultAction
)
.
help
(
"检查并保存当前项目设置"
)
}
}
.
padding
(
.
horizontal
,
22
)
...
...
@@ -285,6 +289,7 @@ struct ProjectSettings: View {
private
struct
SettingsButtonStyle
:
ButtonStyle
{
var
prominent
=
false
@Environment(\.isEnabled)
private
var
enabled
func
makeBody
(
configuration
:
Configuration
)
->
some
View
{
configuration
.
label
...
...
@@ -295,7 +300,7 @@ private struct SettingsButtonStyle: ButtonStyle {
.
modifier
(
ReleaseHover
(
base
:
prominent
?
ReleaseColors
.
action
:
ReleaseColors
.
surface
,
highlight
:
prominent
?
ReleaseColors
.
actionHover
:
ReleaseColors
.
hover
,
radius
:
6
))
.
overlay
{
RoundedRectangle
(
cornerRadius
:
6
)
.
strokeBorder
(
ReleaseColors
.
border
)
.
allowsHitTesting
(
false
)
}
.
opacity
(
configuration
.
isPressed
?
0.72
:
1
)
.
opacity
(
!
enabled
?
0.4
:
configuration
.
isPressed
?
0.72
:
1
)
.
contentShape
(
Rectangle
())
}
}
Sources/JavaReleaseMenu/ReleaseStyle.swift
View file @
c86ed293
...
...
@@ -8,6 +8,9 @@ enum ReleaseColors {
static
let
muted
=
Color
(
red
:
0.62
,
green
:
0.66
,
blue
:
0.73
)
static
let
blue
=
Color
(
red
:
0.31
,
green
:
0.62
,
blue
:
1
)
static
let
action
=
Color
(
red
:
0.13
,
green
:
0.35
,
blue
:
0.86
)
static
let
success
=
Color
(
red
:
0.32
,
green
:
0.80
,
blue
:
0.54
)
static
let
warning
=
Color
(
red
:
0.98
,
green
:
0.68
,
blue
:
0.31
)
static
let
danger
=
Color
(
red
:
1
,
green
:
0.40
,
blue
:
0.42
)
static
let
hover
=
Color
(
red
:
0.17
,
green
:
0.22
,
blue
:
0.29
)
static
let
actionHover
=
Color
(
red
:
0.20
,
green
:
0.46
,
blue
:
0.98
)
}
...
...
@@ -41,6 +44,8 @@ struct ReleaseButtonStyle: ButtonStyle {
var
base
:
Color
=
.
clear
var
prominent
=
false
var
radius
:
CGFloat
=
7
var
disabledOpacity
:
Double
=
0.40
@Environment(\.isEnabled)
private
var
enabled
func
makeBody
(
configuration
:
Configuration
)
->
some
View
{
configuration
.
label
...
...
@@ -50,6 +55,40 @@ struct ReleaseButtonStyle: ButtonStyle {
highlight
:
prominent
?
ReleaseColors
.
actionHover
:
ReleaseColors
.
hover
,
radius
:
radius
)
)
.
opacity
(
configuration
.
isPressed
?
0.82
:
1
)
.
opacity
(
!
enabled
?
disabledOpacity
:
configuration
.
isPressed
?
0.82
:
1
)
}
}
struct
ReleaseIconButton
:
View
{
let
symbol
:
String
let
title
:
String
var
tint
:
Color
=
ReleaseColors
.
muted
let
action
:
()
->
Void
var
body
:
some
View
{
Button
(
action
:
action
)
{
Image
(
systemName
:
symbol
)
.
font
(
.
system
(
size
:
12
,
weight
:
.
medium
))
.
foregroundStyle
(
tint
)
.
frame
(
width
:
28
,
height
:
28
)
.
contentShape
(
RoundedRectangle
(
cornerRadius
:
6
))
}
.
buttonStyle
(
ReleaseButtonStyle
(
radius
:
6
))
.
help
(
title
)
.
accessibilityLabel
(
title
)
}
}
struct
ReleaseStatusBadge
:
View
{
let
title
:
String
let
symbol
:
String
let
color
:
Color
var
body
:
some
View
{
Label
(
title
,
systemImage
:
symbol
)
.
font
(
.
system
(
size
:
10
,
weight
:
.
medium
))
.
foregroundStyle
(
color
)
.
padding
(
.
horizontal
,
7
)
.
padding
(
.
vertical
,
4
)
.
background
(
color
.
opacity
(
0.10
),
in
:
Capsule
())
}
}
Sources/JavaReleaseMenu/SplitReleaseModel.swift
View file @
c86ed293
...
...
@@ -2,6 +2,19 @@ import Foundation
import
Observation
import
ReleaseCore
struct
ReleaseRunSummary
{
let
total
:
Int
let
completed
:
Int
let
running
:
Int
let
queued
:
Int
let
succeeded
:
Int
let
failed
:
Int
let
skipped
:
Int
let
isBatch
:
Bool
let
isPaused
:
Bool
let
estimatedPercentage
:
Int
}
private
struct
SavedPane
:
Codable
{
var
id
:
UUID
var
projectID
:
UUID
...
...
@@ -33,6 +46,8 @@ final class ReleasePaneState: Identifiable {
var
search
=
""
var
availableModules
:
[
String
]
=
[]
var
servers
:
[
InventoryTarget
]
=
[]
var
loadingServers
=
false
var
inventoryError
:
String
?
var
state
:
State
=
.
idle
var
phase
:
ReleasePhase
?
var
result
:
ReleaseResult
?
...
...
@@ -96,10 +111,13 @@ final class ReleasePaneState: Identifiable {
func
refreshServers
(
for
project
:
ReleaseProject
)
{
inventoryTask
?
.
cancel
()
servers
=
[]
inventoryError
=
nil
loadingServers
=
project
.
type
==
.
cityKeeper
guard
project
.
type
==
.
cityKeeper
else
{
return
}
inventoryTask
=
Task
{
let
targets
=
await
Task
.
detached
{
Result
{
try
project
.
inventoryTargets
()
}
}
.
value
guard
!
Task
.
isCancelled
else
{
return
}
loadingServers
=
false
switch
targets
{
case
let
.
success
(
found
):
servers
=
found
...
...
@@ -107,7 +125,7 @@ final class ReleasePaneState: Identifiable {
self
.
server
=
nil
}
case
let
.
failure
(
error
):
self
.
e
rror
=
error
.
localizedDescription
inventoryE
rror
=
error
.
localizedDescription
}
}
}
...
...
@@ -140,6 +158,7 @@ final class SplitReleaseModel {
private
var
unread
=
false
private
var
runIDs
=
Set
<
UUID
>
()
private
var
runResults
:
[
UUID
:
ReleaseResult
]
=
[:]
private
var
skippedIDs
=
Set
<
UUID
>
()
private
var
batchStarted
:
Date
?
private
var
completionTask
:
Task
<
Void
,
Never
>
?
private(set)
var
completionDuration
:
Int
?
...
...
@@ -186,12 +205,62 @@ final class SplitReleaseModel {
var
progressPercentage
:
Int
?
{
let
active
=
panes
.
filter
{
runIDs
.
contains
(
$0
.
id
)
}
guard
isRunning
,
!
runIDs
.
isEmpty
else
{
return
nil
}
let
completed
=
runResults
.
count
let
completed
=
runResults
.
count
+
skippedIDs
.
count
let
partial
=
active
.
filter
{
$0
.
state
==
.
running
}
.
reduce
(
0
)
{
$0
+
(
$1
.
phase
?
.
estimatedPercentage
??
0
)
}
return
min
(
99
,
(
completed
*
100
+
partial
)
/
runIDs
.
count
)
}
var
runSummary
:
ReleaseRunSummary
?
{
guard
!
runIDs
.
isEmpty
else
{
return
nil
}
let
active
=
panes
.
filter
{
runIDs
.
contains
(
$0
.
id
)
&&
$0
.
state
==
.
running
}
return
ReleaseRunSummary
(
total
:
runIDs
.
count
,
completed
:
runResults
.
count
,
running
:
active
.
count
,
queued
:
queued
.
count
,
succeeded
:
runResults
.
values
.
filter
{
$0
.
status
==
.
succeeded
}
.
count
,
failed
:
runResults
.
values
.
filter
{
$0
.
status
!=
.
succeeded
}
.
count
,
skipped
:
skippedIDs
.
count
,
isBatch
:
batch
,
isPaused
:
!
active
.
isEmpty
&&
active
.
allSatisfy
(\
.
paused
),
estimatedPercentage
:
progressPercentage
??
100
)
}
func
readinessMessage
(
for
pane
:
ReleasePaneState
)
->
String
?
{
guard
let
project
=
project
(
for
:
pane
)
else
{
return
"请先选择项目"
}
if
pane
.
modules
.
isEmpty
{
return
"请选择至少一个模块"
}
if
project
.
type
==
.
cityKeeper
{
if
pane
.
profileID
==
nil
||
!
project
.
profiles
.
contains
(
where
:
{
$0
.
id
==
pane
.
profileID
})
{
return
"请选择发布配置"
}
if
pane
.
loadingServers
{
return
"正在读取服务器清单…"
}
if
pane
.
inventoryError
!=
nil
{
return
"服务器清单读取失败,请检查 hosts 配置"
}
if
!
ReleaseProject
.
containsInventoryTarget
(
pane
.
server
??
""
,
in
:
pane
.
servers
)
{
return
"请选择发布服务器"
}
}
return
nil
}
func
canPublish
(
_
pane
:
ReleasePaneState
)
->
Bool
{
!
isRunning
&&
readinessMessage
(
for
:
pane
)
==
nil
}
var
canPublishAll
:
Bool
{
panes
.
count
>
1
&&
!
isRunning
&&
panes
.
allSatisfy
{
readinessMessage
(
for
:
$0
)
==
nil
}
}
var
publishAllHelp
:
String
{
if
isRunning
{
return
"发布正在执行,完成后可再次发布;进度为按阶段估算"
}
if
panes
.
count
<
2
{
return
"增加一个不同项目的窗口后可一起发布"
}
if
let
pane
=
panes
.
first
(
where
:
{
readinessMessage
(
for
:
$0
)
!=
nil
}),
let
message
=
readinessMessage
(
for
:
pane
)
{
return
"
\(
project
(
for
:
pane
)?
.
name
??
"项目"
)
:
\(
message
)
"
}
return
"发布所有窗口中的项目;存在构建或服务器冲突时会自动排队"
}
var
indicator
:
ReleaseStatus
?
{
if
isRunning
{
return
nil
}
if
completionTask
!=
nil
{
return
.
succeeded
}
...
...
@@ -325,6 +394,7 @@ final class SplitReleaseModel {
batchStarted
=
Date
()
runIDs
=
Set
(
prepared
.
map
{
$0
.
pane
.
id
})
runResults
.
removeAll
()
skippedIDs
.
removeAll
()
if
together
,
prepared
.
count
>
1
{
let
cityJobs
=
prepared
.
filter
{
$0
.
project
.
type
==
.
cityKeeper
&&
$0
.
action
==
.
standard
...
...
@@ -423,6 +493,7 @@ final class SplitReleaseModel {
jobs
.
removeValue
(
forKey
:
pane
.
id
)
if
result
.
status
!=
.
succeeded
&&
batch
{
for
id
in
queued
{
skippedIDs
.
insert
(
id
)
jobs
[
id
]?
.
pane
.
state
=
.
skipped
jobs
[
id
]?
.
pane
.
error
=
"前序项目失败,未执行"
jobs
.
removeValue
(
forKey
:
id
)
...
...
Sources/JavaReleaseMenu/SplitReleasePanel.swift
View file @
c86ed293
...
...
@@ -27,10 +27,15 @@ struct SplitReleasePanel: View {
}
private
var
columnHeight
:
CGFloat
{
let
base
:
CGFloat
=
model
.
panes
.
count
==
1
?
460
:
500
let
desired
=
model
.
panes
.
map
{
pane
->
CGFloat
in
if
pane
.
showsConsole
{
return
pane
.
expandedConsole
?
650
:
base
}
if
pane
.
showsConsole
{
return
pane
.
expandedConsole
?
650
:
(
model
.
panes
.
count
==
1
?
420
:
460
)
}
let
cityKeeper
=
model
.
project
(
for
:
pane
)?
.
type
==
.
cityKeeper
let
base
:
CGFloat
=
cityKeeper
?
(
model
.
panes
.
count
==
1
?
450
:
490
)
:
(
model
.
panes
.
count
==
1
?
280
:
330
)
guard
let
field
=
pane
.
expandedField
else
{
return
base
}
let
extra
:
CGFloat
switch
field
{
...
...
@@ -48,61 +53,61 @@ struct SplitReleasePanel: View {
extra
=
max
(
44
,
min
(
220
,
CGFloat
(
pane
.
availableModules
.
count
)
*
31
+
8
))
+
44
}
return
min
(
650
,
base
+
extra
)
}
.
max
()
??
base
return
min
(
desired
,
max
(
380
,
(
NSScreen
.
main
?
.
visibleFrame
.
height
??
900
)
-
160
))
}
.
max
()
??
280
let
reserved
:
CGFloat
=
64
+
(
model
.
panes
.
count
>
1
?
88
:
0
)
+
(
model
.
error
==
nil
?
0
:
40
)
+
24
return
min
(
desired
,
max
(
300
,
(
NSScreen
.
main
?
.
visibleFrame
.
height
??
900
)
-
reserved
))
}
var
body
:
some
View
{
VStack
(
spacing
:
0
)
{
HStack
(
spacing
:
12
)
{
if
model
.
isRunning
{
ZStack
{
Circle
()
.
stroke
(
ReleaseColors
.
blue
.
opacity
(
0.25
),
lineWidth
:
3
)
Circle
()
.
trim
(
from
:
0
,
to
:
0.76
)
.
stroke
(
ReleaseColors
.
blue
,
style
:
StrokeStyle
(
lineWidth
:
3
,
lineCap
:
.
round
)
)
.
rotationEffect
(
.
degrees
(
-
90
))
}
.
frame
(
width
:
32
,
height
:
32
)
}
else
{
HStack
(
spacing
:
10
)
{
ZStack
{
RoundedRectangle
(
cornerRadius
:
9
)
.
fill
(
ReleaseColors
.
blue
.
opacity
(
0.12
))
Image
(
systemName
:
"shippingbox"
)
.
font
(
.
system
(
size
:
26
))
.
foregroundStyle
(
.
white
.
opacity
(
0.9
))
.
frame
(
width
:
32
,
height
:
32
)
.
font
(
.
system
(
size
:
19
,
weight
:
.
medium
))
.
foregroundStyle
(
ReleaseColors
.
blue
)
}
.
frame
(
width
:
34
,
height
:
34
)
VStack
(
alignment
:
.
leading
,
spacing
:
2
)
{
Text
(
"Java 发布"
)
.
font
(
.
system
(
size
:
18
,
weight
:
.
semibold
))
Text
(
model
.
isRunning
?
"发布任务进行中"
:
"本地项目 · 编译与部署"
)
.
font
(
.
system
(
size
:
10
))
.
foregroundStyle
(
ReleaseColors
.
muted
)
}
Text
(
"Java 发布"
)
.
font
(
.
system
(
size
:
23
,
weight
:
.
semibold
))
Spacer
()
Spacer
(
minLength
:
8
)
Button
(
action
:
model
.
add
)
{
Label
(
"增加窗口"
,
systemImage
:
"plus"
)
.
font
(
ReleaseTypography
.
action
)
.
padding
(
.
horizontal
,
10
)
.
frame
(
height
:
35
)
.
font
(
ReleaseTypography
.
detail
)
.
padding
(
.
horizontal
,
10
)
.
frame
(
height
:
30
)
}
.
disabled
(
model
.
isRunning
||
model
.
panes
.
count
>=
4
||
model
.
panes
.
count
>=
model
.
settings
.
projects
.
count
)
.
buttonStyle
(
ReleaseButtonStyle
())
.
overlay
{
RoundedRectangle
(
cornerRadius
:
7
)
.
strokeBorder
(
ReleaseColors
.
border
)
}
.
buttonStyle
(
ReleaseButtonStyle
(
base
:
ReleaseColors
.
surface
))
.
help
(
model
.
isRunning
?
"发布期间不能增加项目窗口"
:
model
.
panes
.
count
>=
4
?
"最多支持四个窗口"
:
model
.
panes
.
count
>=
model
.
settings
.
projects
.
count
?
"没有其他项目,请先在项目设置中添加"
:
"增加一个不同项目的发布窗口"
)
ReleaseIconButton
(
symbol
:
"gearshape"
,
title
:
model
.
isRunning
?
"发布期间不能修改项目设置"
:
"项目设置"
,
action
:
settings
)
.
disabled
(
model
.
isRunning
)
Menu
{
Button
(
"项目设置…"
,
action
:
settings
)
Text
(
"Java 发布 1.4.2"
)
Divider
()
Button
(
"退出 Java 发布"
,
action
:
quit
)
}
label
:
{
Label
(
"项目设置"
,
systemImage
:
"gearshape"
)
.
font
(
.
system
(
size
:
13
))
.
padding
(
.
horizontal
,
5
)
.
frame
(
height
:
29
)
Image
(
systemName
:
"ellipsis"
)
.
font
(
.
system
(
size
:
15
))
.
foregroundStyle
(
ReleaseColors
.
muted
)
.
frame
(
width
:
24
,
height
:
28
)
}
.
menuStyle
(
.
borderlessButton
)
.
menuIndicator
(
.
hidden
)
.
fixedSize
()
.
disabled
(
model
.
isRunning
)
.
accessibilityLabel
(
"项目设置"
)
.
menuStyle
(
.
borderlessButton
)
.
menuIndicator
(
.
hidden
)
.
fixedSize
()
.
help
(
"更多选项"
)
.
accessibilityLabel
(
"更多选项"
)
}
.
padding
(
.
horizontal
,
18
)
.
frame
(
height
:
70
)
.
padding
(
.
horizontal
,
18
)
.
frame
(
height
:
64
)
Rectangle
()
.
fill
(
ReleaseColors
.
border
)
.
frame
(
height
:
1
)
...
...
@@ -129,30 +134,8 @@ struct SplitReleasePanel: View {
.
scrollIndicators
(
.
hidden
)
Rectangle
()
.
fill
(
ReleaseColors
.
border
)
.
frame
(
height
:
1
)
if
model
.
panes
.
count
>
1
{
HStack
{
if
model
.
isRunning
{
Text
(
"运行
\(
model
.
panes
.
filter
{
$0
.
state
==
.
running
}
.
count
)
/
\(
model
.
panes
.
count
)
· 排队
\(
model
.
panes
.
filter
{
$0
.
state
==
.
queued
}
.
count
)
"
)
}
else
{
Text
(
"
\(
model
.
panes
.
count
)
/ 4 个窗口"
)
}
Spacer
()
Button
(
action
:
model
.
publishAll
)
{
Text
(
"一起发布
\(
model
.
panes
.
count
)
个项目"
)
.
font
(
.
system
(
size
:
18
,
weight
:
.
semibold
))
.
foregroundStyle
(
.
white
)
.
padding
(
.
horizontal
,
36
)
.
frame
(
height
:
46
)
}
.
disabled
(
model
.
isRunning
||
model
.
panes
.
count
<
2
)
.
buttonStyle
(
ReleaseButtonStyle
(
base
:
ReleaseColors
.
action
,
prominent
:
true
))
}
.
font
(
.
system
(
size
:
16
))
.
foregroundStyle
(
.
white
.
opacity
(
0.9
))
.
padding
(
.
horizontal
,
18
)
.
frame
(
height
:
78
)
ReleaseBatchFooter
(
model
:
model
)
}
}
if
let
error
=
model
.
error
{
...
...
@@ -164,12 +147,12 @@ struct SplitReleasePanel: View {
.
background
{
LinearGradient
(
colors
:
[
Color
(
red
:
0.15
,
green
:
0.16
,
blue
:
0.18
)
,
Color
(
red
:
0.
105
,
green
:
0.115
,
blue
:
0.135
),
ReleaseColors
.
panel
,
Color
(
red
:
0.
09
,
green
:
0.105
,
blue
:
0.13
),
],
startPoint
:
.
topLeading
,
endPoint
:
.
bottomTrailing
)
}
.
overlay
{
RoundedRectangle
(
cornerRadius
:
14
)
.
strokeBorder
(
Color
.
white
.
opacity
(
0.18
)
)
RoundedRectangle
(
cornerRadius
:
14
)
.
strokeBorder
(
ReleaseColors
.
border
)
.
allowsHitTesting
(
false
)
}
.
environment
(\
.
colorScheme
,
.
dark
)
...
...
@@ -177,6 +160,95 @@ struct SplitReleasePanel: View {
}
}
private
struct
ReleaseBatchFooter
:
View
{
let
model
:
SplitReleaseModel
private
var
summary
:
ReleaseRunSummary
?
{
model
.
runSummary
}
private
var
percentage
:
Int
{
summary
?
.
estimatedPercentage
??
0
}
private
var
paused
:
Bool
{
summary
?
.
isPaused
==
true
}
var
body
:
some
View
{
HStack
(
spacing
:
24
)
{
VStack
(
alignment
:
.
leading
,
spacing
:
7
)
{
if
model
.
isRunning
{
HStack
(
spacing
:
6
)
{
Image
(
systemName
:
paused
?
"pause.circle.fill"
:
"arrow.triangle.2.circlepath"
)
.
foregroundStyle
(
paused
?
ReleaseColors
.
warning
:
ReleaseColors
.
blue
)
Text
(
paused
?
"发布已暂停"
:
"正在发布"
)
Text
(
"· 已完成
\(
summary
?
.
completed
??
0
)
/
\(
summary
?
.
total
??
model
.
panes
.
count
)
"
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
Spacer
(
minLength
:
0
)
}
.
font
(
.
system
(
size
:
12
,
weight
:
.
medium
))
ProgressView
(
value
:
Double
(
percentage
),
total
:
100
)
.
tint
(
paused
?
ReleaseColors
.
warning
:
ReleaseColors
.
blue
)
.
frame
(
maxWidth
:
340
)
Text
(
"运行
\(
summary
?
.
running
??
0
)
· 排队
\(
summary
?
.
queued
??
0
)
· 预计
\(
percentage
)
%"
)
.
font
(
.
system
(
size
:
10
))
.
monospacedDigit
()
.
foregroundStyle
(
ReleaseColors
.
muted
)
}
else
if
let
summary
,
summary
.
isBatch
{
Label
(
summary
.
failed
==
0
&&
summary
.
skipped
==
0
?
"发布完成"
:
"发布已结束"
,
systemImage
:
summary
.
failed
==
0
&&
summary
.
skipped
==
0
?
"checkmark.circle.fill"
:
"exclamationmark.circle.fill"
)
.
font
(
.
system
(
size
:
12
,
weight
:
.
medium
))
.
foregroundStyle
(
summary
.
failed
==
0
&&
summary
.
skipped
==
0
?
ReleaseColors
.
success
:
summary
.
failed
>
0
?
ReleaseColors
.
danger
:
ReleaseColors
.
warning
)
Text
(
"成功
\(
summary
.
succeeded
)
· 异常
\(
summary
.
failed
)
· 未执行
\(
summary
.
skipped
)
"
)
.
font
(
.
system
(
size
:
10
))
.
foregroundStyle
(
ReleaseColors
.
muted
)
}
else
{
Label
(
"
\(
model
.
panes
.
count
)
/ 4 个窗口"
,
systemImage
:
"rectangle.split.2x1"
)
.
font
(
.
system
(
size
:
12
,
weight
:
.
medium
))
Text
(
"各项目独立输出 · 冲突任务自动排队"
)
.
font
(
.
system
(
size
:
10
))
.
foregroundStyle
(
ReleaseColors
.
muted
)
}
}
.
frame
(
maxWidth
:
.
infinity
,
alignment
:
.
leading
)
Button
(
action
:
model
.
publishAll
)
{
HStack
(
spacing
:
9
)
{
Image
(
systemName
:
model
.
isRunning
?
"lock.fill"
:
"arrow.up.right"
)
.
font
(
.
system
(
size
:
13
,
weight
:
.
medium
))
VStack
(
alignment
:
.
leading
,
spacing
:
3
)
{
Text
(
model
.
isRunning
?
(
paused
?
"已暂停"
:
"发布中"
)
:
"一起发布
\(
model
.
panes
.
count
)
个项目"
)
.
font
(
.
system
(
size
:
14
,
weight
:
.
semibold
))
if
model
.
isRunning
{
Text
(
"已完成
\(
summary
?
.
completed
??
0
)
/
\(
summary
?
.
total
??
model
.
panes
.
count
)
· 预计
\(
percentage
)
%"
)
.
font
(
.
system
(
size
:
10
))
.
foregroundStyle
(
ReleaseColors
.
muted
)
.
monospacedDigit
()
}
}
}
.
foregroundStyle
(
model
.
isRunning
?
ReleaseColors
.
muted
:
.
white
)
.
padding
(
.
horizontal
,
18
)
.
frame
(
minWidth
:
185
,
minHeight
:
46
)
}
.
buttonStyle
(
ReleaseButtonStyle
(
base
:
model
.
isRunning
?
ReleaseColors
.
surface
:
ReleaseColors
.
action
,
prominent
:
!
model
.
isRunning
,
disabledOpacity
:
model
.
isRunning
?
1
:
0.4
)
)
.
disabled
(
!
model
.
canPublishAll
)
.
help
(
model
.
publishAllHelp
)
.
accessibilityLabel
(
model
.
isRunning
?
"发布中,已锁定"
:
"一起发布"
)
.
accessibilityValue
(
model
.
isRunning
?
"预计进度
\(
percentage
)
%"
:
model
.
publishAllHelp
)
}
.
padding
(
.
horizontal
,
18
)
.
frame
(
height
:
88
)
}
}
private
struct
ProjectReleaseColumn
:
View
{
let
model
:
SplitReleaseModel
@Bindable
var
pane
:
ReleasePaneState
...
...
@@ -199,19 +271,21 @@ private struct ProjectReleaseColumn: View {
var
body
:
some
View
{
VStack
(
alignment
:
.
leading
,
spacing
:
16
)
{
if
model
.
panes
.
count
>
1
{
HStack
{
Text
(
project
?
.
name
??
"选择项目"
)
.
font
(
.
system
(
size
:
1
8
,
weight
:
.
semibold
))
.
lineLimit
(
1
)
HStack
(
spacing
:
6
)
{
Text
(
project
?
.
name
??
"选择项目"
)
.
font
(
.
system
(
size
:
1
5
,
weight
:
.
semibold
))
.
lineLimit
(
1
)
.
help
(
project
?
.
name
??
"选择项目"
)
Spacer
(
minLength
:
4
)
Button
{
paneBadge
ReleaseIconButton
(
symbol
:
"xmark"
,
title
:
pane
.
state
==
.
running
||
pane
.
state
==
.
queued
?
"运行中或排队中的窗口暂不能关闭"
:
"关闭此项目窗口"
)
{
model
.
remove
(
pane
)
}
label
:
{
Label
(
"减少窗口"
,
systemImage
:
"xmark"
)
.
font
(
.
system
(
size
:
11
))
.
padding
(
6
)
}
.
buttonStyle
(
ReleaseButtonStyle
())
.
disabled
(
pane
.
state
==
.
running
||
pane
.
state
==
.
queued
)
}
}
if
pane
.
showsConsole
{
console
...
...
@@ -256,6 +330,7 @@ private struct ProjectReleaseColumn: View {
Text
(
"mvn"
)
.
tag
(
MavenCommand
.
mvn
)
}
.
labelsHidden
()
.
pickerStyle
(
.
segmented
)
.
help
(
"默认使用 mvnd;未安装 mvnd 时自动使用 mvn。选择 mvn 后直接使用 Maven。"
)
.
onChange
(
of
:
pane
.
mavenCommand
)
{
model
.
save
()
}
}
.
padding
(
.
horizontal
,
14
)
.
frame
(
height
:
48
)
}
...
...
@@ -272,6 +347,7 @@ private struct ProjectReleaseColumn: View {
Toggle
(
"使用 VPC 镜像地址"
,
isOn
:
$
pane
.
useVPC
)
.
toggleStyle
(
.
checkbox
)
.
disabled
(
!
editable
)
.
onChange
(
of
:
pane
.
useVPC
)
{
model
.
save
()
}
.
help
(
"使用发布脚本提供的 VPC 镜像地址"
)
}
if
let
project
,
project
.
supportsVerifiedRelease
(
profile
)
{
HStack
{
...
...
@@ -280,12 +356,13 @@ private struct ProjectReleaseColumn: View {
Spacer
()
Button
(
"预检"
)
{
model
.
publish
(
pane
,
action
:
.
preflight
)
}
.
buttonStyle
(
ReleaseButtonStyle
())
.
disabled
(
pane
.
modules
.
isEmpty
)
.
disabled
(
!
model
.
canPublish
(
pane
))
.
help
(
"检查发布配置、镜像和服务器,不执行正式发布"
)
}
.
disabled
(
!
editable
)
}
publishButton
(
title
:
"发布
\(
pane
.
selectedCount
)
个模块"
)
if
let
message
=
pane
.
error
{
Text
(
message
)
.
font
(
.
caption
)
.
foregroundStyle
(
.
red
)
.
lineLimit
(
3
)
if
let
message
=
pane
.
error
??
pane
.
inventoryError
{
Text
(
message
)
.
font
(
.
caption
)
.
foregroundStyle
(
ReleaseColors
.
danger
)
.
lineLimit
(
3
)
}
if
pane
.
state
==
.
skipped
{
Text
(
"前序项目失败,本项目未执行"
)
.
foregroundStyle
(
.
orange
)
...
...
@@ -296,18 +373,33 @@ private struct ProjectReleaseColumn: View {
systemName
:
result
.
status
==
.
succeeded
?
"checkmark.circle.fill"
:
"exclamationmark.circle.fill"
)
.
foregroundStyle
(
result
.
status
==
.
succeeded
?
.
green
:
.
red
)
.
foregroundStyle
(
result
.
status
==
.
succeeded
?
ReleaseColors
.
success
:
ReleaseColors
.
danger
)
VStack
(
alignment
:
.
leading
,
spacing
:
4
)
{
Text
(
"
\(
result
.
headline
)
· 耗时
\(
result
.
duration
)
秒"
)
.
lineLimit
(
1
)
.
help
(
"
\(
result
.
headline
)
· 耗时
\(
result
.
duration
)
秒"
)
Text
(
result
.
module
)
.
font
(
.
caption
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
.
lineLimit
(
1
)
.
lineLimit
(
1
)
.
help
(
result
.
module
)
}
Spacer
(
minLength
:
0
)
Button
(
"查看日志"
)
{
pane
.
showLog
()
}
.
buttonStyle
(
ReleaseButtonStyle
())
Button
{
pane
.
showLog
()
}
label
:
{
Label
(
"日志"
,
systemImage
:
"doc.text.magnifyingglass"
)
.
font
(
.
system
(
size
:
11
))
.
foregroundStyle
(
ReleaseColors
.
blue
)
.
padding
(
.
horizontal
,
7
)
.
frame
(
height
:
28
)
}
.
buttonStyle
(
ReleaseButtonStyle
())
.
fixedSize
()
.
help
(
"查看上次发布日志"
)
}
.
font
(
ReleaseTypography
.
detail
)
}
else
{
Text
(
"选择模块后即可发布"
)
.
font
(
ReleaseTypography
.
detail
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
Label
(
model
.
isRunning
?
"其他项目正在发布"
:
model
.
readinessMessage
(
for
:
pane
)
??
"配置已就绪"
,
systemImage
:
model
.
canPublish
(
pane
)
?
"checkmark.circle"
:
"info.circle"
)
.
font
(
ReleaseTypography
.
detail
)
.
foregroundStyle
(
model
.
canPublish
(
pane
)
?
ReleaseColors
.
success
:
ReleaseColors
.
muted
)
}
}
.
padding
(
.
bottom
,
4
)
}
...
...
@@ -331,7 +423,10 @@ private struct ProjectReleaseColumn: View {
pane
.
expandedField
=
pane
.
expandedField
==
field
?
nil
:
field
}
label
:
{
HStack
(
spacing
:
12
)
{
Image
(
systemName
:
symbol
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
.
frame
(
width
:
20
)
Image
(
systemName
:
symbol
)
.
font
(
.
system
(
size
:
15
,
weight
:
.
regular
))
.
foregroundStyle
(
pane
.
expandedField
==
field
?
ReleaseColors
.
blue
:
ReleaseColors
.
muted
)
.
frame
(
width
:
20
)
Text
(
label
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
.
frame
(
width
:
66
,
alignment
:
.
leading
)
Text
(
value
)
.
foregroundStyle
(
.
white
.
opacity
(
0.9
))
.
lineLimit
(
1
)
.
truncationMode
(
.
tail
)
...
...
@@ -340,10 +435,15 @@ private struct ProjectReleaseColumn: View {
.
system
(
size
:
11
)
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
}
.
padding
(
.
horizontal
,
14
)
.
frame
(
height
:
50
)
.
contentShape
(
Rectangle
())
}
.
buttonStyle
(
ReleaseButtonStyle
(
radius
:
0
))
.
accessibilityLabel
(
label
)
.
accessibilityValue
(
value
)
}
.
padding
(
.
horizontal
,
14
)
.
frame
(
height
:
46
)
.
contentShape
(
Rectangle
())
}
.
buttonStyle
(
ReleaseButtonStyle
(
base
:
pane
.
expandedField
==
field
?
ReleaseColors
.
blue
.
opacity
(
0.06
)
:
.
clear
,
radius
:
0
)
)
.
help
(
"
\(
label
)
:
\(
value
)
· 点击
\(
pane
.
expandedField
==
field
?
"收起"
:
"展开"
)
"
)
.
accessibilityLabel
(
label
)
.
accessibilityValue
(
value
)
}
private
func
publishButton
(
title
:
String
)
->
some
View
{
Button
{
...
...
@@ -354,78 +454,199 @@ private struct ProjectReleaseColumn: View {
.
frame
(
maxWidth
:
.
infinity
)
.
frame
(
height
:
46
)
}
.
buttonStyle
(
ReleaseButtonStyle
(
base
:
ReleaseColors
.
action
,
prominent
:
true
))
.
disabled
(
model
.
isRunning
||
pane
.
modules
.
isEmpty
)
.
opacity
(
model
.
isRunning
||
pane
.
modules
.
isEmpty
?
0.5
:
1
)
.
disabled
(
!
model
.
canPublish
(
pane
))
.
help
(
model
.
isRunning
?
"已有发布任务正在运行"
:
model
.
readinessMessage
(
for
:
pane
)
??
"发布当前项目选中的
\(
pane
.
selectedCount
)
个模块"
)
}
@State
private
var
copiedLog
=
false
private
var
console
:
some
View
{
VStack
(
alignment
:
.
leading
,
spacing
:
1
4
)
{
Text
(
configurationSummary
)
.
font
(
.
caption
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
.
lineLimit
(
1
)
VStack
(
alignment
:
.
leading
,
spacing
:
1
0
)
{
Text
(
configurationSummary
)
.
font
(
.
system
(
size
:
11
)
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
.
lineLimit
(
1
)
.
help
(
configurationSummary
)
ScrollView
(
.
horizontal
)
{
HStack
(
spacing
:
6
)
{
ForEach
(
pane
.
modules
,
id
:
\
.
self
)
{
module
in
Text
(
module
)
.
font
(
ReleaseTypography
.
detail
)
.
foregroundStyle
(
.
white
)
.
padding
(
.
horizontal
,
10
)
.
padding
(
.
vertical
,
6
)
.
background
(
ReleaseColors
.
action
,
in
:
Capsule
())
Text
(
module
)
.
font
(
.
system
(
size
:
11
,
weight
:
.
medium
))
.
foregroundStyle
(
ReleaseColors
.
blue
)
.
padding
(
.
horizontal
,
9
)
.
padding
(
.
vertical
,
5
)
.
background
(
ReleaseColors
.
blue
.
opacity
(
0.12
),
in
:
Capsule
())
.
help
(
module
)
}
}
}
.
frame
(
height
:
30
)
.
scrollIndicators
(
.
hidden
)
}
.
frame
(
height
:
27
)
.
scrollIndicators
(
.
hidden
)
if
pane
.
state
==
.
running
||
pane
.
state
==
.
queued
{
VStack
(
spacing
:
6
)
{
HStack
{
Text
(
paneTitle
)
.
lineLimit
(
1
)
Spacer
()
if
pane
.
state
==
.
running
{
Text
(
"预计
\(
pane
.
phase
?
.
estimatedPercentage
??
0
)
%"
)
.
monospacedDigit
()
}
}
.
font
(
.
system
(
size
:
11
))
.
foregroundStyle
(
ReleaseColors
.
muted
)
ProgressView
(
value
:
Double
(
pane
.
state
==
.
queued
?
0
:
pane
.
phase
?
.
estimatedPercentage
??
0
),
total
:
100
)
.
tint
(
pane
.
paused
?
ReleaseColors
.
warning
:
ReleaseColors
.
blue
)
}
.
help
(
pane
.
state
==
.
queued
?
"等待构建资源或前序项目结束"
:
"进度按发布阶段估算,具体状态以日志为准"
)
}
VStack
(
spacing
:
0
)
{
HStack
{
Text
(
"实时输出 ·
\(
paneTitle
)
"
)
.
font
(
.
system
(
size
:
13
,
weight
:
.
medium
))
.
lineLimit
(
1
)
Spacer
(
minLength
:
4
)
Button
{
HStack
(
spacing
:
2
)
{
Image
(
systemName
:
"terminal"
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
Text
(
"实时输出"
)
.
font
(
.
system
(
size
:
11
,
weight
:
.
medium
))
Spacer
(
minLength
:
2
)
ReleaseIconButton
(
symbol
:
copiedLog
?
"checkmark"
:
"doc.on.doc"
,
title
:
copiedLog
?
"日志已复制"
:
"复制当前显示的日志"
)
{
NSPasteboard
.
general
.
clearContents
()
copiedLog
=
NSPasteboard
.
general
.
setString
(
pane
.
log
,
forType
:
.
string
)
}
.
disabled
(
pane
.
log
.
isEmpty
)
ReleaseIconButton
(
symbol
:
pane
.
expandedConsole
?
"arrow.down.right.and.arrow.up.left"
:
"arrow.up.left.and.arrow.down.right"
,
title
:
pane
.
expandedConsole
?
"收起日志"
:
"展开日志"
)
{
pane
.
expandedConsole
.
toggle
()
}
label
:
{
Image
(
systemName
:
pane
.
expandedConsole
?
"arrow.down.right.and.arrow.up.left"
:
"arrow.up.left.and.arrow.down.right"
)
}
.
help
(
pane
.
expandedConsole
?
"收起日志"
:
"展开日志"
)
if
let
result
=
pane
.
result
{
ReleaseIconButton
(
symbol
:
"doc.text.magnifyingglass"
,
title
:
"打开完整日志文件"
)
{
NSWorkspace
.
shared
.
open
(
model
.
logURL
(
for
:
result
))
}
}
if
pane
.
state
==
.
running
{
Button
(
pane
.
paused
?
"继续"
:
"暂停"
)
{
model
.
togglePause
(
pane
)
}
.
disabled
(
pane
.
stopping
)
Button
(
"停止"
)
{
model
.
stop
(
pane
)
}
.
disabled
(
pane
.
stopping
)
ReleaseIconButton
(
symbol
:
pane
.
paused
?
"play.fill"
:
"pause.fill"
,
title
:
pane
.
paused
?
"继续发布"
:
"暂停发布"
)
{
model
.
togglePause
(
pane
)
}
.
disabled
(
pane
.
stopping
)
ReleaseIconButton
(
symbol
:
"stop.fill"
,
title
:
pane
.
stopping
?
"正在停止发布…"
:
"停止当前发布"
,
tint
:
ReleaseColors
.
danger
)
{
model
.
stop
(
pane
)
}
.
disabled
(
pane
.
stopping
)
}
}
.
padding
(
10
)
.
background
(
ReleaseColors
.
surface
)
}
.
padding
(
.
horizontal
,
9
)
.
frame
(
height
:
36
)
.
background
(
ReleaseColors
.
surface
)
Rectangle
()
.
fill
(
ReleaseColors
.
border
)
.
frame
(
height
:
1
)
LogTextView
(
text
:
pane
.
log
.
isEmpty
?
"等待构建资源…"
:
pane
.
log
,
text
:
pane
.
log
.
isEmpty
?
(
pane
.
state
==
.
queued
?
"等待构建资源…"
:
"等待命令输出…"
)
:
pane
.
log
,
errorLine
:
nil
,
jumpRequest
:
0
,
followsOutput
:
pane
.
state
==
.
running
,
fontSize
:
1
3
fontSize
:
1
2
)
.
frame
(
maxWidth
:
.
infinity
,
maxHeight
:
.
infinity
)
}
.
background
(
ReleaseColors
.
terminal
,
in
:
RoundedRectangle
(
cornerRadius
:
8
))
.
clipShape
(
RoundedRectangle
(
cornerRadius
:
8
))
.
overlay
{
RoundedRectangle
(
cornerRadius
:
8
)
.
strokeBorder
(
ReleaseColors
.
border
)
}
.
background
(
ReleaseColors
.
terminal
,
in
:
RoundedRectangle
(
cornerRadius
:
9
))
.
clipShape
(
RoundedRectangle
(
cornerRadius
:
9
))
.
overlay
{
RoundedRectangle
(
cornerRadius
:
9
)
.
strokeBorder
(
ReleaseColors
.
border
)
.
allowsHitTesting
(
false
)
}
if
let
result
=
pane
.
result
{
Text
(
"
\(
result
.
headline
)
· 耗时
\(
result
.
duration
)
秒"
)
.
font
(
.
caption
)
.
foregroundStyle
(
result
.
status
==
.
succeeded
?
.
green
:
.
red
)
if
let
message
=
result
.
message
{
Text
(
message
)
.
font
(
.
caption
)
.
foregroundStyle
(
.
red
)
.
lineLimit
(
2
)
VStack
(
alignment
:
.
leading
,
spacing
:
4
)
{
HStack
{
Label
(
result
.
headline
,
systemImage
:
result
.
status
==
.
succeeded
?
"checkmark.circle.fill"
:
"exclamationmark.circle.fill"
)
Spacer
()
Text
(
"
\(
result
.
duration
)
秒"
)
.
monospacedDigit
()
}
.
font
(
.
system
(
size
:
11
,
weight
:
.
medium
))
if
let
message
=
result
.
message
{
Text
(
message
)
.
font
(
.
system
(
size
:
11
))
.
lineLimit
(
2
)
.
textSelection
(
.
enabled
)
.
help
(
message
)
}
}
.
foregroundStyle
(
result
.
status
==
.
succeeded
?
ReleaseColors
.
success
:
result
.
status
==
.
cancelled
?
ReleaseColors
.
warning
:
ReleaseColors
.
danger
)
HStack
{
Button
(
"返回配置"
)
{
pane
.
returnToConfiguration
()
}
Spacer
()
Button
(
"完整日志"
)
{
NSWorkspace
.
shared
.
open
(
model
.
logURL
(
for
:
result
))
}
Button
{
pane
.
returnToConfiguration
()
}
label
:
{
Label
(
"返回配置"
,
systemImage
:
"chevron.left"
)
.
font
(
ReleaseTypography
.
detail
)
.
padding
(
.
horizontal
,
8
)
.
frame
(
height
:
30
)
}
.
buttonStyle
(
ReleaseButtonStyle
())
.
help
(
"保留结果和日志,返回项目配置"
)
Spacer
(
minLength
:
4
)
if
result
.
status
!=
.
succeeded
{
Button
{
model
.
publish
(
pane
)
}
label
:
{
Label
(
"重试发布"
,
systemImage
:
"arrow.clockwise"
)
.
font
(
ReleaseTypography
.
detail
)
.
foregroundStyle
(
.
white
)
.
padding
(
.
horizontal
,
12
)
.
frame
(
height
:
30
)
}
.
buttonStyle
(
ReleaseButtonStyle
(
base
:
ReleaseColors
.
action
,
prominent
:
true
)
)
.
disabled
(
!
model
.
canPublish
(
pane
))
.
help
(
"按当前项目配置重新发布"
)
}
}
if
result
.
status
!=
.
succeeded
{
publishButton
(
title
:
"重试发布"
)
}
}
else
{
Text
(
pane
.
state
==
.
queued
?
"排队等待发布"
:
"发布中,请等待…"
)
.
font
(
.
caption
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
}
}
.
buttonStyle
(
ReleaseButtonStyle
())
}
.
onChange
(
of
:
pane
.
log
)
{
copiedLog
=
false
}
}
@ViewBuilder
private
var
paneBadge
:
some
View
{
switch
pane
.
state
{
case
.
running
:
ReleaseStatusBadge
(
title
:
pane
.
stopping
?
"停止中"
:
pane
.
paused
?
"已暂停"
:
"运行中"
,
symbol
:
pane
.
paused
?
"pause.fill"
:
"circle.fill"
,
color
:
pane
.
paused
?
ReleaseColors
.
warning
:
ReleaseColors
.
blue
)
case
.
queued
:
ReleaseStatusBadge
(
title
:
"排队中"
,
symbol
:
"clock"
,
color
:
ReleaseColors
.
muted
)
case
.
finished
:
if
let
result
=
pane
.
result
{
ReleaseStatusBadge
(
title
:
result
.
status
==
.
succeeded
?
"成功"
:
result
.
status
==
.
cancelled
?
"已停止"
:
result
.
status
==
.
failed
?
"失败"
:
"收尾异常"
,
symbol
:
result
.
status
==
.
succeeded
?
"checkmark"
:
"exclamationmark"
,
color
:
result
.
status
==
.
succeeded
?
ReleaseColors
.
success
:
result
.
status
==
.
failed
?
ReleaseColors
.
danger
:
ReleaseColors
.
warning
)
}
case
.
skipped
:
ReleaseStatusBadge
(
title
:
"未执行"
,
symbol
:
"minus"
,
color
:
ReleaseColors
.
muted
)
case
.
idle
:
EmptyView
()
}
}
private
var
modulePicker
:
some
View
{
VStack
(
alignment
:
.
leading
,
spacing
:
10
)
{
TextField
(
"输入模块名搜索…"
,
text
:
$
pane
.
search
)
.
textFieldStyle
(
.
roundedBorder
)
.
focused
(
$
moduleSearchFocused
)
.
onAppear
{
moduleSearchFocused
=
true
}
HStack
(
spacing
:
7
)
{
Image
(
systemName
:
"magnifyingglass"
)
.
foregroundStyle
(
ReleaseColors
.
muted
)
TextField
(
"输入模块名搜索…"
,
text
:
$
pane
.
search
)
.
textFieldStyle
(
.
plain
)
.
focused
(
$
moduleSearchFocused
)
.
accessibilityLabel
(
"搜索模块"
)
.
onAppear
{
moduleSearchFocused
=
true
}
if
!
pane
.
search
.
isEmpty
{
ReleaseIconButton
(
symbol
:
"xmark.circle.fill"
,
title
:
"清空搜索"
)
{
pane
.
search
=
""
}
}
}
.
font
(
ReleaseTypography
.
detail
)
.
padding
(
.
horizontal
,
9
)
.
frame
(
height
:
32
)
.
background
(
ReleaseColors
.
terminal
,
in
:
RoundedRectangle
(
cornerRadius
:
6
))
.
overlay
{
RoundedRectangle
(
cornerRadius
:
6
)
.
strokeBorder
(
moduleSearchFocused
?
ReleaseColors
.
blue
.
opacity
(
0.7
)
:
ReleaseColors
.
border
)
.
allowsHitTesting
(
false
)
}
HStack
{
Text
(
"匹配
\(
matches
.
count
)
个模块"
)
Spacer
()
Text
(
"已选
\(
pane
.
selectedCount
)
个"
)
}
.
font
(
.
system
(
size
:
10
))
.
foregroundStyle
(
ReleaseColors
.
muted
)
ScrollView
{
LazyVStack
(
spacing
:
2
)
{
ForEach
(
matches
,
id
:
\
.
self
)
{
module
in
...
...
@@ -440,7 +661,7 @@ private struct ProjectReleaseColumn: View {
.
foregroundStyle
(
pane
.
modules
.
contains
(
module
)
?
ReleaseColors
.
blue
:
ReleaseColors
.
muted
)
Text
(
module
)
.
lineLimit
(
1
)
Text
(
module
)
.
lineLimit
(
1
)
.
help
(
module
)
Spacer
()
}
.
padding
(
.
horizontal
,
10
)
...
...
@@ -467,6 +688,7 @@ private struct ProjectReleaseColumn: View {
}
private
var
configurationSummary
:
String
{
if
project
?
.
type
!=
.
cityKeeper
{
return
"脚本发布 ·
\(
pane
.
selectedCount
)
个模块"
}
let
destination
=
pane
.
servers
.
first
(
where
:
{
$0
.
name
==
pane
.
server
})?
.
displayName
??
"选择服务器"
let
configuration
=
profile
?
.
title
??
"选择配置"
...
...
@@ -529,6 +751,7 @@ private struct ProjectReleaseColumn: View {
base
:
selected
?
ReleaseColors
.
blue
.
opacity
(
0.12
)
:
.
clear
,
radius
:
5
)
)
.
accessibilityAddTraits
(
selected
?
.
isSelected
:
[])
.
help
(
title
)
}
private
var
configurationChoices
:
some
View
{
...
...
@@ -600,14 +823,16 @@ private struct ProjectReleaseColumn: View {
base
:
selected
?
ReleaseColors
.
blue
.
opacity
(
0.12
)
:
.
clear
,
radius
:
5
)
)
.
accessibilityAddTraits
(
selected
?
.
isSelected
:
[])
.
help
(
"
\(
option
.
title
)
·
\(
file
)
"
)
Button
{
configurationDraft
=
option
}
label
:
{
Image
(
systemName
:
"pencil"
)
.
foregroundStyle
(
ReleaseColors
.
blue
)
.
f
rame
(
width
:
27
,
height
:
27
)
.
f
ont
(
.
system
(
size
:
12
,
weight
:
.
medium
))
.
frame
(
width
:
28
,
height
:
28
)
}
.
buttonStyle
(
ReleaseButtonStyle
())
.
accessibilityLabel
(
"编辑
\(
file
)
的别名和选项"
)
.
help
(
"编辑
\(
file
)
的别名和 SSH 目标"
)
}
}
...
...
Tests/ReleaseCoreTests/ReleaseRunnerTests.swift
View file @
c86ed293
...
...
@@ -61,6 +61,113 @@ final class ReleaseRunnerTests: XCTestCase {
XCTAssertTrue
(
restored
.
panes
.
contains
{
$0
.
log
.
contains
(
"first task completed"
)
})
}
@MainActor
func
testBatchProgressLocksRepeatedSubmissionAndReportsCompletion
()
async
throws
{
let
first
=
try
Fixture
()
let
second
=
try
Fixture
()
defer
{
first
.
remove
();
second
.
remove
()
}
for
fixture
in
[
first
,
second
]
{
try
"printf 'launch
\\
n' >> launch-count
\n
sleep 0.4
\n
printf 'done
\\
n'
\n
"
.
write
(
to
:
fixture
.
local
.
appending
(
path
:
"release.sh"
),
atomically
:
true
,
encoding
:
.
utf8
)
}
let
storage
=
first
.
base
.
appending
(
path
:
"progress-state"
)
let
settings
=
AppModel
(
storage
:
storage
)
var
alpha
=
first
.
project
;
alpha
.
name
=
"Alpha"
var
beta
=
second
.
project
;
beta
.
name
=
"Beta"
try
settings
.
save
(
alpha
);
try
settings
.
save
(
beta
)
settings
.
projectID
=
alpha
.
id
let
model
=
SplitReleaseModel
(
settings
:
settings
,
storage
:
storage
)
model
.
add
()
XCTAssertTrue
(
model
.
canPublishAll
)
model
.
publishAll
()
let
initial
=
try
XCTUnwrap
(
model
.
runSummary
)
XCTAssertEqual
(
initial
.
total
,
2
)
XCTAssertEqual
(
initial
.
running
,
1
)
XCTAssertEqual
(
initial
.
queued
,
1
)
XCTAssertEqual
(
initial
.
completed
,
0
)
XCTAssertFalse
(
model
.
canPublishAll
)
XCTAssertTrue
(
model
.
publishAllHelp
.
contains
(
"正在执行"
))
model
.
publishAll
()
model
.
publish
(
model
.
panes
[
0
])
XCTAssertEqual
(
model
.
runSummary
?
.
total
,
2
)
for
_
in
0
..<
300
where
model
.
isRunning
{
try
await
Task
.
sleep
(
for
:
.
milliseconds
(
10
))
}
let
completed
=
try
XCTUnwrap
(
model
.
runSummary
)
XCTAssertEqual
(
completed
.
completed
,
2
)
XCTAssertEqual
(
completed
.
succeeded
,
2
)
XCTAssertEqual
(
completed
.
failed
,
0
)
XCTAssertEqual
(
completed
.
queued
,
0
)
XCTAssertEqual
(
completed
.
estimatedPercentage
,
100
)
XCTAssertTrue
(
model
.
canPublishAll
)
for
fixture
in
[
first
,
second
]
{
let
count
=
try
String
(
contentsOf
:
fixture
.
local
.
appending
(
path
:
"launch-count"
),
encoding
:
.
utf8
)
XCTAssertEqual
(
count
.
split
(
separator
:
"
\n
"
)
.
count
,
1
)
}
}
@MainActor
func
testReadinessExplainsMissingModulesConfigurationAndServer
()
async
throws
{
let
fixture
=
try
Fixture
()
defer
{
fixture
.
remove
()
}
try
fixture
.
createCityKeeperFixture
()
var
project
=
fixture
.
project
project
.
type
=
.
cityKeeper
project
.
inventoryPath
=
"hosts"
project
.
toolPath
=
fixture
.
local
.
appending
(
path
:
"bin"
)
.
path
let
storage
=
fixture
.
base
.
appending
(
path
:
"readiness-state"
)
let
settings
=
AppModel
(
storage
:
storage
)
try
settings
.
save
(
project
)
let
model
=
SplitReleaseModel
(
settings
:
settings
,
storage
:
storage
)
let
pane
=
try
XCTUnwrap
(
model
.
panes
.
first
)
pane
.
modules
=
[]
XCTAssertFalse
(
model
.
canPublish
(
pane
))
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"模块"
))
pane
.
modules
=
[
"gateway"
]
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"配置"
))
var
profile
=
DeployProfile
();
profile
.
file
=
"deploy.yaml"
project
.
profiles
=
[
profile
]
try
settings
.
save
(
project
)
pane
.
profileID
=
profile
.
id
for
_
in
0
..<
100
where
pane
.
loadingServers
{
try
await
Task
.
sleep
(
for
:
.
milliseconds
(
20
))
}
XCTAssertFalse
(
model
.
canPublish
(
pane
))
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"服务器"
))
pane
.
server
=
try
XCTUnwrap
(
pane
.
servers
.
first
?
.
name
)
XCTAssertTrue
(
model
.
canPublish
(
pane
))
pane
.
loadingServers
=
true
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"正在读取"
))
pane
.
loadingServers
=
false
pane
.
inventoryError
=
"inventory failed"
XCTAssertFalse
(
model
.
canPublish
(
pane
))
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"读取失败"
))
}
@MainActor
func
testFailedBatchSummaryIncludesUnstartedProjects
()
async
throws
{
let
first
=
try
Fixture
()
let
second
=
try
Fixture
()
defer
{
first
.
remove
();
second
.
remove
()
}
try
"printf 'failure
\\
n'
\n
exit 3
\n
"
.
write
(
to
:
first
.
local
.
appending
(
path
:
"release.sh"
),
atomically
:
true
,
encoding
:
.
utf8
)
let
storage
=
first
.
base
.
appending
(
path
:
"failed-summary"
)
let
settings
=
AppModel
(
storage
:
storage
)
var
alpha
=
first
.
project
;
alpha
.
name
=
"Alpha"
var
beta
=
second
.
project
;
beta
.
name
=
"Beta"
try
settings
.
save
(
alpha
);
try
settings
.
save
(
beta
)
settings
.
projectID
=
alpha
.
id
let
model
=
SplitReleaseModel
(
settings
:
settings
,
storage
:
storage
)
model
.
add
()
model
.
publishAll
()
for
_
in
0
..<
200
where
model
.
isRunning
{
try
await
Task
.
sleep
(
for
:
.
milliseconds
(
10
))
}
let
summary
=
try
XCTUnwrap
(
model
.
runSummary
)
XCTAssertEqual
(
summary
.
total
,
2
)
XCTAssertEqual
(
summary
.
completed
,
1
)
XCTAssertEqual
(
summary
.
failed
,
1
)
XCTAssertEqual
(
summary
.
skipped
,
1
)
XCTAssertEqual
(
summary
.
queued
,
0
)
model
.
remove
(
model
.
panes
[
1
])
XCTAssertEqual
(
model
.
runSummary
?
.
skipped
,
1
)
XCTAssertEqual
(
model
.
indicator
,
.
failed
)
}
@MainActor
func
testIdlePaneCanCloseWhileAnotherReleaseRuns
()
async
throws
{
let
first
=
try
Fixture
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment