-
-
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 #15928 from storybookjs/tech/babel-mode-v7
Core: Add Babel mode v7
- Loading branch information
Showing
35 changed files
with
731 additions
and
511 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { writeFile, access } from 'fs-extra'; | ||
import { logger } from '@storybook/node-logger'; | ||
import { getStorybookBabelConfig } from '@storybook/core-common'; | ||
import path from 'path'; | ||
import prompts from 'prompts'; | ||
|
||
export const generateStorybookBabelConfigInCWD = async () => { | ||
const target = process.cwd(); | ||
return generateStorybookBabelConfig({ target }); | ||
}; | ||
export const generateStorybookBabelConfig = async ({ target }: { target: string }) => { | ||
logger.info(`Generating the storybook default babel config at ${target}`); | ||
|
||
const config = getStorybookBabelConfig({ local: true }); | ||
const contents = JSON.stringify(config, null, 2); | ||
|
||
const fileName = '.babelrc.json'; | ||
const location = path.join(target, fileName); | ||
|
||
const exists = await access(location).then( | ||
() => true, | ||
() => false | ||
); | ||
|
||
if (exists) { | ||
const { overwrite } = await prompts({ | ||
type: 'confirm', | ||
initial: true, | ||
name: 'overwrite', | ||
message: `${fileName} already exists. Would you like overwrite it?`, | ||
}); | ||
|
||
if (overwrite === false) { | ||
logger.warn(`Cancelled, babel config file was NOT written to file-system.`); | ||
return; | ||
} | ||
} | ||
|
||
logger.info(`Writing file to ${location}`); | ||
await writeFile(location, contents); | ||
}; |
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
Oops, something went wrong.