How to use the @vue/cli-shared-utils.chalk.red function in @vue/cli-shared-utils

To help you get started, we’ve selected a few @vue/cli-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 / vue-cli / packages / @vue / cli-service / lib / util / prepareProxy.js View on Github external
// It can either be a string or an object conforming to the Webpack dev server proxy configuration
  // https://webpack.github.io/docs/webpack-dev-server.html
  if (!proxy) {
    return undefined
  }
  if (Array.isArray(proxy) || (typeof proxy !== 'object' && typeof proxy !== 'string')) {
    console.log(
      chalk.red(
        'When specified, "proxy" in package.json must be a string or an object.'
      )
    )
    console.log(
      chalk.red('Instead, the type of "proxy" was "' + typeof proxy + '".')
    )
    console.log(
      chalk.red(
        'Either remove "proxy" from package.json, or make it an object.'
      )
    )
    process.exit(1)
  }

  // If proxy is specified, let it handle any request except for
  // files in the public folder and requests to the WebpackDevServer socket endpoint.
  // https://github.com/facebook/create-react-app/issues/6720
  function mayProxy (pathname) {
    const maybePublicPath = path.resolve(appPublicFolder, pathname.slice(1))
    const isPublicFileRequest = fs.existsSync(maybePublicPath)
    const isWdsEndpointRequest = pathname.startsWith('/sockjs-node') // used by webpackHotDevClient
    return !(isPublicFileRequest || isWdsEndpointRequest)
  }
github vuejs / vue-cli / packages / @vue / cli-service / lib / util / prepareProxy.js View on Github external
module.exports = function prepareProxy (proxy, appPublicFolder) {
  // `proxy` lets you specify alternate servers for specific requests.
  // It can either be a string or an object conforming to the Webpack dev server proxy configuration
  // https://webpack.github.io/docs/webpack-dev-server.html
  if (!proxy) {
    return undefined
  }
  if (Array.isArray(proxy) || (typeof proxy !== 'object' && typeof proxy !== 'string')) {
    console.log(
      chalk.red(
        'When specified, "proxy" in package.json must be a string or an object.'
      )
    )
    console.log(
      chalk.red('Instead, the type of "proxy" was "' + typeof proxy + '".')
    )
    console.log(
      chalk.red(
        'Either remove "proxy" from package.json, or make it an object.'
      )
    )
    process.exit(1)
  }

  // If proxy is specified, let it handle any request except for
  // files in the public folder and requests to the WebpackDevServer socket endpoint.
github vuejs / vue-cli / packages / @vue / cli-service / lib / util / prepareProxy.js View on Github external
// Browsers may send Origin headers even with same-origin
        // requests. To prevent CORS issues, we have to change
        // the Origin to match the target URL.
        if (!proxyReq.agent && proxyReq.getHeader('origin')) {
          proxyReq.setHeader('origin', target)
        }
      },
      onError: onProxyError(target)
    }
  }

  // Support proxy as a string for those who are using the simple proxy option
  if (typeof proxy === 'string') {
    if (!/^http(s)?:\/\//.test(proxy)) {
      console.log(
        chalk.red(
          'When "proxy" is specified in package.json it must start with either http:// or https://'
        )
      )
      process.exit(1)
    }

    return [
      Object.assign({}, defaultConfig, createProxyEntry(proxy))
    ]
  }

  // Otherwise, proxy is an object so create an array of proxies to pass to webpackDevServer
  return Object.keys(proxy).map(context => {
    const config = proxy[context]
    if (!config.hasOwnProperty('target')) {
      console.log(
github vuejs / vue-cli / packages / @vue / cli / bin / vue.js View on Github external
function checkNodeVersion (wanted, id) {
  if (!semver.satisfies(process.version, wanted)) {
    console.log(chalk.red(
      'You are using Node ' + process.version + ', but this version of ' + id +
      ' requires Node ' + wanted + '.\nPlease upgrade your Node version.'
    ))
    process.exit(1)
  }
}
github vuejs / vue-cli / packages / @vue / cli / bin / vue.js View on Github external
function suggestCommands (unknownCommand) {
  const availableCommands = program.commands.map(cmd => cmd._name)

  const suggestion = didYouMean(unknownCommand, availableCommands)
  if (suggestion) {
    console.log(`  ` + chalk.red(`Did you mean ${chalk.yellow(suggestion)}?`))
  }
}
github luoxue-victor / webpack-box / packages / packages-cli / cli / bin / packages-box.js View on Github external
function checkNodeVersionForWarning () {
  if (semver.satisfies(process.version, '10.x')) {
    console.log(chalk.red(
      `你正在用的 node 版本是:${process.version}.\n` +
      '未来版本将不再支持 10.x 版本.\n'
    ))
  }
}
github vuejs / vue-cli / packages / @vue / cli / lib / Upgrader.js View on Github external
}

    log(`${chalk.green('✔')}  Successfully invoked migrator for plugin: ${chalk.cyan(plugin.id)}`)
    if (!process.env.VUE_CLI_TEST && hasProjectGit(this.context)) {
      const { stdout } = await execa('git', [
        'ls-files',
        '--exclude-standard',
        '--modified',
        '--others'
      ], {
        cwd: this.context
      })
      if (stdout.trim()) {
        log(`   The following files have been updated / added:\n`)
        log(
          chalk.red(
            stdout
              .split(/\r?\n/g)
              .map(line => `     ${line}`)
              .join('\n')
          )
        )
        log()
        log(
          `   You should review these changes with ${chalk.cyan(
            `git diff`
          )} and commit them.`
        )
        log()
      }
    }
github vuejs / vue-cli / packages / @vue / cli-plugin-eslint / prompts.js View on Github external
short: 'Prettier'
      }
    ]
  },
  {
    name: 'lintOn',
    type: 'checkbox',
    message: 'Pick additional lint features:',
    choices: [
      {
        name: 'Lint on save',
        value: 'save',
        checked: true
      },
      {
        name: 'Lint and fix on commit' + (hasGit() ? '' : chalk.red(' (requires Git)')),
        value: 'commit'
      }
    ]
  }
]
github vuejs / vue-cli / packages / @vue / cli-ui / apollo-server / connectors / tasks.js View on Github external
id: task.id,
        status: 'error'
      }, context)
      logs.add({
        message: `Error while running task ${task.id} with message'${error.message}'`,
        type: 'error'
      }, context)
      notify({
        title: `Task error`,
        message: `Error while running task ${task.id} with message'${error.message}'`,
        icon: 'error'
      })
      addLog({
        taskId: task.id,
        type: 'stdout',
        text: chalk.red(`Error while running task ${task.id} with message '${error.message}'`)
      }, context)
      console.error(error)
    })
github vuchan / vue-mfe / packages / vue-cli-plugin-mfe / commands / publish.js View on Github external
.on('error', (error) => {
        stopSpinner(false)
        log(chalk.red(`Publish module ${chalk.cyan(name)} failed`))
        log(chalk.red(error))

        reject(error)
      })
      .on('complete', (res, body) => {