Skip to content

Commit

Permalink
fix(storybook): output should match CLI flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Jun 24, 2024
1 parent 8efe26c commit 46e510b
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe('Storybook - Convert To Inferred', () => {
"output-dir": "../../dist/storybook/apps/app1",
},
"outputs": [
"{projectRoot}/{options.outputDir}",
"{projectRoot}/{options.output-dir}",
"{workspaceRoot}/{projectRoot}/storybook-static",
"{options.output-dir}",
"{options.outputDir}",
Expand Down Expand Up @@ -311,7 +311,7 @@ describe('Storybook - Convert To Inferred', () => {
"output-dir": "../../dist/storybook/apps/app1",
},
"outputs": [
"{projectRoot}/{options.outputDir}",
"{projectRoot}/{options.output-dir}",
"{workspaceRoot}/{projectRoot}/storybook-static",
"{options.output-dir}",
"{options.outputDir}",
Expand Down Expand Up @@ -386,7 +386,7 @@ describe('Storybook - Convert To Inferred', () => {
"webpack-stats-json": true,
},
"outputs": [
"{projectRoot}/{options.outputDir}",
"{projectRoot}/{options.output-dir}",
"{workspaceRoot}/{projectRoot}/storybook-static",
"{options.output-dir}",
"{options.outputDir}",
Expand Down Expand Up @@ -445,7 +445,7 @@ describe('Storybook - Convert To Inferred', () => {
"output-dir": "../../dist/storybook/apps/app1",
},
"outputs": [
"{projectRoot}/{options.outputDir}",
"{projectRoot}/{options.output-dir}",
"{workspaceRoot}/{projectRoot}/storybook-static",
"{options.output-dir}",
"{options.outputDir}",
Expand Down Expand Up @@ -564,7 +564,7 @@ describe('Storybook - Convert To Inferred', () => {
"output-dir": "../../dist/storybook/apps/app1",
},
"outputs": [
"{projectRoot}/{options.outputDir}",
"{projectRoot}/{options.output-dir}",
"{workspaceRoot}/{projectRoot}/storybook-static",
"{options.output-dir}",
"{options.outputDir}",
Expand Down Expand Up @@ -596,7 +596,7 @@ describe('Storybook - Convert To Inferred', () => {
"output-dir": "../../dist/storybook/apps/project2",
},
"outputs": [
"{projectRoot}/{options.outputDir}",
"{projectRoot}/{options.output-dir}",
"{workspaceRoot}/{projectRoot}/storybook-static",
"{options.output-dir}",
"{options.outputDir}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ describe('buildPostTargetTransformer', () => {
export default config;"
`);
expect(target).toMatchInlineSnapshot(`
{
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
}
`);
{
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
"outputs": [
"{projectRoot}/{options.output-dir}",
"{projectRoot}/{options.outputDir}",
],
}
`);
});

it('should handle configurations correctly and migrate docsMode and staticDir to storybook config correctly', () => {
Expand Down Expand Up @@ -157,19 +161,23 @@ describe('buildPostTargetTransformer', () => {
export default config;"
`);
expect(target).toMatchInlineSnapshot(`
{
"configurations": {
"dev": {
"config-dir": "./dev/.storybook",
"output-dir": "../../dist/storybook/myapp/dev",
},
},
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
}
`);
{
"configurations": {
"dev": {
"config-dir": "./dev/.storybook",
"output-dir": "../../dist/storybook/myapp/dev",
},
},
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
"outputs": [
"{projectRoot}/{options.output-dir}",
"{projectRoot}/{options.outputDir}",
],
}
`);
const devConfigFile = tree.read(
'apps/myapp/dev/.storybook/main.ts',
'utf-8'
Expand Down Expand Up @@ -262,13 +270,17 @@ describe('buildPostTargetTransformer', () => {
export default config;"
`);
expect(target).toMatchInlineSnapshot(`
{
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
}
`);
{
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
"outputs": [
"{projectRoot}/{options.output-dir}",
"{projectRoot}/{options.outputDir}",
],
}
`);
});

it('should handle configurations correctly and migrate docsMode and staticDir to storybook config correctly', () => {
Expand Down Expand Up @@ -349,19 +361,23 @@ describe('buildPostTargetTransformer', () => {
export default config;"
`);
expect(target).toMatchInlineSnapshot(`
{
"configurations": {
"dev": {
"config-dir": "./dev/.storybook",
"output-dir": "../../dist/storybook/myapp/dev",
},
},
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
}
`);
{
"configurations": {
"dev": {
"config-dir": "./dev/.storybook",
"output-dir": "../../dist/storybook/myapp/dev",
},
},
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
"outputs": [
"{projectRoot}/{options.output-dir}",
"{projectRoot}/{options.outputDir}",
],
}
`);
const devConfigFile = tree.read(
'apps/myapp/dev/.storybook/main.ts',
'utf-8'
Expand Down Expand Up @@ -454,13 +470,17 @@ describe('buildPostTargetTransformer', () => {
export default config;"
`);
expect(target).toMatchInlineSnapshot(`
{
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
}
`);
{
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
"outputs": [
"{projectRoot}/{options.output-dir}",
"{projectRoot}/{options.outputDir}",
],
}
`);
});

it('should handle configurations correctly and migrate docsMode and staticDir to storybook config correctly', () => {
Expand Down Expand Up @@ -541,19 +561,23 @@ describe('buildPostTargetTransformer', () => {
export default config;"
`);
expect(target).toMatchInlineSnapshot(`
{
"configurations": {
"dev": {
"config-dir": "./dev/.storybook",
"output-dir": "../../dist/storybook/myapp/dev",
},
},
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
}
`);
{
"configurations": {
"dev": {
"config-dir": "./dev/.storybook",
"output-dir": "../../dist/storybook/myapp/dev",
},
},
"options": {
"config-dir": ".storybook",
"output-dir": "../../dist/storybook/myapp",
},
"outputs": [
"{projectRoot}/{options.output-dir}",
"{projectRoot}/{options.outputDir}",
],
}
`);
const devConfigFile = tree.read(
'apps/myapp/dev/.storybook/main.ts',
'utf-8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function buildPostTargetTransformer(migrationLogs: AggregatedLog) {
if (target.outputs) {
processTargetOutputs(
target,
[{ newName: 'outputDir', oldName: 'outputDir' }],
[{ newName: 'output-dir', oldName: 'outputDir' }],
inferredTargetConfiguration,
{
projectName: projectDetails.projectName,
Expand Down

0 comments on commit 46e510b

Please sign in to comment.