-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathis-manifest-available.ts
More file actions
34 lines (30 loc) · 1002 Bytes
/
is-manifest-available.ts
File metadata and controls
34 lines (30 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { Options } from 'storybook/internal/types';
export type ManifestStatus = {
available: boolean;
hasManifests: boolean;
hasFeatureFlag: boolean;
};
export const getManifestStatus = async (options: Options): Promise<ManifestStatus> => {
const [
features,
manifests,
// Added for backwards compatibility with Storybook versions prior to v10.2.0-alpha.10
// Should be removed once support for Storybook version < 10.2.0 is dropped
legacyComponentManifestGenerator,
] = await Promise.all([
options.presets.apply('features') as any,
options.presets.apply('experimental_manifests', undefined, {
manifestEntries: [],
}),
options.presets.apply('experimental_componentManifestGenerator'),
]);
const hasManifests = !!manifests || !!legacyComponentManifestGenerator;
const hasFeatureFlag = !!(
features?.componentsManifest ?? features?.experimentalComponentsManifest
);
return {
available: hasFeatureFlag && hasManifests,
hasManifests,
hasFeatureFlag,
};
};