(dir: string, options: DeployCommandOptions)
| 179 | } |
| 180 | |
| 181 | async function _deployCommand(dir: string, options: DeployCommandOptions) { |
| 182 | const span = trace.getSpan(context.active()); |
| 183 | |
| 184 | intro("Deploying project"); |
| 185 | |
| 186 | if (!options.skipUpdateCheck) { |
| 187 | await updateTriggerPackages(dir, { ...options }, true, true); |
| 188 | } |
| 189 | |
| 190 | const authorization = await login({ |
| 191 | embedded: true, |
| 192 | defaultApiUrl: options.apiUrl, |
| 193 | profile: options.profile, |
| 194 | }); |
| 195 | |
| 196 | if (!authorization.ok) { |
| 197 | if (authorization.error === "fetch failed") { |
| 198 | throw new Error( |
| 199 | `Failed to connect to ${authorization.auth?.apiUrl}. Are you sure it's the correct URL?` |
| 200 | ); |
| 201 | } else { |
| 202 | throw new Error( |
| 203 | `You must login first. Use the \`login\` CLI command.\n\n${authorization.error}` |
| 204 | ); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | span?.setAttributes({ |
| 209 | "cli.userId": authorization.userId, |
| 210 | "cli.email": authorization.email, |
| 211 | "cli.config.apiUrl": authorization.auth.apiUrl, |
| 212 | }); |
| 213 | |
| 214 | const resolvedConfig = await readConfig(dir, { |
| 215 | configFile: options.config, |
| 216 | projectRef: options.projectRef, |
| 217 | }); |
| 218 | |
| 219 | if (resolvedConfig.status === "error") { |
| 220 | logger.error("Failed to read config:", resolvedConfig.error); |
| 221 | span && recordSpanException(span, resolvedConfig.error); |
| 222 | |
| 223 | throw new SkipLoggingError("Failed to read config"); |
| 224 | } |
| 225 | |
| 226 | logger.debug("Resolved config", { resolvedConfig }); |
| 227 | |
| 228 | span?.setAttributes({ |
| 229 | "resolvedConfig.status": resolvedConfig.status, |
| 230 | "resolvedConfig.path": resolvedConfig.status === "file" ? resolvedConfig.path : undefined, |
| 231 | "resolvedConfig.config.project": resolvedConfig.config.project, |
| 232 | "resolvedConfig.config.projectDir": resolvedConfig.config.projectDir, |
| 233 | "resolvedConfig.config.triggerUrl": resolvedConfig.config.triggerUrl, |
| 234 | "resolvedConfig.config.triggerDirectories": resolvedConfig.config.triggerDirectories, |
| 235 | ...flattenAttributes(resolvedConfig.config.retries, "resolvedConfig.config.retries"), |
| 236 | }); |
| 237 | |
| 238 | const apiClient = new CliApiClient(authorization.auth.apiUrl, authorization.auth.accessToken); |
no test coverage detected
searching dependent graphs…