-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
/
data.ts
41 lines (35 loc) · 1.16 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
41
import { basename } from 'path';
import type { Options } from '@storybook/types';
import { getRefs } from '@storybook/core-common';
import { readTemplate } from './template';
import { executor, getConfig } from '../index';
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('docs', {});
const tagsOptions = options.presets.apply('tags', {});
const template = readTemplate('template.ejs');
const customHead = options.presets.apply<string>('managerHead');
// 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,
tagsOptions,
};
};