Skip to content

Commit

Permalink
Merge pull request #18728 from storybookjs/export-other-constants-for…
Browse files Browse the repository at this point in the history
…-manager

Set other manager-side constants in build
  • Loading branch information
ndelangen authored Jul 18, 2022
2 parents 3cacf9f + c57358f commit 58acdd0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
22 changes: 20 additions & 2 deletions lib/builder-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,16 @@ const starter: StarterFunction = async function* starterGeneratorFn({

yield;

const html = await renderHTML(template, title, customHead, addonFiles, features, refs, logLevel);
const html = await renderHTML(
template,
title,
customHead,
addonFiles,
features,
refs,
logLevel,
options
);

yield;

Expand Down Expand Up @@ -162,7 +171,16 @@ const builder: BuilderFunction = async function* builderGeneratorFn({ startTime,
const managerFiles = copy(coreDirOrigin, coreDirTarget);
const addonFiles = readDeep(addonsDir);

const html = await renderHTML(template, title, customHead, addonFiles, features, refs, logLevel);
const html = await renderHTML(
template,
title,
customHead,
addonFiles,
features,
refs,
logLevel,
options
);

yield;

Expand Down
11 changes: 9 additions & 2 deletions lib/builder-manager/src/utils/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readFile, pathExists } from 'fs-extra';

import { render } from 'ejs';

import type { Ref } from '@storybook/core-common';
import type { Options, Ref } from '@storybook/core-common';

import { readDeep } from './directory';

Expand Down Expand Up @@ -55,7 +55,8 @@ export const renderHTML = async (
files: ReturnType<typeof readDeep>,
features: Promise<Record<string, any>>,
refs: Promise<Record<string, Ref>>,
logLevel: Promise<string>
logLevel: Promise<string>,
{ versionCheck, releaseNotesData, docsMode, previewUrl, serverChannelUrl }: Options
) => {
const customHeadRef = await customHead;
const titleRef = await title;
Expand All @@ -72,6 +73,12 @@ export const renderHTML = async (
FEATURES: JSON.stringify(await features, null, 2),
REFS: JSON.stringify(await refs, null, 2),
LOGLEVEL: JSON.stringify(await logLevel, null, 2),
// These two need to be double stringified because the UI expects a string
VERSIONCHECK: JSON.stringify(JSON.stringify(versionCheck), null, 2),
RELEASE_NOTES_DATA: JSON.stringify(JSON.stringify(releaseNotesData), null, 2),
DOCS_MODE: JSON.stringify(docsMode, null, 2), // global docs mode
PREVIEW_URL: JSON.stringify(previewUrl, null, 2), // global preview URL
SERVER_CHANNEL_URL: JSON.stringify(serverChannelUrl, null, 2),
},
head: customHeadRef ? await readFile(customHeadRef, 'utf8') : '',
});
Expand Down

0 comments on commit 58acdd0

Please sign in to comment.