How to use @uiengine/util - 10 common examples

To help you get started, we’ve selected a few @uiengine/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dennisreimann / uiengine / packages / core / src / configuration.js View on Github external
async function read (flags = {}) {
  // do not cache and clesar require cache, because of incremental builds
  const explorer = cosmiconfig('uiengine', { cache: false, rcExtensions: true })
  const configPath = resolvePath(process.cwd(), flags.config || 'uiengine.config.js')

  try {
    invalidateRequireCache(configPath)
    const result = await explorer.load(configPath)

    if (result) {
      return _read(result.filepath, result.config, flags)
    } else {
      throw new UiengineInputError(`No configuration found. Please specify it in "${configPath}".`)
    }
  } catch (err) {
    throw new UiengineInputError('Could not read UIengine configuration!', err)
  }
}
github dennisreimann / uiengine / packages / core / src / configuration.js View on Github external
async function read (flags = {}) {
  // do not cache and clesar require cache, because of incremental builds
  const explorer = cosmiconfig('uiengine', { cache: false, rcExtensions: true })
  const configPath = resolvePath(process.cwd(), flags.config || 'uiengine.config.js')

  try {
    invalidateRequireCache(configPath)
    const result = await explorer.load(configPath)

    if (result) {
      return _read(result.filepath, result.config, flags)
    } else {
      throw new UiengineInputError(`No configuration found. Please specify it in "${configPath}".`)
    }
  } catch (err) {
    throw new UiengineInputError('Could not read UIengine configuration!', err)
  }
}
github dennisreimann / uiengine / packages / ui / src / vue / router / index.js View on Github external
const mainComponent = type => {
  if (type === 'documentation') {
    return MainDocumentation
  }

  const componentName = upcaseFirstChar(type)

  return () => import(
    /* webpackPrefetch: true */
    /* webpackChunkName: "[request]" */
    `../components/Main${componentName}`
  )
}
github dennisreimann / uiengine / packages / ui / src / vue / store / preferences.js View on Github external
const mutations = Object.keys(properties).reduce((obj, property) => {
  const upcased = upcaseFirstChar(property)
  const setter = `set${upcased}`

  obj[setter] = (state, value) => {
    // set value in session storage
    setSession(property, value)

    state[property] = reactiveValue(value)
  }

  return obj
}, {})
github dennisreimann / uiengine / packages / core / src / component.js View on Github external
const { base, components } = state.config.source
  const configPath = componentIdToFilePath(components, id)
  const dir = dirname(configPath)
  const readmePath = join(dir, COMPONENT_DOCSNAME)
  const sourcePath = crossPlatformPath(relative(base, dir))
  const data = { attributes: {}, sourcePath }

  // config
  if (exists(configPath)) {
    data.attributes = requireUncached(configPath)
    data.sourceFile = crossPlatformPath(relative(base, configPath))
  }

  // readme
  if (exists(readmePath)) {
    data.content = await MarkdownUtil.fromFile(readmePath)
    data.readmeFile = crossPlatformPath(relative(base, readmePath))
  }

  debug4(state, `Component.readComponentFiles(${id}):end`)

  return data
}
github dennisreimann / uiengine / packages / core / src / page.js View on Github external
const configPath = pageIdToFilePath(pages, id)
  const dir = dirname(configPath)
  const readmePath = join(dir, PAGE_DOCSNAME)
  const sourcePath = crossPlatformPath(relative(base, dir))
  const data = { attributes: {}, sourcePath }

  // config
  if (exists(configPath)) {
    data.attributes = requireUncached(configPath)
    data.sourceFile = crossPlatformPath(relative(base, configPath))
  }

  // readme
  if (exists(readmePath)) {
    data.content = await MarkdownUtil.fromFile(readmePath)
    data.readmeFile = crossPlatformPath(relative(base, readmePath))
  }

  debug4(state, `Page.readPageFiles(${id}):end`)

  return data
}
github dennisreimann / uiengine / packages / cli / src / yaml.js View on Github external
const fromExternalFile = (embeddingFilePath, sourcePaths, filePath) => {
  const isYAML = filePath.match(/\.ya?ml$/)
  const isJS = filePath.match(/\.js(on)?$/)
  const isMarkdown = filePath.match(/\.(md|markdown)?$/)

  if (isYAML) {
    const string = readFileSync(filePath, 'utf8')
    return parseString(string, filePath, sourcePaths)
  } else if (isMarkdown) {
    const string = readFileSync(filePath, 'utf8')
    return renderMarkdown(string, filePath, sourcePaths)
  } else if (isJS) {
    // invalidate require cache so that changes are reflected
    invalidateRequireCache(filePath)
    return require(filePath)
  } else {
    return filePath
  }
}
github dennisreimann / uiengine / packages / cli / src / yaml.js View on Github external
const parseString = (string, filename, sourcePaths) => {
  try {
    const IncludeYamlType = includeYamlType(filename, sourcePaths)
    const DataYamlType = dataYamlType(filename, sourcePaths)
    const schema = yaml.Schema.create([IncludeYamlType, DataYamlType, MarkdownYamlType])
    const json = true // duplicate keys in a mapping will override values rather than throwing an error

    return yaml.safeLoad(string.trim(), { schema, filename, json })
  } catch (err) {
    throw new UiengineInputError(['Could not parse YAML!', markSample(string)], err)
  }
}

const fromFileSync = R.partial(parsing.fromFileSync, [parseString])
const fromFile = R.partial(parsing.fromFile, [parseString])
const fromString = R.partial(parsing.fromString, [parseString])

module.exports = {
  parseString,
  fromFileSync,
  fromFile,
  fromString
}
github dennisreimann / uiengine / packages / cli / src / frontmatter.js View on Github external
}

  if (i === lines.length) { // second '---' is missing; assume entire `str` is body
    return bodyOnly
  }

  return {
    attributes: attributes.length ? YamlUtil.parseString(attributes.join(NEWLINE), filename, sourcePaths) : {},
    body: lines.slice(i + 1).join(NEWLINE)
  }
}

const parseString = (string, filename, sourcePaths) =>
  fastmatter(string.trim(), filename, sourcePaths)

const fromFile = R.partial(ParsingUtil.fromFile, [parseString])

const fromString = R.partial(ParsingUtil.fromString, [parseString])

module.exports = {
  parseString,
  fromFile,
  fromString
}
github dennisreimann / uiengine / packages / cli / src / yaml.js View on Github external
const parseString = (string, filename, sourcePaths) => {
  try {
    const IncludeYamlType = includeYamlType(filename, sourcePaths)
    const DataYamlType = dataYamlType(filename, sourcePaths)
    const schema = yaml.Schema.create([IncludeYamlType, DataYamlType, MarkdownYamlType])
    const json = true // duplicate keys in a mapping will override values rather than throwing an error

    return yaml.safeLoad(string.trim(), { schema, filename, json })
  } catch (err) {
    throw new UiengineInputError(['Could not parse YAML!', markSample(string)], err)
  }
}

const fromFileSync = R.partial(parsing.fromFileSync, [parseString])
const fromFile = R.partial(parsing.fromFile, [parseString])
const fromString = R.partial(parsing.fromString, [parseString])

module.exports = {
  parseString,
  fromFileSync,
  fromFile,
  fromString
}