Convert extensions/ql-vscode/src/variant-analysis/export-results.ts to call typed commands
This commit is contained in:
@@ -1,14 +1,7 @@
|
|||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { ensureDir, writeFile } from "fs-extra";
|
import { ensureDir, writeFile } from "fs-extra";
|
||||||
|
|
||||||
import {
|
import { CancellationToken, Uri, ViewColumn, window, workspace } from "vscode";
|
||||||
CancellationToken,
|
|
||||||
commands,
|
|
||||||
Uri,
|
|
||||||
ViewColumn,
|
|
||||||
window,
|
|
||||||
workspace,
|
|
||||||
} from "vscode";
|
|
||||||
import {
|
import {
|
||||||
ProgressCallback,
|
ProgressCallback,
|
||||||
UserCancellationException,
|
UserCancellationException,
|
||||||
@@ -35,6 +28,7 @@ import {
|
|||||||
RepositoriesFilterSortStateWithIds,
|
RepositoriesFilterSortStateWithIds,
|
||||||
} from "../pure/variant-analysis-filter-sort";
|
} from "../pure/variant-analysis-filter-sort";
|
||||||
import { Credentials } from "../common/authentication";
|
import { Credentials } from "../common/authentication";
|
||||||
|
import { AppCommandManager } from "../common/commands";
|
||||||
|
|
||||||
const MAX_VARIANT_ANALYSIS_EXPORT_PROGRESS_STEPS = 2;
|
const MAX_VARIANT_ANALYSIS_EXPORT_PROGRESS_STEPS = 2;
|
||||||
|
|
||||||
@@ -46,6 +40,7 @@ export async function exportVariantAnalysisResults(
|
|||||||
variantAnalysisManager: VariantAnalysisManager,
|
variantAnalysisManager: VariantAnalysisManager,
|
||||||
variantAnalysisId: number,
|
variantAnalysisId: number,
|
||||||
filterSort: RepositoriesFilterSortStateWithIds | undefined,
|
filterSort: RepositoriesFilterSortStateWithIds | undefined,
|
||||||
|
commandManager: AppCommandManager,
|
||||||
credentials: Credentials,
|
credentials: Credentials,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await withProgress(
|
await withProgress(
|
||||||
@@ -149,6 +144,7 @@ export async function exportVariantAnalysisResults(
|
|||||||
getAnalysesResults(),
|
getAnalysesResults(),
|
||||||
repositories?.length ?? 0,
|
repositories?.length ?? 0,
|
||||||
exportFormat,
|
exportFormat,
|
||||||
|
commandManager,
|
||||||
credentials,
|
credentials,
|
||||||
progress,
|
progress,
|
||||||
token,
|
token,
|
||||||
@@ -169,6 +165,7 @@ export async function exportVariantAnalysisAnalysisResults(
|
|||||||
>,
|
>,
|
||||||
expectedAnalysesResultsCount: number,
|
expectedAnalysesResultsCount: number,
|
||||||
exportFormat: "gist" | "local",
|
exportFormat: "gist" | "local",
|
||||||
|
commandManager: AppCommandManager,
|
||||||
credentials: Credentials,
|
credentials: Credentials,
|
||||||
progress: ProgressCallback,
|
progress: ProgressCallback,
|
||||||
token: CancellationToken,
|
token: CancellationToken,
|
||||||
@@ -199,6 +196,7 @@ export async function exportVariantAnalysisAnalysisResults(
|
|||||||
description,
|
description,
|
||||||
markdownFiles,
|
markdownFiles,
|
||||||
exportFormat,
|
exportFormat,
|
||||||
|
commandManager,
|
||||||
credentials,
|
credentials,
|
||||||
progress,
|
progress,
|
||||||
token,
|
token,
|
||||||
@@ -243,6 +241,7 @@ export async function exportResults(
|
|||||||
description: string,
|
description: string,
|
||||||
markdownFiles: MarkdownFile[],
|
markdownFiles: MarkdownFile[],
|
||||||
exportFormat: "gist" | "local",
|
exportFormat: "gist" | "local",
|
||||||
|
commandManager: AppCommandManager,
|
||||||
credentials: Credentials,
|
credentials: Credentials,
|
||||||
progress?: ProgressCallback,
|
progress?: ProgressCallback,
|
||||||
token?: CancellationToken,
|
token?: CancellationToken,
|
||||||
@@ -255,6 +254,7 @@ export async function exportResults(
|
|||||||
await exportToGist(
|
await exportToGist(
|
||||||
description,
|
description,
|
||||||
markdownFiles,
|
markdownFiles,
|
||||||
|
commandManager,
|
||||||
credentials,
|
credentials,
|
||||||
progress,
|
progress,
|
||||||
token,
|
token,
|
||||||
@@ -263,6 +263,7 @@ export async function exportResults(
|
|||||||
await exportToLocalMarkdown(
|
await exportToLocalMarkdown(
|
||||||
exportedResultsPath,
|
exportedResultsPath,
|
||||||
markdownFiles,
|
markdownFiles,
|
||||||
|
commandManager,
|
||||||
progress,
|
progress,
|
||||||
token,
|
token,
|
||||||
);
|
);
|
||||||
@@ -272,6 +273,7 @@ export async function exportResults(
|
|||||||
export async function exportToGist(
|
export async function exportToGist(
|
||||||
description: string,
|
description: string,
|
||||||
markdownFiles: MarkdownFile[],
|
markdownFiles: MarkdownFile[],
|
||||||
|
commandManager: AppCommandManager,
|
||||||
credentials: Credentials,
|
credentials: Credentials,
|
||||||
progress?: ProgressCallback,
|
progress?: ProgressCallback,
|
||||||
token?: CancellationToken,
|
token?: CancellationToken,
|
||||||
@@ -303,7 +305,7 @@ export async function exportToGist(
|
|||||||
if (!shouldOpenGist) {
|
if (!shouldOpenGist) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return commands.executeCommand("vscode.open", Uri.parse(gistUrl));
|
return commandManager.execute("vscode.open", Uri.parse(gistUrl));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,6 +336,7 @@ const buildVariantAnalysisGistDescription = (
|
|||||||
async function exportToLocalMarkdown(
|
async function exportToLocalMarkdown(
|
||||||
exportedResultsPath: string,
|
exportedResultsPath: string,
|
||||||
markdownFiles: MarkdownFile[],
|
markdownFiles: MarkdownFile[],
|
||||||
|
commandManager: AppCommandManager,
|
||||||
progress?: ProgressCallback,
|
progress?: ProgressCallback,
|
||||||
token?: CancellationToken,
|
token?: CancellationToken,
|
||||||
) {
|
) {
|
||||||
@@ -366,6 +369,6 @@ async function exportToLocalMarkdown(
|
|||||||
const summaryFilePath = join(exportedResultsPath, "_summary.md");
|
const summaryFilePath = join(exportedResultsPath, "_summary.md");
|
||||||
const summaryFile = await workspace.openTextDocument(summaryFilePath);
|
const summaryFile = await workspace.openTextDocument(summaryFilePath);
|
||||||
await window.showTextDocument(summaryFile, ViewColumn.One);
|
await window.showTextDocument(summaryFile, ViewColumn.One);
|
||||||
await commands.executeCommand("revealFileInOS", Uri.file(summaryFilePath));
|
await commandManager.execute("revealFileInOS", Uri.file(summaryFilePath));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -689,6 +689,7 @@ export class VariantAnalysisManager
|
|||||||
this,
|
this,
|
||||||
variantAnalysisId,
|
variantAnalysisId,
|
||||||
filterSort,
|
filterSort,
|
||||||
|
this.app.commands,
|
||||||
this.app.credentials,
|
this.app.credentials,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user