(draftAppId string)
| 117 | } |
| 118 | |
| 119 | func 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 | |
| 151 | func RevertDraft(draftAppId string) error { |
| 152 | if err := ValidateAppId(draftAppId); err != nil { |
no test coverage detected