How to use the promptly.prompt function in promptly

To help you get started, we’ve selected a few promptly 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 jedireza / frame / first-time-setup.js View on Github external
options = {
        default: 'frame'
    };
    const mongodbName = await Promptly.prompt(`MongoDB name: (${options.default})`, options);

    // connect to db

    const db = await MongoModels.connect({ uri: mongodbUri, db: mongodbName });

    if (!db) {
        throw Error('Could not connect to MongoDB.');
    }

    // get root user creds

    const rootEmail = await Promptly.prompt('Root user email:');
    const rootPassword = await Promptly.password('Root user password:');

    // clear tables

    await Promise.all([
        Account.deleteMany({}),
        AdminGroup.deleteMany({}),
        Admin.deleteMany({}),
        AuthAttempt.deleteMany({}),
        Session.deleteMany({}),
        Status.deleteMany({}),
        User.deleteMany({})
    ]);

    // setup root group
github kube-js / kube-ts-server / src / presenter / commander / functions / dbSeed / functions / createUser / index.ts View on Github external
const createUser = (config: FactoryConfig) => async ({
  defaultEmail,
  defaultPassword,
  rolesIds,
  userType,
}: Options) => {
  console.log(`--------------------------------------------------------`);
  console.log(`Creating ${userType}...`);

  const email = await promptly.prompt(
    `Choose email [default: ${defaultEmail}]: `,
    { default: defaultEmail }
  );
  const password = await promptly.password(
    `Choose password [default: ${defaultPassword}]: `,
    { default: defaultPassword }
  );

  const { service } = config;

  console.log('Validating input...');
  validateData(rules)({ email, password });
  console.log('Input validated successfuly!');

  console.log(`Creating ${userType}...`);
github spacekit / spacekit / bin / spacekit.js View on Github external
function signupRequest () {
  let msg = 'Would you like to create a new account?';
  Promptly.prompt(msg, { default: 'yes' }, (err, value) => {
    if (err) {
      console.log('Exception prompting input.');
      return;
    }

    if (value === 'yes') {
      console.log('Ok, let\'s create an account...');
      signup();
    } else {
      console.log('Ok, please enter your credentials...');
      configure();
    }
  });
}
github superfly / fly / packages / core / src / cmd / login.ts View on Github external
.action(async (opts, args, rest) => {
    const email = await promptly.prompt("Email: ")
    const password = await promptly.password("Password: ")
    const otp = await promptly.prompt("2FA code (if any): ", { default: "n/a", retry: false })
    try {
      const res = await axios.post(`${baseURL}/api/v1/sessions`, {
        data: { attributes: { email, password, otp } }
      })
      processResponse(res, () => {
        const homepath = homeConfigPath()
        const credspath = path.join(homepath, "credentials.yml")
        fs.writeFileSync(credspath, YAML.dump({ access_token: res.data.data.attributes.access_token }))
        console.log("Wrote credentials at:", credspath)
      })
    } catch (e) {
      if (e.response) {
        console.log(e.response.data)
      } else {
        throw e
      }
github hydrotik / node-hapi-react-redux-sass-typescript-mongo-webpack-hmr-gulp / setup.js View on Github external
devHost: ['buildDirTests', function (done) {

        Promptly.prompt('Local host: (localhost)', { default: 'localhost' }, done);
    }],
    devPort: ['devHost', function (done) {
github divshot / divshot-cli / lib / commands / weblogin.js View on Github external
function confirmPin (tokenLocation) {
    app.logger.info("To Log-In, Visit: " + tokenLocation.bold.underline);
    promptly.prompt("Enter PIN (you'll receive this upon log-in):", function (error, pin) {
      requestOptions = {}
      request.get(tokenLocation + '/' + pin, function (error, response, body) {
        var data = JSON.parse(body);

        if (error) {
          app.logger.error(error);
        }
        else if (response.statusCode == 200) {
          app.config.user.set('token', JSON.parse(body));
        }
        else if (data.error) {
          app.logger.info(response.statusCode.red.bold + ' ' + response.message);
        }
      })
    });
  }
github hydrotik / node-hapi-react-redux-sass-typescript-mongo-webpack-hmr-gulp / setup.js View on Github external
smtpHost: ['systemEmail', function (done, results) {

        Promptly.prompt('SMTP host: (smtp.gmail.com)', { default: 'smtp.gmail.com' }, done);
    }],
    smtpPort: ['smtpHost', function (done, results) {
github spacekit / spacekit / bin / spacekit.js View on Github external
apiKey: ['username', (done) => {
      Promptly.prompt('Api key', done);
    }]
  }, (err, results) => {
github spacekit / spacekit / bin / spacekit.js View on Github external
username: (done) => {
      let options = state.username
        ? { default: state.username } : undefined;
      Promptly.prompt('Username', options, done);
    },
    email: ['username', (done) => {
github Bannerets / tdl / src / prompt.js View on Github external
export const getAuthCode = (retry?: boolean): Promise =>
  promptly.prompt(retry
    ? 'Wrong auth code, please re-enter: '
    : 'Please enter auth code: ')

promptly

Simple command line prompting utility

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis