How to use the gluegun/toolbox.print function in gluegun

To help you get started, we’ve selected a few gluegun 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 graphprotocol / graph-cli / src / type-generator.js View on Github external
spinner.stop()
        toolbox.print.error(`${error}\n`)
        spinner.start()
      },
    })

    // Catch keyboard interrupt: close watcher and exit process
    process.on('SIGINT', () => {
      watcher.close()
      process.exit()
    })

    try {
      await watcher.watch()
    } catch (e) {
      toolbox.print.error(`${e.message}`)
    }
  }
}
github graphprotocol / graph-cli / src / command-helpers / compiler.js View on Github external
const createCompiler = (manifest, { ipfs, outputDir, outputFormat, skipMigrations }) => {
  // Parse the IPFS URL
  let url
  try {
    url = ipfs ? new URL(ipfs) : undefined
  } catch (e) {
    toolbox.print.error(`Invalid IPFS URL: ${ipfs}
The IPFS URL must be of the following format: http(s)://host[:port]/[path]`)
    return null
  }

  // Connect to the IPFS node (if a node address was provided)
  ipfs = ipfs
    ? ipfsHttpClient({
        protocol: url.protocol.replace(/[:]+$/, ''),
        host: url.hostname,
        port: url.port,
        'api-path': url.pathname.replace(/\/$/, '') + '/api/v0/',
      })
    : undefined

  return new Compiler({
    ipfs,
github infinitered / solidarity / __tests__ / command_helpers / checkRequirement.ts View on Github external
beforeEach(() => {
    fail = jest.fn()
    stop = jest.fn()
    succeed = jest.fn()
    const spinner = {
      fail,
      stop,
      succeed,
    }

    solidarityExtension(context)
    context.print = {
      spin: jest.fn(() => spinner),
      error: jest.fn(),
    }
    context.strings = strings
    context.system = {
      run: jest.fn().mockResolvedValue(true),
      spawn: jest.fn().mockReturnValue(
        Promise.resolve({
          stdout: 'you did it!',
          status: 0,
        })
      ),
    }
  })
github graphprotocol / graph-cli / src / command-helpers / spinner.js View on Github external
const step = (spinner, subject, text) => {
  if (text) {
    spinner.stopAndPersist({
      text: toolbox.print.colors.muted(`${subject} ${text}`),
    })
  } else {
    spinner.stopAndPersist({ text: toolbox.print.colors.muted(subject) })
  }
  spinner.start()
  return spinner
}
github graphprotocol / graph-cli / src / compiler.js View on Github external
})
      }
      let subgraph = await this.loadSubgraph()
      let compiledSubgraph = await this.compileSubgraph(subgraph)
      let localSubgraph = await this.writeSubgraphToOutputDirectory(compiledSubgraph)

      if (this.ipfs !== undefined) {
        let ipfsHash = await this.uploadSubgraphToIPFS(localSubgraph)
        this.completed(ipfsHash)
        return ipfsHash
      } else {
        this.completed(path.join(this.options.outputDir, 'subgraph.yaml'))
        return true
      }
    } catch (e) {
      toolbox.print.error(e)
      return false
    }
  }
github graphprotocol / graph-cli / src / type-generator.js View on Github external
      onReady: () => (spinner = toolbox.print.spin('Watching subgraph files')),
      onTrigger: async changedFile => {
github graphprotocol / graph-cli / src / compiler.js View on Github external
completed(ipfsHashOrPath) {
    toolbox.print.info('')
    toolbox.print.success(`Build completed: ${chalk.blue(ipfsHashOrPath)}`)
    toolbox.print.info('')
  }
github graphprotocol / graph-cli / src / command-helpers / auth.js View on Github external
)
      } else if (process.platform === 'darwin') {
        toolbox.print.warning(
          `Could not get access token from macOS Keychain: ${e.message}`,
        )
      } else if (process.platform === 'linux') {
        toolbox.print.warning(
          `Could not get access token from libsecret ` +
            `(usually gnome-keyring or ksecretservice): ${e.message}`,
        )
      } else {
        toolbox.print.warning(
          `Could not get access token from OS secret storage service: ${e.message}`,
        )
      }
      toolbox.print.info(`Continuing without an access token\n`)
    }
  }
}
github graphprotocol / graph-cli / src / command-helpers / spinner.js View on Github external
const withSpinner = async (text, errorText, warningText, f) => {
  let spinner = toolbox.print.spin(text)
  try {
    let result = await f(spinner)
    if (typeof result === 'object') {
      let hasWarning = Object.keys(result).indexOf('warning') >= 0
      let hasResult = Object.keys(result).indexOf('result') >= 0
      if (hasWarning && hasResult) {
        if (result.warning !== null) {
          spinner.warn(`${warningText}: ${result.warning}`)
        }
        spinner.succeed(text)
        return result.result
      } else {
        spinner.succeed(text)
        return result
      }
    } else {
github graphprotocol / graph-cli / src / command-helpers / jsonrpc.js View on Github external
const createJsonRpcClient = url => {
  let params = {
    host: url.hostname,
    port: url.port,
    path: url.pathname,
  }

  if (url.protocol === 'https:') {
    return jayson.Client.https(params)
  } else if (url.protocol === 'http:') {
    return jayson.Client.http(params)
  } else {
    toolbox.print.error(
      `Unsupported protocol: ${url.protocol.substring(0, url.protocol.length - 1)}`
    )
    toolbox.print.error(
      'The Graph Node URL must be of the following format: http(s)://host[:port]/[path]'
    )
    return null
  }
}