import buildDebug from 'debug'; import { TemplateUIOptions } from '@verdaccio/types'; import { Manifest, getManifestValue } from './utils/manifest'; const debug = buildDebug('verdaccio:web:render:template'); export type Template = { manifest: Manifest; options: TemplateUIOptions; metaScripts?: string[]; scriptsBodyAfter?: string[]; scriptsbodyBefore?: string[]; }; // the outcome of the Webpack Manifest Plugin export interface WebpackManifest { [key: string]: string; } export default function renderTemplate(template: Template, manifest: WebpackManifest) { debug('template %o', template); debug('manifest %o', manifest); return ` ${template?.options?.title ?? ''} ${template?.metaScripts ? template.metaScripts.join('') : ''} ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}
${getManifestValue(template.manifest.js, manifest, template?.options.base) .map((item) => ``) .join('')} ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''} `; }