How to use the consola.warn function in consola

To help you get started, weโ€™ve selected a few consola 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 nuxt / press / packages / core / src / autoregister.js View on Github external
let pressInstances = {}
  for (const mode of modes) {
    try {
      const { Blueprint } = await importModule(`@nuxt-press/${mode}`)

      const modeInstances = await Blueprint.register(this, config)
      if (modeInstances) {
        pressInstances = {
          ...pressInstances,
          ...modeInstances
        }
      }
    } catch (error) {
      // TODO: improve message
      if (error.code === 'MODULE_NOT_FOUND') {
        consola.warn(`Please install @nuxt-press/${mode}`, error)
      } else {
        consola.error(error)
      }
    }
  }

  // first run all setups
  const setupPromises = Object.values(pressInstances).map(modeInstance => modeInstance.setup())
  await Promise.all(setupPromises)

  // then init the mode instances
  const initPromises = Object.values(pressInstances).map(modeInstance => modeInstance.init())
  await Promise.all(initPromises)

  return pressInstances
}
github Akryum / nodepack / packages / @nodepack / cli / src / lib / ProjectCreateJob.js View on Github external
}

          // log instructions
          if (!cliOptions.skipGetStarted) {
            consola.log('')
            consola.success(`๐ŸŽ‰  Successfully created project ${chalk.yellow(projectName)}.`)
            consola.log(
              `๐Ÿ‘‰  Get started with the following commands:\n\n` +
              (cwd === process.cwd() ? `` : chalk.cyan(` ${chalk.gray('$')} cd ${projectName}\n`)) +
              chalk.cyan(` ${chalk.gray('$')} nodepack`),
            )
            consola.log('')
          }

          if (!gitCommitSuccess) {
            consola.warn(
              `Skipped git commit due to missing username and email in git config.\n` +
              `You will need to perform the initial commit yourself.\n`,
            )
          }
        },
      },
