1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-04 12:40:05 +02:00

update packages to latest version

This commit is contained in:
s2
2022-08-20 18:51:33 +02:00
parent 09663a35a5
commit 806ebf9a57
4513 changed files with 366205 additions and 92512 deletions

17
node_modules/npm/test/tap/00-check-mock-dep.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
console.log("TAP Version 13")
process.on("uncaughtException", function (er) {
if (er) { throw er }
console.log("not ok - Failed checking mock registry dep. Expect much fail!")
console.log("1..1")
process.exit(1)
})
var assert = require("assert")
var semver = require("semver")
var mock = require("npm-registry-mock/package.json").version
var req = require("../../package.json").devDependencies["npm-registry-mock"]
assert(semver.satisfies(mock, req))
console.log("ok")
console.log("1..1")

83
node_modules/npm/test/tap/00-config-setup.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
var fs = require("graceful-fs")
var path = require("path")
var userconfigSrc = path.resolve(__dirname, "..", "fixtures", "config", "userconfig")
exports.userconfig = userconfigSrc + "-with-gc"
exports.globalconfig = path.resolve(__dirname, "..", "fixtures", "config", "globalconfig")
exports.builtin = path.resolve(__dirname, "..", "fixtures", "config", "builtin")
exports.malformed = path.resolve(__dirname, "..", "fixtures", "config", "malformed")
exports.ucData =
{ globalconfig: exports.globalconfig,
email: "i@izs.me",
"env-thing": "asdf",
"init.author.name": "Isaac Z. Schlueter",
"init.author.email": "i@izs.me",
"init.author.url": "http://blog.izs.me/",
"init.version": "1.2.3",
"proprietary-attribs": false,
"npm:publishtest": true,
"_npmjs.org:couch": "https://admin:password@localhost:5984/registry",
"npm-www:nocache": "1",
nodedir: "/Users/isaacs/dev/js/node-v0.8",
"sign-git-tag": true,
message: "v%s",
"strict-ssl": false,
"tmp": process.env.HOME + "/.tmp",
_auth: "dXNlcm5hbWU6cGFzc3dvcmQ=",
_token:
{ AuthSession: "yabba-dabba-doodle",
version: "1",
expires: "1345001053415",
path: "/",
httponly: true } }
// set the userconfig in the env
// unset anything else that npm might be trying to foist on us
Object.keys(process.env).forEach(function (k) {
if (k.match(/^npm_config_/i)) {
delete process.env[k]
}
})
process.env.npm_config_userconfig = exports.userconfig
process.env.npm_config_other_env_thing = 1000
process.env.random_env_var = "asdf"
process.env.npm_config__underbar_env_thing = "underful"
process.env.NPM_CONFIG_UPPERCASE_ENV_THING = 42
exports.envData = {
userconfig: exports.userconfig,
"_underbar-env-thing": "underful",
"uppercase-env-thing": "42",
"other-env-thing": "1000"
}
exports.envDataFix = {
userconfig: exports.userconfig,
"_underbar-env-thing": "underful",
"uppercase-env-thing": 42,
"other-env-thing": 1000
}
var projectConf = path.resolve(__dirname, '..', '..', '.npmrc')
try {
fs.statSync(projectConf)
} catch (er) {
// project conf not found, probably working with packed npm
fs.writeFileSync(projectConf, 'save-prefix = ~\nproprietary-attribs = false\n')
}
var projectRc = path.join(__dirname, '..', 'fixtures', 'config', '.npmrc')
try {
fs.statSync(projectRc)
} catch (er) {
// project conf not found, probably working with packed npm
fs.writeFileSync(projectRc, 'just = testing')
}
if (module === require.main) {
// set the globalconfig in the userconfig
var uc = fs.readFileSync(userconfigSrc)
var gcini = "globalconfig = " + exports.globalconfig + "\n"
fs.writeFileSync(exports.userconfig, gcini + uc)
console.log("1..1")
console.log("ok 1 setup done")
}

27
node_modules/npm/test/tap/00-verify-bundle-deps.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
var fs = require("fs")
var path = require("path")
var test = require("tap").test
var manifest = require("../../package.json")
var deps = Object.keys(manifest.dependencies)
var dev = Object.keys(manifest.devDependencies)
var bundled = manifest.bundleDependencies
test("all deps are bundled deps or dev deps", function (t) {
deps.forEach(function (name) {
t.assert(
bundled.indexOf(name) !== -1,
name + " is in bundledDependencies"
)
})
t.same(
fs.readdirSync(path.resolve(__dirname, "../../node_modules")).filter(function (name) {
return (dev.indexOf(name) === -1) && (name !== ".bin")
}).sort(),
bundled.sort(),
"bundleDependencies matches what's in node_modules"
)
t.end()
})

18
node_modules/npm/test/tap/00-verify-ls-ok.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var common = require("../common-tap")
var test = require("tap").test
var path = require("path")
var cwd = path.resolve(__dirname, "..", "..")
var fs = require("fs")
test("npm ls in npm", function (t) {
t.ok(fs.existsSync(cwd), "ensure that the path we are calling ls within exists")
var files = fs.readdirSync(cwd)
t.notEqual(files.length, 0, "ensure there are files in the directory we are to ls")
var opt = { cwd: cwd, stdio: [ "ignore", "ignore", 2 ] }
common.npm(["ls"], opt, function (err, code) {
t.ifError(err, "error should not exist")
t.equal(code, 0, "npm ls exited with code")
t.end()
})
})

57
node_modules/npm/test/tap/404-parent.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
var common = require("../common-tap.js")
var test = require("tap").test
var npm = require("../../")
var osenv = require("osenv")
var path = require("path")
var fs = require("fs")
var rimraf = require("rimraf")
var mkdirp = require("mkdirp")
var pkg = path.resolve(__dirname, "404-parent")
var mr = require("npm-registry-mock")
test("404-parent: if parent exists, specify parent in error message", function (t) {
setup()
rimraf.sync(path.resolve(pkg, "node_modules"))
performInstall(function (err) {
t.ok(err instanceof Error, "error was returned")
t.ok(err.parent === "404-parent-test", "error's parent set")
t.end()
})
})
test("cleanup", function (t) {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
t.end()
})
function setup() {
mkdirp.sync(pkg)
mkdirp.sync(path.resolve(pkg, "cache"))
fs.writeFileSync(path.resolve(pkg, "package.json"), JSON.stringify({
author: "Evan Lucas",
name: "404-parent-test",
version: "0.0.0",
description: "Test for 404-parent",
dependencies: {
"test-npm-404-parent-test": "*"
}
}), "utf8")
process.chdir(pkg)
}
function plugin (server) {
server.get("/test-npm-404-parent-test")
.reply(404, {"error": "version not found"})
}
function performInstall (cb) {
mr({port : common.port, plugin : plugin}, function (er, s) { // create mock registry.
npm.load({registry: common.registry}, function () {
npm.commands.install(pkg, [], function (err) {
cb(err)
s.close() // shutdown mock npm server.
})
})
})
}

View File

@@ -0,0 +1,38 @@
var test = require('tap').test
var common = require('../common-tap.js')
var mr = require('npm-registry-mock')
var server
test('setup', function (t) {
mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
t.ifError(err, 'registry mocked successfully')
server = s
t.end()
})
})
test('scoped package names not mangled on error with non-root registry', function (t) {
common.npm(
[
'cache',
'add',
'@scope/foo@*',
'--force'
],
{},
function (er, code, stdout, stderr) {
t.ifError(er, 'correctly handled 404')
t.equal(code, 1, 'exited with error')
t.match(stderr, /404 Not found/, 'should notify the sort of error as a 404')
t.match(stderr, /@scope\/foo/, 'should have package name in error')
t.end()
}
)
})
test('cleanup', function (t) {
t.pass('cleaned up')
server.done()
server.close()
t.end()
})

39
node_modules/npm/test/tap/404-private-registry.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
var test = require('tap').test
var path = require('path')
var common = require('../common-tap.js')
var mr = require('npm-registry-mock')
var server
var packageName = path.basename(__filename,'.js')
test('setup', function (t) {
mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
t.ifError(err, 'registry mocked successfully')
server = s
t.end()
})
})
test('package names not mangled on error with non-root registry', function (t) {
common.npm(
[
'cache',
'add',
packageName + '@*'
],
{},
function (er, code, stdout, stderr) {
t.ifError(er, 'correctly handled 404')
t.equal(code, 1, 'exited with error')
t.match(stderr, packageName, 'should have package name in error')
t.end()
}
)
})
test('cleanup', function (t) {
t.pass('cleaned up')
server.done()
server.close()
t.end()
})

527
node_modules/npm/test/tap/access.js generated vendored Normal file
View File

@@ -0,0 +1,527 @@
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var mr = require('npm-registry-mock')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'access')
var server
var scoped = {
name: '@scoped/pkg',
version: '1.1.1'
}
test('setup', function (t) {
mkdirp(pkg, function (er) {
t.ifError(er, pkg + ' made successfully')
mr({port: common.port}, function (err, s) {
t.ifError(err, 'registry mocked successfully')
server = s
fs.writeFile(
path.join(pkg, 'package.json'),
JSON.stringify(scoped),
function (er) {
t.ifError(er, 'wrote package.json')
t.end()
}
)
})
})
})
test('npm access public on current package', function (t) {
server.post('/-/package/%40scoped%2Fpkg/access', JSON.stringify({
access: 'public'
})).reply(200, {
accessChanged: true
})
common.npm([
'access',
'public',
'--registry', common.registry,
'--loglevel', 'silent'
], {
cwd: pkg
},
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access')
t.equal(code, 0, 'exited OK')
t.equal(stderr, '', 'no error output')
t.end()
})
})
test('npm access public when no package passed and no package.json', function (t) {
// need to simulate a missing package.json
var missing = path.join(__dirname, 'access-public-missing-guard')
mkdirp.sync(path.join(missing, 'node_modules'))
common.npm([
'access',
'public',
'--registry', common.registry
], {
cwd: missing
},
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access')
t.match(stderr, /no package name passed to command and no package.json found/)
rimraf.sync(missing)
t.end()
})
})
test('npm access public when no package passed and invalid package.json', function (t) {
// need to simulate a missing package.json
var invalid = path.join(__dirname, 'access-public-invalid-package')
mkdirp.sync(path.join(invalid, 'node_modules'))
// it's hard to force `read-package-json` to break w/o ENOENT, but this will do it
fs.writeFileSync(path.join(invalid, 'package.json'), '{\n')
common.npm([
'access',
'public',
'--registry', common.registry
], {
cwd: invalid
},
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access')
t.match(stderr, /Failed to parse json/)
rimraf.sync(invalid)
t.end()
})
})
test('npm access restricted on current package', function (t) {
server.post('/-/package/%40scoped%2Fpkg/access', JSON.stringify({
access: 'restricted'
})).reply(200, {
accessChanged: true
})
common.npm([
'access',
'restricted',
'--registry', common.registry,
'--loglevel', 'silent'
], {
cwd: pkg
},
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access')
t.equal(code, 0, 'exited OK')
t.equal(stderr, '', 'no error output')
t.end()
})
})
test('npm access on named package', function (t) {
server.post('/-/package/%40scoped%2Fanother/access', {
access: 'public'
}).reply(200, {
accessChaged: true
})
common.npm(
[
'access',
'public', '@scoped/another',
'--registry', common.registry,
'--loglevel', 'silent'
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access')
t.equal(code, 0, 'exited OK')
t.equal(stderr, '', 'no error output')
t.end()
}
)
})
test('npm change access on unscoped package', function (t) {
common.npm(
[
'access',
'restricted', 'yargs',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ok(code, 'exited with Error')
t.matches(
stderr, /access commands are only accessible for scoped packages/)
t.end()
}
)
})
test('npm access grant read-only', function (t) {
server.put('/-/team/myorg/myteam/package', {
permissions: 'read-only',
package: '@scoped/another'
}).reply(201, {
accessChaged: true
})
common.npm(
[
'access',
'grant', 'read-only',
'myorg:myteam',
'@scoped/another',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access grant')
t.equal(code, 0, 'exited with Error')
t.end()
}
)
})
test('npm access grant read-write', function (t) {
server.put('/-/team/myorg/myteam/package', {
permissions: 'read-write',
package: '@scoped/another'
}).reply(201, {
accessChaged: true
})
common.npm(
[
'access',
'grant', 'read-write',
'myorg:myteam',
'@scoped/another',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access grant')
t.equal(code, 0, 'exited with Error')
t.end()
}
)
})
test('npm access grant others', function (t) {
common.npm(
[
'access',
'grant', 'rerere',
'myorg:myteam',
'@scoped/another',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ok(code, 'exited with Error')
t.matches(stderr, /read-only/)
t.matches(stderr, /read-write/)
t.end()
}
)
})
test('npm access revoke', function (t) {
server.delete('/-/team/myorg/myteam/package', {
package: '@scoped/another'
}).reply(200, {
accessChaged: true
})
common.npm(
[
'access',
'revoke',
'myorg:myteam',
'@scoped/another',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access grant')
t.equal(code, 0, 'exited with Error')
t.end()
}
)
})
test('npm access ls-packages with no team', function (t) {
var serverPackages = {
'@foo/bar': 'write',
'@foo/util': 'read'
}
var clientPackages = {
'@foo/bar': 'read-write',
'@foo/util': 'read-only'
}
server.get(
'/-/org/username/package?format=cli'
).reply(200, serverPackages)
common.npm(
[
'access',
'ls-packages',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access ls-packages')
t.same(JSON.parse(stdout), clientPackages)
t.end()
}
)
})
test('npm access ls-packages on team', function (t) {
var serverPackages = {
'@foo/bar': 'write',
'@foo/util': 'read'
}
var clientPackages = {
'@foo/bar': 'read-write',
'@foo/util': 'read-only'
}
server.get(
'/-/team/myorg/myteam/package?format=cli'
).reply(200, serverPackages)
common.npm(
[
'access',
'ls-packages',
'myorg:myteam',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access ls-packages')
t.same(JSON.parse(stdout), clientPackages)
t.end()
}
)
})
test('npm access ls-packages on org', function (t) {
var serverPackages = {
'@foo/bar': 'write',
'@foo/util': 'read'
}
var clientPackages = {
'@foo/bar': 'read-write',
'@foo/util': 'read-only'
}
server.get(
'/-/org/myorg/package?format=cli'
).reply(200, serverPackages)
common.npm(
[
'access',
'ls-packages',
'myorg',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access ls-packages')
t.same(JSON.parse(stdout), clientPackages)
t.end()
}
)
})
test('npm access ls-packages on user', function (t) {
var serverPackages = {
'@foo/bar': 'write',
'@foo/util': 'read'
}
var clientPackages = {
'@foo/bar': 'read-write',
'@foo/util': 'read-only'
}
server.get(
'/-/org/myorg/package?format=cli'
).reply(404, {error: 'nope'})
server.get(
'/-/user/myorg/package?format=cli'
).reply(200, serverPackages)
common.npm(
[
'access',
'ls-packages',
'myorg',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access ls-packages')
t.same(JSON.parse(stdout), clientPackages)
t.end()
}
)
})
test('npm access ls-packages with no package specified or package.json', function (t) {
// need to simulate a missing package.json
var missing = path.join(__dirname, 'access-missing-guard')
mkdirp.sync(path.join(missing, 'node_modules'))
var serverPackages = {
'@foo/bar': 'write',
'@foo/util': 'read'
}
var clientPackages = {
'@foo/bar': 'read-write',
'@foo/util': 'read-only'
}
server.get(
'/-/org/myorg/package?format=cli'
).reply(404, {error: 'nope'})
server.get(
'/-/user/myorg/package?format=cli'
).reply(200, serverPackages)
common.npm(
[
'access',
'ls-packages',
'myorg',
'--registry', common.registry
],
{ cwd: missing },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access ls-packages')
t.same(JSON.parse(stdout), clientPackages)
rimraf.sync(missing)
t.end()
}
)
})
test('npm access ls-collaborators on current', function (t) {
var serverCollaborators = {
'myorg:myteam': 'write',
'myorg:anotherteam': 'read'
}
var clientCollaborators = {
'myorg:myteam': 'read-write',
'myorg:anotherteam': 'read-only'
}
server.get(
'/-/package/%40scoped%2Fpkg/collaborators?format=cli'
).reply(200, serverCollaborators)
common.npm(
[
'access',
'ls-collaborators',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access ls-collaborators')
t.same(JSON.parse(stdout), clientCollaborators)
t.end()
}
)
})
test('npm access ls-collaborators on package', function (t) {
var serverCollaborators = {
'myorg:myteam': 'write',
'myorg:anotherteam': 'read'
}
var clientCollaborators = {
'myorg:myteam': 'read-write',
'myorg:anotherteam': 'read-only'
}
server.get(
'/-/package/%40scoped%2Fanother/collaborators?format=cli'
).reply(200, serverCollaborators)
common.npm(
[
'access',
'ls-collaborators',
'@scoped/another',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access ls-collaborators')
t.same(JSON.parse(stdout), clientCollaborators)
t.end()
}
)
})
test('npm access ls-collaborators on current w/user filter', function (t) {
var serverCollaborators = {
'myorg:myteam': 'write',
'myorg:anotherteam': 'read'
}
var clientCollaborators = {
'myorg:myteam': 'read-write',
'myorg:anotherteam': 'read-only'
}
server.get(
'/-/package/%40scoped%2Fanother/collaborators?format=cli&user=zkat'
).reply(200, serverCollaborators)
common.npm(
[
'access',
'ls-collaborators',
'@scoped/another',
'zkat',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access ls-collaborators')
t.same(JSON.parse(stdout), clientCollaborators)
t.end()
}
)
})
test('npm access edit', function (t) {
common.npm(
[
'access',
'edit', '@scoped/another',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ok(code, 'exited with Error')
t.match(stderr, /edit subcommand is not implemented yet/)
t.end()
}
)
})
test('npm access blerg', function (t) {
common.npm(
[
'access',
'blerg', '@scoped/another',
'--registry', common.registry
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ok(code, 'exited with Error')
t.matches(stderr, /Usage:/)
t.end()
}
)
})
test('cleanup', function (t) {
t.pass('cleaned up')
rimraf.sync(pkg)
server.done()
server.close()
t.end()
})

137
node_modules/npm/test/tap/add-local.js generated vendored Normal file
View File

@@ -0,0 +1,137 @@
var path = require('path')
var test = require('tap').test
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var requireInject = require('require-inject')
var pkg = path.join(__dirname, '/local-dir')
var cache = path.join(pkg, '/cache')
var tmp = path.join(pkg, '/tmp')
var prefix = path.join(pkg, '/prefix')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
test('addLocal directory race on Windows', function (t) {
setup()
var p = {
name: 'test',
version: '1.0.0',
type: 'directory',
spec: pkg
}
var fixture = new Tacks(
Dir({
'package.json': File(p)
})
)
var addLocal = requireInject('../../lib/cache/add-local', {
'../../lib/npm.js': {
cache: cache,
tmp: tmp,
prefix: prefix
},
'../../lib/cache/get-stat': function (cb) {
cb(null, {})
},
chownr: function (x, y, z, cb) {
cb(new Error('chownr should never have been called'))
},
'../../lib/cache/add-local-tarball.js': function (tgz, data, shasum, cb) {
cb(null)
},
'../../lib/utils/lifecycle.js': function (data, cycle, p, cb) {
cb(null)
},
'../../lib/utils/tar.js': {
pack: function (tgz, p, data, fancy, cb) {
cb(null)
}
},
'sha': {
get: function (tgz, cb) {
cb(null, 'deadbeef')
}
}
})
fixture.create(pkg)
addLocal(p, null, function (err) {
t.ifErr(err, 'addLocal completed without error')
t.done()
})
})
test('addLocal temporary cache file race', function (t) {
// See https://github.com/npm/npm/issues/12669
setup()
var p = {
name: 'test',
version: '1.0.0',
type: 'directory',
spec: pkg
}
var fixture = new Tacks(
Dir({
'package.json': File(p)
})
)
var addLocal = requireInject('../../lib/cache/add-local', {
// basic setup/mock stuff
'../../lib/npm.js': {
cache: cache,
tmp: tmp,
prefix: prefix
},
'../../lib/cache/add-local-tarball.js': function (tgz, data, shasum, cb) {
cb(null)
},
'../../lib/utils/lifecycle.js': function (data, cycle, p, cb) {
cb(null)
},
'../../lib/utils/tar.js': {
pack: function (tgz, p, data, fancy, cb) {
cb(null)
}
},
'sha': {
get: function (tgz, cb) {
cb(null, 'deadbeef')
}
},
// Test-specific mocked values to simulate race.
'../../lib/cache/get-stat': function (cb) {
cb(null, {uid: 1, gid: 2})
},
chownr: function (x, y, z, cb) {
// Simulate a race condition between `tar.pack` and `chownr`
// where the latter will return `ENOENT` when an async process
// removes a file that its internal `fs.readdir` listed.
cb({code: 'ENOENT'})
}
})
fixture.create(pkg)
addLocal(p, null, function (err) {
t.ifErr(err, 'addLocal completed without error')
t.done()
})
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
mkdirp.sync(cache)
mkdirp.sync(tmp)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

View File

@@ -0,0 +1,113 @@
'use strict'
var path = require('path')
var test = require('tap').test
var common = require('../common-tap')
var mr = require('npm-registry-mock')
var server1
var server2
var packageName = path.basename(__filename, '.js')
var fooPkg = {
name: packageName,
versions: {
'0.0.0': {
name: packageName,
version: '0.0.0',
dist: {
tarball: 'https://localhost:1338/registry/' + packageName + '/-/' + packageName + '-0.0.0.tgz',
shasum: '356a192b7913b04c54574d18c28d46e6395428ab'
}
}
}
}
var iPackageName = packageName + 'i'
var fooiPkg = {
name: iPackageName,
versions: {
'0.0.0': {
name: iPackageName,
version: '0.0.0',
dist: {
tarball: 'http://127.0.0.1:1338/registry/' + iPackageName + '/-/' + iPackageName + '-0.0.0.tgz',
shasum: '356a192b7913b04c54574d18c28d46e6395428ab'
}
}
}
}
test('setup', function (t) {
mr({
port: 1337,
throwOnUnmatched: true
}, function (err, s) {
t.ifError(err, 'registry mocked successfully')
server1 = s
mr({
port: 1338,
throwOnUnmatched: true
}, function (err, s) {
t.ifError(err, 'registry mocked successfully')
server2 = s
t.end()
})
})
})
test('tarball paths should update port if updating protocol', function (t) {
server1.get('/registry/' + packageName).reply(200, fooPkg)
server1.get(
'/registry/' + packageName + '/-/' + packageName + '-0.0.0.tgz'
).reply(200, '1')
common.npm(
[
'cache',
'add',
packageName + '@0.0.0',
'--registry',
'http://localhost:1337/registry'
],
{},
function (er, code, stdout, stderr) {
if (er) { throw er }
t.equal(code, 0, 'addNamed worked')
server1.done()
t.end()
}
)
})
test('tarball paths should NOT update if different hostname', function (t) {
server1.get('/registry/' + iPackageName).reply(200, fooiPkg)
server2.get(
'/registry/' + iPackageName + '/-/' + iPackageName + '-0.0.0.tgz'
).reply(200, '1')
common.npm(
[
'cache',
'add',
iPackageName + '@0.0.0',
'--registry',
'http://localhost:1337/registry'
],
{},
function (er, code, stdout, stderr) {
if (er) { throw er }
t.equal(code, 0, 'addNamed worked')
server1.done()
server2.done()
t.end()
}
)
})
test('cleanup', function (t) {
t.pass('cleaned up')
server1.close()
server2.close()
t.end()
})

View File

@@ -0,0 +1,133 @@
var fs = require('fs')
var resolve = require('path').resolve
var osenv = require('osenv')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var npm = require('../../lib/npm.js')
var common = require('../common-tap.js')
var pkg = resolve(__dirname, 'add-remote-git')
var repo = resolve(__dirname, 'add-remote-git-repo')
var daemon
var daemonPID
var git
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
child: 'git://localhost:1234/child.git'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
setup(function (er, r) {
if (er) {
throw er
}
if (!er) {
daemon = r[r.length - 2]
daemonPID = r[r.length - 1]
}
t.end()
})
})
test('install from repo on \'Windows\'', function (t) {
// before we confuse everything by switching the platform
require('../../lib/install.js')
require('../../lib/unbuild.js')
process.platform = 'win32'
process.chdir(pkg)
npm.commands.install('.', [], function (er) {
t.ifError(er, 'npm installed via git')
t.end()
})
})
test('clean', function (t) {
daemon.on('close', function () {
cleanup()
t.end()
})
process.kill(daemonPID)
})
function bootstrap () {
rimraf.sync(pkg)
mkdirp.sync(pkg)
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
}
function setup (cb) {
rimraf.sync(repo)
mkdirp.sync(repo)
fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
npm.load({ registry: common.registry, loglevel: 'silent' }, function () {
// some really cheesy monkeypatching
require('module')._cache[require.resolve('which')] = {
exports: function (_, cb) { cb() }
}
git = require('../../lib/utils/git.js')
function startDaemon (cb) {
// start git server
var d = git.spawn(
[
'daemon',
'--verbose',
'--listen=localhost',
'--export-all',
'--base-path=.',
'--reuseaddr',
'--port=1234'
],
{
cwd: pkg,
env: process.env,
stdio: ['pipe', 'pipe', 'pipe']
}
)
d.stderr.on('data', childFinder)
function childFinder (c) {
var cpid = c.toString().match(/^\[(\d+)\]/)
if (cpid[1]) {
this.removeListener('data', childFinder)
cb(null, [d, cpid[1]])
}
}
}
common.makeGitRepo({
path: repo,
commands: [
git.chainableExec(
['clone', '--bare', repo, 'child.git'],
{ cwd: pkg, env: process.env }
),
startDaemon
]
}, cb)
})
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(repo)
rimraf.sync(pkg)
}

78
node_modules/npm/test/tap/add-remote-git-file.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
var fs = require('fs')
var resolve = require('path').resolve
var url = require('url')
var osenv = require('osenv')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var npm = require('../../lib/npm.js')
var common = require('../common-tap.js')
var pkg = resolve(__dirname, 'add-remote-git-file')
var repo = resolve(__dirname, 'add-remote-git-file-repo')
var git
var cloneURL = 'git+file://' + resolve(pkg, 'child.git')
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
setup(function (er, r) {
t.ifError(er, 'git started up successfully')
t.end()
})
})
test('cache from repo', function (t) {
process.chdir(pkg)
var addRemoteGit = require('../../lib/cache/add-remote-git.js')
addRemoteGit(cloneURL, function (er, data) {
t.ifError(er, 'cached via git')
t.equal(
url.parse(data._resolved).protocol,
'git+file:',
'npm didn\'t go crazy adding git+git+git+git'
)
t.end()
})
})
test('clean', function (t) {
cleanup()
t.end()
})
function bootstrap () {
cleanup()
mkdirp.sync(pkg)
}
function setup (cb) {
mkdirp.sync(repo)
fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
npm.load({ registry: common.registry, loglevel: 'silent' }, function () {
git = require('../../lib/utils/git.js')
common.makeGitRepo({
path: repo,
commands: [git.chainableExec(
['clone', '--bare', repo, 'child.git'],
{ cwd: pkg, env: process.env }
)]
}, cb)
})
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(repo)
rimraf.sync(pkg)
}

View File

