Skip to content

Commit

Permalink
correct validate function
Browse files Browse the repository at this point in the history
  • Loading branch information
jcolemorrison committed Dec 30, 2017
1 parent 428b6f9 commit 9df4630
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/create/index.js
Expand Up @@ -41,7 +41,7 @@ module.exports = async function create (env) {
return log.e(error.message)
}

log()
log.p()
log.s(`Template ${chk.cyan(`${settings.templatename}`)} template created!`)
return log()
return log.p()
}
4 changes: 3 additions & 1 deletion src/deploy/index.js
Expand Up @@ -130,6 +130,8 @@ module.exports = async function deploy (env, opts) {
throw error
}

log.p(templateName, stackName, profile, stackFile)
// log.p(templateName, stackName, profile, stackFile)
// first we need to handle if there's a template and stack name

// furthermore, let's not write anything until the entire thing is done - this way we can avoid unnecessary midway clean up
}
22 changes: 15 additions & 7 deletions src/utils/index.js
Expand Up @@ -9,7 +9,7 @@ const inq = require('inquirer')
const { NO_AWS_CREDENTIALS, AWS_REGIONS } = require('./constants')

const { log } = console
const { cyan } = chk
const { cyan, whiteBright } = chk

exports.log = {
p: log,
Expand Down Expand Up @@ -222,7 +222,7 @@ const buildNumberInquiry = (param, name) => {
}

if (type === 'input' || type === 'password') {
inquiry.validation = (input) => {
inquiry.validate = (input) => {
if (!/^-?\d+\.?\d*$/.test(input)) {
return ConstraintDescription || `${name} must be an integer or float!`
}
Expand Down Expand Up @@ -271,9 +271,8 @@ const buildStringInquiry = (param, name) => {
inquiry.choices = AllowedValues
}


if (type === 'input' || type === 'password') {
inquiry.validation = (input) => {
inquiry.validate = (input) => {
if (MaxLength && input.length > parseInt(MaxLength, 10)) {
return `${name} can be no greater than ${MaxLength}!`
}
Expand Down Expand Up @@ -316,7 +315,7 @@ const buildNumberListInquiry = (param, name) => {
}

if (type === 'input') {
inquiry.validation = (input) => {
inquiry.validate = (input) => {
if (!input) return true

if (input) {
Expand Down Expand Up @@ -423,10 +422,11 @@ exports.buildParamInquiry = (param, name) => {
default:
throw new Error(`Invalid type ${Type}`)
}
log(param)

return inquiry
}

exports.selectStackParams = (Parameters, profile, region) => {
exports.selectStackParams = async (Parameters, profile, region) => {
const paramNames = Parameters && Object.keys(Parameters)

if (paramNames && paramNames.length < 1) return false
Expand All @@ -438,6 +438,14 @@ exports.selectStackParams = (Parameters, profile, region) => {
})

log(paramInq)

try {
log(chk.bold.whiteBright('Parameter Values to be used for the stack:\n'))
const choices = await inq.prompt(paramInq)
log(choices)
} catch (error) {
throw error
}
}

exports.selectRegion = async (profile, message) => {
Expand Down

0 comments on commit 9df4630

Please sign in to comment.