From 52e09ee5f3ac034553f31bf728711ae3220c8717 Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Wed, 13 Dec 2023 16:19:47 +0100 Subject: [PATCH] wip --- node-src/lib/upload.ts | 6 ++++-- node-src/lib/utils.ts | 2 -- node-src/tasks/upload.test.ts | 8 ++++---- node-src/tasks/upload.ts | 5 +++-- node-src/types.ts | 1 + node-src/ui/messages/errors/fatalError.stories.ts | 3 ++- node-src/ui/messages/info/storybookPublished.stories.ts | 1 + 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/node-src/lib/upload.ts b/node-src/lib/upload.ts index f5ad83571..e9d354c93 100644 --- a/node-src/lib/upload.ts +++ b/node-src/lib/upload.ts @@ -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, })), @@ -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, })), diff --git a/node-src/lib/utils.ts b/node-src/lib/utils.ts index 7b36c0037..dd783734f 100644 --- a/node-src/lib/utils.ts +++ b/node-src/lib/utils.ts @@ -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 diff --git a/node-src/tasks/upload.test.ts b/node-src/tasks/upload.test.ts index 95b34985a..4bf979810 100644 --- a/node-src/tasks/upload.test.ts +++ b/node-src/tasks/upload.test.ts @@ -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( @@ -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, }); diff --git a/node-src/tasks/upload.ts b/node-src/tasks/upload.ts index 93903c3be..cacb17729 100644 --- a/node-src/tasks/upload.ts +++ b/node-src/tasks/upload.ts @@ -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'; @@ -205,7 +205,8 @@ export const uploadStorybook = async (ctx: Context, task: Task) => { transitionTo(preparing)(ctx, task); const files = ctx.fileInfo.paths - .map((path) => ({ + .map((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, diff --git a/node-src/types.ts b/node-src/types.ts index 5014f3205..4eee98335 100644 --- a/node-src/types.ts +++ b/node-src/types.ts @@ -354,6 +354,7 @@ export interface Stats { } export interface FileDesc { + contentHash?: string; contentLength: number; localPath: string; targetPath: string; diff --git a/node-src/ui/messages/errors/fatalError.stories.ts b/node-src/ui/messages/errors/fatalError.stories.ts index f77db2c3b..77a8a4f6a 100644 --- a/node-src/ui/messages/errors/fatalError.stories.ts +++ b/node-src/ui/messages/errors/fatalError.stories.ts @@ -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! diff --git a/node-src/ui/messages/info/storybookPublished.stories.ts b/node-src/ui/messages/info/storybookPublished.stories.ts index 9dbee8d3a..72826e373 100644 --- a/node-src/ui/messages/info/storybookPublished.stories.ts +++ b/node-src/ui/messages/info/storybookPublished.stories.ts @@ -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);