@@ -0,0 +1,130 @@
'use strict'
var test = require('tap').test
var npm = require('../../lib/npm.js')
var common = require('../common-tap.js')
var normalizeGitUrl = require('normalize-git-url')
var getResolved = null
/**
* Note: This is here because `normalizeGitUrl` is usually called
* before getResolved is, and receives *that* URL.
*/
function tryGetResolved(uri, treeish) {
return getResolved(normalizeGitUrl(uri).url, treeish)
}
test('setup', function (t) {
var opts = {
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
getResolved = require('../../lib/cache/add-remote-git.js').getResolved
t.end()
})
})
test('add-remote-git#get-resolved git: passthru', function (t) {
verify('git:github.com/foo/repo')
verify('git:github.com/foo/repo.git')
verify('git://github.com/foo/repo#decadacefadabade')
verify('git://github.com/foo/repo.git#decadacefadabade')
function verify (uri) {
t.equal(
tryGetResolved(uri, 'decadacefadabade'),
'git://github.com/foo/repo.git#decadacefadabade',
uri + ' normalized to canonical form git://github.com/foo/repo.git#decadacefadabade'
)
}
t.end()
})
test('add-remote-git#get-resolved SSH', function (t) {
t.comment('tests for https://github.com/npm/npm/issues/7961')
verify('git@github.com:foo/repo')
verify('git@github.com:foo/repo#master')
verify('git+ssh://git@github.com/foo/repo#master')
verify('git+ssh://git@github.com/foo/repo#decadacefadabade')
function verify (uri) {
t.equal(
tryGetResolved(uri, 'decadacefadabade'),
'git+ssh://git@github.com/foo/repo.git#decadacefadabade',
uri + ' normalized to canonical form git+ssh://git@github.com/foo/repo.git#decadacefadabade'
)
}
t.end()
})
test('add-remote-git#get-resolved HTTPS', function (t) {
verify('https://github.com/foo/repo')
verify('https://github.com/foo/repo#master')
verify('git+https://github.com/foo/repo.git#master')
verify('git+https://github.com/foo/repo#decadacefadabade')
// DEPRECATED
// this is an invalid URL but we normalize it
// anyway. Users shouldn't use this in the future. See note
// below for how this affected non-hosted URLs.
// See https://github.com/npm/npm/issues/8881
verify('git+https://github.com:foo/repo.git#master')
function verify (uri) {
t.equal(
tryGetResolved(uri, 'decadacefadabade'),
'git+https://github.com/foo/repo.git#decadacefadabade',
uri + ' normalized to canonical form git+https://github.com/foo/repo.git#decadacefadabade'
)
}
t.end()
})
test('add-remote-git#get-resolved edge cases', function (t) {
t.equal(
tryGetResolved('git+ssh://user@bananaboat.com:galbi/blah.git', 'decadacefadabade'),
'git+ssh://user@bananaboat.com:galbi/blah.git#decadacefadabade',
'don\'t break non-hosted scp-style locations'
)
t.equal(
tryGetResolved('git+ssh://bananaboat:galbi/blah', 'decadacefadabade'),
'git+ssh://bananaboat:galbi/blah#decadacefadabade',
'don\'t break non-hosted scp-style locations'
)
// DEPRECATED
// When we were normalizing all git URIs, git+https: was being
// automatically converted to ssh:. Some users were relying
// on this funky behavior, so after removing the aggressive
// normalization from non-hosted URIs, we brought this back.
// See https://github.com/npm/npm/issues/8881
t.equal(
tryGetResolved('git+https://bananaboat:galbi/blah', 'decadacefadabade'),
'git+https://bananaboat/galbi/blah#decadacefadabade',
'don\'t break non-hosted scp-style locations'
)
t.equal(
tryGetResolved('git+ssh://git.bananaboat.net/foo', 'decadacefadabade'),
'git+ssh://git.bananaboat.net/foo#decadacefadabade',
'don\'t break non-hosted SSH URLs'
)
t.equal(
tryGetResolved('git+ssh://git.bananaboat.net:/foo', 'decadacefadabade'),
'git+ssh://git.bananaboat.net:/foo#decadacefadabade',
'don\'t break non-hosted SSH URLs'
)
t.equal(
tryGetResolved('git://gitbub.com/foo/bar.git', 'decadacefadabade'),
'git://gitbub.com/foo/bar.git#decadacefadabade',
'don\'t break non-hosted git: URLs'
)
t.end()
})

161
node_modules/npm/test/tap/add-remote-git-shrinkwrap.js generated vendored Normal file
View File

@@ -0,0 +1,161 @@
var fs = require('fs')
var resolve = require('path').resolve
var osenv = require('osenv')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var npm = require('../../lib/npm.js')
var common = require('../common-tap.js')
var pkg = resolve(__dirname, 'add-remote-git-shrinkwrap')
var repo = resolve(__dirname, 'add-remote-git-shrinkwrap-repo')
var daemon
var daemonPID
var git
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
'child': 'git://localhost:1234/child.git#master'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
setup(function (er, r) {
t.ifError(er, 'git started up successfully')
if (!er) {
daemon = r[r.length - 2]
daemonPID = r[r.length - 1]
}
t.end()
})
})
test('install from repo', function (t) {
process.chdir(pkg)
npm.commands.install('.', [], function (er) {
t.ifError(er, 'npm installed via git')
t.end()
})
})
test('shrinkwrap gets correct _from and _resolved (#7121)', function (t) {
common.npm(
[
'shrinkwrap',
'--loglevel', 'silent'
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm shrinkwrapped without errors')
t.notOk(code, '`npm shrinkwrap` exited with 0')
t.equal(stdout.trim(), 'wrote npm-shrinkwrap.json')
t.notOk(stderr, 'no error output on successful shrinkwrap')
var shrinkwrap = require(resolve(pkg, 'npm-shrinkwrap.json'))
t.equal(
shrinkwrap.dependencies.child.from,
'git://localhost:1234/child.git#master',
'npm shrinkwrapped from correctly'
)
git.whichAndExec(
['rev-list', '-n1', 'master'],
{ cwd: repo, env: process.env },
function (er, stdout, stderr) {
t.ifErr(er, 'git rev-list ran without error')
t.notOk(stderr, 'no error output')
var treeish = stdout.trim()
t.equal(
shrinkwrap.dependencies.child.resolved,
'git://localhost:1234/child.git#' + treeish,
'npm shrinkwrapped resolved correctly'
)
t.end()
}
)
}
)
})
test('clean', function (t) {
daemon.on('close', function () {
cleanup()
t.end()
})
process.kill(daemonPID)
})
function bootstrap () {
mkdirp.sync(pkg)
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
}
function setup (cb) {
mkdirp.sync(repo)
fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
npm.load({ prefix: pkg, registry: common.registry, loglevel: 'silent' }, function () {
git = require('../../lib/utils/git.js')
function startDaemon (cb) {
// start git server
var d = git.spawn(
[
'daemon',
'--verbose',
'--listen=localhost',
'--export-all',
'--base-path=.',
'--reuseaddr',
'--port=1234'
],
{
cwd: pkg,
env: process.env,
stdio: ['pipe', 'pipe', 'pipe']
}
)
d.stderr.on('data', childFinder)
function childFinder (c) {
var cpid = c.toString().match(/^\[(\d+)\]/)
if (cpid[1]) {
this.removeListener('data', childFinder)
cb(null, [d, cpid[1]])
}
}
}
common.makeGitRepo({
path: repo,
commands: [
git.chainableExec(
['clone', '--bare', repo, 'child.git'],
{ cwd: pkg, env: process.env }
),
startDaemon
]
}, cb)
})
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(repo)
rimraf.sync(pkg)
}

120
node_modules/npm/test/tap/add-remote-git.js generated vendored Normal file
View File

@@ -0,0 +1,120 @@
var fs = require('fs')
var resolve = require('path').resolve
var osenv = require('osenv')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var npm = require('../../lib/npm.js')
var common = require('../common-tap.js')
var pkg = resolve(__dirname, 'add-remote-git')
var repo = resolve(__dirname, 'add-remote-git-repo')
var daemon
var daemonPID
var git
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
child: 'git://localhost:1234/child.git'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
setup(function (er, r) {
t.ifError(er, 'git started up successfully')
if (!er) {
daemon = r[r.length - 2]
daemonPID = r[r.length - 1]
}
t.end()
})
})
test('install from repo', function (t) {
process.chdir(pkg)
npm.commands.install('.', [], function (er) {
t.ifError(er, 'npm installed via git')
t.end()
})
})
test('clean', function (t) {
daemon.on('close', function () {
cleanup()
t.end()
})
process.kill(daemonPID)
})
function bootstrap () {
mkdirp.sync(pkg)
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
}
function setup (cb) {
mkdirp.sync(repo)
fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
npm.load({ registry: common.registry, loglevel: 'silent' }, function () {
git = require('../../lib/utils/git.js')
function startDaemon (cb) {
// start git server
var d = git.spawn(
[
'daemon',
'--verbose',
'--listen=localhost',
'--export-all',
'--base-path=.',
'--reuseaddr',
'--port=1234'
],
{
cwd: pkg,
env: process.env,
stdio: ['pipe', 'pipe', 'pipe']
}
)
d.stderr.on('data', childFinder)
function childFinder (c) {
var cpid = c.toString().match(/^\[(\d+)\]/)
if (cpid[1]) {
this.removeListener('data', childFinder)
cb(null, [d, cpid[1]])
}
}
}
common.makeGitRepo({
path: repo,
commands: [
git.chainableExec(
['clone', '--bare', repo, 'child.git'],
{ cwd: pkg, env: process.env }
),
startDaemon
]
}, cb)
})
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(repo)
rimraf.sync(pkg)
}

264
node_modules/npm/test/tap/adduser-always-auth.js generated vendored Normal file
View File

@@ -0,0 +1,264 @@
var fs = require("fs")
var path = require("path")
var rimraf = require("rimraf")
var mr = require("npm-registry-mock")
var test = require("tap").test
var common = require("../common-tap.js")
var opts = {cwd : __dirname}
var outfile = path.resolve(__dirname, "_npmrc")
var responses = {
"Username" : "u\n",
"Password" : "p\n",
"Email" : "u@p.me\n"
}
function verifyStdout (runner, successMessage, t) {
var remaining = Object.keys(responses).length
return function (chunk) {
if (remaining > 0) {
remaining--
var label = chunk.toString('utf8').split(':')[0]
runner.stdin.write(responses[label])
if (remaining === 0) runner.stdin.end()
} else {
var message = chunk.toString('utf8').trim()
t.equal(message, successMessage)
}
}
}
function mocks (server) {
server.filteringRequestBody(function (r) {
if (r.match(/\"_id\":\"org\.couchdb\.user:u\"/)) {
return "auth"
}
})
server.put("/-/user/org.couchdb.user:u", "auth")
.reply(201, {username : "u", password : "p", email : "u@p.me"})
}
test("npm login", function (t) {
mr({port : common.port, plugin : mocks}, function (er, s) {
var runner = common.npm(
[
"login",
"--registry", common.registry,
"--loglevel", "silent",
"--userconfig", outfile
],
opts,
function (err, code) {
t.notOk(code, "exited OK")
t.notOk(err, "no error output")
var config = fs.readFileSync(outfile, "utf8")
t.like(config, /:always-auth=false/, "always-auth is scoped and false (by default)")
s.close()
rimraf(outfile, function (err) {
t.ifError(err, "removed config file OK")
t.end()
})
})
var message = 'Logged in as u on ' + common.registry + '/.'
runner.stdout.on('data', verifyStdout(runner, message, t))
})
})
test('npm login --scope <scope> uses <scope>:registry as its URI', function (t) {
var port = common.port + 1
var uri = 'http://localhost:' + port + '/'
var scope = '@myco'
common.npm(
[
'config',
'--userconfig', outfile,
'set',
scope + ':registry',
uri
],
opts,
function (err, code) {
t.notOk(code, 'exited OK')
t.notOk(err, 'no error output')
mr({ port: port, plugin: mocks }, function (er, s) {
var runner = common.npm(
[
'login',
'--loglevel', 'silent',
'--userconfig', outfile,
'--scope', scope
],
opts,
function (err, code) {
t.notOk(code, 'exited OK')
t.notOk(err, 'no error output')
var config = fs.readFileSync(outfile, 'utf8')
t.like(config, new RegExp(scope + ':registry=' + uri), 'scope:registry is set')
s.close()
rimraf(outfile, function (err) {
t.ifError(err, 'removed config file OK')
t.end()
})
})
var message = 'Logged in as u to scope ' + scope + ' on ' + uri + '.'
runner.stdout.on('data', verifyStdout(runner, message, t))
})
})
})
test('npm login --scope <scope> makes sure <scope> is prefixed by an @', function (t) {
var port = common.port + 1
var uri = 'http://localhost:' + port + '/'
var scope = 'myco'
var prefixedScope = '@' + scope
common.npm(
[
'--userconfig', outfile,
'config',
'set',
prefixedScope + ':registry',
uri
],
opts,
function (err, code) {
t.notOk(code, 'exited OK')
t.notOk(err, 'no error output')
mr({ port: port, plugin: mocks }, function (er, s) {
var runner = common.npm(
[
'login',
'--loglevel', 'silent',
'--userconfig', outfile,
'--scope', scope
],
opts,
function (err, code) {
t.notOk(code, 'exited OK')
t.notOk(err, 'no error output')
var config = fs.readFileSync(outfile, 'utf8')
t.like(config, new RegExp(prefixedScope + ':registry=' + uri), 'scope:registry is set')
s.close()
rimraf(outfile, function (err) {
t.ifError(err, 'removed config file OK')
t.end()
})
})
var message = 'Logged in as u to scope ' + prefixedScope + ' on ' + uri + '.'
runner.stdout.on('data', verifyStdout(runner, message, t))
})
})
})
test('npm login --scope <scope> --registry <registry> uses <registry> as its URI', function (t) {
var scope = '@myco'
common.npm(
[
'--userconfig', outfile,
'config',
'set',
scope + ':registry',
'invalidurl'
],
opts,
function (err, code) {
t.notOk(code, 'exited OK')
t.notOk(err, 'no error output')
mr({ port: common.port, plugin: mocks }, function (er, s) {
var runner = common.npm(
[
'login',
'--registry', common.registry,
'--loglevel', 'silent',
'--userconfig', outfile,
'--scope', scope
],
opts,
function (err, code) {
t.notOk(code, 'exited OK')
t.notOk(err, 'no error output')
var config = fs.readFileSync(outfile, 'utf8')
t.like(config, new RegExp(scope + ':registry=' + common.registry), 'scope:registry is set')
s.close()
rimraf(outfile, function (err) {
t.ifError(err, 'removed config file OK')
t.end()
})
})
var message = 'Logged in as u to scope ' + scope + ' on ' + common.registry + '/.'
runner.stdout.on('data', verifyStdout(runner, message, t))
})
})
})
test("npm login --always-auth", function (t) {
mr({port : common.port, plugin : mocks}, function (er, s) {
var runner = common.npm(
[
"login",
"--registry", common.registry,
"--loglevel", "silent",
"--userconfig", outfile,
"--always-auth"
],
opts,
function (err, code) {
t.notOk(code, "exited OK")
t.notOk(err, "no error output")
var config = fs.readFileSync(outfile, "utf8")
t.like(config, /:always-auth=true/, "always-auth is scoped and true")
s.close()
rimraf(outfile, function (err) {
t.ifError(err, "removed config file OK")
t.end()
})
})
var message = 'Logged in as u on ' + common.registry + '/.'
runner.stdout.on('data', verifyStdout(runner, message, t))
})
})
test("npm login --no-always-auth", function (t) {
mr({port : common.port, plugin : mocks}, function (er, s) {
var runner = common.npm(
[
"login",
"--registry", common.registry,
"--loglevel", "silent",
"--userconfig", outfile,
"--no-always-auth"
],
opts,
function (err, code) {
t.notOk(code, "exited OK")
t.notOk(err, "no error output")
var config = fs.readFileSync(outfile, "utf8")
t.like(config, /:always-auth=false/, "always-auth is scoped and false")
s.close()
rimraf(outfile, function (err) {
t.ifError(err, "removed config file OK")
t.end()
})
})
var message = 'Logged in as u on ' + common.registry + '/.'
runner.stdout.on('data', verifyStdout(runner, message, t))
})
})
test("cleanup", function (t) {
rimraf.sync(outfile)
t.pass("cleaned up")
t.end()
})

97
node_modules/npm/test/tap/adduser-legacy-auth.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var mr = require('npm-registry-mock')
var test = require('tap').test
var common = require('../common-tap.js')
var opts = { cwd: __dirname }
var pkg = path.resolve(__dirname, 'adduser-legacy-auth')
var outfile = path.resolve(pkg, '_npmrc')
var contents = '_auth=' + new Buffer('u:x').toString('base64') + '\n' +
'registry=https://nonexistent.lvh.me/registry\n' +
'email=u@p.me\n'
var responses = {
'Username': 'u\n',
'Password': 'p\n',
'Email': 'u@p.me\n'
}
function mocks (server) {
server.filteringRequestBody(function (r) {
if (r.match(/"_id":"org\.couchdb\.user:u"/)) {
return 'auth'
}
})
server.put('/-/user/org.couchdb.user:u', 'auth')
.reply(409, { error: 'user exists' })
server.get('/-/user/org.couchdb.user:u?write=true')
.reply(200, { _rev: '3-deadcafebabebeef' })
server.put(
'/-/user/org.couchdb.user:u/-rev/3-deadcafebabebeef',
'auth',
{ authorization: 'Basic dTpw' }
).reply(201, { username: 'u', password: 'p', email: 'u@p.me' })
}
test('setup', function (t) {
mkdirp(pkg, function (er) {
t.ifError(er, pkg + ' made successfully')
fs.writeFile(outfile, contents, function (er) {
t.ifError(er, 'wrote legacy config')
t.end()
})
})
})
test('npm login', function (t) {
mr({ port: common.port, plugin: mocks }, function (er, s) {
var runner = common.npm(
[
'login',
'--registry', common.registry,
'--loglevel', 'silent',
'--userconfig', outfile
],
opts,
function (err, code, stdout, stderr) {
t.ifError(err, 'npm ran without issue')
t.notOk(code, 'exited OK')
t.notOk(stderr, 'no error output')
var config = fs.readFileSync(outfile, 'utf8')
t.like(config, /:always-auth=false/, 'always-auth is scoped and false (by default)')
s.close()
rimraf(outfile, function (err) {
t.ifError(err, 'removed config file OK')
t.end()
})
})
var remaining = Object.keys(responses).length
runner.stdout.on('data', function (chunk) {
if (remaining > 0) {
remaining--
var label = chunk.toString('utf8').split(':')[0]
runner.stdin.write(responses[label])
if (remaining === 0) runner.stdin.end()
} else {
var message = chunk.toString('utf8').trim()
t.equal(message, 'Logged in as u on ' + common.registry + '/.')
}
})
})
})
test('cleanup', function (t) {
rimraf.sync(pkg)
t.pass('cleaned up')
t.end()
})

119
node_modules/npm/test/tap/bearer-token-check.js generated vendored Normal file
View File

@@ -0,0 +1,119 @@
var resolve = require('path').resolve
var writeFileSync = require('graceful-fs').writeFileSync
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var toNerfDart = require('../../lib/config/nerf-dart.js')
var pkg = resolve(__dirname, 'install-bearer-check')
var outfile = resolve(pkg, '_npmrc')
var modules = resolve(pkg, 'node_modules')
var tarballPath = '/scoped-underscore/-/scoped-underscore-1.3.1.tgz'
// needs to be a different hostname to verify tokens (not) being sent correctly
var tarballURL = 'http://lvh.me:' + common.port + tarballPath
var tarball = resolve(__dirname, '../fixtures/scoped-underscore-1.3.1.tgz')
var server
var EXEC_OPTS = { cwd: pkg }
function mocks (server) {
var auth = 'Bearer 0xabad1dea'
server.get(tarballPath, { authorization: auth }).reply(403, {
error: 'token leakage',
reason: 'This token should not be sent.'
})
server.get(tarballPath).replyWithFile(200, tarball)
}
test('setup', function (t) {
mr({ port: common.port, plugin: mocks }, function (er, s) {
server = s
t.ok(s, 'set up mock registry')
setup()
t.end()
})
})
test('authed npm install with tarball not on registry', function (t) {
common.npm(
[
'install',
'--loglevel', 'silent',
'--json',
'--fetch-retries', 0,
'--userconfig', outfile
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, 'test runner executed without error')
t.equal(code, 0, 'npm install exited OK')
t.notOk(stderr, 'no output on stderr')
try {
var results = JSON.parse(stdout)
} catch (ex) {
console.error('#', ex)
t.ifError(ex, 'stdout was valid JSON')
}
if (results) {
var installedversion = {
'name': '@scoped/underscore',
'version': '1.3.1',
'from': 'http://lvh.me:1337/scoped-underscore/-/scoped-underscore-1.3.1.tgz',
'dependencies': {}
}
t.isDeeply(results[0], installedversion, '@scoped/underscore installed')
}
t.end()
}
)
})
test('cleanup', function (t) {
server.close()
cleanup()
t.end()
})
var contents = '@scoped:registry=' + common.registry + '\n' +
toNerfDart(common.registry) + ':_authToken=0xabad1dea\n'
var json = {
name: 'test-package-install',
version: '1.0.0'
}
var shrinkwrap = {
name: 'test-package-install',
version: '1.0.0',
dependencies: {
'@scoped/underscore': {
resolved: tarballURL,
from: '>=1.3.1 <2',
version: '1.3.1'
}
}
}
function setup () {
cleanup()
mkdirp.sync(modules)
writeFileSync(resolve(pkg, 'package.json'), JSON.stringify(json, null, 2) + '\n')
writeFileSync(outfile, contents)
writeFileSync(
resolve(pkg, 'npm-shrinkwrap.json'),
JSON.stringify(shrinkwrap, null, 2) + '\n'
)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

17
node_modules/npm/test/tap/bin.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
var path = require("path")
var test = require("tap").test
var common = require("../common-tap.js")
var opts = { cwd: __dirname }
var binDir = "../../node_modules/.bin"
var fixture = path.resolve(__dirname, binDir)
test('npm bin', function (t) {
common.npm(["bin"], opts, function (err, code, stdout, stderr) {
t.ifError(err, "bin ran without issue")
t.notOk(stderr, "should have no stderr")
t.equal(code, 0, "exit ok")
var res = path.resolve(stdout)
t.equal(res, fixture + "\n")
t.end()
})
})

View File

@@ -0,0 +1,83 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'bitbucket-https-url-with-creds-package')
var json = {
name: 'bitbucket-https-url-with-creds-package',
version: '0.0.0',
dependencies: {
'private': 'git+https://user:pass@bitbucket.org/foo/private.git'
}
}
test('setup', function (t) {
setup()
t.end()
})
test('bitbucket-https-url-with-creds-package', function (t) {
var cloneUrls = [
['https://user:pass@bitbucket.org/foo/private.git', 'Bitbucket URLs with passwords try only that.']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install([], function (er) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

View File

@@ -0,0 +1,80 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'bitbucket-https-url-with-creds')
var json = {
name: 'bitbucket-https-url-with-creds',
version: '0.0.0'
}
test('setup', function (t) {
setup()
t.end()
})
test('bitbucket-https-url-with-creds', function (t) {
var cloneUrls = [
['https://user:pass@bitbucket.org/foo/private.git', 'Bitbucket URLs with passwords try only that.']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install(['git+https://user:pass@bitbucket.org/foo/private.git'], function (er) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

View File

@@ -0,0 +1,84 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'bitbucket-shortcut-package')
var json = {
name: 'bitbucket-shortcut-package',
version: '0.0.0',
dependencies: {
'private': 'bitbucket:foo/private'
}
}
test('setup', function (t) {
setup()
t.end()
})
test('bitbucket-shortcut', function (t) {
var cloneUrls = [
['git@bitbucket.org:foo/private.git', 'Bitbucket shortcuts try SSH first'],
['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs second']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install([], function (er) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

81
node_modules/npm/test/tap/bitbucket-shortcut.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'bitbucket-shortcut')
var json = {
name: 'bitbucket-shortcut',
version: '0.0.0'
}
test('setup', function (t) {
setup()
t.end()
})
test('bitbucket-shortcut', function (t) {
var cloneUrls = [
['git@bitbucket.org:foo/private.git', 'Bitbucket shortcuts try SSH first'],
['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs second']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install(['bitbucket:foo/private'], function (er) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

151
node_modules/npm/test/tap/bugs.js generated vendored Normal file
View File

@@ -0,0 +1,151 @@
if (process.platform === "win32") {
console.error("skipping test, because windows and shebangs")
return
}
var common = require("../common-tap.js")
var mr = require("npm-registry-mock")
var test = require("tap").test
var rimraf = require("rimraf")
var fs = require("fs")
var path = require("path")
var join = path.join
var outFile = path.join(__dirname, "/_output")
var opts = { cwd: __dirname }
test("setup", function (t) {
var s = "#!/usr/bin/env bash\n" +
"echo \"$@\" > " + JSON.stringify(__dirname) + "/_output\n"
fs.writeFileSync(join(__dirname, "/_script.sh"), s, "ascii")
fs.chmodSync(join(__dirname, "/_script.sh"), "0755")
t.pass("made script")
t.end()
})
test("npm bugs underscore", function (t) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "underscore",
"--registry=" + common.registry,
"--loglevel=silent",
"--browser=" + join(__dirname, "/_script.sh")
], opts, function (err, code, stdout, stderr) {
t.ifError(err, "bugs ran without issue")
t.notOk(stderr, "should have no stderr")
t.equal(code, 0, "exit ok")
var res = fs.readFileSync(outFile, "ascii")
s.close()
t.equal(res, "https://github.com/jashkenas/underscore/issues\n")
rimraf.sync(outFile)
t.end()
})
})
})
test("npm bugs optimist - github (https://)", function (t) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "optimist",
"--registry=" + common.registry,
"--loglevel=silent",
"--browser=" + join(__dirname, "/_script.sh")
], opts, function (err, code, stdout, stderr) {
t.ifError(err, "bugs ran without issue")
t.notOk(stderr, "should have no stderr")
t.equal(code, 0, "exit ok")
var res = fs.readFileSync(outFile, "ascii")
s.close()
t.equal(res, "https://github.com/substack/node-optimist/issues\n")
rimraf.sync(outFile)
t.end()
})
})
})
test("npm bugs npm-test-peer-deps - no repo", function (t) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "npm-test-peer-deps",
"--registry=" + common.registry,
"--loglevel=silent",
"--browser=" + join(__dirname, "/_script.sh")
], opts, function (err, code, stdout, stderr) {
t.ifError(err, "bugs ran without issue")
t.notOk(stderr, "should have no stderr")
t.equal(code, 0, "exit ok")
var res = fs.readFileSync(outFile, "ascii")
s.close()
t.equal(res, "https://www.npmjs.org/package/npm-test-peer-deps\n")
rimraf.sync(outFile)
t.end()
})
})
})
test("npm bugs test-repo-url-http - non-github (http://)", function (t) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "test-repo-url-http",
"--registry=" + common.registry,
"--loglevel=silent",
"--browser=" + join(__dirname, "/_script.sh")
], opts, function (err, code, stdout, stderr) {
t.ifError(err, "bugs ran without issue")
t.notOk(stderr, "should have no stderr")
t.equal(code, 0, "exit ok")
var res = fs.readFileSync(outFile, "ascii")
s.close()
t.equal(res, "https://www.npmjs.org/package/test-repo-url-http\n")
rimraf.sync(outFile)
t.end()
})
})
})
test("npm bugs test-repo-url-https - non-github (https://)", function (t) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "test-repo-url-https",
"--registry=" + common.registry,
"--loglevel=silent",
"--browser=" + join(__dirname, "/_script.sh")
], opts, function (err, code, stdout, stderr) {
t.ifError(err, "bugs ran without issue")
t.notOk(stderr, "should have no stderr")
t.equal(code, 0, "exit ok")
var res = fs.readFileSync(outFile, "ascii")
s.close()
t.equal(res, "https://www.npmjs.org/package/test-repo-url-https\n")
rimraf.sync(outFile)
t.end()
})
})
})
test("npm bugs test-repo-url-ssh - non-github (ssh://)", function (t) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "test-repo-url-ssh",
"--registry=" + common.registry,
"--loglevel=silent",
"--browser=" + join(__dirname, "/_script.sh")
], opts, function (err, code, stdout, stderr) {
t.ifError(err, "bugs ran without issue")
t.notOk(stderr, "should have no stderr")
t.equal(code, 0, "exit ok")
var res = fs.readFileSync(outFile, "ascii")
s.close()
t.equal(res, "https://www.npmjs.org/package/test-repo-url-ssh\n")
rimraf.sync(outFile)
t.end()
})
})
})
test("cleanup", function (t) {
fs.unlinkSync(join(__dirname, "/_script.sh"))
t.pass("cleaned up")
t.end()
})

