How to use the @vuepress/shared-utils.logger.warn function in @vuepress/shared-utils

To help you get started, we’ve selected a few @vuepress/shared-utils 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 giserman001 / blogs / docs / .vuepress / theme / index.js View on Github external
infoCard: {},
    plugins: {},
    pagination: {
      perPage: 5,
    },
    comments: {},
  }, opts))

  // resolve theme language
  if (typeof opts.lang === 'string') {
    try {
      // 可以监听是否有此文件
      require.resolve(`./langs/${opts.lang}`)
    } catch (e) {
      opts.lang = 'en-US'
      logger.warn(`[vuepress-theme-meteorlxy] lang '${opts.lang}' is not available, fallback to 'en-US'`)
    }
    opts.lang = require(`./langs/${opts.lang}`)
  }
  console.log(opts, 'opts')
  const { comments, lang, defaultPages, header, infoCard } = opts
  const noopGeo = (
    header.background && (
      header.background.url || header.background.useGeo === false
    )
  ) && (
    infoCard.headerBackground && (
      infoCard.headerBackground.url || infoCard.headerBackground.useGeo === false
    )
  )
  const options = {
    name: 'vuepress-theme-meteorlxy',
github vuejs / vuepress / packages / @vuepress / core / lib / node / theme-api / index.js View on Github external
)
    }
    // built-in named layout or not.
    const layoutComponentMap = resolveSFCs(layoutDirs)

    const { Layout, NotFound } = layoutComponentMap
    // layout component does not exist.
    if (!Layout) {
      const fallbackLayoutPath = resolve(__dirname, 'Layout.fallback.vue')
      layoutComponentMap.Layout = {
        filename: 'Layout.vue',
        componentName: 'Layout',
        path: fallbackLayoutPath,
        isInternal: true
      }
      logger.warn(
        `[vuepress] Cannot resolve Layout.vue file in \n ${layoutDirs.join('\n')}, `
          + `\n fallback to default layout: ${fallbackLayoutPath}`
      )
    }
    if (!NotFound) {
      layoutComponentMap.NotFound = {
        filename: 'NotFound.vue',
        componentName: 'NotFound',
        path: resolve(__dirname, '../../client/components/NotFound.vue'),
        isInternal: true
      }
    }
    return layoutComponentMap
  }
}
github vuejs / vuepress / packages / @vuepress / core / lib / node / App.js View on Github external
async addPage (options) {
    options.permalinkPattern = this.siteConfig.permalink
    options.extractHeaders = this.siteConfig.markdown && this.siteConfig.markdown.extractHeaders
    const page = new Page(options, this)
    await page.process({
      markdown: this.markdown,
      computed: new this.ClientComputedMixinConstructor(),
      enhancers: this.pluginAPI.getOption('extendPageData').items
    })
    const index = this.pages.findIndex(({ path }) => path === page.path)
    if (index >= 0) {
      // Override a page if corresponding path already exists
      logger.warn(`Override existing page ${chalk.yellow(page.path)}.`)
      this.pages.splice(index, 1, page)
    } else {
      this.pages.push(page)
    }
  }
github vuejs / vuepress / packages / @vuepress / core / lib / node / plugin-api / util.js View on Github external
exports.flattenPlugin = function (
  { entry: config, name, shortcut, fromDep },
  pluginOptions,
  pluginContext,
  self
) {
  const { valid, warnMsg } = assertTypes(pluginOptions, [Object, Array, Boolean])
  if (!valid) {
    if (pluginOptions !== undefined) {
      logger.warn(
        `[${chalk.gray(shortcut)}] `
        + `Invalid value for "pluginOptions" ${chalk.cyan(name)}: ${warnMsg}`
      )
    }
    pluginOptions = {}
  }

  let enabled = true
  if (typeof pluginOptions === 'boolean') {
    enabled = pluginOptions
    pluginOptions = {}
  }

  if (typeof config === 'function') {
    // 'Object.create' here is to give each plugin a separate context,
    // but also own the inheritance context.
github vuejs / vuepress / packages / @vuepress / core / lib / node / plugin-api / index.js View on Github external
registerOption (key, value, pluginName) {
    const option = PLUGIN_OPTION_MAP[key]
    const types = option.types
    const { valid, warnMsg } = assertTypes(value, types)
    if (valid) {
      this.options[option.name].add(pluginName, value)
    } else if (value !== undefined) {
      logger.warn(
        `${chalk.gray(pluginName)} `
        + `Invalid value for "option" ${chalk.cyan(option.name)}: ${warnMsg}`
      )
    }
    return this
  }
github appcelerator / docs-devkit / packages / vuepress / vuepress-plugin-apidocs / index.js View on Github external
if (!metadata) {
        logger.warn(`no metadata found for type ${typeName} of API page ${page.path}`)
        return
      }

      page.metadataKey = typeName
      page.frontmatter.pageClass = 'api-page'

      if (processed[version] && processed[version][typeName]) {
        const metadataProcessor = processed[version][typeName]
        metadataProcessor.appendAdditionalHeaders(page)
        return
      }

      logger.warn(`no metadata found for type ${typeName} of API page ${page.path}`)
    },
github vuejs / vuepress / packages / @vuepress / core / lib / node / loadTheme.js View on Github external
path = normalizeThemePath(resolved)
    name = resolved.name
    shortcut = resolved.shortcut

    /**
     * 3. fallback
     */
  } else {
    return {}
  }

  try {
    entry = pluginAPI.normalizePlugin('theme', path, ctx.themeConfig)
  } catch (e) {
    logger.warn(e.message)
    entry = {}
  }

  return { path, name, shortcut, entry }
}
github vuejs / vuepress / packages / @vuepress / core / lib / node / plugin-api / index.js View on Github external
use (pluginRaw, pluginOptions = {}) {
    if (this._initialized) {
      throw new Error(`Cannot add new plugins after initialization.`)
    }

    let plugin
    if (isPlainObject(pluginRaw) && pluginRaw.$$normalized) {
      plugin = pluginRaw
    } else {
      try {
        plugin = this.normalizePlugin('plugin', pluginRaw, pluginOptions)
      } catch (e) {
        logger.warn(e.message)
        return this
      }
    }

    if (plugin.multiple !== true) {
      const duplicateIndex = this._pluginQueue.findIndex(({ name }) => name === plugin.name)
      if (duplicateIndex !== -1) {
        this._pluginQueue.splice(duplicateIndex, 1)
      }
    }

    this._pluginQueue.push(plugin)

    if (plugin.plugins) {
      logger.debug(`Plugins defined at ${chalk.gray(plugin.name)}`, plugin.plugins)
      this.useByPluginsConfig(plugin.plugins)
github vuejs / vuepress / packages / @vuepress / core / lib / node / App.js View on Github external
constructor (options = {}) {
    this.isProd = process.env.NODE_ENV === 'production'
    this.options = options
    this.sourceDir = this.options.sourceDir || path.join(__dirname, 'docs.fallback')
    logger.debug('sourceDir', this.sourceDir)
    if (!fs.existsSync(this.sourceDir)) {
      logger.warn(`Source directory doesn't exist: ${chalk.yellow(this.sourceDir)}`)
    }

    this.vuepressDir = path.resolve(this.sourceDir, '.vuepress')
    this.libDir = path.join(__dirname, '../')
  }