How to use the cli-ux.cli.confirm 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 1MB / 1mb-cli / src / commands / deploy.js View on Github external
if (flags.clearcreds === true) {
            conf.clear()
        }

        let username = conf.get('username')
        if (typeof username === 'undefined') {
            username = await cli.prompt('What is your 1mbsite username?')
        }

        let key = conf.get('key')
        if (typeof key === 'undefined') {
            key = await cli.prompt('What is your 1mbsite api key?', {
                type: 'mask'
            })

            if (await cli.confirm('Would you like to save these credentials for future deployments?')) {
                conf.set('key', key)
                conf.set('username', username)
                this.log('Saved credentials!')
            }
        }

        if(flags.clear_files || flags.vuejs || flags.reactjs) {
            // clear all active resources
            request.post('https://api.1mb.site', {
                form: {
                    action: 'resources',
                    site: username,
                    key: key
                }
            }, function(error, response, body) {
                body = JSON.parse(body)
github LewisArdern / metasecjs / src / commands / audit.js View on Github external
this.log('Checking for ReDoS (This can take some time for large projects, so go get a coffee)')
        // Globs all of the JavaScript files in the provided directory and will run each file against vuln-regex-detect
        const jsFiles = await regex.findFiles(flags.dir, '/**/*.js')
        redos.checkRedos(jsFiles, outDir)
      }
      // Currently very hacky but identifies the use of electron in the package.json file, if it exists runs electronegativity
      for (let [key, value] of Object.entries(suggestions)) {
        if (value.usesElectron) {
          this.log('Application uses Electron, running dyosec')
          electron.electronegativity(key, outDir)
        }
      }
    }
    // Command-line verification if secrets checking should be performed

    const s = await cli.confirm('Do you want to look for Secrets?')
    if (s === true) {
      // TODO: Fix regex, fast-glob *.git does not find hidden files
      // const git = await regex.findFiles(flags.dir, '/*\\.git')
      // this.log(git)
      // if (git.length !== 0) {
      //   this.log('.git found, running truffleHog')
      //   secrets.truffleHog(git, outDir)
      // }
      secrets.rg(flags.dir, outDir)
    }
    this.log('Running security linting against directory')
    lint.checkLint(flags.dir, outDir)
  }
}
github LewisArdern / metasecjs / src / commands / audit.js View on Github external
const outDir = setup.setupFolders(flags)
    // Retrieve package.json(s)
    const packages = await regex.findFiles(flags.dir, '/**/package.json')
    // Read package.json and match to database for suggestions
    if (packages !== []) {
      this.log(`Found ${packages.length} package.json, beginning audit`)
      this.log('Checking Database for potential problem areas with identified dependencies')
      // Looks at the package.json file for matches against the 'repository' and reports any security concerns with a particular package
      const suggestions = helper.createSuggestions(packages)
      await helper.writeSuggestions(suggestions, outDir)
      this.log('Auditing third-party dependencies')
      // Runs third-party dependency checking against package.json files that were identified
      const dependencies = helper.retrieveDependencies(packages)
      audit.thirdPartyDependencies(dependencies, outDir)
      // Command-line verification if ReDoS checking should be performed
      const rd = await cli.confirm('Do you want to check for ReDoS?')
      if (rd === true) {
        this.log('Checking for ReDoS (This can take some time for large projects, so go get a coffee)')
        // Globs all of the JavaScript files in the provided directory and will run each file against vuln-regex-detect
        const jsFiles = await regex.findFiles(flags.dir, '/**/*.js')
        redos.checkRedos(jsFiles, outDir)
      }
      // Currently very hacky but identifies the use of electron in the package.json file, if it exists runs electronegativity
      for (let [key, value] of Object.entries(suggestions)) {
        if (value.usesElectron) {
          this.log('Application uses Electron, running dyosec')
          electron.electronegativity(key, outDir)
        }
      }
    }
    // Command-line verification if secrets checking should be performed
github SakkuCloud / sakku-cli / old / app.ts View on Github external
let appName = await cli.prompt('Enter your app name') || 'random-name'
                await cli.action.start('please wait...')
                await cli.wait(2000)
                cli.action.stop('created!')
                this.log(`${appName} is ready to deploy :)`)
                break
            case 'stop':
                var appId = await cli.prompt('Enter your app id',{required:true})
                await cli.action.start('please wait...')
                await cli.wait(2000)
                cli.action.stop('stoped!')
                this.log(`your app (${appId}) is stoped`)
                break
            case 'rm':
                var appId = await cli.prompt('Enter your app id',{required:true})
                var confimation = await cli.confirm('are you really sure to remove?')
                if (confimation){
                    await cli.action.start('please wait...')
                    await cli.wait(2000)
                    cli.action.stop('removed!')
                    this.log('your app is not any more exist in this universe!')
                }else {
                    this.log('notting happend!')
                }
                break
            case 'scale':
                var appId = await cli.prompt('Enter your app id',{required:true})
                var appId = await cli.prompt('Enter your app scale',{required:true})
                
        }
    }
}
github heroku / cli / packages / config / src / commands / config / edit.ts View on Github external
private async diffPrompt(original: Config, newConfig: Config): Promise {
    if (_.isEqual(original, newConfig)) {
      this.warn('no changes to config')
      return false
    }
    cli.log()
    cli.log('Config Diff:')
    showDiff(original, newConfig)
    cli.log()
    return cli.confirm(`Update config on ${color.app(this.app)} with these values?`)
  }
github fauna / fauna-shell / src / lib / misc.js View on Github external
function confirmEndpointDelete(alias) {
  return cli.confirm(`Are you sure you want to delete the '${alias}' endpoint? [y/n]`)
}
github HAECHI-LABS / henesis-cli / src / hooks / analytics / check.ts View on Github external
const hook = async function({}): Promise {
  const isAgree = configstore.get('analytics');

  if (isAgree || isAgree === false) return;

  cli.log(
    `Allow Henesis to collect anonymous CLI usage and error reporting information`,
  );
  let input = await cli.confirm(`yes(y) or no(n)`);

  configstore.set('analytics', input);
};
github HAECHI-LABS / henesis-cli / src / utils.ts View on Github external
export const confirmPrompt = async (): Promise => {
  return await cli.confirm(`(y)es or (n)o`);
};