����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /proc/self/root/home/real/node-v13.0.1/deps/npm/test/tap/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/home/real/node-v13.0.1/deps/npm/test/tap/aliases.js
'use strict'

const BB = require('bluebird')

const common = require('../common-tap.js')
const fs = require('graceful-fs')
const mockTar = require('../util/mock-tarball.js')
const mr = common.fakeRegistry.compat
const path = require('path')
const rimraf = BB.promisify(require('rimraf'))
const Tacks = require('tacks')
const { test } = require('tap')

const { Dir, File } = Tacks
const readdirAsync = BB.promisify(fs.readdir)
const readFileAsync = BB.promisify(fs.readFile)

const testDir = common.pkg

let server
test('setup', t => {
  mr({}, (err, s) => {
    t.ifError(err, 'registry mocked successfully')
    server = s
    t.end()
  })
})

test('installs an npm: protocol alias package', t => {
  const fixture = new Tacks(Dir({
    'package.json': File({})
  }))
  fixture.create(testDir)
  const packument = {
    name: 'foo',
    'dist-tags': { latest: '1.2.4' },
    versions: {
      '1.2.3': {
        name: 'foo',
        version: '1.2.3',
        dist: {
          tarball: `${server.registry}/foo/-/foo-1.2.3.tgz`
        }
      },
      '1.2.4': {
        name: 'foo',
        version: '1.2.4',
        dist: {
          tarball: `${server.registry}/foo/-/foo-1.2.4.tgz`
        }
      }
    }
  }
  server.get('/foo').reply(200, packument)
  return mockTar({
    'package.json': JSON.stringify({
      name: 'foo',
      version: '1.2.3'
    })
  }).then(tarball => {
    server.get('/foo/-/foo-1.2.3.tgz').reply(200, tarball)
    server.get('/foo/-/foo-1.2.4.tgz').reply(200, tarball)
    return common.npm([
      'install', '[email protected]',
      '--cache', path.join(testDir, 'npmcache'),
      '--registry', server.registry
    ], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    t.equal(code, 0)
    t.comment(stdout)
    t.comment(stderr)
    return common.npm([
      'install', 'bar@npm:[email protected]',
      '--cache', path.join(testDir, 'npmcache'),
      '--registry', server.registry
    ], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    t.equal(code, 0)
    t.comment(stdout)
    t.comment(stderr)
    t.match(stdout, /\+ foo@1\.2\.3 \(as bar\)/, 'useful message')
    return readFileAsync(
      path.join(testDir, 'node_modules', 'bar', 'package.json'),
      'utf8'
    )
  }).then(JSON.parse).then(pkg => {
    t.similar(pkg, {
      name: 'foo',
      version: '1.2.3'
    }, 'successfully installed foo as bar in node_modules')
    return common.npm(['ls', '--json'], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    t.comment(stdout)
    t.comment(stderr)
    t.equal(code, 0, 'ls is clean')
    t.deepEqual(JSON.parse(stdout), {
      dependencies: {
        bar: {
          version: '1.2.3',
          from: 'bar@npm:[email protected]',
          resolved: 'http://localhost:' + common.port + '/foo/-/foo-1.2.3.tgz'
        },
        foo: {
          version: '1.2.3',
          from: '[email protected]',
          resolved: 'http://localhost:' + common.port + '/foo/-/foo-1.2.3.tgz'
        }
      }
    }, 'both dependencies listed correctly')
    return common.npm([
      'outdated', '--json',
      '--registry', server.registry
    ], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    t.equal(code, 1, 'non-zero because some packages outdated')
    t.comment(stdout)
    t.comment(stderr)
    const parsed = JSON.parse(stdout)
    t.match(parsed, {
      foo: {
        current: '1.2.3',
        wanted: '1.2.4',
        latest: '1.2.4',
        location: /node_modules[/\\]foo/
      },
      bar: {
        current: 'npm:[email protected]',
        wanted: 'npm:[email protected]',
        latest: 'npm:[email protected]',
        location: /node_modules[/\\]bar/
      }
    }, 'both regular and aliased dependency reported')
    return common.npm([
      'update',
      '--registry', server.registry
    ], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    t.equal(code, 0, 'update succeeded')
    t.comment(stdout)
    t.comment(stderr)
    return common.npm(['ls', '--json'], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    t.equal(code, 0, 'ls succeeded')
    t.comment(stdout)
    t.comment(stderr)
    const parsed = JSON.parse(stdout)
    t.deepEqual(parsed, {
      dependencies: {
        bar: {
          version: '1.2.4',
          from: 'bar@npm:[email protected]',
          resolved: 'http://localhost:' + common.port + '/foo/-/foo-1.2.4.tgz'
        },
        foo: {
          version: '1.2.4',
          from: '[email protected]',
          resolved: 'http://localhost:' + common.port + '/foo/-/foo-1.2.4.tgz'
        }
      }
    }, 'ls shows updated packages')
    return common.npm([
      'rm', 'bar',
      '--registry', server.registry
    ], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    t.equal(code, 0, 'rm succeeded')
    t.comment(stdout)
    t.comment(stderr)
    t.match(stdout, 'removed 1 package', 'notified of removed package')
    return readdirAsync(path.join(testDir, 'node_modules'))
  }).then(dir => {
    t.deepEqual(dir, ['foo'], 'regular foo left in place')
  }).then(() => rimraf(testDir))
})

test('installs a tarball dep as a different name than package.json', t => {
  return mockTar({
    'package.json': JSON.stringify({
      name: 'foo',
      version: '1.2.3'
    })
  }).then(tarball => {
    const fixture = new Tacks(Dir({
      'package.json': File({}),
      'foo.tgz': File(tarball)
    }))
    fixture.create(testDir)
    return common.npm([
      'install', 'file:foo.tgz',
      '--cache', path.join(testDir, 'npmcache'),
      '--registry', server.registry
    ], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    return common.npm([
      'install', 'bar@file:foo.tgz',
      '--cache', path.join(testDir, 'npmcache'),
      '--registry', server.registry
    ], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    t.comment(stdout)
    t.comment(stderr)
    t.match(stdout, /^\+ foo@1\.2\.3 \(as bar\)/, 'useful message')
    return readFileAsync(
      path.join(testDir, 'node_modules', 'bar', 'package.json'),
      'utf8'
    )
  }).then(JSON.parse).then(pkg => {
    t.similar(pkg, {
      name: 'foo',
      version: '1.2.3'
    }, 'successfully installed foo as bar in node_modules')
    return common.npm(['ls', '--json'], { cwd: testDir })
  }).then(([code, stdout, stderr]) => {
    t.comment(stdout)
    t.comment(stderr)
    t.similar(JSON.parse(stdout), {
      dependencies: {
        bar: {
          version: '1.2.3',
          from: 'file:foo.tgz'
        },
        foo: {
          version: '1.2.3',
          from: 'file:foo.tgz'
        }
      }
    }, 'both dependencies present')
  }).then(() => rimraf(testDir))
})

test('installs a symlink dep as a different name than package.json', t => {
  const fixture = new Tacks(Dir({
    'package.json': File({}),
    'foo': Dir({
      'package.json': File({
        name: 'foo',
        version: '1.2.3'
      })
    })
  }))
  fixture.create(testDir)
  return common.npm([
    'install', 'bar@file:foo',
    '--cache', path.join(testDir, 'npmcache'),
    '--registry', server.registry
  ], { cwd: testDir }).then(([code, stdout, stderr]) => {
    t.comment(stdout)
    t.comment(stderr)
    t.match(stdout, /^\+ foo@1\.2\.3 \(as bar\)/, 'useful message')
    return readFileAsync(
      path.join(testDir, 'node_modules', 'bar', 'package.json'),
      'utf8'
    )
  }).then(JSON.parse).then(pkg => {
    t.similar(pkg, {
      name: 'foo',
      version: '1.2.3'
    }, 'successfully installed foo as bar in node_modules')
  }).then(() => rimraf(testDir))
})

test('cleanup', t => {
  server.close()
  return rimraf(testDir)
})

test('npm audit supports aliases')
test('npm audit fix supports aliases')

ZeroDay Forums Mini