Skip to content

Commit

Permalink
Merge branch 'main' into codacy-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld authored Mar 13, 2024
2 parents 2332ecb + 419e60d commit 3f49d13
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion node-src/tasks/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { uploadBuild } from '../lib/upload';
import { getFileHashes } from '../lib/getFileHashes';
import { waitForSentinel } from '../lib/waitForSentinel';
import { checkStorybookBaseDir } from '../lib/checkStorybookBaseDir';
import semver from 'semver';

interface PathSpec {
pathname: string;
Expand Down Expand Up @@ -108,8 +109,12 @@ export const traceChangedFiles = async (ctx: Context, task: Task) => {
if (!ctx.turboSnap || ctx.turboSnap.unavailable) return;
if (!ctx.git.changedFiles) return;
if (!ctx.fileInfo.statsPath) {
// If we don't know the SB version, we should assume we don't support `--stats-json`
const nonLegacyStatsSupported =
ctx.storybook?.version && semver.gte(semver.coerce(ctx.storybook.version), '8.0.0');

ctx.turboSnap.bailReason = { missingStatsFile: true };
throw new Error(missingStatsFile());
throw new Error(missingStatsFile({ legacy: !nonLegacyStatsSupported }));
}

transitionTo(tracing)(ctx, task);
Expand Down
4 changes: 3 additions & 1 deletion node-src/ui/messages/errors/missingStatsFile.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ export default {
title: 'CLI/Messages/Errors',
};

export const MissingStatsFile = () => missingStatsFile();
export const MissingStatsFile = () => missingStatsFile({ legacy: false });

export const MissingStatsFileLegacy = () => missingStatsFile({ legacy: true });
6 changes: 4 additions & 2 deletions node-src/ui/messages/errors/missingStatsFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { dedent } from 'ts-dedent';

import { error } from '../../components/icons';

export default () =>
export default ({ legacy }: { legacy: boolean }) =>
dedent(chalk`
${error} {bold TurboSnap disabled due to missing stats file}
Did not find {bold preview-stats.json} in your built Storybook.
Make sure you pass {bold --webpack-stats-json} when building your Storybook.
Make sure you pass {bold ${
legacy ? `--webpack-stats-json` : `--stats-json`
}} when building your Storybook.
`);

0 comments on commit 3f49d13

Please sign in to comment.