Skip to content

Commit

Permalink
build: fix public availability of meta.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Jul 1, 2024
1 parent 7e4895f commit 848bd83
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/visual-regression-app/src/components/overview/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Overview extends LitElement {
button-size="s"
link-size="s"
>
${meta.baselineGitSha
${meta.baselineGitSha && !screenshots.baselineOnly
? html`<sbb-block-link
icon-name="document-check-small"
href=${meta.baselineCommitUrl || nothing}
Expand All @@ -56,7 +56,7 @@ export class Overview extends LitElement {
icon-name="arrow-change-horizontal-small"
href=${meta.commitUrl || nothing}
?disabled=${meta.gitSha === 'local'}
>Compare Commit
>Commit
${meta.gitSha === 'local'
? meta.gitSha
: `#${meta.gitSha.substring(0, 7)}`}</sbb-block-link
Expand Down
8 changes: 8 additions & 0 deletions src/visual-regression-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ function prepareScreenshots(): PluginOption {
baselineCommitUrl: `https://github.com/sbb-design-systems/lyne-components/commit/${meta.baselineGitSha}`,
} satisfies Meta;

if (viteConfig.command !== 'serve') {
this.emitFile({
type: 'asset',
fileName: 'meta.json',
source: JSON.stringify(meta),
});
}

return `export const meta = ${JSON.stringify(metaToWrite)};`;
}
},
Expand Down
2 changes: 1 addition & 1 deletion tools/web-test-runner/visual-regression-plugin-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let meta: Partial<Meta> = {

let baselineMeta;
try {
const response = await fetch(`${baselineUrl}screenshots/${metaFileName}`);
const response = await fetch(`${baselineUrl}${metaFileName}`);
baselineMeta = JSON.parse(await response.text()) satisfies Meta;
meta = { ...meta, baselineGitSha: baselineMeta.gitSha ?? 'N/A' };
} catch (e) {
Expand Down

0 comments on commit 848bd83

Please sign in to comment.