Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 42 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 1x 1x 4x 4x 1x 1x 5x 5x 5x 5x 5x 3x 2x 5x 5x 1x 1x 1x 5x 5x 5x 5x | import { type ListOptions, ListSection } from './list-section.js';
import { heading } from '../elements/heading.js';
interface EnvironmentVariable {
name: string;
defaultValue?: string;
}
export interface EnvironmentVariablesOptions
extends Partial<ListOptions<EnvironmentVariable>> {}
export class EnvironmentVariables extends ListSection<EnvironmentVariable> {
constructor(options?: EnvironmentVariablesOptions) {
super({
title: options?.title ?? 'Environment Variables',
type: 'None',
...options,
});
}
protected itemMapper(item: EnvironmentVariable): string {
return `${item.name}=${item.defaultValue ?? ''}`;
}
protected synthesizeContent(): string[] {
return [
heading(this.headingLevel, this.title),
'',
`To run this project, you will need to add the following environment variables to your .env file`,
...(this.items.length
? ['', '```bash', this.items.map(this.itemMapper).join('\n'), '```']
: []),
];
}
}
export function environmentVariablesSection(
options?: EnvironmentVariablesOptions,
) {
return new EnvironmentVariables(options);
}
|