-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
Copy pathdata.ts
40 lines (35 loc) · 1.22 KB
/
data.ts
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
35
36
37
38
39
40
import { basename, join } from 'path';
import type { DocsOptions, Options } from '@storybook/types';
import { getRefs } from '@storybook/core-common';
import { readTemplate } from './template';
// eslint-disable-next-line import/no-cycle
import { executor, getConfig } from '../index';
import { safeResolve } from './safeResolve';
export const getData = async (options: Options) => {
const refs = getRefs(options);
const favicon = options.presets.apply<string>('favicon').then((p) => basename(p));
const features = options.presets.apply<Record<string, string | boolean>>('features');
const logLevel = options.presets.apply<string>('logLevel');
const title = options.presets.apply<string>('title');
const docsOptions = options.presets.apply<DocsOptions>('docs', {});
const template = readTemplate('template.ejs');
const customHead = safeResolve(join(options.configDir, 'manager-head.html'));
// we await these, because crucially if these fail, we want to bail out asap
const [instance, config] = await Promise.all([
//
executor.get(),
getConfig(options),
]);
return {
refs,
features,
title,
docsOptions,
template,
customHead,
instance,
config,
logLevel,
favicon,
};
};