Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: warn if plugin doesnt have snapshot #703

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/commands/cli/artifacts/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,22 @@ export default class ArtifactsTest extends SfCommand<ArtifactsCompareResult> {

private async getSnapshot(owner: string, repo: string, ref: string | null): Promise<CommandSnapshot[]> {
if (!ref) return [];
const response = await this.octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
owner,
repo,
path: 'command-snapshot.json',
accept: 'application/vnd.github.json',
ref,
});
// @ts-expect-error octokit doesn't have a type for this
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return JSON.parse(Buffer.from(response.data.content ?? '', 'base64').toString()) as CommandSnapshot[];
try {
const response = await this.octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
owner,
repo,
path: 'command-snapshot.json',
accept: 'application/vnd.github.json',
ref,
});
// @ts-expect-error octokit doesn't have a type for this
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return JSON.parse(Buffer.from(response.data.content ?? '', 'base64').toString()) as CommandSnapshot[];
} catch {
this.warn(`No command-snapshot.json found for ${owner}/${repo}@${ref}`);
return [];
}

}

private async getTags(owner: string, repo: string): Promise<string[]> {
Expand Down