How to use the @kui-shell/core/core/repl.qexec function in @kui-shell/core

To help you get started, we’ve selected a few @kui-shell/core 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 IBM / kui / packages / builder / examples / plugin-sample / src / lib / cmds / open-sidecar.ts View on Github external
const openSidecar = async () => {
  if (isHeadless()) {
    throw new Error(`Can't open sidecar in headless mode. Suggested command: sample sidecar --ui.`)
  }

  const action = await $('sample create action')
  console.error('!!!!!', action)

  // here we add a field
  action.demo = { sampleField: 'This is a sample sidecar mode' }

  return action
}
github IBM / kui / plugins / plugin-openwhisk-debug / src / plugin.ts View on Github external
.then(entry => {
        // this is where we launch the local debugger, and wait for it to terminate
        // as to why we need to hack for the Waiting for debugger on stderr:
        // https://bugs.chromium.org/p/chromium/issues/detail?id=706916
        const logLines = []
        qexec(`! docker exec shell-local node --inspect-brk=0.0.0.0:5858 ${containerFolderPath}/${entry}`, undefined, undefined,
          { stdout: line => logLines.push(logLine('stdout', line)),
            stderr: line => {
              if (line.indexOf('Waiting for the debugger to disconnect') >= 0) {
                qexec(`! docker cp shell-local:${resultFilePath} ${dirPath}/debug-session.out`)
                  .then(() => fs.readFile(`${dirPath}/debug-session.out`))
                  .then(result => JSON.parse(result.toString()))
                  .then(result => { cleanupCallback(); return result }) // clean up tmpPath
                  .then(result => resolve({
                    result,
                    logs: logLines,
                    init_time: 0
                  }))
              } else if (line.indexOf('Debugger listening on') >= 0) {
                // squash
              } else if (line.indexOf('For help see https://nodejs.org/en/docs/inspector') >= 0) {
                // squash
github IBM / kui / plugins / plugin-bash-like / src / lib / cmds / git-commit.ts View on Github external
eventBus.once('/editor/save', (model, { event }) => {
              if (event === 'save') {
                debug('got save event', model)
                clearSidecar(tab)

                if (model.exec.code === msg) {
                  debug('empty commit message')
                  reject(new Error('Aborting commit due to empty commit message.'))
                } else {
                  // continue with the actual commit
                  resolve(qexec(`${command} --file "${filepath}"`))
                }
              }
            })

            const editor = await qexec(`edit ${filepath}`, undefined, undefined, execOptions)
            debug('editor', editor)
            showInSidecar(tab, editor)
          }
        })
      } catch (err) {
github IBM / kui / plugins / plugin-openwhisk-debug / src / plugin.ts View on Github external
stderr: line => {
              if (line.indexOf('Waiting for the debugger to disconnect') >= 0) {
                qexec(`! docker cp shell-local:${resultFilePath} ${dirPath}/debug-session.out`)
                  .then(() => fs.readFile(`${dirPath}/debug-session.out`))
                  .then(result => JSON.parse(result.toString()))
                  .then(result => { cleanupCallback(); return result }) // clean up tmpPath
                  .then(result => resolve({
                    result,
                    logs: logLines,
                    init_time: 0
                  }))
              } else if (line.indexOf('Debugger listening on') >= 0) {
                // squash
              } else if (line.indexOf('For help see https://nodejs.org/en/docs/inspector') >= 0) {
                // squash
              } else if (line.indexOf('Debugger attached') >= 0) {
                // squash
              } else {
                // otherwise, hopefully this is a legit application log line
github IBM / kui / plugins / plugin-bash-like / src / lib / cmds / git-commit.ts View on Github external
eventBus.once('/editor/save', (model, { event }) => {
              if (event === 'save') {
                debug('got save event', model)
                clearSidecar(tab)

                if (model.exec.code === msg) {
                  debug('empty commit message')
                  reject(new Error('Aborting commit due to empty commit message.'))
                } else {
                  // continue with the actual commit
                  resolve(qexec(`${command} --file "${filepath}"`))
                }
              }
            })
github IBM / kui / plugins / plugin-openwhisk-debug / src / plugin.ts View on Github external
const displayAsActivation = async (tab: Tab, sessionType: string, { kind, name: actionName, name }: { kind: string; actionName: string; name: string }, start: number, protoActivation?: ProtoActivation) => {
  try {
    // when the session ended
    const end = Date.now()

    const ns = await qexec('wsk namespace current')

    const annotations: { key: string; value: string | number | boolean }[] = [
      { key: 'path', value: `${ns}/${name}` },
      { key: 'kind', value: kind }
    ]

    if (protoActivation && protoActivation.init_time) {
      // fake up an initTime annotation
      annotations.push({ key: 'initTime', value: protoActivation.init_time })
    }

    // fake up an activation record and show it
    showEntity(tab, addActivationModes({
      type: 'activations',
      activationId: sessionType, // e.g. "debug session"
      name: actionName,
github IBM / kui / plugins / plugin-core-support / src / lib / cmds / run.ts View on Github external
const execInSequence = async function(
  arr: string[],
  status: { value: string; css: string; done?: boolean; onclick?: (evt: MouseEvent) => void }[],
  idx: number
) {
  const item = arr[idx]

  try {
    const thisResult = await repl.qexec(item)
    status[idx].value = 'Done'
    status[idx].css = status[idx].css.replace(/yellow-background/, 'green-background')
    status[idx].done = true
    status[idx].onclick = (event: MouseEvent) => {
      event.stopPropagation()
      repl.pexec('show', {
        parameters: {
          command: item,
          success: true,
          content: thisResult
        }
      })
    }
  } catch (err) {
    const content = await Promise.resolve(err.message)
    const isWarning = /already exists|already has/i.test(typeof content === 'string' ? content : err.raw.message)
github IBM / kui / plugins / plugin-openwhisk-debug / src / plugin.ts View on Github external
const getActionCode = (actionName: string, spinnerDiv: Element) => {
  appendIncreContent('Fetching action', spinnerDiv)
  return qexec(`wsk action get ${actionName}`)
    .then(action => {
      let param = {}
      if (action.parameters) {
        action.parameters.forEach(a => { param[a.name] = a.value })
      }
      return Object.assign(action.exec, { param: param })
    })
}
github IBM / kui / plugins / plugin-wskflow / src / lib / fsm2graph.ts View on Github external
names.forEach(name => {
      array.push(repl.qexec(`wsk action get "${name}"`))
    })
    await Promise.all(array.map(p => p.catch(e => e)))