mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-18 05:02:24 +08:00
improve sb-scripts automigration logic
This commit is contained in:
parent
91659a8bf8
commit
51cf0dccae
@ -50,11 +50,12 @@ describe('getStorybookScripts', () => {
|
||||
})
|
||||
).toEqual({
|
||||
custom: {
|
||||
'sb:start': 'start-storybook',
|
||||
'sb:mocked': 'MOCKS=true start-storybook',
|
||||
},
|
||||
official: {
|
||||
'sb:start': 'start-storybook',
|
||||
'sb:build': 'build-storybook',
|
||||
},
|
||||
official: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -115,7 +116,7 @@ describe('sb scripts fix', () => {
|
||||
'sb:build': 'build-storybook -o buid/storybook',
|
||||
'sb:build-mocked': 'MOCKS=true sb:build',
|
||||
'test-storybook:ci':
|
||||
'concurrently -k -s first -n "SB,TEST" -c "magenta,blue" "yarn build-storybook --quiet && npx http-server storybook-static --port 6006 --silent" "wait-on tcp:6006 && yarn test-storybook"',
|
||||
'concurrently -k -s first -n "SB,TEST" -c "magenta,blue" "yarn sb:build --quiet && npx http-server storybook-static --port 6006 --silent" "wait-on tcp:6006 && yarn test-storybook"',
|
||||
},
|
||||
};
|
||||
|
||||
@ -127,13 +128,11 @@ describe('sb scripts fix', () => {
|
||||
).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
storybookScripts: {
|
||||
custom: {
|
||||
'sb:start': 'start-storybook -p 6006',
|
||||
'sb:build': 'build-storybook -o buid/storybook',
|
||||
'test-storybook:ci':
|
||||
'concurrently -k -s first -n "SB,TEST" -c "magenta,blue" "yarn build-storybook --quiet && npx http-server storybook-static --port 6006 --silent" "wait-on tcp:6006 && yarn test-storybook"',
|
||||
custom: {},
|
||||
official: {
|
||||
'sb:build': 'storybook build -o buid/storybook',
|
||||
'sb:start': 'storybook dev -p 6006',
|
||||
},
|
||||
official: {},
|
||||
},
|
||||
storybookVersion: '^7.0.0-alpha.0',
|
||||
})
|
||||
@ -153,7 +152,7 @@ describe('sb scripts fix', () => {
|
||||
'storybook:build': 'build-storybook -o buid/storybook',
|
||||
'storybook:build-mocked': 'MOCKS=true yarn storybook:build',
|
||||
'test-storybook:ci':
|
||||
'concurrently -k -s first -n "SB,TEST" -c "magenta,blue" "yarn build-storybook --quiet && npx http-server storybook-static --port 6006 --silent" "wait-on tcp:6006 && yarn test-storybook"',
|
||||
'concurrently -k -s first -n "SB,TEST" -c "magenta,blue" "yarn storybook:build-mocked --quiet && npx http-server storybook-static --port 6006 --silent" "wait-on tcp:6006 && yarn test-storybook"',
|
||||
},
|
||||
};
|
||||
it('should update scripts to new format', async () => {
|
||||
@ -164,12 +163,9 @@ describe('sb scripts fix', () => {
|
||||
).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
storybookScripts: {
|
||||
custom: {
|
||||
'storybook:build': 'build-storybook -o buid/storybook',
|
||||
'test-storybook:ci':
|
||||
'concurrently -k -s first -n "SB,TEST" -c "magenta,blue" "yarn build-storybook --quiet && npx http-server storybook-static --port 6006 --silent" "wait-on tcp:6006 && yarn test-storybook"',
|
||||
},
|
||||
custom: {},
|
||||
official: {
|
||||
'storybook:build': 'storybook build -o buid/storybook',
|
||||
storybook: 'storybook dev -p 6006',
|
||||
},
|
||||
},
|
||||
@ -204,8 +200,8 @@ describe('sb scripts fix', () => {
|
||||
storybook: '^7.0.0-alpha.0',
|
||||
},
|
||||
scripts: {
|
||||
storybook: 'npx sb dev -p 6006',
|
||||
'build-storybook': 'npx sb build -o build/storybook',
|
||||
storybook: 'storybook dev -p 6006',
|
||||
'build-storybook': 'storybook build -o build/storybook',
|
||||
},
|
||||
};
|
||||
it('should no-op', async () => {
|
||||
|
@ -24,7 +24,12 @@ export const getStorybookScripts = (scripts: Record<string, string>) => {
|
||||
};
|
||||
|
||||
Object.keys(scripts).forEach((key) => {
|
||||
if (key === 'storybook' || key === 'build-storybook') {
|
||||
if (
|
||||
key === 'storybook' ||
|
||||
key === 'build-storybook' ||
|
||||
scripts[key].startsWith('start-storybook') ||
|
||||
scripts[key].startsWith('build-storybook')
|
||||
) {
|
||||
storybookScripts.official[key] = scripts[key];
|
||||
} else if (scripts[key].match(/start-storybook/) || scripts[key].match(/build-storybook/)) {
|
||||
storybookScripts.custom[key] = scripts[key];
|
||||
|
Loading…
x
Reference in New Issue
Block a user