-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22443 from storybookjs/shilman/fix-cli-server-init
CLI: Fix server init
- Loading branch information
Showing
11 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
import { join } from 'path'; | ||
import { baseGenerator } from '../baseGenerator'; | ||
import type { Generator } from '../types'; | ||
import { copyTemplate } from '../../helpers'; | ||
import { getCliDir } from '../../dirs'; | ||
|
||
const generator: Generator = async (packageManager, npmOptions, options) => { | ||
await baseGenerator(packageManager, npmOptions, options, 'server', { | ||
extensions: ['json'], | ||
}); | ||
|
||
const templateDir = join(getCliDir(), 'templates', 'server'); | ||
if (templateDir) { | ||
copyTemplate(templateDir); | ||
} | ||
}; | ||
|
||
export default generator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./dist/preset'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import fs from 'fs-extra'; | ||
import { toId } from '@storybook/csf'; | ||
import type { StaticMeta } from '@storybook/csf-tools'; | ||
import type { IndexerOptions, IndexedStory, StoryIndexer } from '@storybook/types'; | ||
|
||
export const storyIndexers = (indexers: StoryIndexer[] | null) => { | ||
const jsonIndexer = async (fileName: string, opts: IndexerOptions) => { | ||
const json = await fs.readJson(fileName, 'utf-8'); | ||
const meta: StaticMeta = { | ||
title: json.title, | ||
}; | ||
const stories: IndexedStory[] = json.stories.map((story: { name: string }) => { | ||
const id = toId(meta.title, story.name); | ||
const { name } = story; | ||
const indexedStory: IndexedStory = { | ||
id, | ||
name, | ||
}; | ||
return indexedStory; | ||
}); | ||
return { | ||
meta, | ||
stories, | ||
}; | ||
}; | ||
return [ | ||
{ | ||
test: /(stories|story)\.json$/, | ||
indexer: jsonIndexer, | ||
}, | ||
...(indexers || []), | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters