How to use the @kui-shell/plugin-editor.extension function in @kui-shell/plugin-editor

To help you get started, we’ve selected a few @kui-shell/plugin-editor 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 / plugins / plugin-openwhisk-editor-extensions / src / lib / cmds / compose.ts View on Github external
console.error(err)
          } else {
            resolve()
          }
        })
      })

    const action = getEntity()
    debug('addWskflow action', action)
    if (action.type !== 'compositions') {
      // no need to generate wskflows if this isn't a composition
      return
    }

    if (!filepath) {
      filepath = await mktemp(extension(action.exec.kind))
    }

    const source = editor.getValue()
    await write(source)

    const ast = await generateAST(source, filepath)
    if (ast.statusCode || ast.code) {
      // some error generating the AST
      editor.clearDecorations()
      handleParseError(ast, filepath, editor)
    } else {
      if (differentASTs(action.ast, ast)) {
        action.ast = ast
        await updateView()
      }
    }
github IBM / kui / plugins / plugin-openwhisk-editor-extensions / src / lib / model / composition-persister.ts View on Github external
new Promise((resolve, reject) => {
      // eslint-disable-next-line @typescript-eslint/no-var-requires
      const fs = require('fs')
      // eslint-disable-next-line @typescript-eslint/no-var-requires
      const tmp = require('tmp')

      tmp.file({ prefix: 'shell-', postfix: extension(app.exec.kind) }, (err, filepath, fd, cleanup) => {
        if (err) {
          reject(err)
        } else {
          fs.write(fd, app.exec.code, async err => {
            if (err) {
              reject(err)
            } else {
              const { REPL } = await import('@kui-shell/core/api/repl')
              return REPL.pexec(
                `wsk app update ${REPL.encodeComponent(app.name)} ${REPL.encodeComponent(filepath)} --kind ${
                  app.exec.kind
                }`
              )
                .then(app => {
                  cleanup()
                  resolve(app)