81
node_modules/npm/test/tap/build-already-built.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
// if "npm rebuild" is run with bundled dependencies,
// message "already built" should not be error
var test = require("tap").test
var path = require("path")
var osenv = require("osenv")
var rimraf = require("rimraf")
var npmlog = require("npmlog")
var mkdirp = require("mkdirp")
var requireInject = require("require-inject")
var npm = require("../../lib/npm.js")
var PKG_DIR = path.resolve(__dirname, "build-already-built")
var fakePkg = "foo"
test("setup", function (t) {
cleanup()
t.end()
})
test("issue #6735 build 'already built' message", function (t) {
npm.load({loglevel : "warn"}, function () {
// capture log messages with level
var log = ""
npmlog.on("log", function (chunk) {
log += chunk.level + " " + chunk.message + "\n"
})
mkdirp.sync(fakePkg)
var folder = path.resolve(fakePkg)
var global = npm.config.get("global")
var build = requireInject("../../lib/build", {
})
t.test("pin previous behavior", function (t) {
build([fakePkg], global, false, false, function (err) {
t.ok(err, "build failed as expected")
t.similar(err.message, /package.json/, "missing package.json as expected")
t.notSimilar(log, /already built/, "no already built message written")
t.end()
})
})
t.test("simulate rebuild of bundledDependency", function (t) {
log = ""
build._didBuild[folder] = true
build([fakePkg], global, false, false, function (err) {
t.ok(err, "build failed as expected")
t.similar(err.message, /package.json/, "missing package.json as expected")
t.similar(log, /already built/, "already built message written")
t.notSimilar(log, /ERR! already built/, "already built message written is not error")
t.similar(log, /info already built/, "already built message written is info")
t.end()
})
})
t.end()
})
})
test("cleanup", function (t) {
cleanup()
t.end()
})
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(PKG_DIR)
}

126
node_modules/npm/test/tap/builtin-config.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
var fs = require("fs")
if (process.argv[2] === "write-builtin") {
var pid = process.argv[3]
fs.writeFileSync("npmrc", "foo=bar\npid=" + pid + "\n")
return
}
var rcdata = "foo=bar\npid=" + process.pid + "\n"
var common = require("../common-tap.js")
var path = require("path")
var rimraf = require("rimraf")
var mkdirp = require("mkdirp")
var folder = path.resolve(__dirname, "builtin-config")
var test = require("tap").test
var npm = path.resolve(__dirname, "../..")
var spawn = require("child_process").spawn
var node = process.execPath
test("setup", function (t) {
rimraf.sync(folder)
mkdirp.sync(folder + "/first")
mkdirp.sync(folder + "/second")
mkdirp.sync(folder + "/cache")
mkdirp.sync(folder + "/tmp")
t.pass("finished setup")
t.end()
})
test("install npm into first folder", function (t) {
var args = ["install", npm, "-g",
"--prefix=" + folder + "/first",
"--ignore-scripts",
"--cache=" + folder + "/cache",
"--no-spin",
"--loglevel=silent",
"--tmp=" + folder + "/tmp"]
common.npm(args, {stdio: "inherit"}, function (er, code) {
if (er) throw er
t.equal(code, 0)
t.end()
})
})
test("write npmrc file", function (t) {
common.npm(["explore", "npm", "-g",
"--prefix=" + folder + "/first",
"--cache=" + folder + "/cache",
"--tmp=" + folder + "/tmp",
"--no-spin",
"--",
node, __filename, "write-builtin", process.pid
],
{"stdio": "inherit"},
function (er, code) {
if (er) throw er
t.equal(code, 0)
t.end()
})
})
test("use first npm to install second npm", function (t) {
// get the root location
common.npm([ "root", "-g",
"--prefix=" + folder + "/first",
"--cache=" + folder + "/cache",
"--tmp=" + folder + "/tmp",
"--no-spin"
], {}, function (er, code, so) {
if (er) throw er
t.equal(code, 0)
var root = so.trim()
t.ok(fs.statSync(root).isDirectory())
var bin = path.resolve(root, "npm/bin/npm-cli.js")
spawn( node
, [ bin
, "install", npm
, "-g"
, "--prefix=" + folder + "/second"
, "--cache=" + folder + "/cache"
, "--tmp=" + folder + "/tmp"
, "--no-spin"
])
.on("error", function (er) { throw er })
.on("close", function (code) {
t.equal(code, 0, "code is zero")
t.end()
})
})
})
test("verify that the builtin config matches", function (t) {
common.npm([ "root", "-g",
"--prefix=" + folder + "/first",
"--cache=" + folder + "/cache",
"--tmp=" + folder + "/tmp"
], {}, function (er, code, so) {
if (er) throw er
t.equal(code, 0)
var firstRoot = so.trim()
common.npm([ "root", "-g",
"--prefix=" + folder + "/second",
"--cache=" + folder + "/cache",
"--tmp=" + folder + "/tmp"
], {}, function (er, code, so) {
if (er) throw er
t.equal(code, 0)
var secondRoot = so.trim()
var firstRc = path.resolve(firstRoot, "npm", "npmrc")
var secondRc = path.resolve(secondRoot, "npm", "npmrc")
var firstData = fs.readFileSync(firstRc, "utf8")
var secondData = fs.readFileSync(secondRc, "utf8")
t.equal(firstData, secondData)
t.end()
})
})
})
test("clean", function (t) {
rimraf.sync(folder)
t.end()
})

View File

@@ -0,0 +1,77 @@
var fs = require('graceful-fs')
var path = require('path')
var osenv = require('osenv')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var npm = require('../../lib/npm.js')
var common = require('../common-tap.js')
var dir = path.resolve(__dirname, 'bundleddependencies')
var pkg = path.resolve(dir, 'pkg-with-bundled')
var dep = path.resolve(dir, 'a-bundled-dep')
var pj = JSON.stringify({
name: 'pkg-with-bundled',
version: '1.0.0',
dependencies: {
'a-bundled-dep': 'file:../a-bundled-dep'
},
bundledDependencies: {
'a-bundled-dep': 'file:../a-bundled-dep'
}
}, null, 2) + '\n'
var pjDep = JSON.stringify({
name: 'a-bundled-dep',
version: '2.0.0'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
t.end()
})
test('errors on non-array bundleddependencies', function (t) {
t.plan(6)
process.chdir(pkg)
npm.load({},
function () {
common.npm(['install'], { cwd: pkg }, function (err, code, stdout, stderr) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'exited with a non-error code')
t.notOk(stderr, 'no error output')
common.npm(['install', './pkg-with-bundled'], { cwd: dir },
function (err, code, stdout, stderr) {
t.ifError(err, 'npm install ran without issue')
t.ok(code, 'exited with a error code')
t.ok(stderr.indexOf('be an array') > -1, 'nice error output')
}
)
})
}
)
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function bootstrap () {
mkdirp.sync(dir)
mkdirp.sync(pkg)
fs.writeFileSync(path.resolve(pkg, 'package.json'), pj)
mkdirp.sync(dep)
fs.writeFileSync(path.resolve(dep, 'package.json'), pjDep)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(dir)
}

View File

@@ -0,0 +1,84 @@
var path = require("path")
var test = require("tap").test
var npm = require("../../lib/npm.js")
var requireInject = require("require-inject")
var realizePackageSpecifier = requireInject("realize-package-specifier", {
"fs": {
stat: function (file, cb) {
process.nextTick(function () {
switch (file) {
case path.resolve("named"):
cb(new Error("ENOENT"))
break
case path.resolve("file.tgz"):
cb(null, { isDirectory: function () { return false } })
break
case path.resolve("dir-no-package"):
cb(null, { isDirectory: function () { return true } })
break
case path.resolve("dir-no-package/package.json"):
cb(new Error("ENOENT"))
break
case path.resolve("dir-with-package"):
cb(null, { isDirectory: function () { return true } })
break
case path.resolve("dir-with-package/package.json"):
cb(null, {})
break
case path.resolve(__dirname, "dir-with-package"):
cb(null, { isDirectory: function () { return true } })
break
case path.join(__dirname, "dir-with-package", "package.json"):
cb(null, {})
break
case path.resolve(__dirname, "file.tgz"):
cb(null, { isDirectory: function () { return false } })
break
default:
throw new Error("Unknown test file passed to stat: " + file)
}
})
}
}
})
npm.load({loglevel : "silent"}, function () {
var cache = requireInject("../../lib/cache.js", {
"realize-package-specifier": realizePackageSpecifier,
"../../lib/cache/add-named.js": function addNamed (name, version, data, cb) {
cb(null, "addNamed")
},
"../../lib/cache/add-local.js": function addLocal (name, data, cb) {
cb(null, "addLocal")
}
})
test("npm install localdir fallback", function (t) {
t.plan(12)
cache.add("named", null, null, false, function (er, which) {
t.ifError(er, "named was cached")
t.is(which, "addNamed", "registry package name")
})
cache.add("file.tgz", null, null, false, function (er, which) {
t.ifError(er, "file.tgz was cached")
t.is(which, "addLocal", "local file")
})
cache.add("dir-no-package", null, null, false, function (er, which) {
t.ifError(er, "local directory was cached")
t.is(which, "addNamed", "local directory w/o package.json")
})
cache.add("dir-with-package", null, null, false, function (er, which) {
t.ifError(er, "local directory with package was cached")
t.is(which,"addLocal", "local directory with package.json")
})
cache.add("file:./dir-with-package", null, __dirname, false, function (er, which) {
t.ifError(er, "local directory (as URI) with package was cached")
t.is(which, "addLocal", "file: URI to local directory with package.json")
})
cache.add("file:./file.tgz", null, __dirname, false, function (er, which) {
t.ifError(er, "local file (as URI) with package was cached")
t.is(which, "addLocal", "file: URI to local file with package.json")
})
})
})

34
node_modules/npm/test/tap/cache-add-unpublished.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
var common = require("../common-tap.js")
var test = require("tap").test
var mr = require("npm-registry-mock")
test("cache add", function (t) {
setup(function (er, s) {
if (er) {
throw er
}
common.npm([
"cache",
"add",
"superfoo",
"--registry=http://localhost:1337/"
], {}, function (er, c, so, se) {
if (er) throw er
t.ok(c, "got non-zero exit code")
t.equal(so, "", "nothing printed to stdout")
t.similar(se, /404 Not Found: superfoo/, "got expected error")
s.close()
t.end()
})
})
})
function setup (cb) {
var s = require("http").createServer(function (req, res) {
res.statusCode = 404
res.end("{\"error\":\"not_found\"}\n")
})
s.listen(1337, function () {
cb(null, s)
})
}

101
node_modules/npm/test/tap/cache-shasum-fork.js generated vendored Normal file
View File

@@ -0,0 +1,101 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
// Install from a tarball that thinks it is underscore@1.5.1
// (but is actually a fork)
var forkPath = path.resolve(
__dirname, '..', 'fixtures', 'forked-underscore-1.5.1.tgz'
)
var pkg = path.resolve(__dirname, 'cache-shasum-fork')
var cache = path.join(pkg, 'cache')
var server
test('setup', function (t) {
setup()
t.comment('test for https://github.com/npm/npm/issues/3265')
mr({ port: common.port }, function (er, s) {
server = s
t.end()
})
})
test('npm cache - install from fork', function (t) {
setup()
common.npm(
[
'--loglevel', 'silent',
'--registry', common.registry,
'install', forkPath
],
{
cwd: pkg,
env: { npm_config_cache: cache }
},
function (err, code, stdout, stderr) {
t.ifErr(err, 'install finished without error')
t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
t.equal(code, 0, 'install finished successfully')
t.equal(stdout, 'underscore@1.5.1 node_modules/underscore\n')
var index = fs.readFileSync(
path.join(pkg, 'node_modules', 'underscore', 'index.js'),
'utf8'
)
t.equal(index, 'console.log("This is the fork");\n\n')
t.end()
}
)
})
// Now install the real 1.5.1.
test('npm cache - install from origin', function (t) {
setup()
common.npm(
[
'--loglevel', 'silent',
'--registry', common.registry,
'install', 'underscore'
],
{
cwd: pkg,
env: { npm_config_cache: cache }
},
function (err, code, stdout, stderr) {
t.ifErr(err, 'install finished without error')
t.equal(code, 0, 'install finished successfully')
t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
t.equal(stdout, 'underscore@1.5.1 node_modules/underscore\n')
var index = fs.readFileSync(
path.join(pkg, 'node_modules', 'underscore', 'index.js'),
'utf8'
)
t.equal(index, 'module.exports = require(\'./underscore\');\n')
t.end()
}
)
})
test('cleanup', function (t) {
server.close()
cleanup()
t.end()
})
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
function setup () {
mkdirp.sync(cache)
mkdirp.sync(path.join(pkg, 'node_modules'))
process.chdir(pkg)
}

59
node_modules/npm/test/tap/cache-shasum.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
var npm = require.resolve("../../")
var test = require("tap").test
var path = require("path")
var rimraf = require("rimraf")
var mkdirp = require("mkdirp")
var mr = require("npm-registry-mock")
var common = require("../common-tap.js")
var cache = path.resolve(__dirname, "cache-shasum")
var spawn = require("child_process").spawn
var sha = require("sha")
var server
test("mock reg", function (t) {
rimraf.sync(cache)
mkdirp.sync(cache)
mr({port : common.port}, function (er, s) {
server = s
t.pass("ok")
t.end()
})
})
test("npm cache add request", function (t) {
var c = spawn(process.execPath, [
npm, "cache", "add", "request@2.27.0",
"--cache=" + cache,
"--registry=" + common.registry,
"--loglevel=quiet"
])
c.stderr.pipe(process.stderr)
c.stdout.on("data", function (d) {
t.fail("Should not get data on stdout: " + d)
})
c.on("close", function (code) {
t.notOk(code, "exit ok")
t.end()
})
})
test("compare", function (t) {
var d = path.resolve(__dirname, "cache-shasum/request")
var p = path.resolve(d, "2.27.0/package.tgz")
var r = require("./cache-shasum/localhost_1337/request/.cache.json")
var rshasum = r.versions["2.27.0"].dist.shasum
sha.get(p, function (er, pshasum) {
if (er)
throw er
t.equal(pshasum, rshasum)
t.end()
})
})
test("cleanup", function (t) {
server.close()
rimraf.sync(cache)
t.end()
})

99
node_modules/npm/test/tap/circular-dep.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
var fs = require('graceful-fs')
var path = require('path')
var existsSync = fs.existsSync || path.existsSync
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var server
var pkg = path.resolve(__dirname, 'circular-dep')
var minimist = path.join(pkg, 'minimist')
var EXEC_OPTS = {
cwd: path.join(pkg, 'minimist/node_modules'),
npm_config_cache: path.join(pkg, 'cache')
}
var json = {
name: 'minimist',
version: '0.0.5',
dependencies: {
optimist: '0.6.0'
}
}
test('setup', function (t) {
t.comment('test for https://github.com/npm/npm/issues/4312')
setup(function () {
t.end()
})
})
test('installing a package that depends on the current package', function (t) {
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'install', 'optimist'
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, 'npm ran without issue')
t.notOk(code, 'npm ran without raising an error code')
t.notOk(stderr, 'no error output')
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'dedupe'
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, 'npm ran without issue')
t.notOk(code, 'npm ran without raising an error code')
t.notOk(stderr, 'no error output')
t.ok(existsSync(path.resolve(
minimist,
'node_modules', 'optimist',
'node_modules', 'minimist'
)), 'circular dependency uncircled')
t.end()
}
)
}
)
})
test('cleanup', function (t) {
cleanup()
server.close()
t.end()
})
function setup (cb) {
cleanup()
mkdirp.sync(minimist)
fs.writeFileSync(
path.join(minimist, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(path.resolve(pkg, 'minimist'))
fs.mkdirSync(path.resolve(pkg, 'minimist/node_modules'))
mr({ port: common.port }, function (er, s) {
server = s
cb()
})
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

66
node_modules/npm/test/tap/config-basic.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
var test = require("tap").test
var npmconf = require("../../lib/config/core.js")
var common = require("./00-config-setup.js")
var path = require("path")
var projectData = {
"save-prefix": "~",
"proprietary-attribs": false
}
var ucData = common.ucData
var envData = common.envData
var envDataFix = common.envDataFix
var gcData = { "package-config:foo": "boo" }
var biData = {}
var cli = { foo: "bar", umask: 022 }
var expectList =
[ cli,
envDataFix,
projectData,
ucData,
gcData,
biData ]
var expectSources = {
cli: { data: cli },
env: {
data: envDataFix,
source: envData,
prefix: ""
},
project: {
path: path.resolve(__dirname, "..", "..", ".npmrc"),
type: "ini",
data: projectData
},
user: {
path: common.userconfig,
type: "ini",
data: ucData
},
global: {
path: common.globalconfig,
type: "ini",
data: gcData
},
builtin: { data: biData }
}
test("no builtin", function (t) {
npmconf.load(cli, function (er, conf) {
if (er) throw er
t.same(conf.list, expectList)
t.same(conf.sources, expectSources)
t.same(npmconf.rootConf.list, [])
t.equal(npmconf.rootConf.root, npmconf.defs.defaults)
t.equal(conf.root, npmconf.defs.defaults)
t.equal(conf.get("umask"), 022)
t.equal(conf.get("heading"), "npm")
t.end()
})
})

68
node_modules/npm/test/tap/config-builtin.js generated vendored Normal file
View File

@@ -0,0 +1,68 @@
var test = require("tap").test
var npmconf = require("../../lib/config/core.js")
var common = require("./00-config-setup.js")
var path = require("path")
var ucData = common.ucData
var envData = common.envData
var envDataFix = common.envDataFix
var gcData = { "package-config:foo": "boo" }
var biData = { "builtin-config": true }
var cli = { foo: "bar", heading: "foo", "git-tag-version": false }
var projectData = {
"save-prefix": "~",
"proprietary-attribs": false
}
var expectList = [
cli,
envDataFix,
projectData,
ucData,
gcData,
biData
]
var expectSources = {
cli: { data: cli },
env: {
data: envDataFix,
source: envData,
prefix: ""
},
project: {
path: path.resolve(__dirname, "..", "..", ".npmrc"),
type: "ini",
data: projectData
},
user: {
path: common.userconfig,
type: "ini",
data: ucData
},
global: {
path: common.globalconfig,
type: "ini",
data: gcData
},
builtin: { data: biData }
}
test("with builtin", function (t) {
npmconf.load(cli, common.builtin, function (er, conf) {
if (er) throw er
t.same(conf.list, expectList)
t.same(conf.sources, expectSources)
t.same(npmconf.rootConf.list, [])
t.equal(npmconf.rootConf.root, npmconf.defs.defaults)
t.equal(conf.root, npmconf.defs.defaults)
t.equal(conf.get("heading"), "foo")
t.equal(conf.get("git-tag-version"), false)
t.end()
})
})

18
node_modules/npm/test/tap/config-certfile.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
require("./00-config-setup.js")
var path = require("path")
var fs = require("fs")
var test = require("tap").test
var npmconf = require("../../lib/config/core.js")
test("cafile loads as ca", function (t) {
var cafile = path.join(__dirname, "..", "fixtures", "config", "multi-ca")
npmconf.load({cafile: cafile}, function (er, conf) {
if (er) throw er
t.same(conf.get("cafile"), cafile)
t.same(conf.get("ca").join("\n"), fs.readFileSync(cafile, "utf8").trim())
t.end()
})
})

350
node_modules/npm/test/tap/config-credentials.js generated vendored Normal file
View File

@@ -0,0 +1,350 @@
var test = require("tap").test
var npmconf = require("../../lib/config/core.js")
var common = require("./00-config-setup.js")
var URI = "https://registry.lvh.me:8661/"
test("getting scope with no credentials set", function (t) {
npmconf.load({}, function (er, conf) {
t.ifError(er, "configuration loaded")
var basic = conf.getCredentialsByURI(URI)
t.equal(basic.scope, "//registry.lvh.me:8661/", "nerfed URL extracted")
t.end()
})
})
test("trying to set credentials with no URI", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
t.throws(function () {
conf.setCredentialsByURI()
}, "enforced missing URI")
t.end()
})
})
test("trying to clear credentials with no URI", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
t.throws(function () {
conf.clearCredentialsByURI()
}, "enforced missing URI")
t.end()
})
})
test("set with missing credentials object", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
t.throws(function () {
conf.setCredentialsByURI(URI)
}, "enforced missing credentials")
t.end()
})
})
test("set with empty credentials object", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
t.throws(function () {
conf.setCredentialsByURI(URI, {})
}, "enforced missing credentials")
t.end()
})
})
test("set with token", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
t.doesNotThrow(function () {
conf.setCredentialsByURI(URI, {token : "simple-token"})
}, "needs only token")
var expected = {
scope: '//registry.lvh.me:8661/',
token: 'simple-token',
username: undefined,
password: undefined,
email: undefined,
auth: undefined,
alwaysAuth: false
}
t.same(conf.getCredentialsByURI(URI), expected, "got bearer token and scope")
t.end()
})
})
test("clear with token", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
t.doesNotThrow(function () {
conf.setCredentialsByURI(URI, {token : "simple-token"})
}, "needs only token")
t.doesNotThrow(function () {
conf.clearCredentialsByURI(URI)
}, "needs only URI")
t.notOk(conf.getCredentialsByURI(URI).token, "token all gone")
t.end()
})
})
test("set with missing username", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
var credentials = {
password : "password",
email : "ogd@aoaioxxysz.net"
}
t.throws(function () {
conf.setCredentialsByURI(URI, credentials)
}, "enforced missing email")
t.end()
})
})
test("set with missing password", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
var credentials = {
username : "username",
email : "ogd@aoaioxxysz.net"
}
t.throws(function () {
conf.setCredentialsByURI(URI, credentials)
}, "enforced missing email")
t.end()
})
})
test("set with missing email", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
var credentials = {
username : "username",
password : "password"
}
t.throws(function () {
conf.setCredentialsByURI(URI, credentials)
}, "enforced missing email")
t.end()
})
})
test("set with old-style credentials", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
var credentials = {
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net"
}
t.doesNotThrow(function () {
conf.setCredentialsByURI(URI, credentials)
}, "requires all of username, password, and email")
var expected = {
scope : "//registry.lvh.me:8661/",
token : undefined,
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net",
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
alwaysAuth : false
}
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
t.end()
})
})
test("clear with old-style credentials", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
var credentials = {
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net"
}
t.doesNotThrow(function () {
conf.setCredentialsByURI(URI, credentials)
}, "requires all of username, password, and email")
t.doesNotThrow(function () {
conf.clearCredentialsByURI(URI)
}, "clearing only required URI")
t.notOk(conf.getCredentialsByURI(URI).username, "username cleared")
t.notOk(conf.getCredentialsByURI(URI).password, "password cleared")
t.end()
})
})
test("get old-style credentials for default registry", function (t) {
npmconf.load(common.builtin, function (er, conf) {
var actual = conf.getCredentialsByURI(conf.get("registry"))
var expected = {
scope : "//registry.npmjs.org/",
token : undefined,
password : "password",
username : "username",
email : "i@izs.me",
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
alwaysAuth : false
}
t.same(actual, expected)
t.end()
})
})
test("set with always-auth enabled", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
var credentials = {
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net",
alwaysAuth : true
}
conf.setCredentialsByURI(URI, credentials)
var expected = {
scope : "//registry.lvh.me:8661/",
token : undefined,
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net",
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
alwaysAuth : true
}
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
t.end()
})
})
test("set with always-auth disabled", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
var credentials = {
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net",
alwaysAuth : false
}
conf.setCredentialsByURI(URI, credentials)
var expected = {
scope : "//registry.lvh.me:8661/",
token : undefined,
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net",
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
alwaysAuth : false
}
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
t.end()
})
})
test("set with global always-auth enabled", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
var original = conf.get("always-auth")
conf.set("always-auth", true)
var credentials = {
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net"
}
conf.setCredentialsByURI(URI, credentials)
var expected = {
scope : "//registry.lvh.me:8661/",
token : undefined,
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net",
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
alwaysAuth : true
}
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
conf.set("always-auth", original)
t.end()
})
})
test("set with global always-auth disabled", function (t) {
npmconf.load(common.builtin, function (er, conf) {
t.ifError(er, "configuration loaded")
var original = conf.get("always-auth")
conf.set("always-auth", false)
var credentials = {
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net"
}
conf.setCredentialsByURI(URI, credentials)
var expected = {
scope : "//registry.lvh.me:8661/",
token : undefined,
username : "username",
password : "password",
email : "ogd@aoaioxxysz.net",
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
alwaysAuth : false
}
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
conf.set("always-auth", original)
t.end()
})
})

72
node_modules/npm/test/tap/config-edit.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
var fs = require("fs")
var path = require("path")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var test = require("tap").test
var common = require("../common-tap.js")
var pkg = path.resolve(__dirname, "npm-global-edit")
var editorSrc = function () {/*
#!/usr/bin/env node
var fs = require("fs")
if (fs.existsSync(process.argv[2])) {
console.log("success")
} else {
console.log("error")
process.exit(1)
}
*/}.toString().split("\n").slice(1, -1).join("\n")
var editorPath = path.join(pkg, "editor")
test("setup", function (t) {
cleanup(function (er) {
t.ifError(er, "old directory removed")
mkdirp(pkg, "0777", function (er) {
fs.writeFileSync(editorPath, editorSrc)
fs.chmodSync(editorPath, "0777")
t.ifError(er, "created package directory correctly")
t.end()
})
})
})
test("saving configs", function (t) {
var opts = {
cwd: pkg,
env: {
PATH: process.env.PATH,
EDITOR: editorPath
}
}
common.npm(
[
"config",
"--prefix", pkg,
"--global",
"edit"
],
opts,
function (err, code, stdout, stderr) {
t.ifError(err, "command ran without issue")
t.equal(stderr, "", "got nothing on stderr")
t.equal(code, 0, "exit ok")
t.equal(stdout, "success\n", "got success message")
t.end()
}
)
})
test("cleanup", function (t) {
cleanup(function (er) {
t.ifError(er, "test directory removed OK")
t.end()
})
})
function cleanup (cb) {
rimraf(pkg, cb)
}

14
node_modules/npm/test/tap/config-malformed.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
var test = require('tap').test
var npmconf = require("../../lib/config/core.js")
var common = require("./00-config-setup.js")
test('with malformed', function (t) {
npmconf.load({}, common.malformed, function (er, conf) {
t.ok(er, 'Expected parse error')
if (!(er && /Failed parsing JSON config key email/.test(er.message))) {
throw er
}
t.end()
})
})

128
node_modules/npm/test/tap/config-meta.js generated vendored Normal file
View File

