(options: {
agent?: Agent;
apiUrl?: string;
debug?: boolean;
deploymentId: string;
files: FilesMap;
outputDir: string;
path: string;
teamId?: string;
token: string;
userAgent?: string;
})
| 183 | } |
| 184 | |
| 185 | async function postContinue(options: { |
| 186 | agent?: Agent; |
| 187 | apiUrl?: string; |
| 188 | debug?: boolean; |
| 189 | deploymentId: string; |
| 190 | files: FilesMap; |
| 191 | outputDir: string; |
| 192 | path: string; |
| 193 | teamId?: string; |
| 194 | token: string; |
| 195 | userAgent?: string; |
| 196 | }): Promise< |
| 197 | | { type: 'success'; deployment: Deployment } |
| 198 | | { type: 'missing_files'; missing: string[] } |
| 199 | | { type: 'error'; error: any } |
| 200 | > { |
| 201 | const debug = createDebug(options.debug); |
| 202 | |
| 203 | debug(`Calling continue deployment endpoint for ${options.deploymentId}`); |
| 204 | const response = await fetchApi( |
| 205 | `/deployments/${options.deploymentId}/continue${ |
| 206 | options.teamId ? `?teamId=${options.teamId}` : '' |
| 207 | }`, |
| 208 | options.token, |
| 209 | { |
| 210 | method: 'POST', |
| 211 | headers: { |
| 212 | Accept: 'application/json', |
| 213 | 'Content-Type': 'application/json', |
| 214 | }, |
| 215 | body: JSON.stringify({ |
| 216 | files: prepareFiles(options.files, { |
| 217 | isDirectory: true, |
| 218 | path: options.path, |
| 219 | token: options.token, |
| 220 | }), |
| 221 | }), |
| 222 | apiUrl: options.apiUrl, |
| 223 | userAgent: options.userAgent, |
| 224 | agent: options.agent, |
| 225 | } |
| 226 | ); |
| 227 | |
| 228 | let result; |
| 229 | try { |
| 230 | result = await response.json(); |
| 231 | } catch { |
| 232 | return { |
| 233 | type: 'error', |
| 234 | error: new Error('Invalid JSON response from continue endpoint'), |
| 235 | }; |
| 236 | } |
| 237 | |
| 238 | if (!response.ok || result.error) { |
| 239 | if ( |
| 240 | result.error?.code === 'missing_files' || |
| 241 | result.code === 'missing_files' |
| 242 | ) { |
no test coverage detected