@halospv3/hce.shared-config
Version:
Automate commit message quality, changelogs, and CI/CD releases. Exports a semantic-release shareable configuration deserialized from this package's '.releaserc.yml'. Shared resources for .NET projects are also distributed with this package.
37 lines • 3.32 kB
TypeScript
import type { NuGetRegistryInfo } from './dotnetHelpers.js';
/**
* @param tokenEnvVar The name of the environment variable containing the NUGET token
* @returns `true` if the token can be used to push nupkg to the given Nuget registry
* @throws
* - TypeError: The environment variable ${tokenEnvVar} is undefined!
* - Error:
* - The value of the token in ${tokenEnvVar} begins with 'github_pat_' which means it's a Fine-Grained token. At the time of writing, GitHub Fine-Grained tokens cannot push packages. If you believe this is statement is outdated, report the issue at https://github.com/halospv3/hce.shared/issues/new. For more information, see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry.
* - The GitHub API response header lacked "x-oauth-scopes". This indicates the token we provided is not a workflow token nor a Personal Access Token (classic) and can never have permission to push packages.
*/
export declare function tokenCanWritePackages(tokenEnvVar: string, url?: string): boolean;
export declare const nugetGitHubUrlBase = "https://nuget.pkg.github.com";
/** @deprecated use {@link getNugetGitHubUrl()} instead. */
export declare const nugetGitHubUrl: string | undefined;
export declare function getNugetGitHubUrl(): string | undefined;
/**
* If tokenEnvVar is NOT 'GITHUB_TOKEN', then test if the token is defined and return the boolean.
* Else If tokenEnvVar is 'GITHUB_TOKEN' and defined, then return true.
* Else If tokenEnvVar is 'GITHUB_TOKEN' and undefined, then set tokenEnvVar to 'GH_TOKEN', test if GH_TOKEN is defined, and return the boolean.
* @param tokenEnvVar the name of the environment variable with the token's value. Defaults to 'GITHUB_TOKEN'. If environment variable 'GITHUB_TOKEN' is undefined, falls back to 'GH_TOKEN'.
* @returns `{isDefined: true}` if the token is defined. Else, if tokenEnvVar is 'GITHUB_TOKEN' (default) and token is defined, returns `true`. Else, if 'GH_TOKEN' is defined, returns `true`. Else, returns `false`
*/
export declare function isTokenDefined(tokenEnvVar?: string): {
isDefined: boolean;
fallback?: string;
};
/**
* Get a {@link NuGetRegistryInfo} for pushing to your GitHub Packages NuGet registry.
* todo: add support for private, custom GitHub instances. Token is only validated against github.com.
* @export
* @param {string | 'GITHUB_TOKEN' | 'GH_TOKEN'} [tokenEnvVar="GITHUB_TOKEN"] The name of environment variable storing the GitHub Packages NuGet registry API key. Defaults to `"GITHUB_TOKEN"`. If GITHUB_TOKEN is undefined, fallback to GH_TOKEN;
* @param {string} [url=tokenEnvVar] The url of the GitHub Packages NuGet registry. Defaults to return value of {@link getNugetGitHubUrl()}.
* @returns {(NuGetRegistryInfo | undefined)} a {@link NuGetRegistryInfo} object if {@link tokenEnvVar} and {@link url} are defined. Else, `undefined`.
* note: `url` defaults to job's repository owner's GitHub registry in GitHub Actions workflow. If GITHUB_REPOSITORY_OWNER is not defined, then an error will be logged and `undefined` will be returned.
*/
export declare function getGithubNugetRegistryPair(tokenEnvVar?: string | 'GITHUB_TOKEN' | 'GH_TOKEN', url?: string | undefined): NuGetRegistryInfo | undefined;
//# sourceMappingURL=dotnetGHPR.d.ts.map