@@ -0,0 +1,128 @@
// this is a weird meta test. It verifies that all the instances of
// `npm.config.get(...)` are:
// a) Simple strings, and not variables
// b) Documented
// c) Defined in the `npmconf` package.
var test = require("tap").test
var fs = require("fs")
var path = require("path")
var root = path.resolve(__dirname, "..", "..")
var lib = path.resolve(root, "lib")
var nm = path.resolve(root, "node_modules")
var doc = path.resolve(root, "doc/misc/npm-config.md")
var FILES = []
var CONFS = {}
var DOC = {}
var exceptions = [
path.resolve(lib, "adduser.js"),
path.resolve(lib, "config.js"),
path.resolve(lib, "publish.js"),
path.resolve(lib, "utils", "lifecycle.js"),
path.resolve(lib, "utils", "map-to-registry.js"),
path.resolve(nm, "npm-registry-client", "lib", "publish.js"),
path.resolve(nm, "npm-registry-client", "lib", "request.js")
]
test("get files", function (t) {
walk(nm)
walk(lib)
t.pass("got files")
t.end()
function walk(lib) {
var files = fs.readdirSync(lib).map(function (f) {
return path.resolve(lib, f)
})
files.forEach(function (f) {
try {
var s = fs.lstatSync(f)
} catch (er) {
return
}
if (s.isDirectory())
walk(f)
else if (f.match(/\.js$/))
FILES.push(f)
})
}
})
test("get lines", function (t) {
FILES.forEach(function (f) {
var lines = fs.readFileSync(f, "utf8").split(/\r|\n/)
lines.forEach(function (l, i) {
var matches = l.split(/conf(?:ig)?\.get\(/g)
matches.shift()
matches.forEach(function (m) {
m = m.split(")").shift()
var literal = m.match(/^['"].+?['"]/)
if (literal) {
m = literal[0].slice(1, -1)
if (!m.match(/^\_/) && m !== "argv")
CONFS[m] = {
file: f,
line: i
}
} else if (exceptions.indexOf(f) === -1) {
t.fail("non-string-literal config used in " + f + ":" + i)
}
})
})
})
t.pass("got lines")
t.end()
})
test("get docs", function (t) {
var d = fs.readFileSync(doc, "utf8").split(/\r|\n/)
// walk down until the "## Config Settings" section
for (var i = 0; i < d.length && d[i] !== "## Config Settings"; i++);
i++
// now gather up all the ^###\s lines until the next ^##\s
for (; i < d.length && !d[i].match(/^## /); i++) {
if (d[i].match(/^### /))
DOC[ d[i].replace(/^### /, "").trim() ] = true
}
t.pass("read the docs")
t.end()
})
test("check configs", function (t) {
var defs = require("../../lib/config/defaults.js")
var types = Object.keys(defs.types)
var defaults = Object.keys(defs.defaults)
for (var c1 in CONFS) {
if (CONFS[c1].file.indexOf(lib) === 0) {
t.ok(DOC[c1], "should be documented " + c1 + " "
+ CONFS[c1].file + ":" + CONFS[c1].line)
t.ok(types.indexOf(c1) !== -1, "should be defined in npmconf " + c1)
t.ok(defaults.indexOf(c1) !== -1, "should have default in npmconf " + c1)
}
}
for (var c2 in DOC) {
if (c2 !== "versions" && c2 !== "version" && c2 !== "init.version") {
t.ok(CONFS[c2], "config in doc should be used somewhere " + c2)
t.ok(types.indexOf(c2) !== -1, "should be defined in npmconf " + c2)
t.ok(defaults.indexOf(c2) !== -1, "should have default in npmconf " + c2)
}
}
types.forEach(function (c) {
if (!c.match(/^\_/) && c !== "argv" && !c.match(/^versions?$/)) {
t.ok(DOC[c], "defined type should be documented " + c)
t.ok(CONFS[c], "defined type should be used " + c)
}
})
defaults.forEach(function (c) {
if (!c.match(/^\_/) && c !== "argv" && !c.match(/^versions?$/)) {
t.ok(DOC[c], "defaulted type should be documented " + c)
t.ok(CONFS[c], "defaulted type should be used " + c)
}
})
t.end()
})

56
node_modules/npm/test/tap/config-new-cafile.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
require('./00-config-setup.js')
var path = require('path')
var fs = require('graceful-fs')
var test = require('tap').test
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var osenv = require('osenv')
var npmconf = require('../../lib/config/core.js')
var dir = path.resolve(__dirname, 'config-new-cafile')
var beep = path.resolve(dir, 'beep.pem')
test('setup', function (t) {
bootstrap()
t.end()
})
test('can set new cafile when old is gone', function (t) {
t.plan(5)
npmconf.load(function (error, conf) {
npmconf.loaded = false
t.ifError(error)
conf.set('cafile', beep, 'user')
conf.save('user', function (error) {
t.ifError(error)
t.equal(conf.get('cafile'), beep)
rimraf.sync(beep)
npmconf.load(function (error, conf) {
if (error) {
throw error
}
t.equal(conf.get('cafile'), beep)
conf.del('cafile')
conf.save('user', function (error) {
t.ifError(error)
})
})
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function bootstrap () {
mkdirp.sync(dir)
fs.writeFileSync(beep, '')
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(dir)
}

81
node_modules/npm/test/tap/config-private.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
var fs = require("fs")
var path = require("path")
var test = require("tap").test
var rimraf = require("rimraf")
var mkdirp = require("mkdirp")
var common = require("../common-tap.js")
var pkg = path.resolve(__dirname, "config-private")
var opts = { cwd: pkg }
test("setup", function (t) {
rimraf.sync(pkg)
mkdirp.sync(pkg)
t.end()
})
test("config get private var (old auth)", function (t) {
common.npm([
"config",
"get",
"_auth"
],
opts,
function (err, code, stdout, stderr) {
t.ifError(err)
t.similar(stderr, /sekretz/, "password blocked on stderr")
t.equal(stdout, "", "no output")
t.end()
}
)
})
test("config get private var (new auth)", function (t) {
common.npm([
"config",
"get",
"//registry.npmjs.org/:_password"
],
opts,
function (err, code, stdout, stderr) {
t.ifError(err)
t.similar(stderr, /sekretz/, "password blocked on stderr")
t.equal(stdout, "", "no output")
t.end()
}
)
})
test("config get public var (new username)", function (t) {
var FIXTURE_PATH = path.resolve(pkg, "fixture_npmrc")
var s = "//registry.lvh.me/:username = wombat\n" +
"//registry.lvh.me/:_password = YmFkIHBhc3N3b3Jk\n" +
"//registry.lvh.me/:email = lindsay@wdu.org.au\n"
fs.writeFileSync(FIXTURE_PATH, s, "ascii")
fs.chmodSync(FIXTURE_PATH, "0444")
common.npm(
[
"config",
"get",
"//registry.lvh.me/:username",
"--userconfig=" + FIXTURE_PATH,
"--registry=http://registry.lvh.me/"
],
opts,
function (err, code, stdout, stderr) {
t.ifError(err)
t.equal(stderr, "", "stderr is empty")
t.equal(stdout, "wombat\n", "got usename is output")
t.end()
}
)
})
test("clean", function (t) {
rimraf.sync(pkg)
t.end()
})

66
node_modules/npm/test/tap/config-project.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
var test = require("tap").test
var path = require("path")
var fix = path.resolve(__dirname, "..", "fixtures", "config")
var projectRc = path.resolve(fix, ".npmrc")
var npmconf = require("../../lib/config/core.js")
var common = require("./00-config-setup.js")
var projectData = { just: "testing" }
var ucData = common.ucData
var envData = common.envData
var envDataFix = common.envDataFix
var gcData = { "package-config:foo": "boo" }
var biData = {}
var cli = { foo: "bar", umask: 022, prefix: fix }
var expectList = [
cli,
envDataFix,
projectData,
ucData,
gcData,
biData
]
var expectSources = {
cli: { data: cli },
env: {
data: envDataFix,
source: envData,
prefix: ""
},
project: {
path: projectRc,
type: "ini",
data: projectData
},
user: {
path: common.userconfig,
type: "ini",
data: ucData
},
global: {
path: common.globalconfig,
type: "ini",
data: gcData
},
builtin: { data: biData }
}
test("no builtin", function (t) {
npmconf.load(cli, function (er, conf) {
if (er) throw er
t.same(conf.list, expectList)
t.same(conf.sources, expectSources)
t.same(npmconf.rootConf.list, [])
t.equal(npmconf.rootConf.root, npmconf.defs.defaults)
t.equal(conf.root, npmconf.defs.defaults)
t.equal(conf.get("umask"), 022)
t.equal(conf.get("heading"), "npm")
t.end()
})
})

88
node_modules/npm/test/tap/config-save.js generated vendored Normal file
View File

@@ -0,0 +1,88 @@
var fs = require("fs")
var ini = require("ini")
var test = require("tap").test
var npmconf = require("../../lib/config/core.js")
var common = require("./00-config-setup.js")
var expectConf = [
"globalconfig = " + common.globalconfig,
"email = i@izs.me",
"env-thing = asdf",
"init.author.name = Isaac Z. Schlueter",
"init.author.email = i@izs.me",
"init.author.url = http://blog.izs.me/",
"init.version = 1.2.3",
"proprietary-attribs = false",
"npm:publishtest = true",
"_npmjs.org:couch = https://admin:password@localhost:5984/registry",
"npm-www:nocache = 1",
"sign-git-tag = false",
"message = v%s",
"strict-ssl = false",
"_auth = dXNlcm5hbWU6cGFzc3dvcmQ=",
"",
"[_token]",
"AuthSession = yabba-dabba-doodle",
"version = 1",
"expires = 1345001053415",
"path = /",
"httponly = true",
""
].join("\n")
var expectFile = [
"globalconfig = " + common.globalconfig,
"email = i@izs.me",
"env-thing = asdf",
"init.author.name = Isaac Z. Schlueter",
"init.author.email = i@izs.me",
"init.author.url = http://blog.izs.me/",
"init.version = 1.2.3",
"proprietary-attribs = false",
"npm:publishtest = true",
"_npmjs.org:couch = https://admin:password@localhost:5984/registry",
"npm-www:nocache = 1",
"sign-git-tag = false",
"message = v%s",
"strict-ssl = false",
"_auth = dXNlcm5hbWU6cGFzc3dvcmQ=",
"",
"[_token]",
"AuthSession = yabba-dabba-doodle",
"version = 1",
"expires = 1345001053415",
"path = /",
"httponly = true",
""
].join("\n")
test("saving configs", function (t) {
npmconf.load(function (er, conf) {
if (er)
throw er
conf.set("sign-git-tag", false, "user")
conf.del("nodedir")
conf.del("tmp")
var foundConf = ini.stringify(conf.sources.user.data)
t.same(ini.parse(foundConf), ini.parse(expectConf))
fs.unlinkSync(common.userconfig)
conf.save("user", function (er) {
if (er)
throw er
var uc = fs.readFileSync(conf.get("userconfig"), "utf8")
t.same(ini.parse(uc), ini.parse(expectFile))
t.end()
})
})
})
test("setting prefix", function (t) {
npmconf.load(function (er, conf) {
if (er)
throw er
conf.prefix = "newvalue"
t.same(conf.prefix, "newvalue")
t.end()
})
})

163
node_modules/npm/test/tap/correct-mkdir.js generated vendored Normal file
View File

@@ -0,0 +1,163 @@
var test = require('tap').test
var assert = require('assert')
var path = require('path')
var requireInject = require('require-inject')
var cache_dir = path.resolve(__dirname, 'correct-mkdir')
test('correct-mkdir: no race conditions', function (t) {
var mock_fs = {}
var did_hook = false
mock_fs.stat = function (path, cb) {
if (path === cache_dir) {
// Return a non-matching owner
cb(null, {
uid: +process.uid + 1,
isDirectory: function () {
return true
}
})
if (!did_hook) {
did_hook = true
doHook()
}
} else {
assert.ok(false, 'Unhandled stat path: ' + path)
}
}
var chown_in_progress = 0
var mock_chownr = function (path, uid, gid, cb) {
++chown_in_progress
process.nextTick(function () {
--chown_in_progress
cb(null)
})
}
var mocks = {
'graceful-fs': mock_fs,
'chownr': mock_chownr
}
var correctMkdir = requireInject('../../lib/utils/correct-mkdir.js', mocks)
var calls_in_progress = 3
function handleCallFinish () {
t.equal(chown_in_progress, 0, 'should not return while chown still in progress')
if (!--calls_in_progress) {
t.end()
}
}
function doHook () {
// This is fired during the first correctMkdir call, after the stat has finished
// but before the chownr has finished
// Buggy old code will fail and return a cached value before initial call is done
correctMkdir(cache_dir, handleCallFinish)
}
// Initial call
correctMkdir(cache_dir, handleCallFinish)
// Immediate call again in case of race condition there
correctMkdir(cache_dir, handleCallFinish)
})
test('correct-mkdir: ignore ENOENTs from chownr', function (t) {
var mock_fs = {}
mock_fs.stat = function (path, cb) {
if (path === cache_dir) {
cb(null, {
isDirectory: function () {
return true
}
})
} else {
assert.ok(false, 'Unhandled stat path: ' + path)
}
}
var mock_chownr = function (path, uid, gid, cb) {
cb({code: 'ENOENT'})
}
var mocks = {
'graceful-fs': mock_fs,
'chownr': mock_chownr
}
var correctMkdir = requireInject('../../lib/utils/correct-mkdir.js', mocks)
function handleCallFinish (err) {
t.ifErr(err, 'chownr\'s ENOENT errors were ignored')
t.end()
}
correctMkdir(cache_dir, handleCallFinish)
})
// NEED TO RUN LAST
// These test checks that Windows users are protected by crashes related to
// unexpectedly having a UID/GID other than 0 if a user happens to add these
// variables to their environment. There are assumptions in correct-mkdir
// that special-case Windows by checking on UID-related things.
test('correct-mkdir: SUDO_UID and SUDO_GID non-Windows', function (t) {
process.env.SUDO_UID = 999
process.env.SUDO_GID = 999
process.getuid = function () { return 0 }
process.getgid = function () { return 0 }
var mock_fs = {}
mock_fs.stat = function (path, cb) {
if (path === cache_dir) {
cb(null, {
uid: 0,
isDirectory: function () {
return true
}
})
} else {
assert.ok(false, 'Unhandled stat path: ' + path)
}
}
var mock_chownr = function (path, uid, gid, cb) {
t.is(uid, +process.env.SUDO_UID, 'using the environment\'s UID')
t.is(gid, +process.env.SUDO_GID, 'using the environment\'s GID')
cb(null, {})
}
var mocks = {
'graceful-fs': mock_fs,
'chownr': mock_chownr
}
var correctMkdir = requireInject('../../lib/utils/correct-mkdir.js', mocks)
function handleCallFinish () {
t.end()
}
correctMkdir(cache_dir, handleCallFinish)
})
test('correct-mkdir: SUDO_UID and SUDO_GID Windows', function (t) {
process.env.SUDO_UID = 999
process.env.SUDO_GID = 999
delete process.getuid
delete process.getgid
var mock_fs = {}
mock_fs.stat = function (path, cb) {
if (path === cache_dir) {
cb(null, {
uid: 0,
isDirectory: function () {
return true
}
})
} else {
assert.ok(false, 'Unhandled stat path: ' + path)
}
}
var mock_chownr = function (path, uid, gid, cb) {
t.fail('chownr should not be called at all on Windows')
cb('nope')
}
var mocks = {
'graceful-fs': mock_fs,
'chownr': mock_chownr
}
var correctMkdir = requireInject('../../lib/utils/correct-mkdir.js', mocks)
function handleCallFinish (err) {
t.ifErr(err, 'chownr was not called because Windows')
t.end()
}
correctMkdir(cache_dir, handleCallFinish)
})

147
node_modules/npm/test/tap/dedupe-scoped.js generated vendored Normal file
View File

@@ -0,0 +1,147 @@
var fs = require('fs')
var join = require('path').join
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = join(__dirname, 'dedupe-scoped')
var modules = join(pkg, 'node_modules')
var EXEC_OPTS = { cwd: pkg }
var prolog = 'dedupe@0.0.0 ' + pkg
var body = function () {/*
├─┬ first@1.0.0
│ └── @scope/shared@2.1.6
└─┬ second@2.0.0
└── @scope/shared@2.1.6
*/}.toString().split('\n').slice(1, -1)
var deduper = {
'name': 'dedupe',
'version': '0.0.0',
'dependencies': {
'first': '1.0.0',
'second': '2.0.0'
}
}
var first = {
'name': 'first',
'version': '1.0.0',
'dependencies': {
'firstUnique': '0.6.0',
'@scope/shared': '2.1.6'
}
}
var second = {
'name': 'second',
'version': '2.0.0',
'dependencies': {
'secondUnique': '1.2.0',
'@scope/shared': '2.1.6'
}
}
var shared = {
'name': '@scope/shared',
'version': '2.1.6'
}
var firstUnique = {
'name': 'firstUnique',
'version': '0.6.0'
}
var secondUnique = {
'name': 'secondUnique',
'version': '1.2.0'
}
test('setup', function (t) {
setup()
t.end()
})
// we like the cars
function ltrimm (l) { return l.trim() }
test('dedupe finds the common scoped modules and moves it up one level', function (t) {
common.npm(
[
'find-dupes' // I actually found a use for this command!
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, 'successful dry run against fake install')
t.notOk(code, 'npm ran without issue')
t.notOk(stderr, 'npm printed no errors')
t.same(
stdout.trim().split('\n').map(ltrimm),
[prolog].concat(body).map(ltrimm),
'got expected output'
)
t.end()
}
)
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup (cb) {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
join(pkg, 'package.json'),
JSON.stringify(deduper, null, 2)
)
mkdirp.sync(join(modules, 'first'))
fs.writeFileSync(
join(modules, 'first', 'package.json'),
JSON.stringify(first, null, 2)
)
mkdirp.sync(join(modules, 'first', 'node_modules', 'firstUnique'))
fs.writeFileSync(
join(modules, 'first', 'node_modules', 'firstUnique', 'package.json'),
JSON.stringify(firstUnique, null, 2)
)
mkdirp.sync(join(modules, 'first', 'node_modules', '@scope', 'shared'))
fs.writeFileSync(
join(modules, 'first', 'node_modules', '@scope', 'shared', 'package.json'),
JSON.stringify(shared, null, 2)
)
mkdirp.sync(join(modules, 'second'))
fs.writeFileSync(
join(modules, 'second', 'package.json'),
JSON.stringify(second, null, 2)
)
mkdirp.sync(join(modules, 'second', 'node_modules', 'secondUnique'))
fs.writeFileSync(
join(modules, 'second', 'node_modules', 'secondUnique', 'package.json'),
JSON.stringify(secondUnique, null, 2)
)
mkdirp.sync(join(modules, 'second', 'node_modules', '@scope', 'shared'))
fs.writeFileSync(
join(modules, 'second', 'node_modules', '@scope', 'shared', 'package.json'),
JSON.stringify(shared, null, 2)
)
}
function cleanup () {
rimraf.sync(pkg)
}

86
node_modules/npm/test/tap/dedupe.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
var fs = require('graceful-fs')
var path = require('path')
var existsSync = fs.existsSync || path.existsSync
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var server
var pkg = path.join(__dirname, 'dedupe')
var EXEC_OPTS = { cwd: pkg }
var json = {
author: 'Dedupe tester',
name: 'dedupe',
version: '0.0.0',
dependencies: {
optimist: '0.6.0',
clean: '2.1.6'
}
}
test('setup', function (t) {
t.comment('test for https://github.com/npm/npm/issues/4675')
setup(function () {
t.end()
})
})
test('dedupe finds the common module and moves it up one level', function (t) {
common.npm(
[
'--registry', common.registry,
'install', '.'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'successfully installed directory')
t.equal(code, 0, 'npm install exited with code')
common.npm(
[
'dedupe'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'successfully deduped against previous install')
t.notOk(code, 'npm dedupe exited with code')
t.ok(existsSync(path.join(pkg, 'node_modules', 'minimist')))
t.notOk(existsSync(path.join(pkg, 'node_modules', 'checker')))
t.end()
}
)
})
})
test('cleanup', function (t) {
server.close()
cleanup()
t.end()
})
function cleanup () {
rimraf.sync(pkg)
}
function setup (cb) {
cleanup()
mkdirp.sync(path.join(pkg, 'node_modules'))
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
mr({ port: common.port }, function (er, s) {
server = s
cb()
})
}

163
node_modules/npm/test/tap/deprecate.js generated vendored Normal file
View File

@@ -0,0 +1,163 @@
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var mr = require('npm-registry-mock')
var semver = require('semver')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'deprecate')
var server
var cache = {
'_id': 'cond',
'_rev': '19-d458a706de1740662cd7728d7d7ddf07',
'name': 'cond',
'time': {
'modified': '2015-02-13T07:33:58.120Z',
'created': '2014-03-16T20:52:52.236Z',
'0.0.0': '2014-03-16T20:52:52.236Z',
'0.0.1': '2014-03-16T21:12:33.393Z',
'0.0.2': '2014-03-16T21:15:25.430Z'
},
'versions': {
'0.0.0': {},
'0.0.1': {},
'0.0.2': {}
},
'dist-tags': {
'latest': '0.0.2'
},
'description': 'Restartable error handling system',
'license': 'CC0'
}
test('setup', function (t) {
mr({port: common.port}, function (err, s) {
t.ifError(err, 'registry mocked successfully')
server = s
t.ok(true)
t.end()
})
})
test('npm deprecate an unscoped package', function (t) {
var deprecated = JSON.parse(JSON.stringify(cache))
deprecated.versions = {
'0.0.0': {},
'0.0.1': { deprecated: 'make it dead' },
'0.0.2': {}
}
server.get('/cond?write=true').reply(200, cache)
server.put('/cond', deprecated).reply(201, { deprecated: true })
common.npm([
'deprecate',
'cond@0.0.1',
'make it dead',
'--registry', common.registry,
'--loglevel', 'silent'
], {},
function (er, code, stdout, stderr) {
t.ifError(er, 'npm deprecate')
t.equal(stderr, '', 'no error output')
t.equal(code, 0, 'exited OK')
t.end()
})
})
test('npm deprecate a scoped package', function (t) {
var cacheCopy = JSON.parse(JSON.stringify(cache))
cacheCopy.name = '@scope/cond'
cacheCopy._id = '@scope/cond'
var deprecated = JSON.parse(JSON.stringify(cacheCopy))
deprecated.versions = {
'0.0.0': {},
'0.0.1': { deprecated: 'make it dead' },
'0.0.2': {}
}
server.get('/@scope%2fcond?write=true').reply(200, cacheCopy)
server.put('/@scope%2fcond', deprecated).reply(201, { deprecated: true })
common.npm([
'deprecate',
'@scope/cond@0.0.1',
'make it dead',
'--registry', common.registry,
'--loglevel', 'silent'
], {},
function (er, code, stdout, stderr) {
t.ifError(er, 'npm deprecate')
t.equal(stderr, '', 'no error output')
t.equal(code, 0, 'exited OK')
t.end()
})
})
test('npm deprecate semver range', function (t) {
var deprecated = JSON.parse(JSON.stringify(cache))
deprecated.versions = {
'0.0.0': { deprecated: 'make it dead' },
'0.0.1': { deprecated: 'make it dead' },
'0.0.2': {}
}
server.get('/cond?write=true').reply(200, cache)
server.put('/cond', deprecated).reply(201, { deprecated: true })
common.npm([
'deprecate',
'cond@<0.0.2',
'make it dead',
'--registry', common.registry,
'--loglevel', 'silent'
], {},
function (er, code, stdout, stderr) {
t.ifError(er, 'npm deprecate')
t.equal(stderr, '', 'no error output')
t.equal(code, 0, 'exited OK')
t.end()
})
})
test('npm deprecate bad semver range', function (t) {
common.npm([
'deprecate',
'cond@-9001',
'make it dead',
'--registry', common.registry
], {},
function (er, code, stdout, stderr) {
t.equal(code, 1, 'errored')
t.match(stderr, /invalid version range/, 'bad semver')
t.end()
})
})
test('npm deprecate a package with no semver range', function (t) {
var deprecated = JSON.parse(JSON.stringify(cache))
deprecated.versions = {
'0.0.0': { deprecated: 'make it dead' },
'0.0.1': { deprecated: 'make it dead' },
'0.0.2': { deprecated: 'make it dead' }
}
server.get('/cond?write=true').reply(200, cache)
server.put('/cond', deprecated).reply(201, { deprecated: true })
common.npm([
'deprecate',
'cond',
'make it dead',
'--registry', common.registry,
'--loglevel', 'silent'
], {},
function (er, code, stdout, stderr) {
t.ifError(er, 'npm deprecate')
t.equal(stderr, '', 'no error output')
t.equal(code, 0, 'exited OK')
t.end()
})
})
test('cleanup', function (t) {
server.close()
t.ok(true)
t.end()
})

195
node_modules/npm/test/tap/dist-tag.js generated vendored Normal file
View File

@@ -0,0 +1,195 @@
var fs = require("fs")
var path = require("path")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var mr = require("npm-registry-mock")
var test = require("tap").test
var common = require("../common-tap.js")
var pkg = path.resolve(__dirname, "dist-tag")
var server
var scoped = {
name : "@scoped/pkg",
version : "1.1.1"
}
function mocks (server) {
// ls current package
server.get("/-/package/@scoped%2fpkg/dist-tags")
.reply(200, { latest : "1.0.0", a : "0.0.1", b : "0.5.0" })
// ls named package
server.get("/-/package/@scoped%2fanother/dist-tags")
.reply(200, { latest : "2.0.0", a : "0.0.2", b : "0.6.0" })
// add c
server.get("/-/package/@scoped%2fanother/dist-tags")
.reply(200, { latest : "2.0.0", a : "0.0.2", b : "0.6.0" })
server.put("/-/package/@scoped%2fanother/dist-tags/c", "\"7.7.7\"")
.reply(200, { latest : "7.7.7", a : "0.0.2", b : "0.6.0", c : "7.7.7" })
// set same version
server.get("/-/package/@scoped%2fanother/dist-tags")
.reply(200, { latest : "2.0.0", b : "0.6.0" })
// rm
server.get("/-/package/@scoped%2fanother/dist-tags")
.reply(200, { latest : "2.0.0", a : "0.0.2", b : "0.6.0", c : "7.7.7" })
server.delete("/-/package/@scoped%2fanother/dist-tags/c")
.reply(200, { c : "7.7.7" })
// rm
server.get("/-/package/@scoped%2fanother/dist-tags")
.reply(200, { latest : "4.0.0" })
}
test("setup", function (t) {
mkdirp(pkg, function (er) {
t.ifError(er, pkg + " made successfully")
mr({port : common.port, plugin : mocks}, function (er, s) {
server = s
fs.writeFile(
path.join(pkg, "package.json"),
JSON.stringify(scoped),
function (er) {
t.ifError(er, "wrote package.json")
t.end()
}
)
})
})
})
test("npm dist-tags ls in current package", function (t) {
common.npm(
[
"dist-tags", "ls",
"--registry", common.registry,
"--loglevel", "silent"
],
{ cwd : pkg },
function (er, code, stdout, stderr) {
t.ifError(er, "npm access")
t.notOk(code, "exited OK")
t.notOk(stderr, "no error output")
t.equal(stdout, "a: 0.0.1\nb: 0.5.0\nlatest: 1.0.0\n")
t.end()
}
)
})
test("npm dist-tags ls on named package", function (t) {
common.npm(
[
"dist-tags",
"ls", "@scoped/another",
"--registry", common.registry,
"--loglevel", "silent"
],
{ cwd : pkg },
function (er, code, stdout, stderr) {
t.ifError(er, "npm access")
t.notOk(code, "exited OK")
t.notOk(stderr, "no error output")
t.equal(stdout, "a: 0.0.2\nb: 0.6.0\nlatest: 2.0.0\n")
t.end()
}
)
})
test("npm dist-tags add @scoped/another@7.7.7 c", function (t) {
common.npm(
[
"dist-tags",
"add", "@scoped/another@7.7.7", "c",
"--registry", common.registry,
"--loglevel", "silent"
],
{ cwd : pkg },
function (er, code, stdout, stderr) {
t.ifError(er, "npm access")
t.notOk(code, "exited OK")
t.notOk(stderr, "no error output")
t.equal(stdout, "+c: @scoped/another@7.7.7\n")
t.end()
}
)
})
test("npm dist-tags set same version", function (t) {
common.npm(
[
"dist-tag",
"set", "@scoped/another@0.6.0", "b",
"--registry", common.registry,
"--loglevel", "warn"
],
{ cwd : pkg },
function (er, code, stdout, stderr) {
t.ifError(er, "npm access")
t.notOk(code, "exited OK")
t.equal(
stderr,
"npm WARN dist-tag add b is already set to version 0.6.0\n",
"warned about setting same version"
)
t.notOk(stdout, "only expecting warning message")
t.end()
}
)
})
test("npm dist-tags rm @scoped/another c", function (t) {
common.npm(
[
"dist-tags",
"rm", "@scoped/another", "c",
"--registry", common.registry,
"--loglevel", "silent"
],
{ cwd : pkg },
function (er, code, stdout, stderr) {
t.ifError(er, "npm access")
t.notOk(code, "exited OK")
t.notOk(stderr, "no error output")
t.equal(stdout, "-c: @scoped/another@7.7.7\n")
t.end()
}
)
})
test("npm dist-tags rm @scoped/another nonexistent", function (t) {
common.npm(
[
"dist-tags",
"rm", "@scoped/another", "nonexistent",
"--registry", common.registry,
"--loglevel", "silent"
],
{ cwd : pkg },
function (er, code, stdout, stderr) {
t.ifError(er, "npm dist-tag")
t.ok(code, "expecting nonzero exit code")
t.notOk(stderr, "no error output")
t.notOk(stdout, "not expecting output")
t.end()
}
)
})
test("cleanup", function (t) {
t.pass("cleaned up")
rimraf.sync(pkg)
server.close()
t.end()
})

85
node_modules/npm/test/tap/false-name.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
// this is a test for fix #2538
// the false_name-test-package has the name property 'test-package' set
// in the package.json and a dependency named 'test-package' is also a
// defined dependency of 'test-package-with-one-dep'.
//
// this leads to a conflict during installation and the fix is covered
// by this test
var fs = require('graceful-fs')
var path = require('path')
var existsSync = fs.existsSync || path.existsSync
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'false-name')
var cache = path.join(pkg, 'cache')
var server
var EXEC_OPTS = { cwd: pkg }
var indexContent = 'module.exports = true\n'
var json = {
name: 'test-package',
version: '0.0.0',
main: 'index.js',
dependencies: {
'test-package-with-one-dep': '0.0.0'
}
}
test('setup', function (t) {
t.comment('test for https://github.com/npm/npm/issues/2538')
setup()
mr({ port: common.port }, function (er, s) {
server = s
t.end()
})
})
test('not every pkg.name can be required', function (t) {
common.npm(
[
'install', '.',
'--cache', cache,
'--registry', common.registry
],
EXEC_OPTS,
function (err, code) {
t.ifErr(err, 'install finished without error')
t.equal(code, 0, 'install exited ok')
t.ok(existsSync(path.join(
pkg,
'node_modules/test-package-with-one-dep',
'node_modules/test-package'
)), 'package installed OK')
t.end()
}
)
})
test('cleanup', function (t) {
server.close()
cleanup()
t.end()
})
function cleanup () {
rimraf.sync(pkg)
}
function setup () {
cleanup()
mkdirp.sync(cache)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
fs.writeFileSync(path.join(pkg, 'index.js'), indexContent)
}

558
node_modules/npm/test/tap/files-and-ignores.js generated vendored Normal file
View File

@@ -0,0 +1,558 @@
'use strict'
var test = require('tap').test
var common = require('../common-tap.js')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var fs = require('graceful-fs')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-files')
var modulepath = path.resolve(basepath, 'node_modules')
var installedpath = path.resolve(modulepath, 'npm-test-files')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
test('basic file inclusion', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5',
files: [
'include',
'sub/include'
]
}),
include: File(''),
sub: Dir({ include: File('') }),
notincluded: File('')
})
)
withFixture(t, fixture, function (done) {
t.ok(fileExists('include'), 'toplevel file included')
t.ok(fileExists('sub/include'), 'nested file included')
t.notOk(fileExists('notincluded'), 'unspecified file not included')
done()
})
})
test('basic file exclusion', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5'
}),
'.npmignore': File(
'ignore\n' +
'sub/ignore\n'
),
include: File(''),
ignore: File(''),
sub: Dir({ ignore: File('') })
})
)
withFixture(t, fixture, function (done) {
t.notOk(fileExists('ignore'), 'toplevel file excluded')
t.notOk(fileExists('sub/ignore'), 'nested file excluded')
t.ok(fileExists('include'), 'unignored file included')
done()
})
})
test('toplevel-only and blanket ignores', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5'
}),
'.npmignore': File(
'./shallow1\n' +
'/shallow2\n' +
'/sub/onelevel\n' +
'deep\n' +
''
),
shallow1: File(''),
shallow2: File(''),
deep: File(''),
sub: Dir({
shallow1: File(''),
shallow2: File(''),
onelevel: File(''),
deep: File(''),
sub: Dir({
deep: File(''),
onelevel: File('')
})
})
})
)
withFixture(t, fixture, function (done) {
t.notOk(fileExists('shallow2'), '/ file excluded')
t.ok(fileExists('sub/shallow1'), 'nested ./ file included')
t.ok(fileExists('sub/shallow2'), 'nested / file included')
t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')
t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')
t.notOk(fileExists('deep'), 'deep file excluded')
t.notOk(fileExists('sub/deep'), 'nested deep file excluded')
t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')
t.ok(fileExists('shallow1'), './ file included')
done()
})
})
test('.npmignore works for nested directories recursively', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5'
}),
'.npmignore': File(
'/ignore\n' +
'deep\n'
),
include: File(''),
ignore: File(''),
deep: File(''),
sub: Dir({
ignore: File(''),
include: File(''),
deep: File(''),
sub: Dir({
'.npmignore': File(
'/ignore\n'
),
ignore: File(''),
include: File(''),
deep: File('')
})
})
})
)
withFixture(t, fixture, function (done) {
t.notOk(fileExists('ignore'), 'toplevel file excluded')
t.ok(fileExists('include'), 'unignored file included')
t.ok(fileExists('sub/ignore'), 'same-name file in nested dir included')
t.ok(fileExists('sub/include'), 'unignored nested dir file included')
t.notOk(fileExists('sub/sub/ignore'), 'sub-sub-directory file excluded')
t.ok(fileExists('sub/sub/include'), 'sub-sube-directory file included')
t.notOk(fileExists('deep'), 'deep file excluded')
t.notOk(fileExists('sub/deep'), 'sub-dir deep file excluded')
t.notOk(fileExists('sub/sub/deep'), 'sub-sub-dir deep file excluded')
done()
})
})
test('.gitignore should have identical semantics', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5'
}),
'.gitignore': File(
'./shallow1\n' +
'/shallow2\n' +
'/sub/onelevel\n' +
'deep\n' +
''
),
shallow1: File(''),
shallow2: File(''),
deep: File(''),
sub: Dir({
shallow1: File(''),
shallow2: File(''),
onelevel: File(''),
deep: File(''),
sub: Dir({
deep: File(''),
onelevel: File('')
})
})
})
)
withFixture(t, fixture, function (done) {
t.notOk(fileExists('shallow2'), '/ file excluded')
t.ok(fileExists('sub/shallow1'), 'nested ./ file included')
t.ok(fileExists('sub/shallow2'), 'nested / file included')
t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')
t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')
t.notOk(fileExists('deep'), 'deep file excluded')
t.notOk(fileExists('sub/deep'), 'nested deep file excluded')
t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')
t.ok(fileExists('shallow1'), './ file included')
done()
})
})
test('.npmignore should always be overridden by files array', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5',
files: [
'include',
'sub'
]
}),
'.npmignore': File(
'include\n' +
'ignore\n' +
'sub/included\n'
),
include: File(''),
ignore: File(''),
sub: Dir({
include: File('')
})
})
)
withFixture(t, fixture, function (done) {
t.notOk(fileExists('ignore'), 'toplevel file excluded')
t.ok(fileExists('include'), 'unignored file included')
t.ok(fileExists('sub/include'), 'nested file included')
done()
})
})
test('.gitignore supported for ignores', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5'
}),
'.gitignore': File(
'ignore\n' +
'sub/ignore\n'
),
include: File(''),
ignore: File(''),
sub: Dir({ ignore: File('') })
})
)
withFixture(t, fixture, function (done) {
t.notOk(fileExists('ignore'), 'toplevel file excluded')
t.notOk(fileExists('sub/ignore'), 'nested file excluded')
t.ok(fileExists('include'), 'unignored file included')
done()
})
})
test('.npmignore completely overrides .gitignore', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5'
}),
'.npmignore': File(
'ignore\n' +
'sub/ignore\n'
),
'.gitignore': File(
'include\n' +
'sub/include\n' +
'extra\n'
),
include: File(''),
sub: Dir({ include: File('') }),
extra: File('')
})
)
withFixture(t, fixture, function (done) {
t.ok(fileExists('include'), 'gitignored toplevel file included')
t.ok(fileExists('extra'), 'gitignored extra toplevel file included')
t.ok(fileExists('sub/include'), 'gitignored nested file included')
t.notOk(fileExists('ignore'), 'toplevel file excluded')
t.notOk(fileExists('sub/ignore'), 'nested file excluded')
done()
})
})
test('files array overrides .npmignore', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5',
files: [
'include',
'sub/include'
]
}),
'.npmignore': File(
'include\n' +
'sub/include\n'
),
include: File(''),
sub: Dir({ include: File('') })
})
)
withFixture(t, fixture, function (done) {
t.ok(fileExists('include'), 'toplevel file included')
t.ok(fileExists('sub/include'), 'nested file included')
done()
})
})
test('includes files regardless of emptiness', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5',
files: [
'full',
'empty'
]
}),
full: File('This file has contents~'),
empty: File('')
})
)
withFixture(t, fixture, function (done) {
t.ok(fileExists('full'), 'contentful file included')
t.ok(fileExists('empty'), 'empty file included')
done()
})
})
test('.npmignore itself gets included', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5',
files: [
'.npmignore'
]
}),
'.npmignore': File('')
})
)
withFixture(t, fixture, function (done) {
t.ok(fileExists('.npmignore'), '.npmignore included')
done()
})
})
test('include default files when missing files spec', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5'
}),
'index.js': File(''),
foo: File(''),
node_modules: Dir({foo: Dir({bar: File('')})})
})
)
withFixture(t, fixture, function (done) {
t.ok(fileExists('index.js'), 'index.js included')
t.ok(fileExists('foo'), 'foo included')
t.notOk(fileExists('node_modules'), 'node_modules not included')
done()
})
})
test('include main file', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5',
main: 'foo.js',
files: []
}),
'index.js': File(''),
'foo.js': File('')
})
)
withFixture(t, fixture, function (done) {
t.ok(fileExists('foo.js'), 'foo.js included because of main')
t.notOk(fileExists('index.js'), 'index.js not included')
done()
})
})
test('certain files ignored unconditionally', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5',
files: [
'.git',
'.svn',
'CVS',
'.hg',
'.lock-wscript',
'.wafpickle-0',
'.wafpickle-5',
'.wafpickle-50',
'build/config.gypi',
'npm-debug.log',
'.npmrc',
'.foo.swp',
'.DS_Store',
'._ohno'
]
}),
'.git': Dir({foo: File('')}),
'.svn': Dir({foo: File('')}),
'CVS': Dir({foo: File('')}),
'.hg': Dir({foo: File('')}),
'.lock-wscript': File(''),
'.wafpickle-0': File(''),
'.wafpickle-5': File(''),
'.wafpickle-50': File(''),
'build': Dir({'config.gypi': File('')}),
'npm-debug.log': File(''),
'.npmrc': File(''),
'.foo.swp': File(''),
'.DS_Store': Dir({foo: File('')}),
'._ohno': File(''),
'._ohnoes': Dir({noes: File('')})
})
)
withFixture(t, fixture, function (done) {
t.notOk(fileExists('.git'), '.git not included')
t.notOk(fileExists('.svn'), '.svn not included')
t.notOk(fileExists('CVS'), 'CVS not included')
t.notOk(fileExists('.hg'), '.hg not included')
t.notOk(fileExists('.lock-wscript'), '.lock-wscript not included')
t.notOk(fileExists('.wafpickle-0'), '.wafpickle-0 not included')
t.notOk(fileExists('.wafpickle-5'), '.wafpickle-5 not included')
t.notOk(fileExists('.wafpickle-50'), '.wafpickle-50 not included')
t.notOk(fileExists('build/config.gypi'), 'build/config.gypi not included')
t.notOk(fileExists('npm-debug.log'), 'npm-debug.log not included')
t.notOk(fileExists('.npmrc'), '.npmrc not included')
t.notOk(fileExists('.foo.swp'), '.foo.swp not included')
t.notOk(fileExists('.DS_Store'), '.DS_Store not included')
t.notOk(fileExists('._ohno'), '._ohno not included')
t.notOk(fileExists('._ohnoes'), '._ohnoes not included')
done()
})
})
test('certain files included unconditionally', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5'
}),
'.npmignore': File(
'package.json',
'README',
'Readme',
'readme.md',
'readme.randomext',
'changelog',
'CHAngelog',
'ChangeLOG.txt',
'license',
'licence',
'LICENSE',
'LICENCE'
),
'README': File(''),
'Readme': File(''),
'readme.md': File(''),
'readme.randomext': File(''),
'changelog': File(''),
'CHAngelog': File(''),
'ChangeLOG.txt': File(''),
'license': File(''),
'licence': File(''),
'LICENSE': File(''),
'LICENCE': File('')
})
)
withFixture(t, fixture, function (done) {
t.ok(fileExists('package.json'), 'package.json included')
t.ok(fileExists('README'), 'README included')
t.ok(fileExists('Readme'), 'Readme included')
t.ok(fileExists('readme.md'), 'readme.md included')
t.ok(fileExists('readme.randomext'), 'readme.randomext included')
t.ok(fileExists('changelog'), 'changelog included')
t.ok(fileExists('CHAngelog'), 'CHAngelog included')
t.ok(fileExists('ChangeLOG.txt'), 'ChangeLOG.txt included')
t.ok(fileExists('license'), 'license included')
t.ok(fileExists('licence'), 'licence included')
t.ok(fileExists('LICENSE'), 'LICENSE included')
t.ok(fileExists('LICENCE'), 'LICENCE included')
done()
})
})
test('folder-based inclusion works', function (t) {
var fixture = new Tacks(
Dir({
'package.json': File({
name: 'npm-test-files',
version: '1.2.5',
files: [
'sub1/sub',
'sub2'
]
}),
sub1: Dir({
sub: Dir({
include1: File(''),
include2: File('')
}),
ignored: File('')
}),
sub2: Dir({
include1: File(''),
include2: File(''),
empty: Dir({})
})
})
)
withFixture(t, fixture, function (done) {
t.ok(fileExists('sub1/sub/include1'), 'nested dir included')
t.ok(fileExists('sub1/sub/include2'), 'nested dir included')
t.notOk(fileExists('sub1/ignored'), 'unspecified file not included')
t.ok(fileExists('sub2/include1'), 'dir contents included')
t.ok(fileExists('sub2/include2'), 'dir contents included')
t.notOk(fileExists('sub2/empty'), 'empty dir not included')
done()
})
})
function fileExists (file) {
try {
return !!fs.statSync(path.resolve(installedpath, file))
} catch (_) {
return false
}
}
function withFixture (t, fixture, tester) {
fixture.create(fixturepath)
mkdirp.sync(modulepath)
common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
function installCheckAndTest (err, code) {
if (err) throw err
t.is(code, 0, 'install went ok')
tester(removeAndDone)
}
function removeAndDone (err) {
if (err) throw err
fixture.remove(fixturepath)
rimraf.sync(basepath)
t.done()
}
}

