1- import { mkdir , readdir , rm , writeFile } from 'node:fs/promises' ;
1+ import { mkdir , readdir , readFile , rm , writeFile } from 'node:fs/promises' ;
22import path from 'node:path' ;
33import { fileURLToPath } from 'node:url' ;
44import { spawnSync } from 'node:child_process' ;
@@ -254,6 +254,23 @@ function renderIndexPage({ branchName, commitSha, buildTimestamp }) {
254254` ;
255255}
256256
257+ const TESTENV_HIDE_HEADER_STYLE = `
258+ <style data-testenv-hide-header>
259+ .header {
260+ display: none !important;
261+ }
262+ </style>` ;
263+
264+ async function hideTopHeaderInBuiltPage ( pagePath ) {
265+ const html = await readFile ( pagePath , 'utf8' ) ;
266+ if ( html . includes ( 'data-testenv-hide-header' ) ) {
267+ return ;
268+ }
269+
270+ const nextHtml = html . replace ( '</head>' , `${ TESTENV_HIDE_HEADER_STYLE } \n </head>` ) ;
271+ await writeFile ( pagePath , nextHtml , 'utf8' ) ;
272+ }
273+
257274await clearDirectoryContents ( outputDir ) ;
258275
259276const buildMetadata = resolveBuildMetadata ( ) ;
@@ -272,6 +289,9 @@ runCommand('pnpm', [
272289
273290runCommand ( 'pnpm' , [ 'exec' , 'storybook' , 'build' , '--output-dir' , storybookDir ] ) ;
274291
292+ await hideTopHeaderInBuiltPage ( path . join ( outputDir , 'app.html' ) ) ;
293+ await hideTopHeaderInBuiltPage ( path . join ( outputDir , 'generator.html' ) ) ;
294+
275295await writeFile ( path . join ( outputDir , 'index.html' ) , renderIndexPage ( buildMetadata ) , 'utf8' ) ;
276296
277297console . log ( `Created test environment in ${ outputDir } ` ) ;
0 commit comments