diff --git a/.github/workflows/generate-sandboxes.yml b/.github/workflows/generate-sandboxes.yml index 3e86e63c2547..f25c744697e6 100644 --- a/.github/workflows/generate-sandboxes.yml +++ b/.github/workflows/generate-sandboxes.yml @@ -6,9 +6,9 @@ on: workflow_dispatch: # To test fixes on push rather than wait for the scheduling, do the following: # 1. Uncomment the lines below and add your branch. - # push: - # branches: - # - + push: + branches: + - yann/fix-sandbox-generation-2 # 2. Change the "ref" value to in the actions/checkout step below. # 3. Comment out the whole "generate-main" job starting at line 77 # 4. 👉 DON'T FORGET TO UNDO THE STEPS BEFORE YOU MERGE YOUR CHANGES! @@ -27,9 +27,26 @@ jobs: if: github.repository_owner == 'storybookjs' runs-on: ubuntu-latest steps: + - name: Remove unnecessary files to release disk space + working-directory: ${{ github.workspace }} + run: | + sudo rm -rf \ + /opt/ghc \ + /opt/google/chrome \ + /opt/microsoft/msedge \ + /opt/microsoft/powershell \ + /usr/lib/mono \ + /usr/local/julia* \ + /usr/local/lib/android \ + /usr/local/share/chromium \ + /usr/local/share/powershell \ + /usr/local/share/powershell \ + /usr/share/dotnet \ + /usr/share/swift + - uses: actions/checkout@v4 with: - ref: next + ref: yann/fix-sandbox-generation-2 - uses: actions/setup-node@v4 with: @@ -80,9 +97,25 @@ jobs: if: github.repository_owner == 'storybookjs' runs-on: ubuntu-latest steps: + - name: Remove unnecessary files to release disk space + working-directory: ${{ github.workspace }} + run: | + sudo rm -rf \ + /opt/ghc \ + /opt/google/chrome \ + /opt/microsoft/msedge \ + /opt/microsoft/powershell \ + /usr/lib/mono \ + /usr/local/julia* \ + /usr/local/lib/android \ + /usr/local/share/chromium \ + /usr/local/share/powershell \ + /usr/local/share/powershell \ + /usr/share/dotnet \ + /usr/share/swift - uses: actions/checkout@v4 with: - ref: main + ref: yann/fix-sandbox-generation-2 - uses: actions/setup-node@v4 with: diff --git a/code/core/src/core-server/utils/__search-files-tests__/src/node_modules/file-in-common.js b/code/core/src/core-server/utils/__search-files-tests__/src/node_modules/file-in-common.js deleted file mode 100644 index 1626d1e76d96..000000000000 --- a/code/core/src/core-server/utils/__search-files-tests__/src/node_modules/file-in-common.js +++ /dev/null @@ -1,3 +0,0 @@ -export default () => { - return 'commonjs-default'; -} \ No newline at end of file diff --git a/code/lib/cli-storybook/src/sandbox-templates.ts b/code/lib/cli-storybook/src/sandbox-templates.ts index 82b5d94d6939..c6a7f29ebbcd 100644 --- a/code/lib/cli-storybook/src/sandbox-templates.ts +++ b/code/lib/cli-storybook/src/sandbox-templates.ts @@ -491,7 +491,7 @@ export const baseTemplates = { builder: 'storybook-builder-rsbuild', }, modifications: { - extraDependencies: ['prop-types', 'storybook-react-rsbuild@^3.0.0-beta.1'], + extraDependencies: ['prop-types'], useCsfFactory: true, mainConfig: { features: { @@ -598,10 +598,12 @@ export const baseTemplates = { builder: 'storybook-builder-rsbuild', }, modifications: { - extraDependencies: ['storybook-html-rsbuild@^3.0.0-beta.1'], skipMocking: true, }, skipTasks: ['e2e-tests', 'e2e-tests-dev', 'bench', 'vitest-integration'], + initOptions: { + type: ProjectType.HTML, + }, }, 'svelte-vite/default-js': { name: 'Svelte Latest (Vite | JavaScript)', @@ -696,7 +698,6 @@ export const baseTemplates = { builder: 'storybook-builder-rsbuild', }, modifications: { - extraDependencies: ['storybook-web-components-rsbuild@^3.0.0-beta.1'], skipMocking: true, }, skipTasks: ['e2e-tests', 'e2e-tests-dev', 'bench', 'vitest-integration'], diff --git a/code/lib/cli-storybook/src/sandbox.ts b/code/lib/cli-storybook/src/sandbox.ts index 9e4467f6260c..5bfcc854048f 100644 --- a/code/lib/cli-storybook/src/sandbox.ts +++ b/code/lib/cli-storybook/src/sandbox.ts @@ -1,5 +1,5 @@ import { existsSync } from 'node:fs'; -import { readdir, rm } from 'node:fs/promises'; +import { mkdir, readdir, rm } from 'node:fs/promises'; import { isAbsolute } from 'node:path'; import type { PackageManagerName } from 'storybook/internal/common'; @@ -199,7 +199,11 @@ export const sandbox = async ({ try { // Download the sandbox based on subfolder "after-storybook" and selected branch const gitPath = `storybookjs/sandboxes/tree/${branch}/${templateId}/${downloadType}`; - spawnSync('npx', ['gitpick@4.12.4', gitPath, templateDestination, '-o']); + // create `templateDestination` first + await mkdir(templateDestination, { recursive: true }); + spawnSync('npx', ['gitpick@4.12.4', gitPath, templateDestination, '-o'], { + stdio: 'inherit', + }); // throw an error if templateDestination is an empty directory if ((await readdir(templateDestination)).length === 0) { const selected = picocolors.yellow(templateId); diff --git a/scripts/check-dependencies.js b/scripts/check-dependencies.js index 95e2a88a10c1..1ee1bb870ef6 100644 --- a/scripts/check-dependencies.js +++ b/scripts/check-dependencies.js @@ -10,53 +10,32 @@ import { existsSync } from 'node:fs'; import { join } from 'node:path'; import * as url from 'node:url'; -const logger = console; - const dirname = url.fileURLToPath(new URL('.', import.meta.url)); -const checkDependencies = async () => { - const scriptsPath = join(dirname); - const codePath = join(dirname, '..', 'code'); +const ROOT_DIRECTORY = join(dirname, '..'); - const tasks = []; - - if (!existsSync(join(scriptsPath, 'node_modules'))) { - tasks.push( - spawn('yarn', ['install'], { - cwd: scriptsPath, - shell: true, - stdio: ['inherit', 'inherit', 'inherit'], - }) - ); - } - if (!existsSync(join(codePath, 'node_modules'))) { - tasks.push( - spawn('yarn', ['install'], { - cwd: codePath, - shell: true, - stdio: ['inherit', 'inherit', 'inherit'], - }) - ); - } +const logger = console; - if (tasks.length > 0) { +const checkDependencies = async () => { + if (!existsSync(join(ROOT_DIRECTORY, 'node_modules'))) { logger.log('installing dependencies'); - await Promise.all( - tasks.map( - (t) => - new Promise((res, rej) => { - t.on('exit', (code) => { - if (code !== 0) { - rej(); - } else { - res(); - } - }); - }) - ) - ).catch(() => { - tasks.forEach((t) => t.kill()); + const task = spawn('yarn', ['install'], { + cwd: ROOT_DIRECTORY, + shell: true, + stdio: ['inherit', 'inherit', 'inherit'], + }); + + await new Promise((res, rej) => { + task.on('exit', (code) => { + if (code !== 0) { + rej(); + } else { + res(); + } + }); + }).catch(() => { + task.kill(); throw new Error('Failed to install dependencies'); }); diff --git a/scripts/sandbox/generate.ts b/scripts/sandbox/generate.ts index 81d906001238..92d8676e9874 100755 --- a/scripts/sandbox/generate.ts +++ b/scripts/sandbox/generate.ts @@ -1,5 +1,6 @@ import { cp, mkdir, readdir, rename, rm, writeFile } from 'node:fs/promises'; import { readFile } from 'node:fs/promises'; +import { homedir } from 'node:os'; import { join, relative } from 'node:path'; import * as ghActions from '@actions/core'; @@ -196,6 +197,8 @@ const runGenerators = async ( limit(async () => { const baseDir = join(REPROS_DIRECTORY, dirName); const beforeDir = join(baseDir, BEFORE_DIR_NAME); + let createBaseDir: string | undefined; + try { let flags: string[] = ['--no-dev']; @@ -208,7 +211,7 @@ const runGenerators = async ( await emptyDir(baseDir); // We do the creation inside a temp dir to avoid yarn container problems - const createBaseDir = await temporaryDirectory(); + createBaseDir = await temporaryDirectory(); if (!script.includes('pnp')) { try { await setupYarn({ cwd: createBaseDir }); @@ -306,6 +309,15 @@ const runGenerators = async ( recursive: true, force: true, }); + await rm(join(homedir(), '.yarn', 'berry'), { + recursive: true, + force: true, + }); + } + + // Clean up the temporary base directory + if (createBaseDir) { + await rm(createBaseDir, { recursive: true, force: true }); } } })