62
node_modules/npm/test/tap/gently-rm-overeager.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
var resolve = require("path").resolve
var fs = require("graceful-fs")
var test = require("tap").test
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var common = require("../common-tap.js")
var pkg = resolve(__dirname, "gently-rm-overeager")
var dep = resolve(__dirname, "test-whoops")
var EXEC_OPTS = {
cwd : pkg
}
var fixture = {
name: "@test/whoops",
version: "1.0.0",
scripts: {
postinstall: "echo \"nope\" && exit 1"
}
}
test("setup", function (t) {
cleanup()
setup()
t.end()
})
test("cache add", function (t) {
common.npm(["install", "../test-whoops"], EXEC_OPTS, function (er, c) {
t.ifError(er, "test-whoops install didn't explode")
t.ok(c, "test-whoops install also failed")
fs.readdir(pkg, function (er, files) {
t.ifError(er, "package directory is still there")
t.deepEqual(files, ["npm-debug.log"], "only debug log remains")
t.end()
})
})
})
test("cleanup", function (t) {
cleanup()
t.end()
})
function cleanup () {
rimraf.sync(pkg)
rimraf.sync(dep)
}
function setup () {
mkdirp.sync(pkg)
// so it doesn't try to install into npm's own node_modules
mkdirp.sync(resolve(pkg, "node_modules"))
mkdirp.sync(dep)
fs.writeFileSync(resolve(dep, "package.json"), JSON.stringify(fixture))
}

113
node_modules/npm/test/tap/gently-rm-symlink.js generated vendored Normal file
View File

@@ -0,0 +1,113 @@
var resolve = require("path").resolve
var fs = require("graceful-fs")
var test = require("tap").test
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var common = require("../common-tap.js")
var pkg = resolve(__dirname, "gently-rm-linked")
var dep = resolve(__dirname, "test-linked")
var glb = resolve(__dirname, "test-global")
var lnk = resolve(__dirname, "test-global-link")
var EXEC_OPTS = {
cwd : pkg
}
var index = "module.exports = function () { console.log('whoop whoop') }"
var fixture = {
name: "@test/linked",
version: "1.0.0",
bin: {
linked: "./index.js"
}
}
test("setup", function (t) {
cleanup()
setup()
t.end()
})
test("install and link", function (t) {
common.npm(
[
"--global",
"--prefix", lnk,
"--loglevel", "silent",
"install", "../test-linked"
],
EXEC_OPTS,
function (er, code, stdout, stderr) {
t.ifError(er, "test-linked install didn't explode")
t.notOk(code, "test-linked install also failed")
t.notOk(stderr, "no log output")
verify(t, stdout)
// again, to make sure unlinking works properlyt
common.npm(
[
"--global",
"--prefix", lnk,
"--loglevel", "silent",
"install", "../test-linked"
],
EXEC_OPTS,
function (er, code, stdout, stderr) {
t.ifError(er, "test-linked install didn't explode")
t.notOk(code, "test-linked install also failed")
t.notOk(stderr, "no log output")
verify(t, stdout)
fs.readdir(pkg, function (er, files) {
t.ifError(er, "package directory is still there")
t.deepEqual(files, ["node_modules"], "only stub modules dir remains")
t.end()
})
}
)
}
)
})
test("cleanup", function (t) {
cleanup()
t.end()
})
function verify (t, stdout) {
var binPath = resolve(lnk, "bin", "linked")
var pkgPath = resolve(lnk, "lib", "node_modules", "@test", "linked")
var trgPath = resolve(pkgPath, "index.js")
t.equal(
stdout,
binPath+" -> "+trgPath+"\n@test/linked@1.0.0 "+pkgPath+"\n",
"got expected install output"
)
}
function cleanup () {
rimraf.sync(pkg)
rimraf.sync(dep)
rimraf.sync(lnk)
rimraf.sync(glb)
}
function setup () {
mkdirp.sync(pkg)
mkdirp.sync(glb)
fs.symlinkSync(glb, lnk)
// so it doesn't try to install into npm's own node_modules
mkdirp.sync(resolve(pkg, "node_modules"))
mkdirp.sync(dep)
fs.writeFileSync(resolve(dep, "package.json"), JSON.stringify(fixture))
fs.writeFileSync(resolve(dep, "index.js"), index)
}

126
node_modules/npm/test/tap/get.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
var common = require("../common-tap.js")
var test = require("tap").test
var cacheFile = require("npm-cache-filename")
var npm = require("../../")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var path = require("path")
var mr = require("npm-registry-mock")
var fs = require("graceful-fs")
function nop () {}
var URI = "https://npm.registry:8043/rewrite"
var TIMEOUT = 3600
var FOLLOW = false
var STALE_OK = true
var TOKEN = "lolbutts"
var AUTH = {
token : TOKEN
}
var PARAMS = {
timeout : TIMEOUT,
follow : FOLLOW,
staleOk : STALE_OK,
auth : AUTH
}
var PKG_DIR = path.resolve(__dirname, "get-basic")
var CACHE_DIR = path.resolve(PKG_DIR, "cache")
var BIGCO_SAMPLE = {
name : "@bigco/sample",
version : "1.2.3"
}
// mock server reference
var server
var mocks = {
"get": {
"/@bigco%2fsample/1.2.3" : [200, BIGCO_SAMPLE]
}
}
var mapper = cacheFile(CACHE_DIR)
function getCachePath (uri) {
return path.join(mapper(uri), ".cache.json")
}
test("setup", function (t) {
mkdirp.sync(CACHE_DIR)
mr({port: common.port, mocks: mocks}, function (er, s) {
t.ifError(er)
npm.load({cache: CACHE_DIR, registry: common.registry}, function (er) {
t.ifError(er)
server = s
t.end()
})
})
})
test("get call contract", function (t) {
t.throws(function () {
npm.registry.get(undefined, PARAMS, nop)
}, "requires a URI")
t.throws(function () {
npm.registry.get([], PARAMS, nop)
}, "requires URI to be a string")
t.throws(function () {
npm.registry.get(URI, undefined, nop)
}, "requires params object")
t.throws(function () {
npm.registry.get(URI, "", nop)
}, "params must be object")
t.throws(function () {
npm.registry.get(URI, PARAMS, undefined)
}, "requires callback")
t.throws(function () {
npm.registry.get(URI, PARAMS, "callback")
}, "callback must be function")
t.end()
})
test("basic request", function (t) {
t.plan(9)
var versioned = common.registry + "/underscore/1.3.3"
npm.registry.get(versioned, PARAMS, function (er, data) {
t.ifError(er, "loaded specified version underscore data")
t.equal(data.version, "1.3.3")
fs.stat(getCachePath(versioned), function (er) {
t.ifError(er, "underscore 1.3.3 cache data written")
})
})
var rollup = common.registry + "/underscore"
npm.registry.get(rollup, PARAMS, function (er, data) {
t.ifError(er, "loaded all metadata")
t.deepEqual(data.name, "underscore")
fs.stat(getCachePath(rollup), function (er) {
t.ifError(er, "underscore rollup cache data written")
})
})
var scoped = common.registry + "/@bigco%2fsample/1.2.3"
npm.registry.get(scoped, PARAMS, function (er, data) {
t.ifError(er, "loaded all metadata")
t.equal(data.name, "@bigco/sample")
fs.stat(getCachePath(scoped), function (er) {
t.ifError(er, "scoped cache data written")
})
})
})
test("cleanup", function (t) {
server.close()
rimraf.sync(PKG_DIR)
t.end()
})

View File

