import normalizePath from 'normalize-path'; import type { Node } from 'typescript'; import upath from 'upath'; import { SourceMeta } from '../../plugins/ComponentMeta.js'; export function buildSourceMetaFromNode(node: Node): SourceMeta { const sourceFile = node.getSourceFile(); const sourceFilePath = normalizePath(sourceFile.fileName); const sourceFileInfo = upath.parse(sourceFilePath); return { node: sourceFile, file: sourceFile, fileBase: sourceFileInfo.base, fileName: sourceFileInfo.name, filePath: sourceFilePath, fileExt: sourceFileInfo.ext, dirName: upath.basename(sourceFileInfo.dir), dirPath: sourceFileInfo.dir, }; }