How to use the cli-ux.log function in cli-ux

To help you get started, we’ve selected a few cli-ux 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 heroku / cli / packages / pipelines / src / commands / pipelines / promote.ts View on Github external
async function streamReleaseCommand(heroku: APIClient, targets: Array, promotion: any) {
  if (targets.length !== 1 || targets.every(isComplete)) {
    return pollPromotionStatus(heroku, promotion.id, false)
  }
  const target = targets[0]
  const release = await getRelease(heroku, target.app.id, target.release.id)

  if (!release.output_stream_url) {
    return pollPromotionStatus(heroku, promotion.id, false)
  }

  cli.log('Running release command...')
  const fetch = (retry = 100) => new Promise((resolve, reject) => {
    const stream = got.stream(release.output_stream_url!)
    stream.on('error', async err => {
      await wait(100)
      if (retry && err.code === '404') {
        fetch(retry - 1).then(resolve).catch(reject)
      } else reject(err)
    })
    stream.on('end', resolve)
    const piped = stream.pipe(process.stdout)
    piped.on('error', reject)
  })
  await fetch()

  return pollPromotionStatus(heroku, promotion.id, false)
}
github heroku / cli / packages / pipelines / src / ownership.ts View on Github external
export function warnMixedOwnership(pipelineApps: Array, pipeline: Heroku.Pipeline, owner: string) {
  const hasMixedOwnership = pipelineApps.some(app => {
    return (app.owner && app.owner.id) !== pipeline.owner.id
  })

  if (hasMixedOwnership) {
    cli.log()
    let message = `Some apps in this pipeline do not belong to ${color.cmd(owner)}.`
    message += '\n\nAll apps in a pipeline must have the same owner as the pipeline owner.'
    message += '\nTransfer these apps or change the pipeline owner in pipeline settings.'
    message += `\nSee ${color.cyan('https://devcenter.heroku.com/articles/pipeline-ownership-transition')} for more info.`
    cli.warn(message)
  }
}
github heroku / cli / packages / heroku-cli-plugin-auth / src / commands / auth / login.ts View on Github external
async run() {
    let name = this.flags.name || 'world'
    cli.log(`hello ${name} from heroku-cli-auth!`)
  }
}
github heroku / cli / packages / apps / src / commands / domains / index.ts View on Github external
async run() {
    const {flags} = this.parse(DomainsIndex)
    const {body: domains} = await this.heroku.get>(`/apps/${flags.app}/domains`)
    const herokuDomain = domains.find(domain => domain.kind === 'heroku')
    const customDomains = domains.filter(domain => domain.kind === 'custom')

    if (flags.json) {
      cli.styledJSON(domains)
    } else {
      cli.styledHeader(`${flags.app} Heroku Domain`)
      cli.log(herokuDomain && herokuDomain.hostname)
      if (customDomains && customDomains.length > 0) {
        cli.log()
        cli.styledHeader(`${flags.app} Custom Domains`)
        cli.table(customDomains, {
          hostname: {header: 'Domain Name'},
          kind: {header: 'DNS Record Type', get: domain => {
            if (domain.hostname) {
              return isApexDomain(domain.hostname) ? 'ALIAS or ANAME' : 'CNAME'
            }
          }},
          cname: {header: 'DNS Target'},
          acm_status: {header: 'ACM Status', extended: true},
          acm_status_reason: {header: 'ACM Status', extended: true}
        }, {
          ...flags,
          'no-truncate': true
        })
      }
github stackpath / serverless-scripting-cli / src / api / services / log.ts View on Github external
export function logVerbose(log: string) {
  if (process.env.STACKPATH_LOG_LEVEL === LogLevel.VERBOSE) {
    cliUx.log(log);
  }
}
github stackpath / serverless-scripting-cli / src / commands / deploy.ts View on Github external
await Auth.getAccessToken();
        cliUx.action.stop("Refreshing access token done.");
      } else {
        Log.logVerbose(`Access token is not expired.`);
      }
    } catch (e) {
      cliUx.error(e.message);
    }

    const deploy = new DeployService();
    try {
      await deploy.deployScripts({
        force: Boolean(process.env.STACKPATH_FORCE)
      });
    } catch (e) {
      cliUx.log(e.message);
    }
  }
}
github taneliheikkinen / heroku-wp-environment-sync / src / commands / sync / init.ts View on Github external
default : Globals.default_local_server
            })

            let local_db_config = env_file.getDBConfig();
            
            await MySQL.localDatabaseCreationQuestionare(local_db_config)

            ux.action.start("Finding wordpress installation location.")

            let wp_installation_dir = await WP.searchWPLocation()

            ux.action.stop()

            if(wp_installation_dir == false) {
                ux.log()
                ux.log(`Tried to search wordpress installation folder automatically, but failed.`)

                wp_installation_dir = await ux.prompt(`Input the path to your wordpress installation folder`, {
                    default : Globals.default_wp_installation_dir
                })
            }

            wp_installation_dir = wp_installation_dir as string

            if(!await WP.checkWPInstallation(wp_installation_dir)) {
                ux.error(`Seems that wp installation directory (${Colors.file(wp_installation_dir)}) isn't a correct wp installation directory.`)
            }

            await new_syncfile.envFromApp("localhost", new LocalApp(local_dev_server), true, {
                is_local : true,
                wp_dir : wp_installation_dir
            })
