Skip to content

Commit

Permalink
move templates to preview-api
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed May 26, 2023
1 parent 66edbab commit b9c3d16
Show file tree
Hide file tree
Showing 26 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions code/e2e-tests/preview-web.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.describe('preview-web', () => {

test('should pass over shortcuts, but not from play functions, story', async ({ page }) => {
const sbPage = new SbPage(page);
await sbPage.navigateToStory('lib/store/shortcuts', 'keydown-during-play');
await sbPage.navigateToStory('lib/preview-api/shortcuts', 'keydown-during-play');

await expect(sbPage.page.locator('.sidebar-container')).toBeVisible();

Expand All @@ -22,7 +22,7 @@ test.describe('preview-web', () => {

test('should pass over shortcuts, but not from play functions, docs', async ({ page }) => {
const sbPage = new SbPage(page);
await sbPage.navigateToStory('lib/store/shortcuts', 'docs');
await sbPage.navigateToStory('lib/preview-api/shortcuts', 'docs');

await expect(sbPage.page.locator('.sidebar-container')).toBeVisible();

Expand Down
8 changes: 4 additions & 4 deletions code/lib/core-server/src/utils/summarizeIndex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ describe('summarizeIndex', () => {
tags: ['autodocs', 'story'],
type: 'story',
},
'lib-store-shortcuts--docs': {
id: 'lib-store-shortcuts--docs',
title: 'lib/store/shortcuts',
'lib-preview-api-shortcuts--docs': {
id: 'lib-preview-api-shortcuts--docs',
title: 'lib/preview-api/shortcuts',
name: 'Docs',
importPath: './template-stories/lib/store/shortcuts.stories.ts',
importPath: './template-stories/lib/preview-api/shortcuts.stories.ts',
type: 'docs',
tags: ['autodocs', 'docs'],
storiesImports: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export default {

export const Default = {
play: async ({ title }: PlayFunctionContext<any>) => {
await expect(title).toBe('lib/store/autotitle');
await expect(title).toBe('lib/preview-api/autotitle');
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export default {

export const Default = {
play: async ({ title }: PlayFunctionContext<any>) => {
await expect(title).toBe('lib/store/manual title');
await expect(title).toBe('lib/preview-api/manual title');
},
};
14 changes: 7 additions & 7 deletions scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ async function linkPackageStories(
const storiesFolderName = variant ? getStoriesFolderWithVariant(variant) : 'stories';
const source = join(CODE_DIRECTORY, packageDir, 'template', storiesFolderName);
// By default we link `stories` directories
// e.g '../../../code/deprecated/store/template/stories' to 'template-stories/lib/store'
// if the directory <code>/lib/store/template/stories exists
// e.g '../../../code/lib/preview-api/template/stories' to 'template-stories/lib/preview-api'
// if the directory <code>/lib/preview-api/template/stories exists
//
// The files must be linked in the cwd, in order to ensure that any dependencies they
// reference are resolved in the cwd. In particular 'react' resolved by MDX files.
Expand All @@ -315,8 +315,8 @@ async function linkPackageStories(
}

// Add `previewAnnotation` entries of the form
// './template-stories/lib/store/preview.[tj]s'
// if the file <code>/lib/store/template/stories/preview.[jt]s exists
// './template-stories/lib/preview-api/preview.[tj]s'
// if the file <code>/lib/preview-api/template/stories/preview.[jt]s exists
await Promise.all(
['js', 'ts'].map(async (ext) => {
const previewFile = `preview.${ext}`;
Expand Down Expand Up @@ -384,7 +384,7 @@ export const addStories: Task['run'] = async (
const storiesVariantFolder = getStoriesFolderWithVariant(sandboxSpecificStoriesFolder);

if (isCoreRenderer) {
// Link in the template/components/index.js from store, the renderer and the addons
// Link in the template/components/index.js from preview-api, the renderer and the addons
const rendererPath = await workspacePath('renderer', template.expected.renderer);
await ensureSymlink(
join(CODE_DIRECTORY, rendererPath, 'template', 'components'),
Expand Down Expand Up @@ -450,9 +450,9 @@ export const addStories: Task['run'] = async (
}

if (isCoreRenderer) {
// Add stories for lib/store (and addons below). NOTE: these stories will be in the
// Add stories for lib/preview-api (and addons below). NOTE: these stories will be in the
// template-stories folder and *not* processed by the framework build config (instead by esbuild-loader)
await linkPackageStories(await workspacePath('core package', '@storybook/store'), {
await linkPackageStories(await workspacePath('core package', '@storybook/preview-api'), {
mainConfig,
cwd,
});
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/filterExistsInCodeDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import { pathExists } from 'fs-extra';
import { CODE_DIRECTORY } from './constants';

// packageDirs of the form `lib/store`
// packageDirs of the form `lib/preview-api`
// paths to check of the form 'template/stories'
export const filterExistsInCodeDir = async (packageDirs: string[], pathToCheck: string) =>
(
Expand Down

0 comments on commit b9c3d16

Please sign in to comment.