-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release: Prerelease 8.4.0-alpha.7 #29332
Changes from all commits
4c861a2
4e4716a
dcca2f0
d071ee9
e660a1a
e530835
e189008
c5e384e
0eb384b
93a24de
d60a9d7
7a27337
48915df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export default <T>(a: T[], b: T[]): T[] => { | ||
// no point in intersecting if one of the input is ill-defined | ||
if (!a || !b) { | ||
return []; | ||
} | ||
|
||
return a.reduce((acc: T[], aValue) => { | ||
if (b.includes(aValue)) { | ||
acc.push(aValue); | ||
} | ||
|
||
return acc; | ||
}, []); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import intersect from '../lib/intersect'; | ||
|
||
describe('Manager API utilities - intersect', () => { | ||
it('returns identity when intersecting identity', () => { | ||
const a = ['foo', 'bar']; | ||
expect(intersect(a, a)).toEqual(a); | ||
}); | ||
|
||
it('returns a when b is a superset of a', () => { | ||
const a = ['foo', 'bar']; | ||
const b = ['a', 'foo', 'b', 'bar', 'c', 'ter']; | ||
expect(intersect(a, b)).toEqual(a); | ||
}); | ||
|
||
it('returns b when a is a superset of b', () => { | ||
const a = ['a', 'foo', 'b', 'bar', 'c', 'ter']; | ||
const b = ['foo', 'bar']; | ||
expect(intersect(a, b)).toEqual(b); | ||
}); | ||
|
||
it('returns an intersection', () => { | ||
const a = ['a', 'bar', 'b', 'c']; | ||
const b = ['foo', 'bar', 'ter']; | ||
expect(intersect(a, b)).toEqual(['bar']); | ||
}); | ||
|
||
it('returns an empty set when there is no overlap', () => { | ||
const a = ['a', 'b', 'c']; | ||
const b = ['foo', 'bar', 'ter']; | ||
expect(intersect(a, b)).toEqual([]); | ||
}); | ||
|
||
it('returns an empty set if a is undefined', () => { | ||
const b = ['foo', 'bar', 'ter']; | ||
expect(intersect(undefined as unknown as [], b)).toEqual([]); | ||
}); | ||
|
||
it('returns an empty set if b is undefined', () => { | ||
const a = ['foo', 'bar', 'ter']; | ||
expect(intersect(a, undefined as unknown as [])).toEqual([]); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import type { JsPackageManager } from '@storybook/core/common'; | ||
|
||
import { getAddonSvelteCsfVersion } from './index'; | ||
|
||
describe('installed', () => { | ||
it.each([ | ||
['3.0.0', ''], | ||
['4.0.0', '4'], | ||
['5.0.0', '^5.0.0-next.0'], | ||
['6.0.0', ''], | ||
['3.0.0-next.0', ''], | ||
['4.0.0-next.0', '4'], | ||
['4.2.19::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fsvelte%2F-%2Fsvelte-4.2.19.tgz', '4'], | ||
['5.0.0-next.0', '^5.0.0-next.0'], | ||
['6.0.0-next.0', ''], | ||
])('svelte %s => %s', async (svelteVersion, expectedAddonSpecifier) => { | ||
const packageManager = { | ||
getInstalledVersion: async (pkg: string) => (pkg === 'svelte' ? svelteVersion : undefined), | ||
getAllDependencies: async () => ({ svelte: `^${svelteVersion}` }), | ||
} as any as JsPackageManager; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Avoid using 'any' type casting. Consider creating a mock object that implements the JsPackageManager interface |
||
await expect(getAddonSvelteCsfVersion(packageManager)).resolves.toBe(expectedAddonSpecifier); | ||
}); | ||
}); | ||
|
||
describe('uninstalled', () => { | ||
it.each([ | ||
['^3', ''], | ||
['^4', '4'], | ||
['^5', '^5.0.0-next.0'], | ||
['^6', ''], | ||
['^3.0.0-next.0', ''], | ||
['^4.0.0-next.0', '4'], | ||
['^5.0.0-next.0', '^5.0.0-next.0'], | ||
['^6.0.0-next.0', ''], | ||
])('svelte %s => %s', async (svelteSpecifier, expectedAddonSpecifier) => { | ||
const packageManager = { | ||
getInstalledVersion: async (pkg: string) => undefined, | ||
getAllDependencies: async () => ({ svelte: svelteSpecifier }), | ||
} as any as JsPackageManager; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Avoid using 'any' type casting here as well. Create a mock object implementing JsPackageManager |
||
await expect(getAddonSvelteCsfVersion(packageManager)).resolves.toBe(expectedAddonSpecifier); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,48 @@ | ||
import type { JsPackageManager } from 'storybook/internal/common'; | ||
|
||
import { coerce, major } from 'semver'; | ||
|
||
import { baseGenerator } from '../baseGenerator'; | ||
import type { Generator } from '../types'; | ||
|
||
const versionHelper = (svelteMajor?: number) => { | ||
if (svelteMajor === 4) { | ||
return '4'; | ||
} | ||
// TODO: update when addon-svelte-csf v5 is released | ||
if (svelteMajor === 5) { | ||
return '^5.0.0-next.0'; | ||
} | ||
return ''; | ||
}; | ||
Comment on lines
+8
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: consider using a switch statement for better readability and maintainability |
||
|
||
export const getAddonSvelteCsfVersion = async (packageManager: JsPackageManager) => { | ||
const svelteVersion = await packageManager.getInstalledVersion('svelte'); | ||
try { | ||
if (svelteVersion) { | ||
return versionHelper(major(coerce(svelteVersion) || '')); | ||
} else { | ||
const deps = await packageManager.getAllDependencies(); | ||
const svelteSpecifier = deps['svelte']; | ||
const coerced = coerce(svelteSpecifier); | ||
if (coerced?.version) { | ||
return versionHelper(major(coerced.version)); | ||
} | ||
} | ||
} catch { | ||
// fallback to latest version | ||
} | ||
return ''; | ||
}; | ||
|
||
const generator: Generator = async (packageManager, npmOptions, options) => { | ||
const addonSvelteCsfVersion = await getAddonSvelteCsfVersion(packageManager); | ||
|
||
await baseGenerator(packageManager, npmOptions, options, 'svelte', { | ||
extensions: ['js', 'ts', 'svelte'], | ||
extraAddons: ['@storybook/addon-svelte-csf'], | ||
extraAddons: [ | ||
`@storybook/addon-svelte-csf${addonSvelteCsfVersion && `@${addonSvelteCsfVersion}`}`, | ||
], | ||
}); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,5 +293,6 @@ | |
"Dependency Upgrades" | ||
] | ||
] | ||
} | ||
}, | ||
"deferredNextVersion": "8.4.0-alpha.7" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```shell renderer="common" language="js" packageManager="npm" | ||
npx storybook add @storybook/addon-a11y | ||
``` | ||
|
||
```shell renderer="common" language="js" packageManager="pnpm" | ||
pnpm exec storybook add @storybook/addon-a11y | ||
``` | ||
|
||
```shell renderer="common" language="js" packageManager="yarn" | ||
yarn exec storybook add @storybook/addon-a11y | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,3 @@ const config: StorybookConfig = { | |
|
||
export default config; | ||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":"8.4.0-alpha.6","info":{"plain":"- Addon-docs, blocks: Prebundle dependencies - [#29301](https://github.com/storybookjs/storybook/pull/29301), thanks @JReinhold!\n- React: Prebundle all of `renderers/react`'s dependencies - [#29298](https://github.com/storybookjs/storybook/pull/29298), thanks @ndelangen!\n- Vite: Cleanup and prebundle dependencies - [#29302](https://github.com/storybookjs/storybook/pull/29302), thanks @JReinhold!"}} | ||
{"version":"8.4.0-alpha.7","info":{"plain":"- CLI: Install Svelte CSF v5 in Svelte5 projects - [#29323](https://github.com/storybookjs/storybook/pull/29323), thanks @shilman!\n- Manager: Add tags property to ComponentEntry objects - [#29343](https://github.com/storybookjs/storybook/pull/29343), thanks @Sidnioulz!"}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a constant for this long URL to improve readability