MCPcopy
hub / github.com/wavetermdev/waveterm / PublishDraft

Function PublishDraft

pkg/waveappstore/waveappstore.go:119–149  ·  view source on GitHub ↗
(draftAppId string)

Source from the content-addressed store, hash-verified

117}
118
119func PublishDraft(draftAppId string) (string, error) {
120 if err := ValidateAppId(draftAppId); err != nil {
121 return "", fmt.Errorf("invalid appId: %w", err)
122 }
123
124 appNS, appName, _ := ParseAppId(draftAppId)
125 if appNS != AppNSDraft {
126 return "", fmt.Errorf("appId must be in draft namespace, got: %s", appNS)
127 }
128
129 draftDir, err := GetAppDir(draftAppId)
130 if err != nil {
131 return "", err
132 }
133
134 if _, err := os.Stat(draftDir); os.IsNotExist(err) {
135 return "", fmt.Errorf("draft app does not exist: %s", draftDir)
136 }
137
138 localAppId := MakeAppId(AppNSLocal, appName)
139 localDir, err := GetAppDir(localAppId)
140 if err != nil {
141 return "", err
142 }
143
144 if err := copyDir(draftDir, localDir); err != nil {
145 return "", err
146 }
147
148 return localAppId, nil
149}
150
151func RevertDraft(draftAppId string) error {
152 if err := ValidateAppId(draftAppId); err != nil {

Callers 1

PublishAppCommandMethod · 0.92

Calls 6

ValidateAppIdFunction · 0.85
ParseAppIdFunction · 0.85
GetAppDirFunction · 0.85
MakeAppIdFunction · 0.85
copyDirFunction · 0.85
StatMethod · 0.80

Tested by

no test coverage detected