Wrap fetchActionsMetadata in provider checking sessionToken
This commit is contained in:
@@ -26,7 +26,7 @@ import {getFileProvider} from "./file-provider";
|
||||
import {InitializationOptions, RepositoryContext} from "./initializationOptions";
|
||||
import {onCompletion} from "./on-completion";
|
||||
import {ReadFileRequest, Requests} from "./request";
|
||||
import {fetchActionMetadata} from "./utils/action-metadata";
|
||||
import {getActionsMetadataProvider} from "./utils/action-metadata";
|
||||
import {TTLCache} from "./utils/cache";
|
||||
import {timeOperation} from "./utils/timer";
|
||||
import {valueProviders} from "./value-providers";
|
||||
@@ -108,13 +108,7 @@ export function initConnection(connection: Connection) {
|
||||
const config: ValidationConfig = {
|
||||
valueProviderConfig: valueProviders(client, repoContext, cache),
|
||||
contextProviderConfig: contextProviders(client, repoContext, cache),
|
||||
fetchActionMetadata: async action => {
|
||||
if (client) {
|
||||
return await fetchActionMetadata(client, cache, action);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
actionsMetadataProvider: getActionsMetadataProvider(client, cache),
|
||||
fileProvider: getFileProvider(client, cache, repoContext?.workspaceUri, async path => {
|
||||
return await connection.sendRequest(Requests.ReadFile, {path} satisfies ReadFileRequest);
|
||||
})
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
import {actionIdentifier, ActionMetadata, ActionReference} from "@actions/languageservice/action";
|
||||
import {ActionsMetadataProvider} from "@actions/languageservice";
|
||||
import {error} from "@actions/languageservice/log";
|
||||
import {Octokit, RestEndpointMethodTypes} from "@octokit/rest";
|
||||
import {parse} from "yaml";
|
||||
import {TTLCache} from "./cache";
|
||||
import {errorMessage, errorStatus} from "./error";
|
||||
|
||||
export function getActionsMetadataProvider(
|
||||
client: Octokit | undefined,
|
||||
cache: TTLCache
|
||||
): ActionsMetadataProvider | undefined {
|
||||
if (!client) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
fetchActionMetadata: async action => fetchActionMetadata(client, cache, action)
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchActionMetadata(
|
||||
client: Octokit,
|
||||
cache: TTLCache,
|
||||
|
||||
Reference in New Issue
Block a user