github taneliheikkinen / heroku-wp-environment-sync / src / lib / Apps / RemoteApp.ts View on Github external
async handleEnvNotRecognized () {
        ux.warn(`Could not find any of the recognized db env variable names in the app ${Colors.app(this.name)}.`);

        ux.warn(`These are the searched db env variable names: ${this.constructEnvList(this.db_envs)}`);

        ux.log();
                
        while(!this.db_env_name) {
            const input_variable_name = await ux.confirm("Do you want to input the db environment variable name? ")

            if(!input_variable_name) {
                ux.error(`Ok, cannot resolve the db env variable name, so quitting.`)
                return false
            }

            const new_env = await ux.prompt(`Type in the env variable in the app ${Colors.app(this.name)}`)
            
            const exists = await this.hasAppEnv(new_env);

            if(!exists) {
                ux.warn(`The ${Colors.app(new_env)} -app doesn't have that env variable .`);
                continue
github muenzpraeger / create-lwc-app / packages / create-lwc-app / src / utils / logger.ts View on Github external
export function welcome(): void {
    let message = '\n'
    const i = 5
    const zap = emoji.get('zap')
    for (let m = 0; m < i; m++) {
        message = message.concat(zap)
    }
    message = message.concat('  Lightning Web Components  ')
    for (let m = 0; m < i; m++) {
        message = message.concat(zap)
    }
    cli.log(message.concat('\n\n'))
}
github heroku / cli / packages / pipelines / src / commands / pipelines / transfer.ts View on Github external
async run() {
    const {args, flags} = this.parse(PipelinesTransfer)
    const pipeline = await disambiguate(this.heroku, flags.pipeline)
    const newOwner = await getOwner(this.heroku, args.owner)
    const apps = await listPipelineApps(this.heroku, pipeline.id!)
    const displayType = newOwner.type === 'user' ? 'account' : newOwner.type
    let confirmName = flags.confirm

    if (!confirmName) {
      await renderPipeline(this.heroku, pipeline, apps)
      cli.log('')
      cli.warn(`This will transfer ${color.pipeline(pipeline.name!)} and all of the listed apps to the ${args.owner} ${displayType}`)
      cli.warn(`to proceed, type ${color.red(pipeline.name!)} or re-run this command with ${color.red('--confirm')} ${pipeline.name}`)
      confirmName = await cli.prompt('', {})
    }

    if (confirmName !== pipeline.name) {
      cli.warn(`Confirmation did not match ${color.red(pipeline.name!)}. Aborted.`)
      return
    }

    cli.action.start(`Transferring ${color.pipeline(pipeline.name!)} pipeline to the ${args.owner} ${displayType}`)
    await createPipelineTransfer(this.heroku, {pipeline: {id: pipeline.id}, new_owner: newOwner})
    cli.action.stop()
  }
}