Point ReleasesApiConsumer at nightly repo if config value is set
This commit is contained in:
@@ -50,6 +50,16 @@ const DEFAULT_DISTRIBUTION_OWNER_NAME = "github";
|
||||
*/
|
||||
const DEFAULT_DISTRIBUTION_REPOSITORY_NAME = "codeql-cli-binaries";
|
||||
|
||||
/**
|
||||
* Owner name of the nightly version of the extension-managed distribution on GitHub.
|
||||
*/
|
||||
const NIGHTLY_DISTRIBUTION_OWNER_NAME = "dsp-testing";
|
||||
|
||||
/**
|
||||
* Repository name of the nightly version of the extension-managed distribution on GitHub.
|
||||
*/
|
||||
const NIGHTLY_DISTRIBUTION_REPOSITORY_NAME = "codeql-cli-nightlies";
|
||||
|
||||
/**
|
||||
* Range of versions of the CLI that are compatible with the extension.
|
||||
*
|
||||
@@ -476,19 +486,33 @@ class ExtensionSpecificDistributionManager {
|
||||
}
|
||||
|
||||
private createReleasesApiConsumer(): ReleasesApiConsumer {
|
||||
const ownerName = this.config.ownerName
|
||||
? this.config.ownerName
|
||||
: DEFAULT_DISTRIBUTION_OWNER_NAME;
|
||||
const repositoryName = this.config.repositoryName
|
||||
? this.config.repositoryName
|
||||
: DEFAULT_DISTRIBUTION_REPOSITORY_NAME;
|
||||
return new ReleasesApiConsumer(
|
||||
ownerName,
|
||||
repositoryName,
|
||||
this.distributionOwnerName(),
|
||||
this.distributionRepositoryName(),
|
||||
this.config.personalAccessToken,
|
||||
);
|
||||
}
|
||||
|
||||
private distributionOwnerName(): string {
|
||||
if (this.config.ownerName) {
|
||||
return this.config.ownerName;
|
||||
} else if (this.config.channel === "nightly") {
|
||||
return NIGHTLY_DISTRIBUTION_OWNER_NAME;
|
||||
} else {
|
||||
return DEFAULT_DISTRIBUTION_OWNER_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
private distributionRepositoryName(): string {
|
||||
if (this.config.repositoryName) {
|
||||
return this.config.repositoryName;
|
||||
} else if (this.config.channel === "nightly") {
|
||||
return NIGHTLY_DISTRIBUTION_REPOSITORY_NAME;
|
||||
} else {
|
||||
return DEFAULT_DISTRIBUTION_REPOSITORY_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
private async bumpDistributionFolderIndex(): Promise<void> {
|
||||
const index = this.extensionContext.globalState.get(
|
||||
ExtensionSpecificDistributionManager._currentDistributionFolderIndexStateKey,
|
||||
|
||||
@@ -95,6 +95,7 @@ const PERSONAL_ACCESS_TOKEN_SETTING = new Setting(
|
||||
"personalAccessToken",
|
||||
DISTRIBUTION_SETTING,
|
||||
);
|
||||
const CLI_CHANNEL_SETTING = new Setting("channel", DISTRIBUTION_SETTING);
|
||||
|
||||
// Query History configuration
|
||||
const QUERY_HISTORY_SETTING = new Setting("queryHistory", ROOT_SETTING);
|
||||
@@ -111,6 +112,8 @@ const DISTRIBUTION_CHANGE_SETTINGS = [
|
||||
PERSONAL_ACCESS_TOKEN_SETTING,
|
||||
];
|
||||
|
||||
export type CLIChannel = "released" | "nightly";
|
||||
|
||||
export interface DistributionConfig {
|
||||
readonly customCodeQlPath?: string;
|
||||
updateCustomCodeQlPath: (newPath: string | undefined) => Promise<void>;
|
||||
@@ -118,6 +121,7 @@ export interface DistributionConfig {
|
||||
personalAccessToken?: string;
|
||||
ownerName?: string;
|
||||
repositoryName?: string;
|
||||
channel: CLIChannel;
|
||||
onDidChangeConfiguration?: Event<void>;
|
||||
|
||||
/**
|
||||
@@ -283,6 +287,12 @@ export class DistributionConfigListener
|
||||
);
|
||||
}
|
||||
|
||||
public get channel(): CLIChannel {
|
||||
return CLI_CHANNEL_SETTING.getValue() === "nightly"
|
||||
? "nightly"
|
||||
: "released";
|
||||
}
|
||||
|
||||
public forceUpdateConfiguration() {
|
||||
this._onDidChangeConfiguration.fire(undefined);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user