github nuxt / nuxt.js / packages / core / src / resolver.js View on Github external
resolvePath (path, { alias, isAlias = alias, module, isModule = module, isStyle } = {}) {
    // TODO: Remove in Nuxt 3
    if (alias) {
      consola.warn('Using alias is deprecated and will be removed in Nuxt 3. Use `isAlias` instead.')
    }
    if (module) {
      consola.warn('Using module is deprecated and will be removed in Nuxt 3. Use `isModule` instead.')
    }

    // Fast return in case of path exists
    if (fs.existsSync(path)) {
      return path
    }

    let resolvedPath

    // Try to resolve it as a regular module
    if (isModule !== false) {
      resolvedPath = this.resolveModule(path)
    }

    // Try to resolve alias
    if (!resolvedPath && isAlias !== false) {
github nuxt / nuxt.js / packages / config / src / options.js View on Github external
? options.render.ssrLog === undefined || options.render.ssrLog
    : false

  // We assume the SPA fallback path is 404.html (for GitHub Pages, Surge, etc.)
  if (options.generate.fallback === true) {
    options.generate.fallback = '404.html'
  }

  if (options.build.stats === 'none' || options.build.quiet === true) {
    options.build.stats = false
  }

  // Vendor backward compatibility with nuxt 1.x
  if (typeof options.build.vendor !== 'undefined') {
    delete options.build.vendor
    consola.warn('vendor has been deprecated due to webpack4 optimization')
  }

  // Disable CSS extraction due to incompatibility with thread-loader
  if (options.build.extractCSS && options.build.parallel) {
    options.build.parallel = false
    consola.warn('extractCSS cannot work with parallel build due to limited work pool in thread-loader')
  }

  // build.extractCSS.allChunks has no effect
  if (typeof options.build.extractCSS.allChunks !== 'undefined') {
    consola.warn('build.extractCSS.allChunks has no effect from v2.0.0. Please use build.optimization.splitChunks settings instead.')
  }

  // devModules has been renamed to buildModules
  if (typeof options.devModules !== 'undefined') {
    consola.warn('`devModules` has been renamed to `buildModules` and will be removed in Nuxt 3.')
github nuxt / nuxt.js / packages / config / src / options.js View on Github external
}

  // Disable CSS extraction due to incompatibility with thread-loader
  if (options.build.extractCSS && options.build.parallel) {
    options.build.parallel = false
    consola.warn('extractCSS cannot work with parallel build due to limited work pool in thread-loader')
  }

  // build.extractCSS.allChunks has no effect
  if (typeof options.build.extractCSS.allChunks !== 'undefined') {
    consola.warn('build.extractCSS.allChunks has no effect from v2.0.0. Please use build.optimization.splitChunks settings instead.')
  }

  // devModules has been renamed to buildModules
  if (typeof options.devModules !== 'undefined') {
    consola.warn('`devModules` has been renamed to `buildModules` and will be removed in Nuxt 3.')
    options.buildModules.push(...options.devModules)
    delete options.devModules
  }

  // Enable minimize for production builds
  if (options.build.optimization.minimize === undefined) {
    options.build.optimization.minimize = !options.dev
  }

  // Enable optimizeCSS only when extractCSS is enabled
  if (options.build.optimizeCSS === undefined) {
    options.build.optimizeCSS = options.build.extractCSS ? {} : false
  }

  const { loaders } = options.build
  const vueLoader = loaders.vue
github nuxt / nuxt.js / packages / generator / src / generator.js View on Github external
async afterGenerate () {
    const { fallback } = this.options.generate

    // Disable SPA fallback if value isn't a non-empty string
    if (typeof fallback !== 'string' || !fallback) {
      return
    }

    const fallbackPath = path.join(this.distPath, fallback)

    // Prevent conflicts
    if (await fsExtra.exists(fallbackPath)) {
      consola.warn(`SPA fallback was configured, but the configured path (${fallbackPath}) already exists.`)
      return
    }

    // Render and write the SPA template to the fallback path
    let { html } = await this.nuxt.server.renderRoute('/', { spa: true })

    try {
      html = this.minifyHtml(html)
    } catch (error) {
      consola.warn('HTML minification failed for SPA fallback')
    }

    await fsExtra.writeFile(fallbackPath, html, 'utf8')
  }
github nuxt / nuxt.js / test / utils / chrome.js View on Github external
resolveChromePath () {
    if (this.canAccess(process.env.CHROME_PATH)) {
      return process.env.CHROME_PATH
    }
    if (this.canAccess(process.env.LIGHTHOUSE_CHROMIUM_PATH)) {
      consola.warn(
        'ChromeLauncher',
        'LIGHTHOUSE_CHROMIUM_PATH is deprecated, use CHROME_PATH env variable instead.'
      )
      return process.env.LIGHTHOUSE_CHROMIUM_PATH
    }
  }
github nuxt / fabula / src / cli.js View on Github external
export async function loadConfig(rcFile = null) {
  let config
  if (rcFile === null) {
    for (rcFile of ['fabula.js', '.fabularc.js', '.fabularc']) {
      if (existsSync(resolvePath(rcFile))) {
        config = require(resolvePath(rcFile))
        break
      }
      rcFile = null
    }
  } else {
    config = require(rcFile)
  }
  if (rcFile === null) {
    consola.warn('No Fabula configuration file found.')
    config = {}
  }
  config = config.default || config
  if (typeof config === 'function') {
    config = await config()
  }
  return config
}
github nuxt / now-builder / src / prepare-cache.ts View on Github external
async function prepareCache ({ workPath, entrypoint }: PrepareCacheOptions): Promise> {
  const entryDir = path.dirname(entrypoint)

  startStep('Collect cache')
  const cache: Record = {}
  for (const dir of ['.now_cache', 'node_modules_dev', 'node_modules_prod']) {
    const activeDirectory = path.join(workPath, entryDir, dir)
    if (!fs.existsSync(activeDirectory)) {
      consola.warn(activeDirectory, 'not exists. skipping!')
      continue
    }
    const files = await glob(path.join(entryDir, dir, '**'), workPath)
    consola.info(`${Object.keys(files).length} files collected from ${dir}`)
    Object.assign(cache, files)
  }
  endStep()

  return cache
}