How to use the @vuepress/shared-utils.logger.wait 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 vuejs / vuepress / packages / @vuepress / core / lib / build.js View on Github external
module.exports = async function build (sourceDir, cliOptions = {}) {
  process.env.NODE_ENV = 'production'

  const { path } = require('@vuepress/shared-utils')
  const webpack = require('webpack')
  const readline = require('readline')
  const escape = require('escape-html')

  const { chalk, fs, logger } = require('@vuepress/shared-utils')
  const prepare = require('./prepare/index')
  const createClientConfig = require('./webpack/createClientConfig')
  const createServerConfig = require('./webpack/createServerConfig')
  const { createBundleRenderer } = require('vue-server-renderer')
  const { normalizeHeadTag, applyUserWebpackConfig } = require('./util/index')

  logger.wait('\nExtracting site metadata...')
  const options = await prepare(sourceDir, cliOptions, true /* isProd */)
  if (cliOptions.outDir) {
    options.outDir = cliOptions.outDir
  }

  const { outDir } = options
  if (process.cwd() === outDir) {
    return console.error(logger.error(chalk.red('Unexpected option: outDir cannot be set to the current working directory.\n'), false))
  }
  await fs.remove(outDir)
  logger.debug('Dist directory: ' + chalk.gray(require('path').resolve(process.cwd(), outDir)))

  let clientConfig = createClientConfig(options, cliOptions).toConfig()
  let serverConfig = createServerConfig(options, cliOptions).toConfig()

  // apply user config...
github vuejs / vuepress / packages / @vuepress / core / lib / build.js View on Github external
module.exports = async function build (sourceDir, cliOptions = {}) {
  process.env.NODE_ENV = 'production'

  const webpack = require('webpack')
  const readline = require('readline')
  const escape = require('escape-html')

  const { chalk, fs, path, logger, env, performance } = require('@vuepress/shared-utils')
  const prepare = require('./prepare/index')
  const createClientConfig = require('./webpack/createClientConfig')
  const createServerConfig = require('./webpack/createServerConfig')
  const { createBundleRenderer } = require('vue-server-renderer')
  const { normalizeHeadTag, applyUserWebpackConfig } = require('./util/index')

  logger.wait('Extracting site metadata...')
  const ctx = await prepare(sourceDir, cliOptions, true /* isProd */)

  const { outDir, cwd } = ctx
  if (cwd === outDir) {
    return console.error(logger.error(chalk.red('Unexpected option: outDir cannot be set to the current working directory.\n'), false))
  }

  await fs.emptyDir(outDir)
  logger.debug('Dist directory: ' + chalk.gray(outDir))

  let clientConfig = createClientConfig(ctx, cliOptions).toConfig()
  let serverConfig = createServerConfig(ctx, cliOptions).toConfig()

  // apply user config...
  const userConfig = ctx.siteConfig.configureWebpack
  if (userConfig) {
github vuejs / vuepress / packages / @vuepress / core / lib / build.js View on Github external
shouldPrefetch: ctx.siteConfig.shouldPrefetch || (() => true),
    template: await fs.readFile(ctx.ssrTemplate, 'utf-8')
  })

  // pre-render head tags from user config
  const userHeadTags = (ctx.siteConfig.head || [])
    .map(renderHeadTag)
    .join('\n  ')

  // if the user does not have a custom 404.md, generate the theme's default
  if (!ctx.pages.some(p => p.path === '/404.html')) {
    ctx.addPage({ path: '/404.html' })
  }

  // render pages
  logger.wait('Rendering static HTML...')

  const pagePaths = []
  for (const page of ctx.pages) {
    pagePaths.push(await renderPage(page))
  }

  readline.clearLine(process.stdout, 0)
  readline.cursorTo(process.stdout, 0)

  await ctx.pluginAPI.options.generated.apply(pagePaths)

  // DONE.
  const relativeDir = path.relative(cwd, outDir)
  logger.success(`Generated static files in ${chalk.cyan(relativeDir)}.`)
  const { duration } = performance.stop()
  logger.developer(`It took a total of ${chalk.cyan(`${duration}ms`)} to run the ${chalk.cyan('vuepress build')}.`)
github vuejs / vuepress / packages / @vuepress / core / lib / node / build / index.js View on Github external
shouldPrefetch: this.context.siteConfig.shouldPrefetch || (() => true),
      template: await fs.readFile(this.context.ssrTemplate, 'utf-8')
    })

    // pre-render head tags from user config
    this.userHeadTags = (this.context.siteConfig.head || [])
      .map(renderHeadTag)
      .join('\n  ')

    // if the user does not have a custom 404.md, generate the theme's default
    if (!this.context.pages.some(p => p.path === '/404.html')) {
      this.context.addPage({ path: '/404.html' })
    }

    // render pages
    logger.wait('Rendering static HTML...')

    const pagePaths = []
    for (const page of this.context.pages) {
      pagePaths.push(await this.renderPage(page))
    }

    readline.clearLine(process.stdout, 0)
    readline.cursorTo(process.stdout, 0)

    await this.context.pluginAPI.applyAsyncOption('generated', pagePaths)

    // DONE.
    const relativeDir = path.relative(this.context.cwd, this.outDir)
    logger.success(`Generated static files in ${chalk.cyan(relativeDir)}.`)
    const { duration } = performance.stop()
    logger.developer(`It took a total of ${chalk.cyan(`${duration}ms`)} to run the ${chalk.cyan('vuepress build')}.`)
github vuejs / vuepress / packages / @vuepress / test-utils / prepare.js View on Github external
module.exports = function globalSetup () {
  logger.wait('Start preparing for testing ...')
  return prepareForTest().then(() => {
    logger.wait('Finished preparing for testing ...')
  })
}
github vuejs / vuepress / packages / @vuepress / test-utils / prepare.js View on Github external
return prepareForTest().then(() => {
    logger.wait('Finished preparing for testing ...')
  })
}
github vuejs / vuepress / packages / @vuepress / plugin-pwa / index.js View on Github external
async generated () {
    const { serviceWorker } = options
    const { outDir } = context
    const swFilePath = path.resolve(outDir, 'service-worker.js')
    if (serviceWorker) {
      logger.wait('Generating service worker...')
      const wbb = require('workbox-build')
      await wbb.generateSW({
        swDest: swFilePath,
        globDirectory: outDir,
        globPatterns: ['**\/*.{js,css,html,png,jpg,jpeg,gif,svg,woff,woff2,eot,ttf,otf}'],
        ...(options.generateSWConfig || {})
      })
      await fs.writeFile(
        swFilePath,
        await fs.readFile(path.resolve(__dirname, 'lib/skip-waiting.js'), 'utf8'),
        { flag: 'a' }
      )
    }
  }
})
github vuejs / vuepress / packages / @vuepress / core / lib / index.js View on Github external
function createApp (options) {
  logger.wait('Extracting site metadata...')
  return new App(options)
}