-
-
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 #22375 from storybookjs/norbert/fix-22348
CLI: Fix copyTemplate failures on `init`
- Loading branch information
Showing
13 changed files
with
93 additions
and
16 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
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 |
---|---|---|
@@ -1,16 +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'); | ||
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