@shibi-snowball/c3-shared
Version:
43 lines (37 loc) • 1.26 kB
JavaScript
import { fileMap } from './constants.js'
import path from 'path'
import fs from 'fs'
const getFileMap = (projectTarget) => {
return fileMap[projectTarget]
}
const getMandatoryModules = (projectTarget) => {
const fileMap = getFileMap(projectTarget)
return fileMap.reduce((mandatoryModules, module) => {
const { c3Component, isMandatory } = module
mandatoryModules[c3Component] = isMandatory
return mandatoryModules
}, {})
}
const getC3Config = (projectTarget) => {
const c3Config = getFileMap(projectTarget).reduce((c3Config, component) => {
const { c3Component, c3ComponentKey, moduleName, moduleFolderPath } =
component
c3Config[c3Component] = {
path: `${moduleFolderPath}/${moduleName}`,
c3ComponentKey,
}
return c3Config
}, {})
return c3Config
}
const getAsciiArtText = () => {
const currentFileUrl = new URL(import.meta.url)
const asciiArtPath = path.join(
path.dirname(currentFileUrl.pathname),
'../assets',
'kf-logo-ascii-art.txt'
)
const asciiArtText = fs.readFileSync(asciiArtPath, 'utf8')
return asciiArtText
}
export { getFileMap, getC3Config, getMandatoryModules, getAsciiArtText }