@@ -0,0 +1,84 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'gist-short-shortcut-package')
var json = {
name: 'gist-short-shortcut-package',
version: '0.0.0',
dependencies: {
'private-gist': 'gist:deadbeef'
}
}
test('setup', function (t) {
setup()
t.end()
})
test('gist-short-shortcut-package', function (t) {
var cloneUrls = [
['git://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try git URLs first'],
['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs second'],
['git@gist.github.com:/deadbeef.git', 'GitHub gist shortcuts try SSH third']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install([], function (er, result) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

81
node_modules/npm/test/tap/gist-short-shortcut.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'gist-short-shortcut')
var json = {
name: 'gist-short-shortcut',
version: '0.0.0'
}
test('setup', function (t) {
setup()
t.end()
})
test('gist-shortcut', function (t) {
var cloneUrls = [
['git://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try git URLs first'],
['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs second'],
['git@gist.github.com:/deadbeef.git', 'GitHub gist shortcuts try SSH third']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install(['gist:deadbeef'], function (er, result) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

84
node_modules/npm/test/tap/gist-shortcut-package.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'gist-shortcut-package')
var json = {
name: 'gist-shortcut-package',
version: '0.0.0',
dependencies: {
'private-gist': 'gist:foo/deadbeef'
}
}
test('setup', function (t) {
setup()
t.end()
})
test('gist-shortcut-package', function (t) {
var cloneUrls = [
['git://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try git URLs first'],
['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs second'],
['git@gist.github.com:/deadbeef.git', 'GitHub gist shortcuts try SSH third']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install([], function (er, result) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

81
node_modules/npm/test/tap/gist-shortcut.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'gist-shortcut')
var json = {
name: 'gist-shortcut',
version: '0.0.0'
}
test('setup', function (t) {
setup()
t.end()
})
test('gist-shortcut', function (t) {
var cloneUrls = [
['git://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try git URLs first'],
['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs second'],
['git@gist.github.com:/deadbeef.git', 'GitHub gist shortcuts try SSH third']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install(['gist:foo/deadbeef'], function (er, result) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

46
node_modules/npm/test/tap/git-cache-locking.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var test = require('tap').test
var common = require('../common-tap')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var pkg = path.resolve(__dirname, 'git-cache-locking')
var tmp = path.join(pkg, 'tmp')
var cache = path.join(pkg, 'cache')
test('setup', function (t) {
rimraf.sync(pkg)
mkdirp.sync(path.resolve(pkg, 'node_modules'))
t.end()
})
test('git-cache-locking: install a git dependency', function (t) {
// disable git integration tests on Travis.
if (process.env.TRAVIS) return t.end()
// package c depends on a.git#master and b.git#master
// package b depends on a.git#master
common.npm([
'install',
'git://github.com/nigelzor/npm-4503-c.git'
], {
cwd: pkg,
env: {
npm_config_cache: cache,
npm_config_tmp: tmp,
npm_config_prefix: pkg,
npm_config_global: 'false',
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH
}
}, function (err, code, stdout, stderr) {
t.ifErr(err, 'npm install finished without error')
t.equal(0, code, 'npm install should succeed')
t.end()
})
})
test('cleanup', function (t) {
rimraf.sync(pkg)
t.end()
})

63
node_modules/npm/test/tap/git-cache-no-hooks.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
var test = require("tap").test
, fs = require("fs")
, path = require("path")
, rimraf = require("rimraf")
, mkdirp = require("mkdirp")
, spawn = require("child_process").spawn
, npmCli = require.resolve("../../bin/npm-cli.js")
, node = process.execPath
, pkg = path.resolve(__dirname, "git-cache-no-hooks")
, tmp = path.join(pkg, "tmp")
, cache = path.join(pkg, "cache")
test("setup", function (t) {
rimraf.sync(pkg)
mkdirp.sync(pkg)
mkdirp.sync(cache)
mkdirp.sync(tmp)
mkdirp.sync(path.resolve(pkg, "node_modules"))
t.end()
})
test("git-cache-no-hooks: install a git dependency", function (t) {
// disable git integration tests on Travis.
if (process.env.TRAVIS) return t.end()
var command = [ npmCli
, "install"
, "git://github.com/nigelzor/npm-4503-a.git"
]
var child = spawn(node, command, {
cwd: pkg,
env: {
"npm_config_cache" : cache,
"npm_config_tmp" : tmp,
"npm_config_prefix" : pkg,
"npm_config_global" : "false",
"npm_config_umask" : "00",
HOME : process.env.HOME,
Path : process.env.PATH,
PATH : process.env.PATH
},
stdio: "inherit"
})
child.on("close", function (code) {
t.equal(code, 0, "npm install should succeed")
// verify permissions on git hooks
var repoDir = "git-github-com-nigelzor-npm-4503-a-git-40c5cb24"
var hooksPath = path.join(cache, "_git-remotes", repoDir, "hooks")
fs.readdir(hooksPath, function (err) {
t.equal(err && err.code, "ENOENT", "hooks are not brought along with repo")
t.end()
})
})
})
test("cleanup", function (t) {
rimraf.sync(pkg)
t.end()
})

View File

@@ -0,0 +1,175 @@
var fs = require('fs')
var resolve = require('path').resolve
var osenv = require('osenv')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var readJson = require('read-package-json')
var mr = require('npm-registry-mock')
var npm = require('../../lib/npm.js')
var common = require('../common-tap.js')
var pkg = resolve(__dirname, 'git-dependency-install-link')
var repo = resolve(__dirname, 'git-dependency-install-link-repo')
var cache = resolve(pkg, 'cache')
var daemon
var daemonPID
var git
var mockRegistry
var EXEC_OPTS = {
registry: common.registry,
cwd: pkg,
cache: cache
}
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
'child': 'git://localhost:1234/child.git'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
setup(function (er, r) {
t.ifError(er, 'git started up successfully')
if (!er) {
daemon = r[r.length - 2]
daemonPID = r[r.length - 1]
}
mr({
port: common.port
}, function (er, server) {
t.ifError(er, 'started mock registry')
mockRegistry = server
t.end()
})
})
})
test('install from git repo [no --link]', function (t) {
process.chdir(pkg)
common.npm(['install', '--loglevel', 'error'], EXEC_OPTS, function (err, code, stdout, stderr) {
t.ifError(err, 'npm install failed')
t.dissimilar(stderr, /Command failed:/, 'expect git to succeed')
t.dissimilar(stderr, /version not found/, 'should not go to repository')
readJson(resolve(pkg, 'node_modules', 'child', 'package.json'), function (err, data) {
t.ifError(err, 'error reading child package.json')
t.equal(data && data.version, '1.0.3')
t.end()
})
})
})
test('install from git repo [with --link]', function (t) {
process.chdir(pkg)
rimraf.sync(resolve(pkg, 'node_modules'))
common.npm(['install', '--link', '--loglevel', 'error'], EXEC_OPTS, function (err, code, stdout, stderr) {
t.ifError(err, 'npm install --link failed')
t.dissimilar(stderr, /Command failed:/, 'expect git to succeed')
t.dissimilar(stderr, /version not found/, 'should not go to repository')
readJson(resolve(pkg, 'node_modules', 'child', 'package.json'), function (err, data) {
t.ifError(err, 'error reading child package.json')
t.equal(data && data.version, '1.0.3')
t.end()
})
})
})
test('clean', function (t) {
mockRegistry.close()
daemon.on('close', function () {
cleanup()
t.end()
})
process.kill(daemonPID)
})
function bootstrap () {
rimraf.sync(repo)
rimraf.sync(pkg)
mkdirp.sync(pkg)
mkdirp.sync(cache)
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
}
function setup (cb) {
mkdirp.sync(repo)
fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
npm.load({
link: true,
prefix: pkg,
loglevel: 'silent'
}, function () {
git = require('../../lib/utils/git.js')
function startDaemon (cb) {
// start git server
var d = git.spawn(
[
'daemon',
'--verbose',
'--listen=localhost',
'--export-all',
'--base-path=.',
'--reuseaddr',
'--port=1234'
],
{
cwd: pkg,
env: process.env,
stdio: ['pipe', 'pipe', 'pipe']
}
)
d.stderr.on('data', childFinder)
function childFinder (c) {
var cpid = c.toString().match(/^\[(\d+)\]/)
if (cpid[1]) {
this.removeListener('data', childFinder)
cb(null, [d, cpid[1]])
}
}
}
common.makeGitRepo({
path: repo,
commands: [
git.chainableExec(
['clone', '--bare', repo, 'child.git'],
{ cwd: pkg, env: process.env }
),
startDaemon
]
}, cb)
})
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(repo)
rimraf.sync(pkg)
}

173
node_modules/npm/test/tap/git-npmignore.js generated vendored Normal file
View File

@@ -0,0 +1,173 @@
var cat = require("graceful-fs").writeFileSync
var exec = require("child_process").exec
var readdir = require("graceful-fs").readdirSync
var resolve = require("path").resolve
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var test = require("tap").test
var tmpdir = require("osenv").tmpdir
var which = require("which")
var common = require("../common-tap.js")
var pkg = resolve(__dirname, "git-npmignore")
var dep = resolve(pkg, "deps", "gitch")
var packname = "gitch-1.0.0.tgz"
var packed = resolve(pkg, packname)
var modules = resolve(pkg, "node_modules")
var installed = resolve(modules, "gitch")
var expected = [
"a.js",
"package.json",
".npmignore"
].sort()
var EXEC_OPTS = {
cwd : pkg
}
var gitignore = "node_modules/\n"
var npmignore = "t.js\n"
var a = "console.log('hi');"
var t = "require('tap').test(function (t) { t.pass('I am a test!'); t.end(); });"
var fixture = {
"name" : "gitch",
"version" : "1.0.0",
"private" : true,
"main" : "a.js"
}
test("setup", function (t) {
setup(function (er) {
t.ifError(er, "setup ran OK")
t.end()
})
})
test("npm pack directly from directory", function (t) {
packInstallTest(dep, t)
})
test("npm pack via git", function (t) {
packInstallTest("git+file://"+dep, t)
})
test("cleanup", function (t) {
cleanup()
t.end()
})
function packInstallTest (spec, t) {
common.npm(
[
"--loglevel", "silent",
"pack", spec
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, "npm pack ran without error")
t.notOk(code, "npm pack exited cleanly")
t.notOk(stderr, "npm pack ran silently")
t.equal(stdout.trim(), packname, "got expected package name")
common.npm(
[
"--loglevel", "silent",
"install", packed
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, "npm install ran without error")
t.notOk(code, "npm install exited cleanly")
t.notOk(stderr, "npm install ran silently")
var actual = readdir(installed).sort()
t.same(actual, expected, "no unexpected files in packed directory")
rimraf(packed, function () {
t.end()
})
}
)
}
)
}
function cleanup () {
process.chdir(tmpdir())
rimraf.sync(pkg)
}
function setup (cb) {
cleanup()
mkdirp.sync(modules)
mkdirp.sync(dep)
process.chdir(dep)
cat(resolve(dep, ".npmignore"), npmignore)
cat(resolve(dep, ".gitignore"), gitignore)
cat(resolve(dep, "a.js"), a)
cat(resolve(dep, "t.js"), t)
cat(resolve(dep, "package.json"), JSON.stringify(fixture))
common.npm(
[
"--loglevel", "silent",
"cache", "clean"
],
EXEC_OPTS,
function (er, code, _, stderr) {
if (er) return cb(er)
if (code) return cb(new Error("npm cache nonzero exit: "+code))
if (stderr) return cb(new Error("npm cache clean error: "+stderr))
which("git", function found (er, git) {
if (er) return cb(er)
exec(git+" init", init)
function init (er, _, stderr) {
if (er) return cb(er)
if (stderr) return cb(new Error("git init error: "+stderr))
exec(git+" config user.name 'Phantom Faker'", user)
}
function user (er, _, stderr) {
if (er) return cb(er)
if (stderr) return cb(new Error("git config error: "+stderr))
exec(git+" config user.email nope@not.real", email)
}
function email (er, _, stderr) {
if (er) return cb(er)
if (stderr) return cb(new Error("git config error: "+stderr))
exec(git+" add .", addAll)
}
function addAll (er, _, stderr) {
if (er) return cb(er)
if (stderr) return cb(new Error("git add . error: "+stderr))
exec(git+" commit -m boot", commit)
}
function commit (er, _, stderr) {
if (er) return cb(er)
if (stderr) return cb(new Error("git commit error: "+stderr))
cb()
}
})
}
)
}

213
node_modules/npm/test/tap/git-races.js generated vendored Normal file
View File

@@ -0,0 +1,213 @@
var execFile = require('child_process').execFile
var path = require('path')
var zlib = require('zlib')
var asyncMap = require('slide').asyncMap
var deepEqual = require('deep-equal')
var fs = require('graceful-fs')
var mkdirp = require('mkdirp')
var once = require('once')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var tar = require('tar')
var test = require('tap').test
var tmpdir = require('osenv').tmpdir
var which = require('which')
var wd = path.resolve(tmpdir(), 'git-races')
var fixtures = path.resolve(__dirname, '../fixtures')
var testcase = 'github-com-BryanDonovan-npm-git-test'
var testcase_git = path.resolve(wd, testcase + '.git')
var testcase_path = path.resolve(wd, testcase)
var testcase_tgz = path.resolve(fixtures, testcase + '.git.tar.gz')
var testtarballs = []
var testrepos = {}
var testurls = {}
/*
This test is specifically for #7202, where the bug was if you tried installing multiple git urls that
pointed at the same repo but had different comittishes, you'd sometimes get the wrong version.
The test cases, provided by @BryanDonovan, have a dependency tree like this:
top
bar#4.0.0
buzz#3.0.0
foo#3.0.0
buzz#3.0.0
foo#4.0.0
buzz#2.0.0
But what would happen is that buzz#2.0.0 would end up installed under bar#4.0.0.
bar#4.0.0 shouldn't have gotten its own copy if buzz, and if it did, it shouldn've been buzz#3.0.0
*/
;['bar', 'foo', 'buzz'].forEach(function (name) {
var mockurl = 'ssh://git@github.com/BryanDonovan/dummy-npm-' + name + '.git'
var realrepo = path.resolve(wd, 'github-com-BryanDonovan-dummy-npm-' + name + '.git')
var tgz = path.resolve(fixtures, 'github-com-BryanDonovan-dummy-npm-' + name + '.git.tar.gz')
testrepos[mockurl] = realrepo
testtarballs.push(tgz)
})
function cleanup () {
process.chdir(tmpdir())
rimraf.sync(wd)
}
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
// If it's a clone we swap any requests for any of the urls we're mocking
// with the path to the bare repo
if (args[0] === 'clone') {
var m2 = args.length - 2
var m1 = args.length - 1
if (testrepos[args[m2]]) {
testurls[args[m1]] = args[m2]
args[m2] = testrepos[args[m2]]
}
execFile(cmd, args, options, cb)
// here, we intercept npm validating the remote origin url on one of the
// clones we've done previously and return the original url that was requested
} else if (args[0] === 'config' && args[1] === '--get' && args[2] === 'remote.origin.url') {
process.nextTick(function () {
cb(null, testurls[options.cwd], '')
})
} else {
execFile(cmd, args, options, cb)
}
}
}
})
function extract (tarball, target, cb) {
cb = once(cb)
fs.createReadStream(tarball).on('error', function (er) { cb(er) })
.pipe(zlib.createGunzip()).on('error', function (er) { cb(er) })
.pipe(tar.Extract({path: target})).on('error', function (er) { cb(er) })
.on('end', function () {
cb()
})
}
// Copied from lib/utils/git, because we need to use
// it before calling npm.load and lib/utils/git uses npm.js
// which doesn't allow that. =( =(
function prefixGitArgs () {
return process.platform === 'win32' ? ['-c', 'core.longpaths=true'] : []
}
var gitcmd
function execGit (args, options, cb) {
var fullArgs = prefixGitArgs().concat(args || [])
return execFile(gitcmd, fullArgs, options, cb)
}
function gitWhichAndExec (args, options, cb) {
if (gitcmd) return execGit(args, options, cb)
which('git', function (err, pathtogit) {
if (err) {
err.code = 'ENOGIT'
return cb(err)
}
gitcmd = pathtogit
execGit(args, options, cb)
})
}
function andClone (gitdir, repodir, cb) {
return function (er) {
if (er) return cb(er)
gitWhichAndExec(['clone', gitdir, repodir], {}, cb)
}
}
function setup (cb) {
cleanup()
mkdirp.sync(wd)
extract(testcase_tgz, wd, andClone(testcase_git, testcase_path, andExtractPackages))
function andExtractPackages (er) {
if (er) return cb(er)
asyncMap(testtarballs, function (tgz, done) {
extract(tgz, wd, done)
}, andChdir)
}
function andChdir (er) {
if (er) return cb(er)
process.chdir(testcase_path)
andLoadNpm()
}
function andLoadNpm () {
var opts = {
cache: path.resolve(wd, 'cache')
}
npm.load(opts, cb)
}
}
// there are two (sic) valid trees that can result we don't care which one we
// get in npm@2
var oneTree = [
'npm-git-test@1.0.0', [
['dummy-npm-bar@4.0.0', [
['dummy-npm-foo@3.0.0', []]
]],
['dummy-npm-buzz@3.0.0', []],
['dummy-npm-foo@4.0.0', [
['dummy-npm-buzz@2.0.0', []]
]]
]
]
var otherTree = [
'npm-git-test@1.0.0', [
['dummy-npm-bar@4.0.0', [
['dummy-npm-buzz@3.0.0', []],
['dummy-npm-foo@3.0.0', []]
]],
['dummy-npm-buzz@3.0.0', []],
['dummy-npm-foo@4.0.0', [
['dummy-npm-buzz@2.0.0', []]
]]
]
]
function toSimple (tree) {
var deps = []
Object.keys(tree.dependencies || {}).forEach(function (dep) {
deps.push(toSimple(tree.dependencies[dep]))
})
return [ tree['name'] + '@' + tree['version'], deps ]
}
test('setup', function (t) {
setup(function (er) {
t.ifError(er, 'setup ran OK')
t.end()
})
})
test('correct versions are installed for git dependency', function (t) {
t.plan(3)
t.comment('test for https://github.com/npm/npm/issues/7202')
npm.commands.install([], function (er) {
t.ifError(er, 'installed OK')
npm.commands.ls([], true, function (er, result) {
t.ifError(er, 'ls OK')
var simplified = toSimple(result)
t.ok(
deepEqual(simplified, oneTree) || deepEqual(simplified, otherTree),
'install tree is correct'
)
})
})
})

84
node_modules/npm/test/tap/github-shortcut-package.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'github-shortcut-package')
var json = {
name: 'github-shortcut-package',
version: '0.0.0',
dependencies: {
'private': 'foo/private'
}
}
test('setup', function (t) {
setup()
t.end()
})
test('github-shortcut-package', function (t) {
var cloneUrls = [
['git://github.com/foo/private.git', 'GitHub shortcuts try git URLs first'],
['https://github.com/foo/private.git', 'GitHub shortcuts try HTTPS URLs second'],
['git@github.com:foo/private.git', 'GitHub shortcuts try SSH third']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install([], function (er, result) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

81
node_modules/npm/test/tap/github-shortcut.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'github-shortcut')
var json = {
name: 'github-shortcut',
version: '0.0.0'
}
test('setup', function (t) {
setup()
t.end()
})
test('github-shortcut', function (t) {
var cloneUrls = [
['git://github.com/foo/private.git', 'GitHub shortcuts try git URLs first'],
['https://github.com/foo/private.git', 'GitHub shortcuts try HTTPS URLs third'],
['git@github.com:foo/private.git', 'GitHub shortcuts try SSH second']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install(['foo/private'], function (er, result) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

83
node_modules/npm/test/tap/gitlab-shortcut-package.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'gitlab-shortcut-package')
var json = {
name: 'gitlab-shortcut-package',
version: '0.0.0',
dependencies: {
'private': 'gitlab:foo/private'
}
}
test('setup', function (t) {
setup()
t.end()
})
test('gitlab-shortcut-package', function (t) {
var cloneUrls = [
['git@gitlab.com:foo/private.git', 'GitLab shortcuts try SSH first'],
['https://gitlab.com/foo/private.git', 'GitLab shortcuts try HTTPS URLs second']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install([], function (er, result) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

80
node_modules/npm/test/tap/gitlab-shortcut.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'gitlab-shortcut')
var json = {
name: 'gitlab-shortcut',
version: '0.0.0'
}
test('setup', function (t) {
setup()
t.end()
})
test('gitlab-shortcut', function (t) {
var cloneUrls = [
['git@gitlab.com:foo/private.git', 'GitLab shortcuts try SSH first'],
['https://gitlab.com/foo/private.git', 'GitLab shortcuts try HTTPS URLs second']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
if (args[0] !== 'clone') return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
t.is(args[3], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
cb(new Error())
})
}
}
})
var opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
npm.commands.install(['gitlab:foo/private'], function (er, result) {
t.ok(er, 'mocked install failed as expected')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

View File

@@ -0,0 +1,36 @@
var common = require("../common-tap.js")
var test = require("tap").test
var rimraf = require("rimraf")
var prefix = __filename.replace(/\.js$/, "")
var rcfile = __filename.replace(/\.js$/, ".npmrc")
var fs = require("fs")
var conf = "prefix = " + prefix + "\n"
test("setup", function (t) {
rimraf.sync(prefix)
fs.writeFileSync(rcfile, conf)
t.pass("ready")
t.end()
})
test("run command", function (t) {
var args = ["prefix", "-g", "--userconfig=" + rcfile]
common.npm(args, {env: {}}, function (er, code, so) {
if (er) throw er
t.notOk(code, "npm prefix exited with code 0")
t.equal(so.trim(), prefix)
t.end()
})
})
test("made dir", function (t) {
t.ok(fs.statSync(prefix).isDirectory())
t.end()
})
test("cleanup", function (t) {
rimraf.sync(prefix)
rimraf.sync(rcfile)
t.pass("clean")
t.end()
})

118
node_modules/npm/test/tap/graceful-restart.js generated vendored Normal file
View File

@@ -0,0 +1,118 @@
var fs = require('fs')
var resolve = require('path').resolve
var osenv = require('osenv')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = resolve(__dirname, 'graceful-restart')
var outGraceless = [
'prerestart',
'prestop',
'stop',
'poststop',
'prestart',
'start',
'poststart',
'postrestart',
''
].join('\n')
var outGraceful = [
'prerestart',
'restart',
'postrestart',
''
].join('\n')
var pjGraceless = JSON.stringify({
name: 'graceless',
version: '1.2.3',
scripts: {
'prestop': 'echo prestop',
'stop': 'echo stop',
'poststop': 'echo poststop',
'prerestart': 'echo prerestart',
'postrestart': 'echo postrestart',
'prestart': 'echo prestart',
'start': 'echo start',
'poststart': 'echo poststart'
}
}, null, 2) + '\n'
var pjGraceful = JSON.stringify({
name: 'graceful',
version: '1.2.3',
scripts: {
'prestop': 'echo prestop',
'stop': 'echo stop',
'poststop': 'echo poststop',
'prerestart': 'echo prerestart',
'restart': 'echo restart',
'postrestart': 'echo postrestart',
'prestart': 'echo prestart',
'start': 'echo start',
'poststart': 'echo poststart'
}
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
t.end()
})
test('graceless restart', function (t) {
fs.writeFileSync(resolve(pkg, 'package.json'), pjGraceless)
createChild(['run-script', 'restart'], function (err, code, out) {
t.ifError(err, 'restart finished successfully')
t.equal(code, 0, 'npm run-script exited with code')
t.equal(out, outGraceless, 'expected all scripts to run')
t.end()
})
})
test('graceful restart', function (t) {
fs.writeFileSync(resolve(pkg, 'package.json'), pjGraceful)
createChild(['run-script', 'restart'], function (err, code, out) {
t.ifError(err, 'restart finished successfully')
t.equal(code, 0, 'npm run-script exited with code')
t.equal(out, outGraceful, 'expected only *restart scripts to run')
t.end()
})
})
test('clean', function (t) {
cleanup()
t.end()
})
function bootstrap () {
mkdirp.sync(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
function createChild (args, cb) {
var env = {
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH,
'npm_config_loglevel': 'silent'
}
if (process.platform === 'win32')
env.npm_config_cache = '%APPDATA%\\npm-cache'
return common.npm(args, {
cwd: pkg,
stdio: ['ignore', 'pipe', 'ignore'],
env: env
}, cb)
}

69
node_modules/npm/test/tap/ignore-install-link.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
if (process.platform === "win32") {
console.log("ok - symlinks are weird on windows, skip this test")
return
}
var common = require("../common-tap.js")
var test = require("tap").test
var path = require("path")
var fs = require("fs")
var rimraf = require("rimraf")
var mkdirp = require("mkdirp")
var root = path.resolve(__dirname, "ignore-install-link")
var pkg = path.resolve(root, "pkg")
var dep = path.resolve(root, "dep")
var target = path.resolve(pkg, "node_modules", "dep")
var cache = path.resolve(root, "cache")
var globalPath = path.resolve(root, "global")
var pkgj = { "name":"pkg", "version": "1.2.3"
, "dependencies": { "dep": "1.2.3" } }
var depj = { "name": "dep", "version": "1.2.3" }
var myreg = require("http").createServer(function (q, s) {
s.statusCode = 403
s.end(JSON.stringify({"error":"forbidden"}) + "\n")
}).listen(common.port)
test("setup", function (t) {
rimraf.sync(root)
mkdirp.sync(root)
mkdirp.sync(path.resolve(pkg, "node_modules"))
mkdirp.sync(dep)
mkdirp.sync(cache)
mkdirp.sync(globalPath)
fs.writeFileSync(path.resolve(pkg, "package.json"), JSON.stringify(pkgj))
fs.writeFileSync(path.resolve(dep, "package.json"), JSON.stringify(depj))
fs.symlinkSync(dep, target, "dir")
t.end()
})
test("ignore install if package is linked", function (t) {
common.npm(["install"], {
cwd: pkg,
env: {
PATH: process.env.PATH || process.env.Path,
HOME: process.env.HOME,
"npm_config_prefix": globalPath,
"npm_config_cache": cache,
"npm_config_registry": common.registry,
"npm_config_loglevel": "silent"
},
stdio: "inherit"
}, function (er, code) {
if (er) throw er
t.equal(code, 0, "npm install exited with code")
t.end()
})
})
test("still a symlink", function (t) {
t.equal(true, fs.lstatSync(target).isSymbolicLink())
t.end()
})
test("cleanup", function (t) {
rimraf.sync(root)
myreg.close()
t.end()
})

124
node_modules/npm/test/tap/ignore-scripts.js generated vendored Normal file
View File

@@ -0,0 +1,124 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap')
// ignore-scripts/package.json has scripts that always exit with non-zero error
// codes.
var pkg = path.resolve(__dirname, 'ignore-scripts')
var gypfile = 'bad_binding_file\n'
var json = {
author: 'Milton the Aussie',
name: 'ignore-scripts',
version: '0.0.0',
scripts: {
prepublish: 'exit 123',
publish: 'exit 123',
postpublish: 'exit 123',
preinstall: 'exit 123',
install: 'exit 123',
postinstall: 'exit 123',
preuninstall: 'exit 123',
uninstall: 'exit 123',
postuninstall: 'exit 123',
pretest: 'exit 123',
test: 'exit 123',
posttest: 'exit 123',
prestop: 'exit 123',
stop: 'exit 123',
poststop: 'exit 123',
prestart: 'exit 123',
start: 'exit 123',
poststart: 'exit 123',
prerestart: 'exit 123',
restart: 'exit 123',
postrestart: 'exit 123',
preversion: 'exit 123',
version: 'exit 123',
postversion: 'exit 123'
}
}
test('setup', function (t) {
setup()
t.end()
})
test('ignore-scripts: install using the option', function (t) {
createChild(['install', '--ignore-scripts'], function (err, code) {
t.ifError(err, 'install with scripts ignored finished successfully')
t.equal(code, 0, 'npm install exited with code')
t.end()
})
})
test('ignore-scripts: install NOT using the option', function (t) {
createChild(['install'], function (err, code) {
t.ifError(err, 'install with scripts successful')
t.notEqual(code, 0, 'npm install exited with code')
t.end()
})
})
var scripts = [
'prepublish', 'publish', 'postpublish',
'preinstall', 'install', 'postinstall',
'preuninstall', 'uninstall', 'postuninstall',
'pretest', 'test', 'posttest',
'prestop', 'stop', 'poststop',
'prestart', 'start', 'poststart',
'prerestart', 'restart', 'postrestart',
'preversion', 'version', 'postversion'
]
scripts.forEach(function (script) {
test('ignore-scripts: run-script ' + script + ' using the option', function (t) {
createChild(['--ignore-scripts', 'run-script', script], function (err, code, stdout, stderr) {
t.ifError(err, 'run-script ' + script + ' with ignore-scripts successful')
t.equal(code, 0, 'npm run-script exited with code')
t.end()
})
})
})
scripts.forEach(function (script) {
test('ignore-scripts: run-script ' + script + ' NOT using the option', function (t) {
createChild(['run-script', script], function (err, code) {
t.ifError(err, 'run-script ' + script + ' finished successfully')
t.notEqual(code, 0, 'npm run-script exited with code')
t.end()
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function cleanup () {
rimraf.sync(pkg)
}
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(path.join(pkg, 'binding.gyp'), gypfile)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
}
function createChild (args, cb) {
return common.npm(
args.concat(['--loglevel', 'silent']),
{ cwd: pkg },
cb
)
}

135
node_modules/npm/test/tap/ignore-shrinkwrap.js generated vendored Normal file
View File

@@ -0,0 +1,135 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = require('path').join(__dirname, 'ignore-shrinkwrap')
var EXEC_OPTS = { cwd: pkg }
var customMocks = {
'get': {
'/package.js': [200, { ente: true }],
'/shrinkwrap.js': [200, { ente: true }]
}
}
var json = {
author: 'Rocko Artischocko',
name: 'ignore-shrinkwrap',
version: '0.0.0',
dependencies: {
'npm-test-ignore-shrinkwrap-file': 'http://localhost:1337/package.js'
}
}
var shrinkwrap = {
name: 'ignore-shrinkwrap',
version: '0.0.0',
dependencies: {
'npm-test-ignore-shrinkwrap-file': {
version: '1.2.3',
from: 'http://localhost:1337/shrinkwrap.js',
resolved: 'http://localhost:1337/shrinkwrap.js',
dependencies: {
opener: {
version: '1.3.0',
from: 'opener@1.3.0'
}
}
}
}
}
test('setup', function (t) {
setup()
t.end()
})
test('npm install --no-shrinkwrap', function (t) {
mr({ port: common.port, mocks: customMocks }, function (err, s) {
t.ifError(err, 'mock registry bootstrapped without issue')
s._server.on('request', function (req) {
switch (req.url) {
case '/shrinkwrap.js':
t.fail('npm-shrinkwrap.json used instead of package.json')
break
case '/package.js':
t.pass('package.json used')
}
})
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'install', '--no-shrinkwrap'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm ran without issue')
t.ok(code, "install isn't going to succeed")
s.close()
t.end()
}
)
})
})
test('npm install (with shrinkwrap)', function (t) {
mr({ port: common.port, mocks: customMocks }, function (err, s) {
t.ifError(err, 'mock registry bootstrapped without issue')
s._server.on('request', function (req) {
switch (req.url) {
case '/shrinkwrap.js':
t.pass('shrinkwrap used')
break
case '/package.js':
t.fail('shrinkwrap ignored')
}
})
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'install'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm ran without issue')
t.ok(code, "install isn't going to succeed")
s.close()
t.end()
}
)
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function cleanup () {
rimraf.sync(pkg)
}
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
fs.writeFileSync(
path.join(pkg, 'npm-shrinkwrap.json'),
JSON.stringify(shrinkwrap, null, 2)
)
process.chdir(pkg)
}

58
node_modules/npm/test/tap/init-interrupt.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
// if "npm init" is interrupted with ^C, don't report
// "init written successfully"
var test = require("tap").test
var path = require("path")
var osenv = require("osenv")
var rimraf = require("rimraf")
var npmlog = require("npmlog")
var requireInject = require("require-inject")
var npm = require("../../lib/npm.js")
var PKG_DIR = path.resolve(__dirname, "init-interrupt")
test("setup", function (t) {
cleanup()
t.end()
})
test("issue #6684 remove confusing message", function (t) {
var initJsonMock = function (dir, input, config, cb) {
process.nextTick(function () {
cb({message : "canceled"})
})
}
initJsonMock.yes = function () { return true }
npm.load({loglevel : "silent"}, function () {
var log = ""
var init = requireInject("../../lib/init", {
"init-package-json": initJsonMock
})
// capture log messages
npmlog.on("log", function (chunk) { log += chunk.message + "\n" } )
init([], function (err, code) {
t.ifError(err, "init ran successfully")
t.notOk(code, "exited without issue")
t.notSimilar(log, /written successfully/, "no success message written")
t.similar(log, /canceled/, "alerted that init was canceled")
t.end()
})
})
})
test("cleanup", function (t) {
cleanup()
t.end()
})
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(PKG_DIR)
}

69
node_modules/npm/test/tap/install-at-locally.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'install-at-locally')
var EXEC_OPTS = { cwd: pkg }
var json = {
name: 'install-at-locally',
version: '0.0.0'
}
test('setup', function (t) {
cleanup()
t.end()
})
test('\'npm install ./package@1.2.3\' should install local pkg', function (t) {
var target = './package@1.2.3'
setup(target)
common.npm(['install', target], EXEC_OPTS, function (err, code) {
var p = path.resolve(pkg, 'node_modules/install-at-locally/package.json')
t.ifError(err, 'install local package successful')
t.equal(code, 0, 'npm install exited with code')
t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
t.end()
})
})
test('\'npm install install/at/locally@./package@1.2.3\' should install local pkg', function (t) {
var target = 'install/at/locally@./package@1.2.3'
setup(target)
common.npm(['install', target], EXEC_OPTS, function (err, code) {
var p = path.resolve(pkg, 'node_modules/install-at-locally/package.json')
t.ifError(err, 'install local package in explicit directory successful')
t.equal(code, 0, 'npm install exited with code')
t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
t.end()
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
function setup (target) {
cleanup()
var root = path.resolve(pkg, target)
mkdirp.sync(root)
fs.writeFileSync(
path.join(root, 'package.json'),
JSON.stringify(json, null, 2)
)
mkdirp.sync(path.resolve(pkg, 'node_modules'))
process.chdir(pkg)
}

80
node_modules/npm/test/tap/install-bad-man.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
var fs = require("fs")
var resolve = require("path").resolve
var osenv = require("osenv")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var test = require("tap").test
var common = require("../common-tap.js")
var pkg = resolve(__dirname, "install-bad-man")
var target = resolve(__dirname, "install-bad-man-target")
var EXEC_OPTS = {
cwd: target
}
var json = {
name : "install-bad-man",
version : "1.2.3",
man : [ "./install-bad-man.1.lol" ]
}
test("setup", function (t) {
setup()
t.pass("setup ran")
t.end()
})
test("install from repo on 'OS X'", function (t) {
common.npm(
[
"install",
"--prefix", target,
"--global",
pkg
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, "npm command ran from test")
t.equals(code, 1, "install exited with failure (1)")
t.notOk(stdout, "no output indicating success")
t.notOk(
stderr.match(/Cannot read property '1' of null/),
"no longer has cryptic error output"
)
t.ok(
stderr.match(/install-bad-man\.1\.lol is not a valid name/),
"got expected error output"
)
t.end()
}
)
})
test("clean", function (t) {
cleanup()
t.pass("cleaned up")
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
// make sure it installs locally
mkdirp.sync(resolve(target, "node_modules"))
fs.writeFileSync(
resolve(pkg, "package.json"),
JSON.stringify(json, null, 2)+"\n"
)
fs.writeFileSync(resolve(pkg, "install-bad-man.1.lol"), "lol\n")
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
rimraf.sync(target)
}

88
node_modules/npm/test/tap/install-cli-production.js generated vendored Normal file
View File

@@ -0,0 +1,88 @@
var fs = require('graceful-fs')
var path = require('path')
var existsSync = fs.existsSync || path.existsSync
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'install-cli-production')
var EXEC_OPTS = { cwd: pkg }
var json = {
name: 'install-cli-production',
description: 'fixture',
version: '0.0.0',
scripts: {
prepublish: 'exit 123'
},
dependencies: {
dependency: 'file:./dependency'
},
devDependencies: {
'dev-dependency': 'file:./dev-dependency'
}
}
var dependency = {
name: 'dependency',
description: 'fixture',
version: '0.0.0'
}
var devDependency = {
name: 'dev-dependency',
description: 'fixture',
version: '0.0.0'
}
test('setup', function (t) {
mkdirp.sync(path.join(pkg, 'dependency'))
fs.writeFileSync(
path.join(pkg, 'dependency', 'package.json'),
JSON.stringify(dependency, null, 2)
)
mkdirp.sync(path.join(pkg, 'devDependency'))
fs.writeFileSync(
path.join(pkg, 'devDependency', 'package.json'),
JSON.stringify(devDependency, null, 2)
)
mkdirp.sync(path.join(pkg, 'node_modules'))
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
t.end()
})
test('\'npm install --production\' should only install dependencies', function (t) {
common.npm(['install', '--production'], EXEC_OPTS, function (err, code) {
t.ifError(err, 'install production successful')
t.equal(code, 0, 'npm install did not raise error code')
t.ok(
JSON.parse(fs.readFileSync(
path.resolve(pkg, 'node_modules/dependency/package.json'), 'utf8')
),
'dependency was installed'
)
t.notOk(
existsSync(path.resolve(pkg, 'node_modules/dev-dependency/package.json')),
'devDependency was NOT installed'
)
t.end()
})
})
test('cleanup', function (t) {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
t.end()
})

71
node_modules/npm/test/tap/install-cli-unicode.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var server
var pkg = path.resolve(__dirname, 'install-cli-unicode')
function hasOnlyAscii (s) {
return /^[\000-\177]*$/.test(s)
}
var EXEC_OPTS = { cwd: pkg }
var json = {
name: 'install-cli',
description: 'fixture',
version: '0.0.1',
dependencies: {
read: '1.0.5'
}
}
test('setup', function (t) {
rimraf.sync(pkg)
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
mr({ port: common.port }, function (er, s) {
server = s
t.end()
})
})
test('does not use unicode with --unicode false', function (t) {
common.npm(
[
'--unicode', 'false',
'--registry', common.registry,
'--loglevel', 'silent',
'install', 'optimist'
],
EXEC_OPTS,
function (err, code, stdout) {
t.ifError(err, 'install package read without unicode success')
t.notOk(code, 'npm install exited with code 0')
t.ifError(err, 'npm install ran without issue')
t.ok(stdout, 'got some output')
t.ok(hasOnlyAscii(stdout), 'only ASCII in install output')
t.end()
}
)
})
test('cleanup', function (t) {
server.close()
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
t.end()
})

98
node_modules/npm/test/tap/install-from-local.js generated vendored Normal file
View File

@@ -0,0 +1,98 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap')
var root = path.join(__dirname, 'install-from-local')
var pkg = path.join(root, 'package-with-local-paths')
var EXEC_OPTS = { cwd: pkg }
var localPaths = {
name: 'package-with-local-paths',
version: '0.0.0',
dependencies: {
'package-local-dependency': 'file:../package-local-dependency'
},
devDependencies: {
'package-local-dev-dependency': 'file:../package-local-dev-dependency'
}
}
var localDependency = {
name: 'package-local-dependency',
version: '0.0.0',
description: 'Test for local installs'
}
var localDevDependency = {
name: 'package-local-dev-dependency',
version: '0.0.0',
description: 'Test for local installs'
}
test('setup', function (t) {
rimraf.sync(pkg)
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(localPaths, null, 2)
)
mkdirp.sync(path.join(root, 'package-local-dependency'))
fs.writeFileSync(
path.join(root, 'package-local-dependency', 'package.json'),
JSON.stringify(localDependency, null, 2)
)
mkdirp.sync(path.join(root, 'package-local-dev-dependency'))
fs.writeFileSync(
path.join(root, 'package-local-dev-dependency', 'package.json'),
JSON.stringify(localDevDependency, null, 2)
)
process.chdir(pkg)
t.end()
})
test('\'npm install\' should install local packages', function (t) {
common.npm(
[
'install', '.'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'error should not exist')
t.notOk(code, 'npm install exited with code 0')
var dependencyPackageJson = path.resolve(
pkg,
'node_modules/package-local-dependency/package.json'
)
t.ok(
JSON.parse(fs.readFileSync(dependencyPackageJson, 'utf8')),
'package with local dependency installed'
)
var devDependencyPackageJson = path.resolve(
pkg, 'node_modules/package-local-dev-dependency/package.json'
)
t.ok(
JSON.parse(fs.readFileSync(devDependencyPackageJson, 'utf8')),
'package with local dev dependency installed'
)
t.end()
}
)
})
test('cleanup', function (t) {
process.chdir(osenv.tmpdir())
rimraf.sync(root)
t.end()
})

132
node_modules/npm/test/tap/install-link-scripts.js generated vendored Normal file
View File

@@ -0,0 +1,132 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'install-link-scripts')
var tmp = path.join(pkg, 'tmp')
var dep = path.join(pkg, 'dep')
var json = {
name: 'install-link-scripts',
version: '1.0.0',
description: 'a test',
repository: 'git://github.com/npm/npm.git',
license: 'ISC'
}
var dependency = {
name: 'dep',
version: '1.0.0',
scripts: {
install: './bin/foo'
}
}
var foo = function () {/*
#!/usr/bin/env node
console.log('hey sup')
*/}.toString().split('\n').slice(1, -1).join('\n')
process.env.npm_config_prefix = tmp
test('plain install', function (t) {
setup()
common.npm(
[
'install', dep,
'--tmp', tmp
],
{ cwd: pkg },
function (err, code, stdout, stderr) {
t.ifErr(err, 'npm install ' + dep + ' finished without error')
t.equal(code, 0, 'exited ok')
t.notOk(stderr, 'no output stderr')
t.match(stdout, /hey sup/, 'postinstall script for dep ran')
t.end()
}
)
})
test('link', function (t) {
setup()
common.npm(
[
'link',
'--tmp', tmp
],
{ cwd: dep },
function (err, code, stdout, stderr) {
t.ifErr(err, 'npm link finished without error')
t.equal(code, 0, 'exited ok')
t.notOk(stderr, 'no output stderr')
t.match(stdout, /hey sup/, 'script ran')
t.end()
}
)
})
test('install --link', function (t) {
setup()
common.npm(
[
'link',
'--tmp', tmp
],
{ cwd: dep },
function (err, code, stdout, stderr) {
t.ifErr(err, 'npm link finished without error')
common.npm(
[
'install', '--link', dependency.name,
'--tmp', tmp
],
{ cwd: pkg },
function (err, code, stdout, stderr) {
t.ifErr(err, 'npm install --link finished without error')
t.equal(code, 0, 'exited ok')
t.notOk(stderr, 'no output stderr')
t.notMatch(stdout, /hey sup/, "script didn't run")
t.end()
}
)
}
)
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(tmp)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
mkdirp.sync(path.join(dep, 'bin'))
fs.writeFileSync(
path.join(dep, 'package.json'),
JSON.stringify(dependency, null, 2)
)
fs.writeFileSync(path.join(dep, 'bin', 'foo'), foo)
fs.chmod(path.join(dep, 'bin', 'foo'), '0755')
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

75
node_modules/npm/test/tap/install-man.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
var fs = require("fs")
var resolve = require("path").resolve
var osenv = require("osenv")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var test = require("tap").test
var common = require("../common-tap.js")
var pkg = resolve(__dirname, "install-man")
var target = resolve(__dirname, "install-man-target")
var EXEC_OPTS = {
cwd: target
}
var json = {
name : "install-man",
version : "1.2.3",
man : [ "./install-man.1" ]
}
test("setup", function (t) {
setup()
t.pass("setup ran")
t.end()
})
test("install man page", function (t) {
common.npm(
[
"install",
"--prefix", target,
"--global",
pkg
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, "npm command ran from test")
t.equals(code, 0, "install exited with success (0)")
t.ok(stdout, "output indicating success")
t.ok(
fs.existsSync(resolve(target, "share", "man", "man1", "install-man.1")),
"man page link was created"
)
t.end()
}
)
})
test("clean", function (t) {
cleanup()
t.pass("cleaned up")
t.end()
})
function setup () {
cleanup()
mkdirp.sync(pkg)
// make sure it installs locally
mkdirp.sync(resolve(target, "node_modules"))
fs.writeFileSync(
resolve(pkg, "package.json"),
JSON.stringify(json, null, 2)+"\n"
)
fs.writeFileSync(resolve(pkg, "install-man.1"), "THIS IS A MANPAGE\n")
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
rimraf.sync(target)
}

109
node_modules/npm/test/tap/install-noargs-dev.js generated vendored Normal file
View File

@@ -0,0 +1,109 @@
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var server
var pkg = path.join(__dirname, 'install-noargs-dev')
var EXEC_OPTS = { cwd: pkg }
var PACKAGE_JSON1 = {
name: 'install-noargs-dev',
version: '0.0.1',
devDependencies: {
'underscore': '1.3.1'
}
}
var PACKAGE_JSON2 = {
name: 'install-noargs-dev',
version: '0.0.2',
devDependencies: {
'underscore': '1.5.1'
}
}
test('setup', function (t) {
setup()
mr({ port: common.port }, function (er, s) {
t.ifError(er, 'started mock registry')
server = s
t.end()
})
})
test('install noargs installs devDependencies', function (t) {
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'install'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'npm install exited with code 0')
var p = path.join(pkg, 'node_modules', 'underscore', 'package.json')
var pkgJson = JSON.parse(fs.readFileSync(p))
t.equal(pkgJson.version, '1.3.1')
t.end()
}
)
})
test('install noargs installs updated devDependencies', function (t) {
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(PACKAGE_JSON2, null, 2)
)
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'install'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'npm install exited with code 0')
var p = path.join(pkg, 'node_modules', 'underscore', 'package.json')
var pkgJson = JSON.parse(fs.readFileSync(p))
t.equal(pkgJson.version, '1.5.1')
t.end()
}
)
})
test('cleanup', function (t) {
server.close()
cleanup()
t.end()
})
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
function setup () {
cleanup()
mkdirp.sync(path.resolve(pkg, 'node_modules'))
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(PACKAGE_JSON1, null, 2)
)
process.chdir(pkg)
}

View File

@@ -0,0 +1,131 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var preferGlobalJson = {
name: 'npm-test-preferglobal-dep',
version: '0.0.0',
preferGlobal: true
}
var dependenciesJson = {
name: 'npm-test-preferglobal-dependency-check',
version: '0.0.0',
dependencies: {
'npm-test-preferglobal-dep': 'file:../' + preferGlobalJson.name
}
}
var devDependenciesJson = {
name: 'npm-test-preferglobal-devDependency-check',
version: '0.0.0',
devDependencies: {
'npm-test-preferglobal-dep': 'file:../' + preferGlobalJson.name
}
}
var emptyPackage = {
name: 'npm-test-preferglobal-empty-package',
version: '0.0.0'
}
test('install a preferGlobal dependency without warning', function (t) {
setup(dependenciesJson)
common.npm([
'install',
'--loglevel=warn'
], {}, function (err, code, stdout, stderr) {
t.ifError(err, 'packages were installed')
t.notMatch(
stderr,
/WARN.*prefer global/,
'install should not warn when dependency is preferGlobal')
t.end()
})
})
test('install a preferGlobal dependency without warning', function (t) {
setup(devDependenciesJson)
common.npm([
'install',
'--loglevel=warn'
], {}, function (err, code, stdout, stderr) {
t.ifError(err, 'packages were installed')
t.notMatch(
stderr,
/WARN.*prefer global/,
'install should not warn when devDependency is preferGlobal')
t.end()
})
})
test('warn if a preferGlobal package is being installed direct', function (t) {
setup(emptyPackage)
common.npm([
'install',
'file:../' + preferGlobalJson.name,
'--loglevel=warn'
], {}, function (err, code, stdout, stderr) {
t.ifError(err, 'packages were installed')
t.match(
stderr,
/WARN.*prefer global/,
'install should warn when new package is preferGlobal')
t.end()
})
})
test('warn if a preferGlobal package is being saved', function (t) {
setup(emptyPackage)
common.npm([
'install',
'file:../' + preferGlobalJson.name,
'--save',
'--loglevel=warn'
], {}, function (err, code, stdout, stderr) {
t.ifError(err, 'packages were installed')
t.match(
stderr,
/WARN.*prefer global/,
'install should warn when new package is preferGlobal')
t.end()
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup (json) {
cleanup()
mkPkg(preferGlobalJson)
process.chdir(mkPkg(json))
}
function cleanup () {
process.chdir(osenv.tmpdir())
var pkgs = [preferGlobalJson,
dependenciesJson,
devDependenciesJson,
emptyPackage]
pkgs.forEach(function (json) {
rimraf.sync(path.resolve(__dirname, json.name))
})
}
function mkPkg (json) {
var pkgPath = path.resolve(__dirname, json.name)
mkdirp.sync(pkgPath)
fs.writeFileSync(
path.join(pkgPath, 'package.json'),
JSON.stringify(json, null, 2)
)
return pkgPath
}

114
node_modules/npm/test/tap/install-save-exact.js generated vendored Normal file
View File

@@ -0,0 +1,114 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var server
var pkg = path.join(__dirname, 'install-save-exact')
var EXEC_OPTS = { cwd: pkg }
var json = {
name: 'install-save-exact',
version: '0.0.1',
description: 'fixture'
}
test('setup', function (t) {
setup()
mr({ port: common.port }, function (er, s) {
server = s
t.end()
})
})
test('\'npm install --save --save-exact\' should install local pkg', function (t) {
common.npm(
[
'--loglevel', 'silent',
'--registry', common.registry,
'--save',
'--save-exact',
'install', 'underscore@1.3.1'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm ran without issue')
t.notOk(code, 'npm install exited without raising an error code')
var p = path.resolve(pkg, 'node_modules/underscore/package.json')
t.ok(JSON.parse(fs.readFileSync(p)))
p = path.resolve(pkg, 'package.json')
var pkgJson = JSON.parse(fs.readFileSync(p, 'utf8'))
t.same(
pkgJson.dependencies,
{ 'underscore': '1.3.1' },
'underscore dependency should specify exactly 1.3.1'
)
t.end()
}
)
})
test('\'npm install --save-dev --save-exact\' should install local pkg', function (t) {
setup()
common.npm(
[
'--loglevel', 'silent',
'--registry', common.registry,
'--save-dev',
'--save-exact',
'install', 'underscore@1.3.1'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm ran without issue')
t.notOk(code, 'npm install exited without raising an error code')
var p = path.resolve(pkg, 'node_modules/underscore/package.json')
t.ok(JSON.parse(fs.readFileSync(p)))
p = path.resolve(pkg, 'package.json')
var pkgJson = JSON.parse(fs.readFileSync(p, 'utf8'))
t.same(
pkgJson.devDependencies,
{ 'underscore': '1.3.1' },
'underscore dependency should specify exactly 1.3.1'
)
t.end()
}
)
})
test('cleanup', function (t) {
server.close()
cleanup()
t.end()
})
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
function setup () {
cleanup()
mkdirp.sync(path.resolve(pkg, 'node_modules'))
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}

126
node_modules/npm/test/tap/install-save-local.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var root = path.join(__dirname, 'install-save-local')
var pkg = path.join(root, 'package')
var EXEC_OPTS = { cwd: pkg }
var json = {
name: 'install-save-local',
version: '0.0.0'
}
var localDependency = {
name: 'package-local-dependency',
version: '0.0.0'
}
var localDevDependency = {
name: 'package-local-dev-dependency',
version: '0.0.0'
}
test('setup', function (t) {
setup()
t.end()
})
test('\'npm install --save ../local/path\' should save to package.json', function (t) {
common.npm(
[
'--loglevel', 'silent',
'--save',
'install', '../package-local-dependency'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'npm install exited with code 0')
var dependencyPackageJson = path.join(
pkg, 'node_modules', 'package-local-dependency', 'package.json'
)
t.ok(JSON.parse(fs.readFileSync(dependencyPackageJson, 'utf8')))
var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
t.deepEqual(
pkgJson.dependencies,
{ 'package-local-dependency': 'file:../package-local-dependency' },
'local package saved correctly'
)
t.end()
}
)
})
test('\'npm install --save-dev ../local/path\' should save to package.json', function (t) {
setup()
common.npm(
[
'--loglevel', 'silent',
'--save-dev',
'install', '../package-local-dev-dependency'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'npm install exited with code 0')
var dependencyPackageJson = path.resolve(
pkg, 'node_modules', 'package-local-dev-dependency', 'package.json'
)
t.ok(JSON.parse(fs.readFileSync(dependencyPackageJson, 'utf8')))
var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
t.deepEqual(
pkgJson.devDependencies,
{ 'package-local-dev-dependency': 'file:../package-local-dev-dependency' },
'local package saved correctly'
)
t.end()
}
)
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function cleanup () {
process.chdir(osenv.tmpdir())
process.chdir(__dirname)
rimraf.sync(root)
}
function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
mkdirp.sync(path.join(root, 'package-local-dependency'))
fs.writeFileSync(
path.join(root, 'package-local-dependency', 'package.json'),
JSON.stringify(localDependency, null, 2)
)
mkdirp.sync(path.join(root, 'package-local-dev-dependency'))
fs.writeFileSync(
path.join(root, 'package-local-dev-dependency', 'package.json'),
JSON.stringify(localDevDependency, null, 2)
)
process.chdir(pkg)
}

178
node_modules/npm/test/tap/install-save-prefix.js generated vendored Normal file
View File

@@ -0,0 +1,178 @@
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var server
var pkg = path.join(__dirname, 'install-save-prefix')
var EXEC_OPTS = { cwd: pkg }
var json = {
name: 'install-save-prefix',
version: '0.0.1'
}
test('setup', function (t) {
setup()
mr({ port: common.port }, function (er, s) {
t.ifError(er, 'started mock registry')
server = s
t.end()
})
})
test('install --save with \'^\' save prefix should accept minor updates', function (t) {
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'--save-prefix', '^',
'--save',
'install', 'underscore@latest'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'npm install exited with code 0')
var p = path.join(pkg, 'node_modules', 'underscore', 'package.json')
t.ok(JSON.parse(fs.readFileSync(p)))
var pkgJson = JSON.parse(fs.readFileSync(
path.join(pkg, 'package.json'),
'utf8'
))
t.deepEqual(
pkgJson.dependencies,
{ 'underscore': '^1.5.1' },
'got expected save prefix and version of 1.5.1'
)
t.end()
}
)
})
test('install --save-dev with \'^\' save prefix should accept minor dev updates', function (t) {
setup()
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'--save-prefix', '^',
'--save-dev',
'install', 'underscore@1.3.1'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'npm install exited with code 0')
var p = path.join(pkg, 'node_modules', 'underscore', 'package.json')
t.ok(JSON.parse(fs.readFileSync(p)))
var pkgJson = JSON.parse(fs.readFileSync(
path.join(pkg, 'package.json'),
'utf8'
))
t.deepEqual(
pkgJson.devDependencies,
{ 'underscore': '^1.3.1' },
'got expected save prefix and version of 1.3.1'
)
t.end()
}
)
})
test('install --save with \'~\' save prefix should accept patch updates', function (t) {
setup()
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'--save-prefix', '~',
'--save',
'install', 'underscore@1.3.1'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'npm install exited with code 0')
var p = path.join(pkg, 'node_modules', 'underscore', 'package.json')
t.ok(JSON.parse(fs.readFileSync(p)))
var pkgJson = JSON.parse(fs.readFileSync(
path.join(pkg, 'package.json'),
'utf8'
))
t.deepEqual(
pkgJson.dependencies,
{ 'underscore': '~1.3.1' },
'got expected save prefix and version of 1.3.1'
)
t.end()
}
)
})
test('install --save-dev with \'~\' save prefix should accept patch updates', function (t) {
setup()
common.npm(
[
'--registry', common.registry,
'--loglevel', 'silent',
'--save-prefix', '~',
'--save-dev',
'install', 'underscore@1.3.1'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'npm install exited with code 0')
var p = path.join(pkg, 'node_modules', 'underscore', 'package.json')
t.ok(JSON.parse(fs.readFileSync(p)))
var pkgJson = JSON.parse(fs.readFileSync(
path.join(pkg, 'package.json'),
'utf8'
))
t.deepEqual(
pkgJson.devDependencies,
{ 'underscore': '~1.3.1' },
'got expected save prefix and version of 1.3.1'
)
t.end()
}
)
})
test('cleanup', function (t) {
server.close()
cleanup()
t.end()
})
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
function setup () {
cleanup()
mkdirp.sync(path.resolve(pkg, 'node_modules'))
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}

View File

@@ -0,0 +1,137 @@
var fs = require('graceful-fs')
var path = require('path')
var existsSync = fs.existsSync || path.existsSync
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap')
var root = path.join(__dirname, 'install-scoped-already-installed')
var pkg = path.join(root, 'package-with-scoped-paths')
var modules = path.join(pkg, 'node_modules')
var EXEC_OPTS = { cwd: pkg }
var scopedPaths = {
name: 'package-with-scoped-paths',
version: '0.0.0',
dependencies: {
'package-local-dependency': 'file:../package-local-dependency',
'@scoped/package-scoped-dependency': 'file:../package-scoped-dependency'
}
}
var localDependency = {
name: 'package-local-dependency',
version: '0.0.0',
description: 'Test for local installs'
}
var scopedDependency = {
name: '@scoped/package',
version: '0.0.0',
description: 'Test for local installs'
}
test('setup', function (t) {
rimraf.sync(root)
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(scopedPaths, null, 2)
)
mkdirp.sync(path.join(root, 'package-local-dependency'))
fs.writeFileSync(
path.join(root, 'package-local-dependency', 'package.json'),
JSON.stringify(localDependency, null, 2)
)
mkdirp.sync(path.join(root, 'package-scoped-dependency'))
fs.writeFileSync(
path.join(root, 'package-scoped-dependency', 'package.json'),
JSON.stringify(scopedDependency, null, 2)
)
process.chdir(pkg)
t.end()
})
test('installing already installed local scoped package', function (t) {
common.npm(
[
'--loglevel', 'silent',
'install'
],
EXEC_OPTS,
function (err, code, stdout) {
var installed = parseNpmInstallOutput(stdout)
t.ifError(err, 'install ran to completion without error')
t.notOk(code, 'npm install exited with code 0')
t.ok(
existsSync(path.join(modules, '@scoped', 'package', 'package.json')),
'package installed'
)
t.ok(
contains(installed, 'node_modules/@scoped/package'),
'installed @scoped/package'
)
t.ok(
contains(installed, 'node_modules/package-local-dependency'),
'installed package-local-dependency'
)
common.npm(
[
'--loglevel', 'silent',
'install'
],
EXEC_OPTS,
function (err, code, stdout) {
t.ifError(err, 'install ran to completion without error')
t.notOk(code, 'npm install raised no error code')
installed = parseNpmInstallOutput(stdout)
t.ok(
existsSync(path.join(modules, '@scoped', 'package', 'package.json')),
'package installed'
)
t.notOk(
contains(installed, 'node_modules/@scoped/package'),
'did not reinstall @scoped/package'
)
t.notOk(
contains(installed, 'node_modules/package-local-dependency'),
'did not reinstall package-local-dependency'
)
t.end()
}
)
}
)
})
test('cleanup', function (t) {
process.chdir(osenv.tmpdir())
rimraf.sync(root)
t.end()
})
function contains (list, element) {
for (var i = 0; i < list.length; ++i) {
if (list[i] === element) {
return true
}
}
return false
}
function parseNpmInstallOutput (stdout) {
return stdout.trim().split(/\n\n|\s+/)
}

84
node_modules/npm/test/tap/install-scoped-link.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
var exec = require('child_process').exec
var fs = require('graceful-fs')
var path = require('path')
var existsSync = fs.existsSync || path.existsSync
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'install-scoped-link')
var work = path.join(__dirname, 'install-scoped-link-TEST')
var modules = path.join(work, 'node_modules')
var EXEC_OPTS = { cwd: work }
var world = 'console.log("hello blrbld")\n'
var json = {
name: '@scoped/package',
version: '0.0.0',
bin: {
hello: './world.js'
}
}
test('setup', function (t) {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
fs.writeFileSync(path.join(pkg, 'world.js'), world)
mkdirp.sync(modules)
process.chdir(work)
t.end()
})
test('installing package with links', function (t) {
common.npm(
[
'--loglevel', 'silent',
'install', pkg
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'install ran to completion without error')
t.notOk(code, 'npm install exited with code 0')
t.ok(
existsSync(path.join(modules, '@scoped', 'package', 'package.json')),
'package installed'
)
t.ok(existsSync(path.join(modules, '.bin')), 'binary link directory exists')
var hello = path.join(modules, '.bin', 'hello')
t.ok(existsSync(hello), 'binary link exists')
exec('node ' + hello, function (err, stdout, stderr) {
t.ifError(err, 'command ran fine')
t.notOk(stderr, 'got no error output back')
t.equal(stdout, 'hello blrbld\n', 'output was as expected')
t.end()
})
}
)
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(work)
rimraf.sync(pkg)
}

View File

@@ -0,0 +1,60 @@
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'install-scoped-with-peer-dependency')
var local = path.join(pkg, 'package')
var EXEC_OPTS = { }
var json = {
name: '@scope/package',
version: '0.0.0',
peerDependencies: {
underscore: '*'
}
}
test('setup', function (t) {
setup()
t.end()
})
test('it should install peerDependencies in same tree level as the parent package', function (t) {
common.npm(['install', './package'], EXEC_OPTS, function (err, code, stdout, stderr) {
t.ifError(err, 'install local package successful')
t.equal(code, 0, 'npm install exited with code')
t.notOk(stderr, 'npm install exited without any error output')
var p = path.resolve(pkg, 'node_modules/underscore/package.json')
t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
t.end()
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(local)
mkdirp.sync(path.resolve(pkg, 'node_modules'))
fs.writeFileSync(
path.join(local, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

View File

@@ -0,0 +1,288 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'install-shrinkwrap-equals-ls')
var EXEC_OPTS = {cwd: pkg}
var json = {
"name": "install-shrinkwrap-equals-ls",
"version": "1.0.0",
"dependencies": {
"react": "^0.14.0",
"react-bootstrap": "^0.28.1",
"react-dom": "^0.14.0"
}
}
var shrinkwrap = {
"name": "install-shrinkwrap-equals-ls",
"version": "1.0.0",
"dependencies": {
"react": {
"version": "0.14.8",
"from": "react@>=0.14.0 <0.15.0",
"resolved": "https://registry.npmjs.org/react/-/react-0.14.8.tgz",
"dependencies": {
"envify": {
"version": "3.4.0",
"from": "envify@>=3.0.0 <4.0.0",
"resolved": "https://registry.npmjs.org/envify/-/envify-3.4.0.tgz",
"dependencies": {
"through": {
"version": "2.3.8",
"from": "through@>=2.3.4 <2.4.0",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz"
},
"jstransform": {
"version": "10.1.0",
"from": "jstransform@>=10.0.1 <11.0.0",
"resolved": "https://registry.npmjs.org/jstransform/-/jstransform-10.1.0.tgz",
"dependencies": {
"base62": {
"version": "0.1.1",
"from": "base62@0.1.1",
"resolved": "https://registry.npmjs.org/base62/-/base62-0.1.1.tgz"
},
"esprima-fb": {
"version": "13001.1001.0-dev-harmony-fb",
"from": "esprima-fb@13001.1001.0-dev-harmony-fb",
"resolved": "https://registry.npmjs.org/esprima-fb/-/esprima-fb-13001.1001.0-dev-harmony-fb.tgz"
},
"source-map": {
"version": "0.1.31",
"from": "source-map@0.1.31",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.31.tgz",
"dependencies": {
"amdefine": {
"version": "1.0.0",
"from": "amdefine@>=0.0.4",
"resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.0.tgz"
}
}
}
}
}
}
},
"fbjs": {
"version": "0.6.1",
"from": "fbjs@>=0.6.1 <0.7.0",
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.6.1.tgz",
"dependencies": {
"core-js": {
"version": "1.2.6",
"from": "core-js@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz"
},
"loose-envify": {
"version": "1.1.0",
"from": "loose-envify@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.1.0.tgz",
"dependencies": {
"js-tokens": {
"version": "1.0.3",
"from": "js-tokens@>=1.0.1 <2.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.3.tgz"
}
}
},
"promise": {
"version": "7.1.1",
"from": "promise@>=7.0.3 <8.0.0",
"resolved": "https://registry.npmjs.org/promise/-/promise-7.1.1.tgz",
"dependencies": {
"asap": {
"version": "2.0.3",
"from": "asap@>=2.0.3 <2.1.0",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.3.tgz"
}
}
},
"ua-parser-js": {
"version": "0.7.10",
"from": "ua-parser-js@>=0.7.9 <0.8.0",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.10.tgz"
},
"whatwg-fetch": {
"version": "0.9.0",
"from": "whatwg-fetch@>=0.9.0 <0.10.0",
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-0.9.0.tgz"
}
}
}
}
},
"react-bootstrap": {
"version": "0.28.5",
"from": "react-bootstrap@>=0.28.1 <0.29.0",
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-0.28.5.tgz",
"dependencies": {
"babel-runtime": {
"version": "5.8.38",
"from": "babel-runtime@>=5.8.25 <6.0.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.38.tgz",
"dependencies": {
"core-js": {
"version": "1.2.6",
"from": "core-js@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz"
}
}
},
"classnames": {
"version": "2.2.3",
"from": "classnames@>=2.1.5 <3.0.0",
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.3.tgz"
},
"dom-helpers": {
"version": "2.4.0",
"from": "dom-helpers@>=2.4.0 <3.0.0",
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-2.4.0.tgz"
},
"invariant": {
"version": "2.2.1",
"from": "invariant@>=2.1.2 <3.0.0",
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.1.tgz",
"dependencies": {
"loose-envify": {
"version": "1.1.0",
"from": "loose-envify@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.1.0.tgz",
"dependencies": {
"js-tokens": {
"version": "1.0.3",
"from": "js-tokens@>=1.0.1 <2.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.3.tgz"
}
}
}
}
},
"keycode": {
"version": "2.1.1",
"from": "keycode@>=2.1.0 <3.0.0",
"resolved": "https://registry.npmjs.org/keycode/-/keycode-2.1.1.tgz"
},
"lodash-compat": {
"version": "3.10.2",
"from": "lodash-compat@>=3.10.1 <4.0.0",
"resolved": "https://registry.npmjs.org/lodash-compat/-/lodash-compat-3.10.2.tgz"
},
"react-overlays": {
"version": "0.6.3",
"from": "react-overlays@>=0.6.0 <0.7.0",
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-0.6.3.tgz",
"dependencies": {
"react-prop-types": {
"version": "0.2.2",
"from": "react-prop-types@>=0.2.1 <0.3.0",
"resolved": "https://registry.npmjs.org/react-prop-types/-/react-prop-types-0.2.2.tgz"
}
}
},
"react-prop-types": {
"version": "0.3.0",
"from": "react-prop-types@>=0.3.0 <0.4.0",
"resolved": "https://registry.npmjs.org/react-prop-types/-/react-prop-types-0.3.0.tgz"
},
"uncontrollable": {
"version": "3.2.3",
"from": "uncontrollable@>=3.1.3 <4.0.0",
"resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-3.2.3.tgz"
},
"warning": {
"version": "2.1.0",
"from": "warning@>=2.1.0 <3.0.0",
"resolved": "https://registry.npmjs.org/warning/-/warning-2.1.0.tgz",
"dependencies": {
"loose-envify": {
"version": "1.1.0",
"from": "loose-envify@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.1.0.tgz",
"dependencies": {
"js-tokens": {
"version": "1.0.3",
"from": "js-tokens@>=1.0.1 <2.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.3.tgz"
}
}
}
}
}
}
},
"react-dom": {
"version": "0.14.8",
"from": "react-dom@>=0.14.0 <0.15.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-0.14.8.tgz"
}
}
}
test('setup', function (t) {
setup()
t.end()
})
test('An npm install with shrinkwrap equals npm ls --json', function (t) {
common.npm(
[
'--loglevel', 'silent',
'install'
],
EXEC_OPTS,
function (err, code) {
t.ifError(err, 'npm install ran without issue')
t.notOk(code, 'npm install exited with code 0')
common.npm(
[
'--loglevel', 'silent',
'ls', '--json'
],
EXEC_OPTS,
function (err, code, out) {
t.ifError(err, 'npm ls --json ran without issue')
t.notOk(code, 'npm ls --json exited with code 0')
var actual = common.rmFromInShrinkwrap(JSON.parse(out))
var expected = common.rmFromInShrinkwrap(
JSON.parse(JSON.stringify(shrinkwrap))
)
t.deepEqual(actual, expected)
t.end()
})
}
)
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function cleanup () {
process.chdir(__dirname)
rimraf.sync(pkg)
}
function setup () {
cleanup()
mkdirp.sync(pkg)
process.chdir(pkg)
fs.writeFileSync(
'package.json',
JSON.stringify(json, null, 2)
)
fs.writeFileSync(
'npm-shrinkwrap.json',
JSON.stringify(shrinkwrap, null, 2)
)
}

View File

@@ -0,0 +1,85 @@
var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var npm = npm = require('../../')
var pkg = path.resolve(__dirname, 'dev-dep-duplicate')
var json = {
author: 'Anders Janmyr',
name: 'dev-dep-duplicate',
version: '0.0.0',
dependencies: {
underscore: '1.5.1'
},
devDependencies: {
underscore: '1.3.1'
}
}
var expected = {
name: 'dev-dep-duplicate',
version: '0.0.0',
dependencies: {
underscore: {
version: '1.5.1',
from: 'underscore@1.5.1',
resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz'
}
}
}
test('prefers version from dependencies over devDependencies', function (t) {
t.plan(1)
mr({ port: common.port }, function (er, s) {
setup(function (err) {
if (err) return t.fail(err)
npm.install('.', function (err) {
if (err) return t.fail(err)
npm.commands.ls([], true, function (err, _, results) {
if (err) return t.fail(err)
t.deepEqual(results, expected)
s.close()
t.end()
})
})
})
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup (cb) {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
var opts = {
cache: path.resolve(pkg, 'cache'),
registry: common.registry
}
npm.load(opts, cb)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}

28
node_modules/npm/test/tap/invalid-cmd-exit-code.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
var test = require("tap").test
var common = require("../common-tap.js")
var opts = { cwd: process.cwd() }
test("npm asdf should return exit code 1", function (t) {
common.npm(["asdf"], opts, function (er, c) {
if (er) throw er
t.ok(c, "exit code should not be zero")
t.end()
})
})
test("npm help should return exit code 0", function (t) {
common.npm(["help"], opts, function (er, c) {
if (er) throw er
t.equal(c, 0, "exit code should be 0")
t.end()
})
})
test("npm help fadf should return exit code 0", function (t) {
common.npm(["help", "fadf"], opts, function (er, c) {
if (er) throw er
t.equal(c, 0, "exit code should be 0")
t.end()
})
})

80
node_modules/npm/test/tap/legacy-array-bin.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
'use strict'
var test = require('tap').test
var common = require('../common-tap.js')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-array-bin')
var modulepath = path.resolve(basepath, 'node_modules')
var installedpath = path.resolve(modulepath, 'npm-test-array-bin')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
var fixture = new Tacks(
Dir({
bin: Dir({
'array-bin': File(
'#!/usr/bin/env node\n' +
"console.log('test ran ok')\n"
)
}),
'package.json': File({
name: 'npm-test-array-bin',
version: '1.2.5',
bin: [
'bin/array-bin'
],
scripts: {
test: 'node test.js'
}
}),
'test.js': File(
"require('child_process').exec('array-bin', { env: process.env },\n" +
' function (err, stdout, stderr) {\n' +
" if (err && err.code) throw new Error('exited badly with code = ' + err.code)\n" +
' console.log(stdout)\n' +
' console.error(stderr)\n' +
' }\n' +
')\n'
)
})
)
test('setup', function (t) {
setup()
t.done()
})
test('array-bin', function (t) {
common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
function installCheckAndTest (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'install went ok')
t.equal(stderr, '', 'no error output')
common.npm(['test'], {cwd: installedpath}, testCheckAndRemove)
}
function testCheckAndRemove (err, code, stdout, stderr) {
t.ifError(err, 'npm test on array bin')
t.equal(code, 0, 'exited OK')
t.equal(stderr.trim(), '', 'no error output')
t.match(stdout, /test ran ok/, 'child script ran properly')
common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
}
function removeCheckAndDone (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'remove went ok')
t.done()
}
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
cleanup()
fixture.create(fixturepath)
mkdirp.sync(modulepath)
}
function cleanup () {
fixture.remove(fixturepath)
rimraf.sync(basepath)
}

103
node_modules/npm/test/tap/legacy-bundled-git.js generated vendored Normal file
View File

@@ -0,0 +1,103 @@
'use strict'
var test = require('tap').test
var common = require('../common-tap.js')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-bundled-git')
var modulepath = path.resolve(basepath, 'node_modules')
var installedpath = path.resolve(modulepath, 'npm-test-bundled-git')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
var minimatchExpected = {
name: 'minimatch',
description: 'a glob matcher in javascript',
version: '0.2.1',
repository: {
type: 'git',
url: 'git://github.com/isaacs/minimatch.git'
},
main: 'minimatch.js',
scripts: {
test: 'tap test'
},
engines: {
node: '*'
},
dependencies: {
'lru-cache': '~1.0.5'
},
devDependencies: {
tap: '~0.1.3'
},
licenses: [
{
type: 'MIT',
url: 'http://github.com/isaacs/minimatch/raw/master/LICENSE'
}
]
}
var fixture = new Tacks(
Dir({
README: File(
'just an npm test\n'
),
'package.json': File({
name: 'npm-test-bundled-git',
scripts: {
test: 'node test.js'
},
version: '1.2.5',
dependencies: {
glob: 'git://github.com/isaacs/node-glob.git#npm-test'
},
bundledDependencies: [
'glob'
]
})
})
)
test('setup', function (t) {
setup()
t.done()
})
test('bundled-git', function (t) {
common.npm(['install', '--global-style', fixturepath], {cwd: basepath}, installCheckAndTest)
function installCheckAndTest (err, code, stdout, stderr) {
if (err) throw err
console.error(stderr)
console.log(stdout)
t.is(code, 0, 'install went ok')
var actual = require(path.resolve(installedpath, 'node_modules/glob/node_modules/minimatch/package.json'))
Object.keys(minimatchExpected).forEach(function (key) {
t.isDeeply(actual[key], minimatchExpected[key], key + ' set to the right value')
})
common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
}
function removeCheckAndDone (err, code, stdout, stderr) {
if (err) throw err
console.error(stderr)
console.log(stdout)
t.is(code, 0, 'remove went ok')
t.done()
}
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
cleanup()
fixture.create(fixturepath)
mkdirp.sync(modulepath)
}
function cleanup () {
fixture.remove(fixturepath)
rimraf.sync(basepath)
}

79
node_modules/npm/test/tap/legacy-dir-bin.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
'use strict'
var test = require('tap').test
var common = require('../common-tap.js')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-dir-bin')
var modulepath = path.resolve(basepath, 'node_modules')
var installedpath = path.resolve(modulepath, 'npm-test-dir-bin')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
var fixture = new Tacks(
Dir({
bin: Dir({
'dir-bin': File(
'#!/usr/bin/env node\n' +
"console.log('test ran ok')\n"
)
}),
'package.json': File({
name: 'npm-test-dir-bin',
version: '1.2.5',
directories: {
bin: './bin'
},
scripts: {
test: 'node test.js'
}
}),
'test.js': File(
"require('child_process').exec('dir-bin', { env: process.env },\n" +
' function (err, stdout, stderr) {\n' +
" if (err && err.code) throw new Error('exited badly with code = ' + err.code)\n" +
' console.log(stdout)\n' +
' console.error(stderr)\n' +
' }\n' +
')\n'
)
})
)
test('setup', function (t) {
setup()
t.done()
})
test('dir-bin', function (t) {
common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
function installCheckAndTest (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'install went ok')
common.npm(['test'], {cwd: installedpath}, testCheckAndRemove)
}
function testCheckAndRemove (err, code, stdout, stderr) {
t.ifError(err, 'npm test on array bin')
t.equal(code, 0, 'exited OK')
t.equal(stderr.trim(), '', 'no error output')
t.match(stdout, /test ran ok/, 'child script ran properly')
common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
}
function removeCheckAndDone (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'remove went ok')
t.done()
}
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
cleanup()
fixture.create(fixturepath)
mkdirp.sync(modulepath)
}
function cleanup () {
fixture.remove(fixturepath)
rimraf.sync(basepath)
}

64
node_modules/npm/test/tap/legacy-ignore-nested-nm.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
'use strict'
var test = require('tap').test
var common = require('../common-tap.js')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-ignore-nested-nm')
var modulepath = path.resolve(basepath, 'node_modules')
var installedpath = path.resolve(modulepath, 'npm-test-ignore-nested-nm')
var fs = require('graceful-fs')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
var fileData = 'I WILL NOT BE IGNORED!\n'
var fixture = new Tacks(
Dir({
lib: Dir({
node_modules: Dir({
foo: File(fileData)
})
}),
'package.json': File({
name: 'npm-test-ignore-nested-nm',
version: '1.2.5'
})
})
)
test('setup', function (t) {
setup()
t.done()
})
test('ignore-nested-nm', function (t) {
common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
function installCheckAndTest (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'install went ok')
var foopath = path.resolve(installedpath, 'lib/node_modules/foo')
fs.readFile(foopath, function (err, data) {
t.ifError(err, 'file read successfully')
t.equal(data.toString(), fileData)
common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
})
}
function removeCheckAndDone (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'remove went ok')
t.done()
}
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
cleanup()
fixture.create(fixturepath)
mkdirp.sync(modulepath)
}
function cleanup () {
fixture.remove(fixturepath)
rimraf.sync(basepath)
}

82
node_modules/npm/test/tap/legacy-missing-bindir.js generated vendored Normal file
View File

@@ -0,0 +1,82 @@
'use strict'
var path = require('path')
var fs = require('fs')
var test = require('tap').test
var common = require('../common-tap.js')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-missing-bindir')
var modulepath = path.resolve(basepath, 'node_modules')
var installedpath = path.resolve(modulepath, 'npm-test-missing-bindir')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
var fixture = new Tacks(
Dir({
README: File(
'just an npm test\n'
),
'package.json': File({
name: 'npm-test-missing-bindir',
version: '0.0.0',
directories: {
bin: './not-found'
}
})
})
)
test('setup', function (t) {
setup()
t.done()
})
function installedExists (filename) {
try {
fs.statSync(path.resolve(installedpath, filename))
return true
} catch (ex) {
console.log(ex)
return false
}
}
test('missing-bindir', function (t) {
common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
function installCheckAndTest (err, code, stdout, stderr) {
if (err) throw err
if (stderr) console.error(stderr)
console.log(stdout)
t.is(code, 0, 'install went ok')
t.is(installedExists('README'), true, 'README')
t.is(installedExists('package.json'), true, 'package.json')
common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
}
function removeCheckAndDone (err, code, stdout, stderr) {
if (err) throw err
console.error(stderr)
console.log(stdout)
t.is(code, 0, 'remove went ok')
t.done()
}
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
cleanup()
fixture.create(fixturepath)
mkdirp.sync(modulepath)
}
function cleanup () {
fixture.remove(fixturepath)
rimraf.sync(basepath)
}

75
node_modules/npm/test/tap/legacy-no-auth-leak.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
'use strict'
var test = require('tap').test
var common = require('../common-tap.js')
var path = require('path')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
var fixture = new Tacks(
Dir({
README: File(
'just an npm test\n'
),
'package.json': File({
name: 'npm-test-no-auth-leak',
version: '0.0.0',
scripts: {
test: 'node test.js'
}
}),
'.npmrc': File(
'auth=abc',
'authCrypt=def',
'password=xyz',
'//registry.npmjs.org/:_authToken=nopenope'
),
'test.js': File(
'var authTokenKeys = Object.keys(process.env)\n' +
' .filter(function (key) { return /authToken/.test(key) })\n' +
'console.log(JSON.stringify({\n' +
' password: process.env.npm_config__password || null,\n' +
' auth: process.env.npm_config__auth || null,\n' +
' authCrypt: process.env.npm_config__authCrypt || null ,\n' +
' authToken: authTokenKeys && process.env[authTokenKeys[0]] || null\n' +
'}))'
)
})
)
test('setup', function (t) {
setup()
t.done()
})
test('no-auth-leak', function (t) {
common.npm(['test'], {cwd: basepath}, function (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'test ran ok')
if (stderr) console.log(stderr)
var matchResult = /^[^{]*(\{(?:.|\n)*\})[^}]*$/
t.like(stdout, matchResult, 'got results with a JSON chunk in them')
var stripped = stdout.replace(matchResult, '$1')
var result = JSON.parse(stripped)
t.is(result.password, null, 'password')
t.is(result.auth, null, 'auth')
t.is(result.authCrypt, null, 'authCrypt')
t.is(result.authToken, null, 'authToken')
t.end()
})
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
cleanup()
fixture.create(basepath)
}
function cleanup () {
fixture.remove(basepath)
}

107
node_modules/npm/test/tap/legacy-npm-self-install.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
'use strict'
var test = require('tap').test
var fs = require('graceful-fs')
var common = require('../common-tap.js')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var npmpath = path.resolve(__dirname, '../..')
var basepath = path.resolve(osenv.tmpdir(), path.basename(__filename, '.js'))
var globalpath = path.resolve(basepath, 'global')
var extend = Object.assign || require('util')._extend
var isWin32 = process.platform === 'win32'
test('setup', function (t) {
setup()
t.done()
})
var tarball
test('build-tarball', function (t) {
common.npm(['pack'], {cwd: npmpath, stdio: ['ignore', 'pipe', process.stderr]}, function (err, code, stdout) {
if (err) throw err
t.is(code, 0, 'pack went ok')
tarball = path.resolve(npmpath, stdout.trim().replace(/^(?:.|\n)*(?:^|\n)(.*?[.]tgz)$/, '$1'))
t.match(tarball, /[.]tgz$/, 'got a tarball')
t.done()
})
})
function exists () {
try {
fs.statSync(path.resolve.apply(null, arguments))
return true
} catch (ex) {
return false
}
}
test('npm-self-install', function (t) {
if (!tarball) return t.done()
var env = extend({}, process.env)
var pathsep = isWin32 ? ';' : ':'
env.npm_config_prefix = globalpath
env.npm_config_global = 'true'
env.npm_config_npat = 'false'
env.NODE_PATH = null
env.npm_config_user_agent = null
env.npm_config_color = 'always'
env.npm_config_progress = 'always'
var PATH = env.PATH.split(pathsep)
var binpath = isWin32 ? globalpath : path.join(globalpath, 'bin')
var cmdname = isWin32 ? 'npm.cmd' : 'npm'
PATH.unshift(binpath)
env.PATH = PATH.join(pathsep)
var opts = {cwd: basepath, env: env, stdio: ['ignore', 'ignore', process.stderr]}
common.npm(['install', '--ignore-scripts', tarball], opts, installCheckAndTest)
function installCheckAndTest (err, code) {
if (err) throw err
t.is(code, 0, 'install went ok')
t.is(exists(binpath, cmdname), true, 'binary was installed')
t.is(exists(globalpath, 'lib', 'node_modules', 'npm'), true, 'module path exists')
common.npm(['ls', '--json', '--depth=0'], {cwd: basepath, env: env}, lsCheckAndRemove)
}
function lsCheckAndRemove (err, code, stdout, stderr) {
t.ifError(err, 'npm test on array bin')
t.equal(code, 0, 'exited OK')
t.equal(stderr.trim(), '', 'no error output')
var installed = JSON.parse(stdout.trim())
t.is(Object.keys(installed.dependencies).length, 1, 'one thing installed')
t.is(path.resolve(globalpath, installed.dependencies.npm.from), tarball, 'and it was our npm tarball')
common.npm(['rm', 'npm'], {cwd: basepath, env: env, stdio: 'inherit'}, removeCheck)
}
function removeCheck (err, code) {
if (err) throw err
t.is(code, 0, 'remove went ok')
common.npm(['ls', '--json', '--depth=0'], {cwd: basepath, env: env}, andDone)
}
function andDone (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'remove went ok')
t.equal(stderr.trim(), '', 'no error output')
var installed = JSON.parse(stdout.trim())
t.ok(!installed.dependencies || installed.dependencies.length === 0, 'nothing left')
t.is(exists(binpath, cmdname), false, 'binary was removed')
t.is(exists(globalpath, 'lib', 'node_modules', 'npm'), false, 'module was entirely removed')
t.done()
}
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
cleanup()
mkdirp.sync(globalpath)
}
function cleanup () {
rimraf.sync(basepath)
}

80
node_modules/npm/test/tap/legacy-optional-deps.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
'use strict'
var path = require('path')
var fs = require('fs')
var test = require('tap').test
var common = require('../common-tap.js')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-optional-deps')
var modulepath = path.resolve(basepath, 'node_modules')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
var fixture = new Tacks(
Dir({
README: File(
'just an npm test\n'
),
'package.json': File({
name: 'npm-test-optional-deps',
version: '1.2.5',
optionalDependencies: {
'npm-test-foobarzaaakakaka': 'http://example.com/',
async: '10.999.14234',
mkdirp: '0.3.5',
optimist: 'some invalid version 99 #! $$ x y z',
'npm-test-failer': '*'
}
})
})
)
var server
test('setup', function (t) {
setup()
mr({port: common.port}, function (err, s) {
if (err) throw err
server = s
t.done()
})
})
test('optional-deps', function (t) {
server.get('/npm-test-failer').reply(404, {error: 'nope'})
var opts = ['--registry=' + common.registry, '--timeout=100']
common.npm(opts.concat(['install', fixturepath]), {cwd: basepath}, installCheckAndTest)
function installCheckAndTest (err, code, stdout, stderr) {
if (err) throw err
if (stderr) console.error(stderr)
server.done()
t.is(code, 0, 'install went ok')
var subpath = modulepath + '/npm-test-optional-deps/node_modules/'
var dir = fs.readdirSync(subpath)
t.isDeeply(dir, ['mkdirp'], 'only one optional dep should be there')
t.is(require(path.resolve(subpath, 'mkdirp', 'package.json')).version, '0.3.5', 'mkdirp version right')
t.done()
}
})
test('cleanup', function (t) {
cleanup()
server.close()
t.done()
})
function setup () {
cleanup()
fixture.create(fixturepath)
mkdirp.sync(modulepath)
}
function cleanup () {
fixture.remove(fixturepath)
rimraf.sync(basepath)
}

73
node_modules/npm/test/tap/legacy-platform-all.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
'use strict'
var test = require('tap').test
var common = require('../common-tap.js')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-platform-all')
var modulepath = path.resolve(basepath, 'node_modules')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
var fixture = new Tacks(
Dir({
README: File(
'just an npm test\n'
),
'package.json': File({
name: 'npm-test-platform-all',
version: '9.9.9-9',
homepage: 'http://www.zombo.com/',
os: [
'darwin',
'linux',
'win32',
'solaris',
'haiku',
'sunos',
'freebsd',
'openbsd',
'netbsd'
],
cpu: [
'arm',
'mips',
'ia32',
'x64',
'sparc'
]
})
})
)
test('setup', function (t) {
setup()
t.done()
})
test('platform-all', function (t) {
common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
function installCheckAndTest (err, code, stdout, stderr) {
if (err) throw err
t.is(stderr, '', 'no error messages')
t.is(code, 0, 'install went ok')
t.done()
}
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
cleanup()
fixture.create(fixturepath)
mkdirp.sync(modulepath)
}
function cleanup () {
fixture.remove(fixturepath)
rimraf.sync(basepath)
}

64
node_modules/npm/test/tap/legacy-platform.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
'use strict'
var test = require('tap').test
var common = require('../common-tap.js')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-platform')
var modulepath = path.resolve(basepath, 'node_modules')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
var fixture = new Tacks(
Dir({
README: File(
'just an npm test\n'
),
'package.json': File({
name: 'npm-test-platform',
version: '9.9.9-9',
homepage: 'http://www.youtube.com/watch?v=dQw4w9WgXcQ',
os: [
'!this_is_not_a_real_os',
'!neither_is_this'
],
cpu: [
'!this_is_not_a_real_cpu',
'!this_isnt_either'
]
})
})
)
test('setup', function (t) {
setup()
t.done()
})
test('platform', function (t) {
common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
function installCheckAndTest (err, code, stdout, stderr) {
if (err) throw err
console.error(stderr)
t.is(code, 0, 'install went ok')
t.done()
}
})
test('cleanup', function (t) {
cleanup()
t.done()
})
function setup () {
cleanup()
fixture.create(fixturepath)
mkdirp.sync(modulepath)
}
function cleanup () {
fixture.remove(fixturepath)
rimraf.sync(basepath)
}

Some files were not shown because too many files have changed in this diff Show More