Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Dec 13, 2023
1 parent 910483c commit 52e09ee
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
6 changes: 4 additions & 2 deletions node-src/lib/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export async function uploadBuild(
UploadBuildMutation,
{
buildId: ctx.announcedBuild.id,
files: files.map(({ contentLength, targetPath }) => ({
files: files.map(({ contentHash, contentLength, targetPath }) => ({
contentHash,
contentLength,
filePath: targetPath,
})),
Expand Down Expand Up @@ -178,7 +179,8 @@ export async function uploadMetadata(ctx: Context, files: FileDesc[]) {
UploadMetadataMutation,
{
buildId: ctx.announcedBuild.id,
files: files.map(({ contentLength, targetPath }) => ({
files: files.map(({ contentHash, contentLength, targetPath }) => ({
contentHash,
contentLength,
filePath: targetPath,
})),
Expand Down
2 changes: 0 additions & 2 deletions node-src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export const activityBar = (n = 0, size = 20) => {
return `[${track.join('')}]`;
};

export const baseStorybookUrl = (url: string) => url?.replace(/\/iframe\.html$/, '');

export const rewriteErrorMessage = (err: Error, message: string) => {
try {
// DOMException doesn't allow setting the message, so this might fail
Expand Down
8 changes: 4 additions & 4 deletions node-src/tasks/upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ describe('uploadStorybook', () => {
expect(client.runQuery).toHaveBeenCalledWith(expect.stringMatching(/UploadBuildMutation/), {
buildId: '1',
files: [
{ contentLength: 42, filePath: 'iframe.html' },
{ contentLength: 42, filePath: 'index.html' },
{ contentHash: undefined, contentLength: 42, filePath: 'iframe.html' },
{ contentHash: undefined, contentLength: 42, filePath: 'index.html' },
],
});
expect(http.fetch).toHaveBeenCalledWith(
Expand Down Expand Up @@ -468,8 +468,8 @@ describe('uploadStorybook', () => {
expect(client.runQuery).toHaveBeenCalledWith(expect.stringMatching(/UploadBuildMutation/), {
buildId: '1',
files: [
{ contentLength: 42, filePath: 'iframe.html' },
{ contentLength: 42, filePath: 'index.html' },
{ contentHash: undefined, contentLength: 42, filePath: 'iframe.html' },
{ contentHash: undefined, contentLength: 42, filePath: 'index.html' },
],
zip: true,
});
Expand Down
5 changes: 3 additions & 2 deletions node-src/tasks/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
success,
hashing,
} from '../ui/tasks/upload';
import { Context, Task } from '../types';
import { Context, FileDesc, Task } from '../types';
import { readStatsFile } from './read-stats-file';
import bailFile from '../ui/messages/warnings/bailFile';
import { findChangedPackageFiles } from '../lib/findChangedPackageFiles';
Expand Down Expand Up @@ -205,7 +205,8 @@ export const uploadStorybook = async (ctx: Context, task: Task) => {
transitionTo(preparing)(ctx, task);

const files = ctx.fileInfo.paths
.map((path) => ({
.map<FileDesc>((path) => ({
...(ctx.fileInfo.hashes && { contentHash: ctx.fileInfo.hashes[path] }),
contentLength: ctx.fileInfo.lengths.find(({ knownAs }) => knownAs === path).contentLength,
localPath: join(ctx.sourceDir, path),
targetPath: path,
Expand Down
1 change: 1 addition & 0 deletions node-src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ export interface Stats {
}

export interface FileDesc {
contentHash?: string;
contentLength: number;
localPath: string;
targetPath: string;
Expand Down
3 changes: 2 additions & 1 deletion node-src/ui/messages/errors/fatalError.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ const context = {
build: {
id: '5ec5069ae0d35e0022b6a9cc',
number: 42,
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/',
webUrl: 'https://www.chromatic.com/build?appId=5d67dc0374b2e300209c41e7&number=1400',
},
storybookUrl: 'https://pfkaemtlit.tunnel.chromaticqa.com/',
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/',
};

const stack = `Error: Oh no!
Expand Down
1 change: 1 addition & 0 deletions node-src/ui/messages/info/storybookPublished.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const StorybookPrepared = () =>
errorCount: undefined,
componentCount: 5,
specCount: 8,
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/',
},
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/',
} as any);

0 comments on commit 52e09ee

Please sign in to comment.