-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
144 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
import {resolvePluginConfig, type UserConfig} from "./plugin.js"; | ||
import {newAxiosInstance, resolvePluginConfig, type UserConfig} from "./plugin.js"; | ||
import type {PrepareContext} from "semantic-release"; | ||
import axios, {AxiosError} from "axios"; | ||
import {AxiosError, type AxiosResponse} from "axios"; | ||
|
||
export async function verifyConditions(userConfig: UserConfig, context: PrepareContext): Promise<void> { | ||
const config = resolvePluginConfig(userConfig, context); | ||
context.logger.log(`Resolved Plugin Config: ${JSON.stringify(config)}`); | ||
|
||
try { | ||
const instance = axios.create({}); | ||
await instance.get(config.gitlabBaseUrl, { | ||
headers: {"PRIVATE-TOKEN": config.gitlabToken, "Content-Type": "application/json"}, | ||
}); | ||
} catch (e) { | ||
if (!(e instanceof AxiosError)) { | ||
throw e; | ||
} | ||
const instance = newAxiosInstance(config); | ||
|
||
context.logger.error(`Failed to verify GitLab connection with error: ${JSON.stringify(e.response?.data)}. Please check your GitLab configuration and token.`); | ||
throw e; | ||
const response: AxiosResponse | AxiosError = await instance.get(config.gitlabBaseUrl); | ||
if (response instanceof AxiosError) { | ||
context.logger.error(`Failed to verify GitLab connection with error: ${JSON.stringify(response.response?.data)}. Please check your GitLab configuration and token.`); | ||
throw response; | ||
} else { | ||
context.logger.log(`Verified GitLab connection with status: ${response.status}`); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters