How to use the @serverless/utils.compact function in @serverless/utils

To help you get started, we’ve selected a few @serverless/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 serverless / components / src / plugins / Info / index.js View on Github external
forEach((item) => {
    const { type, data, children } = item
    const title = item.title || data.title
    log(`|- ${title} - ${type}`)
    const subLog = (line) => log(`   ${line}`)
    if (isArray(data)) {
      printArray(compact(data), subLog, level + 1)
    } else {
      // TODO BRN: Fix this...
      // eslint-disable-next-line no-use-before-define
      printObj(compact(data), subLog, level + 1)
    }
    if (children && level <= 1) {
      if (isArray(children)) {
        printArray(compact(children), subLog)
      } else {
        // TODO BRN: Fix this...
        // eslint-disable-next-line no-use-before-define
        printObj(compact(children), subLog)
      }
    }
  }, arr)
github serverless / components / src / plugins / Info / index.js View on Github external
forEach((item) => {
    const { type, data, children } = item
    const title = item.title || data.title
    log(`|- ${title} - ${type}`)
    const subLog = (line) => log(`   ${line}`)
    if (isArray(data)) {
      printArray(compact(data), subLog, level + 1)
    } else {
      // TODO BRN: Fix this...
      // eslint-disable-next-line no-use-before-define
      printObj(compact(data), subLog, level + 1)
    }
    if (children && level <= 1) {
      if (isArray(children)) {
        printArray(compact(children), subLog)
      } else {
        // TODO BRN: Fix this...
        // eslint-disable-next-line no-use-before-define
        printObj(compact(children), subLog)
      }
    }
  }, arr)
github serverless / components / src / plugins / Info / index.js View on Github external
const { instance } = context
    if (!instance) {
      context.log('Nothing deployed!')
      return
    }
    if (!isFunction(instance.info)) {
      throw new Error(`info method is not implemented for the component ${instance.name}`)
    }

    const { title, type, data, children } = await instance.info(context)
    context.log(`${title} - ${type}`)
    printObj(compact(data), context.log)
    if (children) {
      if (isArray(children)) {
        printArray(compact(children), context.log)
      } else {
        printObj(compact(children), context.log)
      }
    }

    return context
  }
}
github serverless / components / src / plugins / Info / index.js View on Github external
}
  const subLog = (line) => log(`   ${line}`)
  if (
    (keys(obj).length === 3 || (keys(obj).length === 4 && obj.children)) &&
    obj.title &&
    obj.type &&
    obj.data
  ) {
    if (isArray(obj.data)) {
      printArray(compact(obj.data), subLog, level + 1)
    } else {
      printObj(compact(obj.data), subLog, level)
    }
    if (obj.children && level <= 1) {
      if (isArray(obj.children)) {
        printArray(compact(obj.children), subLog)
      } else {
        printObj(compact(obj.children), subLog)
      }
    }
  } else {
    forEach((val, key) => {
      if (isArray(val)) {
        printArray(val, subLog, level + 1)
      } else if (isObject(val)) {
        log(`${key}:`)
        printObj(val, subLog, level + 1)
      } else {
        log(`${key}: ${val}`)
      }
    }, obj)
  }
github serverless / components / src / plugins / Info / index.js View on Github external
if (!instance) {
      context.log('Nothing deployed!')
      return
    }
    if (!isFunction(instance.info)) {
      throw new Error(`info method is not implemented for the component ${instance.name}`)
    }

    const { title, type, data, children } = await instance.info(context)
    context.log(`${title} - ${type}`)
    printObj(compact(data), context.log)
    if (children) {
      if (isArray(children)) {
        printArray(compact(children), context.log)
      } else {
        printObj(compact(children), context.log)
      }
    }

    return context
  }
}
github serverless / components / src / plugins / Info / index.js View on Github external
if (
    (keys(obj).length === 3 || (keys(obj).length === 4 && obj.children)) &&
    obj.title &&
    obj.type &&
    obj.data
  ) {
    if (isArray(obj.data)) {
      printArray(compact(obj.data), subLog, level + 1)
    } else {
      printObj(compact(obj.data), subLog, level)
    }
    if (obj.children && level <= 1) {
      if (isArray(obj.children)) {
        printArray(compact(obj.children), subLog)
      } else {
        printObj(compact(obj.children), subLog)
      }
    }
  } else {
    forEach((val, key) => {
      if (isArray(val)) {
        printArray(val, subLog, level + 1)
      } else if (isObject(val)) {
        log(`${key}:`)
        printObj(val, subLog, level + 1)
      } else {
        log(`${key}: ${val}`)
      }
    }, obj)
  }
}
github serverless / components / src / plugins / Info / index.js View on Github external
const printObj = (obj, log, level = 0) => {
  if (!obj) {
    return
  }
  const subLog = (line) => log(`   ${line}`)
  if (
    (keys(obj).length === 3 || (keys(obj).length === 4 && obj.children)) &&
    obj.title &&
    obj.type &&
    obj.data
  ) {
    if (isArray(obj.data)) {
      printArray(compact(obj.data), subLog, level + 1)
    } else {
      printObj(compact(obj.data), subLog, level)
    }
    if (obj.children && level <= 1) {
      if (isArray(obj.children)) {
        printArray(compact(obj.children), subLog)
      } else {
        printObj(compact(obj.children), subLog)
      }
    }
  } else {
    forEach((val, key) => {
      if (isArray(val)) {
        printArray(val, subLog, level + 1)
      } else if (isObject(val)) {
        log(`${key}:`)
        printObj(val, subLog, level + 1)
      } else {
github serverless / components / src / plugins / Info / index.js View on Github external
const printObj = (obj, log, level = 0) => {
  if (!obj) {
    return
  }
  const subLog = (line) => log(`   ${line}`)
  if (
    (keys(obj).length === 3 || (keys(obj).length === 4 && obj.children)) &&
    obj.title &&
    obj.type &&
    obj.data
  ) {
    if (isArray(obj.data)) {
      printArray(compact(obj.data), subLog, level + 1)
    } else {
      printObj(compact(obj.data), subLog, level)
    }
    if (obj.children && level <= 1) {
      if (isArray(obj.children)) {
        printArray(compact(obj.children), subLog)
      } else {
        printObj(compact(obj.children), subLog)
      }
    }
  } else {
    forEach((val, key) => {
      if (isArray(val)) {
        printArray(val, subLog, level + 1)
      } else if (isObject(val)) {
        log(`${key}:`)