Skip to content

Commit

Permalink
fix: handle outside renderers in sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
literalpie committed Jan 18, 2023
1 parent d8944a5 commit c6e7a04
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
1 change: 1 addition & 0 deletions code/lib/cli/src/sandbox-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ const baseTemplates = {
name: 'Qwik CLI (Default TS)',
script: 'yarn create qwik basic {{beforeDir}} --no-install',
inDevelopment: true,
skipTasks: ['e2e-tests'],
expected: {
framework: 'storybook-framework-qwik',
renderer: 'storybook-framework-qwik',
Expand Down
65 changes: 35 additions & 30 deletions scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,47 +339,52 @@ export const addStories: Task['run'] = async (
const packageJson = await import(join(cwd, 'package.json'));
updateStoriesField(mainConfig, detectLanguage(packageJson) === SupportedLanguage.JAVASCRIPT);

// Link in the template/components/index.js from store, the renderer and the addons
const rendererPath = template.expected.renderer.startsWith('@storybook/')
? await workspacePath('renderer', template.expected.renderer)
: require.resolve(template.expected.renderer);
await ensureSymlink(
join(codeDir, rendererPath, 'template', 'components'),
resolve(cwd, storiesPath, 'components')
);
addPreviewAnnotations(mainConfig, [`.${sep}${join(storiesPath, 'components')}`]);

// Add stories for the renderer. NOTE: these *do* need to be processed by the framework build system
await linkPackageStories(rendererPath, {
mainConfig,
cwd,
linkInDir: resolve(cwd, storiesPath),
});

const frameworkPath = await workspacePath('frameworks', template.expected.framework);
const isCoreRenderer = template.expected.renderer.startsWith('@storybook/');
if (isCoreRenderer) {
// Link in the template/components/index.js from store, the renderer and the addons
const rendererPath = await workspacePath('renderer', template.expected.renderer);
await ensureSymlink(
join(codeDir, rendererPath, 'template', 'components'),
resolve(cwd, storiesPath, 'components')
);
addPreviewAnnotations(mainConfig, [`.${sep}${join(storiesPath, 'components')}`]);

// Add stories for the framework if it has one. NOTE: these *do* need to be processed by the framework build system
if (await pathExists(resolve(codeDir, frameworkPath, join('template', 'stories')))) {
await linkPackageStories(frameworkPath, {
// Add stories for the renderer. NOTE: these *do* need to be processed by the framework build system
await linkPackageStories(rendererPath, {
mainConfig,
cwd,
linkInDir: resolve(cwd, storiesPath),
});
}

const frameworkVariant = key.split('/')[1];
const storiesVariantFolder = addVariantToFolder(frameworkVariant);
const isCoreFramework = template.expected.framework.startsWith('@storybook/');

if (await pathExists(resolve(codeDir, frameworkPath, join('template', storiesVariantFolder)))) {
await linkPackageStories(
frameworkPath,
{
if (isCoreFramework) {
const frameworkPath = await workspacePath('frameworks', template.expected.framework);

// Add stories for the framework if it has one. NOTE: these *do* need to be processed by the framework build system
if (await pathExists(resolve(codeDir, frameworkPath, join('template', 'stories')))) {
await linkPackageStories(frameworkPath, {
mainConfig,
cwd,
linkInDir: resolve(cwd, storiesPath),
},
frameworkVariant
);
});
}

const frameworkVariant = key.split('/')[1];
const storiesVariantFolder = addVariantToFolder(frameworkVariant);

if (await pathExists(resolve(codeDir, frameworkPath, join('template', storiesVariantFolder)))) {
await linkPackageStories(
frameworkPath,
{
mainConfig,
cwd,
linkInDir: resolve(cwd, storiesPath),
},
frameworkVariant
);
}
}

// Add stories for lib/store (and addons below). NOTE: these stories will be in the
Expand Down

0 comments on commit c6e7a04

Please sign in to comment.